:root {
  --navy: #073650;
  --navy-deep: #04283f;
  --blue: #008bd2;
  --aqua: #27b5bc;
  --lime: #82c83e;
  --ink: #143244;
  --muted: #6c818c;
  --line: #dce7eb;
  --paper: #f5f8f9;
  --white: #fff;
  --danger: #c73b4d;
  --shadow: 0 22px 60px rgba(4, 40, 63, .12);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body { margin: 0; min-height: 100vh; color: var(--ink); font-family: Inter, Aptos, "Segoe UI", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.eyebrow { color: var(--aqua); font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.eyebrow.light { color: #89dde1; }
.muted { color: var(--muted); line-height: 1.55; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(420px, 1.15fr) minmax(420px, .85fr); background: white; }
.login-visual { position: relative; min-height: 680px; overflow: hidden; padding: 46px 54px; color: white; background: radial-gradient(circle at 72% 17%, rgba(39,181,188,.37), transparent 28%), linear-gradient(145deg, #04283f 4%, #073650 56%, #0b536c 100%); }
.visual-grid { position: absolute; inset: 0; opacity: .19; background-image: linear-gradient(rgba(255,255,255,.16) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.16) 1px, transparent 1px); background-size: 74px 74px; transform: perspective(600px) rotateX(55deg) scale(1.8) translateY(9%); transform-origin: bottom; mask-image: linear-gradient(to top, black, transparent 80%); }
.login-visual::before, .login-visual::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.15); }
.login-visual::before { width: 520px; height: 520px; right: -190px; top: 80px; box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018); }
.login-visual::after { width: 210px; height: 210px; right: 110px; top: 230px; background: linear-gradient(145deg, rgba(130,200,62,.24), rgba(39,181,188,.03)); border: 0; filter: blur(2px); }
.login-brand { position: relative; z-index: 2; }
.login-brand img { width: 176px; height: auto; }
.visual-copy { position: absolute; z-index: 2; left: 9%; bottom: 20%; max-width: 650px; }
.visual-copy h1 { margin: 18px 0 24px; font-size: clamp(3rem, 5.3vw, 6.5rem); line-height: .93; letter-spacing: -.065em; }
.visual-copy h1 em { color: var(--lime); font-family: Georgia, serif; font-weight: 400; }
.visual-copy p { max-width: 520px; margin: 0; color: #cee2e7; font-size: 1.05rem; line-height: 1.65; }
.visual-metric { position: absolute; z-index: 2; left: 9%; bottom: 7%; display: flex; align-items: center; gap: 14px; color: #c7dce2; font-size: .82rem; }
.visual-metric strong { color: var(--navy-deep); background: var(--lime); border-radius: 999px; padding: 7px 10px; font-size: .68rem; letter-spacing: .12em; }

.login-panel { display: grid; place-items: center; padding: 52px; background: linear-gradient(180deg, #fff, #f8fbfb); }
.login-card { width: min(100%, 440px); }
.login-card h2 { margin: 13px 0 8px; color: var(--navy); font-size: clamp(2rem, 3.4vw, 2.75rem); line-height: 1.08; letter-spacing: -.045em; }
.login-card form { margin-top: 32px; }
label { display: block; margin-bottom: 9px; color: var(--navy); font-size: .82rem; font-weight: 750; }
input, textarea { width: 100%; color: var(--ink); background: white; border: 1px solid #cddce1; border-radius: 12px; outline: none; transition: border-color .18s, box-shadow .18s; }
input { height: 52px; padding: 0 15px; }
textarea { padding: 13px 15px; line-height: 1.5; resize: vertical; }
input:focus, textarea:focus { border-color: var(--aqua); box-shadow: 0 0 0 4px rgba(39,181,188,.12); }
.field-with-icon { position: relative; }
.field-with-icon svg { position: absolute; left: 16px; top: 50%; width: 19px; transform: translateY(-50%); fill: none; stroke: #7f959f; stroke-width: 1.8; }
.field-with-icon input { padding-left: 46px; }
.code-input { height: 64px; text-align: center; color: var(--navy); font-size: 1.8rem; font-weight: 800; letter-spacing: .25em; font-variant-numeric: tabular-nums; }
.form-error { min-height: 20px; margin: 7px 0 5px; color: var(--danger); font-size: .78rem; }
.primary-button, .secondary-button, .icon-button, .text-button { border: 0; cursor: pointer; text-decoration: none; transition: transform .16s, box-shadow .16s, background .16s, opacity .16s; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 14px; min-height: 46px; padding: 0 18px; color: var(--navy-deep); background: var(--lime); border-radius: 10px; font-weight: 800; }
.primary-button:hover:not(.disabled) { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(130,200,62,.25); }
.primary-button.full { width: 100%; min-height: 53px; justify-content: space-between; padding: 0 20px; }
.primary-button svg, .secondary-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.primary-button.disabled { opacity: .48; pointer-events: none; }
.secondary-button { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 15px; color: var(--navy); background: white; border: 1px solid var(--line); border-radius: 10px; font-weight: 750; }
.secondary-button:hover { border-color: #b5c9d0; background: #f9fbfb; }
.secondary-button:disabled, .primary-button:disabled { cursor: wait; opacity: .58; }
.text-button { display: block; margin: 18px auto 0; padding: 6px 12px; color: var(--navy); background: transparent; font-size: .82rem; font-weight: 700; }
.security-note { display: flex; align-items: center; gap: 12px; margin-top: 36px; padding-top: 24px; color: var(--muted); border-top: 1px solid var(--line); font-size: .78rem; line-height: 1.45; }
.security-note svg { flex: 0 0 22px; width: 22px; fill: none; stroke: var(--aqua); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mobile-brand { display: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 288px minmax(0, 1fr); background: var(--paper); }
.sidebar { position: sticky; z-index: 30; top: 0; width: 288px; display: flex; flex-direction: column; height: 100vh; color: white; background: linear-gradient(180deg, var(--navy-deep), var(--navy)); }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; min-height: 100px; padding: 0 25px; border-bottom: 1px solid rgba(255,255,255,.11); }
.sidebar-logo { width: 140px; }
.product-name { padding: 5px 7px; color: #b9d0d7; border: 1px solid rgba(255,255,255,.16); border-radius: 6px; font-size: .57rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 27px 17px; }
.nav-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 7px 13px; color: #91aab4; font-size: .67rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.count-pill { min-width: 24px; padding: 3px 7px; text-align: center; color: #c9e0e5; background: rgba(255,255,255,.08); border-radius: 999px; font-size: .65rem; }
.campaign-list { display: grid; gap: 4px; }
.campaign-button { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 13px 14px; text-align: left; color: #e2edf0; background: transparent; border: 0; border-radius: 10px; cursor: pointer; }
.campaign-button:hover { background: rgba(255,255,255,.07); }
.campaign-button.active { color: white; background: rgba(39,181,188,.2); box-shadow: inset 3px 0 var(--lime); }
.campaign-button strong { overflow: hidden; text-overflow: ellipsis; font-size: .82rem; line-height: 1.35; }
.campaign-button small { grid-column: 1; color: #91aab4; font-size: .69rem; }
.campaign-button b { grid-row: 1 / 3; grid-column: 2; align-self: center; min-width: 27px; padding: 4px 6px; text-align: center; color: var(--navy-deep); background: #dbeff1; border-radius: 999px; font-size: .66rem; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 17px; border-top: 1px solid rgba(255,255,255,.11); }
.user-chip { min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; }
.user-chip span:last-child { min-width: 0; }
.user-chip strong, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: .75rem; }
.user-chip small { margin-top: 3px; color: #9eb5bd; font-size: .64rem; }
.avatar { display: grid; place-items: center; width: 35px; height: 35px; color: var(--navy-deep); background: var(--lime); border-radius: 50%; font-size: .76rem; font-weight: 900; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; color: var(--navy); background: white; border: 1px solid var(--line); border-radius: 10px; }
.icon-button:hover { background: #f2f7f8; }
.icon-button svg { width: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button.dark { color: #c4d7dc; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); }

.workspace { min-width: 0; }
.topbar { position: sticky; z-index: 20; top: 0; min-height: 100px; display: flex; align-items: center; gap: 20px; padding: 20px 36px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.topbar h1 { margin: 4px 0 0; color: var(--navy); font-size: clamp(1.45rem, 2vw, 2rem); letter-spacing: -.035em; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.sync-indicator { display: flex; align-items: center; gap: 8px; margin-right: 4px; color: var(--muted); font-size: .7rem; }
.sync-indicator > span:first-child { width: 8px; height: 8px; background: #9cadb4; border-radius: 50%; }
.sync-indicator.success > span:first-child { background: var(--lime); box-shadow: 0 0 0 4px rgba(130,200,62,.13); }
.sync-indicator.failed > span:first-child { background: var(--danger); }
.mobile-menu { display: none; }
.content { max-width: 1600px; margin: 0 auto; padding: 30px 36px 50px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 18px; }
.summary-card { position: relative; min-height: 142px; padding: 24px; overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 15px; }
.summary-card.accent::after { content: ""; position: absolute; width: 110px; height: 110px; right: -46px; bottom: -53px; background: var(--lime); border-radius: 50%; opacity: .17; }
.summary-label { display: block; margin-bottom: 17px; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.summary-card strong { display: block; color: var(--navy); font-size: 2.35rem; line-height: 1; letter-spacing: -.045em; }
.summary-card small { display: block; margin-top: 12px; color: #8799a1; font-size: .7rem; }

.table-card { overflow: hidden; background: white; border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 8px 34px rgba(4,40,63,.045); }
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.table-toolbar h2 { margin: 0; color: var(--navy); font-size: 1.12rem; }
.table-toolbar p { margin: 6px 0 0; color: var(--muted); font-size: .75rem; }
.search-field { position: relative; width: min(370px, 38%); margin: 0; }
.search-field svg { position: absolute; left: 14px; top: 50%; width: 18px; transform: translateY(-50%); fill: none; stroke: #718892; stroke-width: 1.8; }
.search-field input { height: 43px; padding-left: 42px; background: var(--paper); border-color: transparent; font-size: .78rem; }
.table-wrap { position: relative; min-height: 360px; overflow-x: auto; }
table { width: 100%; min-width: 900px; border-collapse: collapse; }
th { padding: 13px 20px; text-align: left; color: #728890; background: #f9fbfb; border-bottom: 1px solid var(--line); font-size: .63rem; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
td { padding: 16px 20px; color: #45606d; border-bottom: 1px solid #edf2f4; font-size: .78rem; vertical-align: middle; }
tbody tr { cursor: pointer; transition: background .14s; }
tbody tr:hover { background: #f8fbfb; }
tbody tr:last-child td { border-bottom: 0; }
.contact-cell strong, .contact-cell small { display: block; }
.contact-cell strong { color: var(--navy); font-size: .81rem; }
.contact-cell small { margin-top: 5px; color: #7a8f98; }
.source-cell strong, .source-cell small { display: block; max-width: 250px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-cell strong { color: #3d5966; font-size: .76rem; }
.source-cell small { margin-top: 4px; color: #8da0a8; font-size: .68rem; }
.note-badge { display: inline-flex; align-items: center; gap: 6px; color: var(--navy); background: #eaf6f6; border-radius: 999px; padding: 6px 9px; font-weight: 750; font-size: .68rem; }
.note-badge.empty { color: #83959d; background: #f1f4f5; }
.row-arrow { color: var(--aqua); font-size: 1.15rem; }
.empty-state { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; padding: 45px; text-align: center; }
.empty-state h3 { margin: 17px 0 7px; color: var(--navy); font-size: 1rem; }
.empty-state p { margin: 0; color: var(--muted); font-size: .76rem; }
.empty-icon { display: grid; place-items: center; width: 62px; height: 62px; color: var(--aqua); background: #ebf7f7; border-radius: 18px; }
.empty-icon svg { width: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; }
.pagination { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; color: var(--muted); border-top: 1px solid var(--line); font-size: .7rem; }
.pagination > div { display: flex; gap: 7px; }
.pagination .icon-button { width: 34px; height: 34px; }
.pagination button:disabled { cursor: not-allowed; opacity: .35; }

.lead-drawer { position: fixed; z-index: 60; top: 0; right: 0; width: min(510px, 100%); height: 100vh; display: flex; flex-direction: column; background: white; box-shadow: -18px 0 50px rgba(4,40,63,.16); transform: translateX(105%); transition: transform .25s ease; }
.lead-drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 25px 26px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 6px 0 0; color: var(--navy); font-size: 1.45rem; letter-spacing: -.035em; }
.drawer-content { flex: 1; overflow-y: auto; padding: 25px 26px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
.detail-item { min-width: 0; padding: 14px; background: var(--paper); border-radius: 10px; }
.detail-item.wide { grid-column: 1 / -1; }
.detail-item span { display: block; margin-bottom: 7px; color: #80939b; font-size: .63rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.detail-item strong { display: block; overflow-wrap: anywhere; color: var(--navy); font-size: .8rem; line-height: 1.45; }
.section-title { margin: 28px 0 12px; color: var(--navy); font-size: .78rem; font-weight: 850; letter-spacing: .07em; text-transform: uppercase; }
.answers { display: grid; gap: 9px; }
.answer-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.answer-row span, .answer-row strong { display: block; }
.answer-row span { margin-bottom: 5px; color: #81949c; font-size: .67rem; }
.answer-row strong { color: #385663; font-size: .77rem; font-weight: 650; line-height: 1.45; }
.notes-list { display: grid; gap: 10px; }
.note { padding: 13px 14px; background: #eff8f8; border-left: 3px solid var(--aqua); border-radius: 0 9px 9px 0; }
.note p { margin: 0; color: #34545f; font-size: .76rem; line-height: 1.55; white-space: pre-wrap; }
.note small { display: block; margin-top: 8px; color: #7d939b; font-size: .64rem; }
.note-form { padding: 20px 26px 24px; background: #f8fbfb; border-top: 1px solid var(--line); }
.note-form textarea { min-height: 90px; background: white; }
.sidebar-scrim { position: fixed; z-index: 50; inset: 0; visibility: hidden; background: rgba(4,40,63,.43); opacity: 0; transition: opacity .2s, visibility .2s; }
.sidebar-scrim.visible { visibility: visible; opacity: 1; }

.toast-region { position: fixed; z-index: 100; top: 18px; right: 18px; display: grid; gap: 8px; }
.toast { max-width: 360px; padding: 13px 16px; color: white; background: var(--navy); border-radius: 10px; box-shadow: var(--shadow); font-size: .76rem; line-height: 1.45; animation: toast-in .2s ease; }
.toast.error { background: #9d2f40; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } }

@media (max-width: 1120px) {
  .sync-indicator { display: none; }
  .topbar { padding-inline: 25px; }
  .content { padding-inline: 25px; }
}

@media (max-width: 920px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-visual { display: none; }
  .login-panel { min-height: 100vh; padding: 32px 22px; }
  .mobile-brand { display: block; margin-bottom: 45px; }
  .mobile-brand img { width: 150px; padding: 13px 17px; background: var(--navy); border-radius: 9px; }
  .app-shell { display: block; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); transition: transform .23s ease; }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-grid; }
  .summary-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 720px) {
  .topbar { min-height: 84px; padding: 14px 16px; }
  .topbar .eyebrow { display: none; }
  .topbar h1 { margin: 0; max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1.15rem; }
  .topbar-actions { gap: 7px; }
  .topbar-actions .secondary-button span, .topbar-actions .primary-button span { display: none; }
  .topbar-actions .secondary-button, .topbar-actions .primary-button { width: 42px; min-height: 42px; padding: 0; }
  .content { padding: 16px 13px 32px; }
  .summary-grid { grid-template-columns: 1fr; gap: 10px; }
  .summary-card { min-height: 102px; padding: 18px; }
  .summary-label { margin-bottom: 10px; }
  .summary-card strong { font-size: 1.8rem; }
  .summary-card small { margin-top: 7px; }
  .table-toolbar { align-items: stretch; flex-direction: column; padding: 18px; }
  .search-field { width: 100%; }
  .table-wrap { min-height: 430px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-item.wide { grid-column: auto; }
  .toast-region { left: 12px; right: 12px; }
  .toast { max-width: none; }
}
