* { box-sizing: border-box; }
:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f3f6fa;
  color: #172033;
}
body { margin: 0; background: #f3f6fa; }
button, select, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem clamp(1.25rem, 4vw, 4rem);
  background: linear-gradient(135deg, #0f2747, #163e70);
  color: white;
  border-bottom: 4px solid #c6d5e8;
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .35rem; font-size: clamp(1.9rem, 4vw, 3rem); }
h2 { margin-bottom: .3rem; font-size: 1.35rem; }
.subtitle { margin: 0; color: #dbe7f5; max-width: 760px; }
.eyebrow { margin-bottom: .4rem; font-size: .76rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; color: #54739a; }
.topbar .eyebrow { color: #b9d1ee; }
.status { align-self: flex-start; padding: .55rem .8rem; border-radius: 999px; background: rgba(255,255,255,.12); font-weight: 700; white-space: nowrap; }
main { width: min(1500px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.summary-card, .panel { background: white; border: 1px solid #dce4ee; border-radius: 12px; box-shadow: 0 4px 14px rgba(31, 56, 88, .06); }
.summary-card { padding: 1rem 1.2rem; }
.summary-card span { display: block; color: #64748b; font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.summary-card strong { display: block; margin-top: .25rem; font-size: 1.8rem; color: #143a66; }
.panel { padding: 1.25rem; margin-bottom: 1rem; }
.primary-workspace { border-color: #c9d8e8; box-shadow: 0 6px 20px rgba(31, 56, 88, .08); }
.panel-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: end; margin-bottom: 1rem; }
.compact-heading { margin-bottom: .8rem; }
.help { color: #667085; margin-bottom: 0; }
.filters { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.filters label { font-size: .85rem; font-weight: 700; color: #475569; }
select, input[type="number"], input[type="search"], input:not([type]), input[type="email"], textarea { border: 1px solid #cbd5e1; border-radius: 7px; padding: .5rem .6rem; background: white; color: #172033; }
.secondary, .action { border: 1px solid #b7c5d6; border-radius: 7px; padding: .48rem .72rem; background: white; color: #173e6b; font-weight: 700; }
.secondary:hover, .action:hover { background: #f3f7fb; }
.action.primary { background: #163e70; border-color: #163e70; color: white; }
.action.primary:hover { background: #102f56; }
.text-button { border: 1px solid gray; background: none; padding: 4px; color: #143a66; font-weight: 800; text-align: left; text-decoration: underline; border-radius: 12px;}
.text-button:hover { color: #0d2d52; }
.workspace-drawer, .tool-drawer { border: 1px solid #d5dfeb; border-radius: 12px; background: #eef3f8; margin-bottom: 1rem; overflow: hidden; }
.workspace-drawer > summary, .tool-drawer > summary { list-style: none; cursor: pointer; padding: 1rem 1.2rem; display: flex; align-items: center; justify-content: space-between; color: #173e6b; background: #eef3f8; }
.workspace-drawer > summary::-webkit-details-marker, .tool-drawer > summary::-webkit-details-marker { display: none; }
.workspace-drawer > summary::after, .tool-drawer > summary::after { content: "▸"; font-size: 1.15rem; transition: transform .15s ease; }
.workspace-drawer[open] > summary::after, .tool-drawer[open] > summary::after { transform: rotate(90deg); }
.workspace-drawer > summary span, .tool-drawer > summary span { display: grid; gap: .2rem; }
.workspace-drawer > summary strong { font-size: 1.05rem; }
.workspace-drawer > summary small, .tool-drawer > summary small { color: #687b90; font-size: .82rem; font-weight: 500; }
.workspace-drawer-body { padding: 1rem; background: #f6f8fb; border-top: 1px solid #d5dfeb; }
.workspace-drawer-body > .panel:last-of-type { margin-bottom: 1rem; }
.tool-drawer { background: white; margin: 0; }
.tool-drawer > summary { background: white; }
.tool-drawer-body { padding: 1rem; border-top: 1px solid #e1e7ee; background: #fbfcfe; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .85rem .7rem; border-bottom: 1px solid #e8edf3; vertical-align: top; }
th { color: #526274; font-size: .78rem; text-transform: uppercase; letter-spacing: .045em; }
.score { font-size: 1.15rem; font-weight: 800; color: #143a66; }
.organization { font-weight: 800; }
.meta { margin-top: .25rem; color: #6b7280; font-size: .82rem; }
.reason { max-width: 500px; }
.actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.empty { padding: 2rem 1rem; border: 1px dashed #c5d0dc; border-radius: 9px; text-align: center; color: #667085; background: #f9fbfd; }
.empty.compact { padding: .85rem; }
.import-summary { display:flex; justify-content:space-between; gap:1rem; align-items:center; padding:.9rem 1rem; border:1px solid #d7e1ec; border-radius:9px; background:#f8fbfe; }
.import-counts { display:flex; gap:.6rem; flex-wrap:wrap; }
.import-counts span { padding:.35rem .55rem; border-radius:7px; background:#eaf1f9; color:#365b84; font-size:.82rem; }
.import-preview { max-height:430px; margin-top:1rem; border:1px solid #e3e9f0; border-radius:9px; }
.import-status { display:inline-block; padding:.2rem .48rem; border-radius:999px; font-size:.72rem; font-weight:800; text-transform:uppercase; letter-spacing:.04em; background:#eef2f6; color:#526274; }
.import-status.new { background:#eaf7ee; color:#27613a; }
.import-status.update { background:#fff6df; color:#7a5712; }
.import-status.current { background:#edf3fb; color:#365b84; }
.profile-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.profile-card { border: 1px solid #dbe3ed; border-radius: 10px; padding: 1rem; background: #fbfcfe; }
.profile-card h3 { margin: 0 0 .35rem; color: #143a66; }
.profile-card .description { min-height: 4.4em; color: #667085; font-size: .9rem; }
.profile-controls { display: grid; gap: .75rem; margin-top: 1rem; }
.profile-controls label { display: grid; gap: .3rem; color: #475569; font-size: .82rem; font-weight: 700; }
.enabled-row { display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: .5rem !important; }
.signal-list { margin: .8rem 0 0; padding-left: 1.1rem; color: #596779; font-size: .82rem; }
.signal-list li { margin-bottom: .25rem; }
.contact-layout { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(0, 2fr); gap: 1rem; }
.contact-list-wrap { border: 1px solid #dbe3ed; border-radius: 10px; overflow: hidden; background: #fbfcfe; }
.contact-list { max-height: 620px; overflow-y: auto; }
.contact-row { width: 100%; border: 0; border-bottom: 1px solid #e8edf3; padding: .8rem; background: white; display: flex; justify-content: space-between; gap: .75rem; text-align: left; }
.contact-row:hover, .contact-row.selected { background: #f0f6fd; }
.contact-detail { border: 1px solid #dbe3ed; border-radius: 10px; padding: 1rem; background: #fff; min-height: 300px; }
.detail-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.contact-methods { display: flex; gap: 1rem; flex-wrap: wrap; margin: .8rem 0; }
.tag-line { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.detail-tags { justify-content: flex-start; margin-bottom: .8rem; }
.tag { display: inline-block; border-radius: 999px; padding: .18rem .48rem; background: #eaf1f9; color: #365b84; font-size: .72rem; font-weight: 700; margin: .1rem .15rem .1rem 0; }
.priority-box { margin: 1rem 0; padding: .9rem; border: 1px solid #c8d8e9; border-radius: 9px; background: #f3f8fd; }
.notes-section { margin-top: 1.2rem; }
.note-form { display: grid; grid-template-columns: 150px minmax(0,1fr) auto; gap: .5rem; align-items: start; }
.notes-list { margin-top: 1rem; display: grid; gap: .65rem; }
.note-item { border-left: 3px solid #cbd9e8; padding: .45rem .7rem; background: #fafcfe; }
.note-meta { color: #6b7280; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .25rem; }
dialog { width: min(720px, calc(100% - 2rem)); border: 1px solid #cbd5e1; border-radius: 12px; padding: 0; box-shadow: 0 20px 50px rgba(15,39,71,.2); }
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-form { display: grid; gap: .8rem; padding: 1.25rem; }
.dialog-form label { display: grid; gap: .3rem; color: #475569; font-size: .84rem; font-weight: 700; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.three-col { display: grid; grid-template-columns: .55fr 1fr 1fr; gap: .75rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }
.toast { position: fixed; right: 1rem; bottom: 1rem; max-width: 420px; padding: .8rem 1rem; background: #172033; color: white; border-radius: 8px; opacity: 0; transform: translateY(10px); pointer-events: none; transition: .18s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
@media (max-width: 1050px) {
  .profile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .contact-layout { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .topbar, .panel-heading, .import-summary { flex-direction: column; align-items: stretch; }
  .summary-grid, .profile-grid { grid-template-columns: 1fr 1fr; }
  .note-form, .two-col, .three-col { grid-template-columns: 1fr; }
}
@media (max-width: 470px) {
  .summary-grid, .profile-grid { grid-template-columns: 1fr; }
}


@media print {
  @page { margin: .55in; }
  body { background:#fff !important; }
  body * { visibility:hidden !important; }
  #contact-detail, #contact-detail * { visibility:visible !important; }
  #contact-detail {
    position:absolute !important;
    left:0 !important;
    top:0 !important;
    width:100% !important;
    min-height:0 !important;
    margin:0 !important;
    padding:0 !important;
    border:0 !important;
    border-radius:0 !important;
    box-shadow:none !important;
    background:#fff !important;
    color:#000 !important;
  }
  #contact-detail .contact-detail-actions,
  #contact-detail #edit-primary-notes,
  #contact-detail #add-note-form,
  #contact-detail button { display:none !important; }
  #contact-detail .detail-head { display:block !important; }
  #contact-detail h3 { color:#000 !important; margin-top:0; }
  #contact-detail .contact-section,
  #contact-detail .priority-box,
  #contact-detail .notes-section,
  #contact-detail .note-item,
  #contact-detail .address-card { break-inside:avoid; }
  #contact-detail .priority-box {
    background:#fff !important;
    border:1px solid #bbb !important;
  }
  #contact-detail .note-item {
    background:#fff !important;
    border-left:2px solid #999 !important;
  }
  #contact-detail .tag {
    background:#fff !important;
    color:#000 !important;
    border:1px solid #bbb !important;
  }
  #contact-detail a { color:#000 !important; text-decoration:none !important; }
  #contact-detail .meta,
  #contact-detail .note-meta { color:#555 !important; }
}
