/* ============================================================================
   Satnam Portal — design system
   One light theme, modern and calm. Indigo primary on a soft slate canvas.
   ========================================================================== */
:root {
  --brand:        #4f46e5;   /* indigo 600 */
  --brand-600:    #4338ca;
  --brand-50:     #eef2ff;
  --brand-100:    #e0e7ff;
  --ink:          #0f172a;   /* slate 900 */
  --ink-2:        #334155;   /* slate 700 */
  --muted:        #64748b;   /* slate 500 */
  --faint:        #94a3b8;   /* slate 400 */
  --line:         #e2e8f0;   /* slate 200 */
  --line-2:       #eef2f6;
  --bg:           #f1f5f9;   /* slate 100 */
  --surface:      #ffffff;
  --surface-2:    #f8fafc;   /* slate 50 */
  --ok:           #059669;   --ok-bg:#d1fae5;
  --warn:         #b45309;   --warn-bg:#fef3c7;
  --danger:       #dc2626;   --danger-bg:#fee2e2;
  --info:         #2563eb;   --info-bg:#dbeafe;
  --radius:       12px;
  --radius-sm:    9px;
  --shadow-sm:    0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
  --shadow:       0 4px 12px rgba(15,23,42,.08);
  --shadow-lg:    0 18px 50px rgba(15,23,42,.20);
  --font:         'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --mono:         'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: light;

  /* Aliases for the older token names still used by some pages' inline styles
     (cases/settings/login). Kept mapped to the current palette so those rules
     resolve — e.g. the active status tab was white text on an unset (→
     transparent) background before these existed. */
  --accent:       var(--brand);
  --accent-mid:   var(--brand-600);
  --accent-soft:  var(--brand-100);
  --border:       var(--line);
  --text:         var(--ink);
  --text-2:       var(--ink-2);
  --text-3:       var(--muted);
}

* , *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 40px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 14px; color: var(--ink); }
::placeholder { color: var(--faint); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: var(--radius-sm); padding: 9px 15px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: background .14s, border-color .14s, box-shadow .14s, transform .05s;
  white-space: nowrap; line-height: 1.2; text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.btn-danger { color: var(--danger); border-color: #f3c8c8; background: #fff; }
.btn-danger:hover { background: var(--danger-bg); border-color: #f0b4b4; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { padding: 7px 9px; font-size: 14px; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.85); backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  padding: 12px 22px; display: flex; align-items: center; gap: 14px;
}
.topbar-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-family: 'Plus Jakarta Sans', var(--font); font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.topbar-sub { font-size: 12.5px; color: var(--muted); }
.topbar-right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-right .topbar-sub { margin-right: 4px; }
nav a.btn.active, .btn.active { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand-600); }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.wrap, .set-shell { max-width: 1180px; margin: 0 auto; padding: 22px; }
.set-shell { max-width: 940px; }

/* ── Cards & sections ────────────────────────────────────────────────────── */
.card, .table-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card { padding: 20px 22px; margin-bottom: 16px; }
.table-card { overflow: hidden; }
.table-head {
  padding: 13px 18px; border-bottom: 1px solid var(--line);
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--muted);
}
.table-scroll { overflow-x: auto; }
.set-section-title { font-family: 'Plus Jakarta Sans', var(--font); font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.set-section-sub { font-size: 13px; color: var(--muted); margin: 4px 0 18px; max-width: 70ch; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th {
  background: var(--surface-2); padding: 10px 14px; text-align: left;
  font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
table.grid, table.cases { font-size: 13.5px; }
table.cases tbody tr.clickable { cursor: pointer; transition: background .1s; }
table.cases tbody tr.clickable:hover { background: var(--brand-50); }
table.cases tbody tr.readonly { color: var(--muted); }
.col-n { width: 40px; color: var(--faint); }
.col-actions { width: 1%; white-space: nowrap; }

/* ── Badges & pills ──────────────────────────────────────────────────────── */
.badge, .pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .2px;
  white-space: nowrap;
}
.b-Lead     { background: var(--info-bg);  color: #1e40af; }
.b-Pending  { background: var(--warn-bg);  color: var(--warn); }
.b-Assigned { background: #ede9fe;         color: #6d28d9; }
.b-Unpaid   { background: var(--danger-bg);color: var(--danger); }
.b-Paid     { background: var(--ok-bg);    color: var(--ok); }
.b-Expired  { background: #f1f5f9;         color: var(--muted); }
.pill-role  { background: var(--brand-50); color: var(--brand-600); }
.pill-off   { background: var(--danger-bg); color: var(--danger); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.field input, .field select, .field textarea, .cell-input, .addr-select, input.dlg-input, select.dlg-input, textarea.dlg-input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.field textarea, textarea.dlg-input { resize: vertical; min-height: 76px; font: inherit; }
.case-notes { white-space: pre-wrap; font-size: 13.5px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; line-height: 1.5; }
/* Licence image: small preview in the create dialog, and the viewer in the case drawer. */
.lic-preview { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.lic-preview[hidden] { display: none; }
.lic-preview img { width: 84px; height: 54px; object-fit: cover; border: 1px solid var(--line); border-radius: 8px; }
.lic-view { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.lic-frame { position: relative; display: inline-block; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; line-height: 0; }
.lic-img { max-width: 100%; display: block; }
/* Hover overlay with a centered eye that opens the image full size. */
.lic-view-btn { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-decoration: none; color: #fff; background: rgba(15,23,42,0); opacity: 0; transition: opacity .15s, background .15s; }
.lic-frame:hover .lic-view-btn, .lic-view-btn:focus-visible { opacity: 1; background: rgba(15,23,42,.4); }
.lic-view-btn .eye { display: flex; padding: 11px; border-radius: 999px; background: rgba(0,0,0,.55); }
/* Always-visible red remove button, top-right. */
.lic-remove { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; padding: 0; border: none; border-radius: 999px; background: var(--danger); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-sm); }
.lic-remove:hover { background: #b91c1c; }
.field input:focus, .field select:focus, .field textarea:focus, .cell-input:focus, .addr-select:focus, .dlg-input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100);
}
.field .hint, .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 16px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.banner { padding: 14px 18px; border-radius: var(--radius); background: var(--info-bg); color: #1e3a8a; font-size: 13.5px; }

/* checkbox that reads as a toggle-ish control */
.check { display: inline-flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }

/* ── Quote page: lead rows ───────────────────────────────────────────────── */
/* A larger, friendlier section header for the Leads/Quotes card. */
.table-card > .table-head {
  font-size: 15px; font-weight: 800; letter-spacing: -.01em; text-transform: none;
  color: var(--ink); padding: 16px 20px; background: var(--surface-2);
}
/* Roomier rows with top-aligned, grouped fields — less "spreadsheet", more form. */
#rows td { padding: 14px 12px; vertical-align: top; }
#rows tr { transition: background .12s; }
#rows tr:hover { background: var(--brand-50); }
#rows tr + tr td { border-top: 1px solid var(--line); }
.cell-input { min-width: 92px; }
textarea.cell-multiline { min-height: 132px; resize: vertical; line-height: 1.45; }
.cell-input.mono { letter-spacing: .3px; }
.cell-input.err, input.dlg-input.err, textarea.dlg-input.err, select.dlg-input.err,
.field input.err, .field select.err { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.modal-fs { margin-top: 6px; }
.modal-fs:empty { display: none; }
.stack-input { margin-top: 8px; }
/* small caption above a stacked field */
.micro-label { display: block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); margin: 0 0 3px 2px; }
.lead-channel { min-width: 120px; cursor: pointer; }
/* WhatsApp field with its quick "same as phone" link */
.wa-row { display: flex; flex-direction: column; gap: 3px; }
.wa-input { min-width: 92px; }
.linkbtn { align-self: flex-start; background: none; border: none; padding: 0; margin: 1px 0 0 2px; color: var(--brand); font-size: 11px; font-weight: 700; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
/* Lead channel picker + chips (leads, cases, settings) */
.channel-picker { display: flex; align-items: center; gap: 8px; }
.channel-ic { display: inline-flex; align-items: center; flex-shrink: 0; }
.channel-ic svg { display: block; }

/* Custom channel dropdown (leads rows) — shows icon + full text, no truncation */
.chan-select { position: relative; width: 100%; }
.chan-btn {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.chan-btn:hover { border-color: var(--brand-300, #c7d2fe); }
.chan-btn.open { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.chan-btn.empty { cursor: default; color: var(--faint); }
.chan-btn-text { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chan-caret { display: inline-flex; color: var(--muted); flex-shrink: 0; transition: transform .15s; }
.chan-btn.open .chan-caret { transform: rotate(180deg); }
.chan-menu {
  position: fixed; z-index: 200; width: max-content; max-width: 320px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: 0 12px 34px rgba(15,23,42,.16); padding: 5px; overflow-y: auto;
}
.chan-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border: none; border-radius: 8px; background: none; color: var(--ink);
  font: inherit; font-size: 13.5px; cursor: pointer; white-space: nowrap;
}
.chan-item:hover { background: var(--brand-50); }
.chan-item.sel { background: var(--brand-100); font-weight: 600; }
.chan-item-text { flex: 1; }
.chan-primary { font-size: 10px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; color: var(--brand); background: var(--brand-50); border-radius: 999px; padding: 2px 8px; }

/* Leads action buttons — a tidy vertical group */
.act-group { display: flex; flex-direction: column; gap: 7px; min-width: 128px; }
.act-btn { display: flex; align-items: center; justify-content: flex-start; gap: 7px; width: 100%; }
.act-btn .act-ic { display: inline-flex; opacity: .85; }
.act-primary { justify-content: center; }
.act-ghost { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
.act-ghost:hover { background: var(--brand-50); border-color: var(--brand-300, #c7d2fe); color: var(--brand); }
.act-remove { background: none; border-color: transparent; color: var(--muted); }
.act-remove:hover { background: var(--danger-bg); color: var(--danger); }
.channel-chip { display: inline-flex; align-items: center; gap: 7px; }
.primary-pill { border: none; cursor: pointer; font: inherit; }
.primary-pill:hover { filter: brightness(.96); }
.field-status { display: block; }
.resolved { display: block; font-size: 11.5px; margin-top: 5px; line-height: 1.4; }
.resolved.ok { color: var(--ok); } .resolved.err { color: var(--danger); }
.resolved.loading { color: var(--muted); } .resolved.empty { color: var(--faint); font-style: italic; }
.addr-select { margin-top: 6px; }
.add-case-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 16px 20px 18px; }
.add-case-bar[hidden] { display: none; }
#btn-add {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border: 1px dashed var(--line); border-radius: 10px;
  background: var(--surface-2); color: var(--brand); font-weight: 700; font-size: 13px;
  box-shadow: none; transition: border-color .12s, background .12s, color .12s;
}
#btn-add:hover { border-color: var(--brand); background: var(--brand-50); color: var(--brand-600, var(--brand)); }
.footbar {
  position: sticky; bottom: 0; z-index: 20; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 11px 22px; display: flex; align-items: center; gap: 10px;
}
.footbar .count { font-size: 12.5px; color: var(--muted); }
.footbar .note-pii { margin-left: auto; margin-right: 12px; font-size: 11.5px; color: var(--faint); }
.empty-state { padding: 52px 20px; text-align: center; color: var(--muted); }
.empty-state p { margin-bottom: 14px; }

/* status/quote cell */
.status { min-width: 140px; font-size: 13px; }
.status.idle { color: var(--faint); }
.status-run { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 12.5px; }
.status-err { color: var(--danger); font-size: 12.5px; display: flex; gap: 6px; align-items: flex-start; }
.status-err .x { font-weight: 800; }
.status-err .msg { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.spinner { width: 15px; height: 15px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.price { font-family: 'Plus Jakarta Sans', var(--font); font-size: 20px; font-weight: 800; color: var(--ok); line-height: 1.15; }
.price-period { font-size: 12px; font-weight: 600; color: var(--faint); }
.price-annual { font-size: 12px; color: var(--muted); margin-top: 1px; }
.quote-num { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-top: 4px; }
.link-details { background: none; border: none; color: var(--brand); font-size: 12px; font-weight: 700; padding: 4px 0 0; cursor: pointer; }
.detail-row td { background: var(--surface-2); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; padding: 4px 2px; }
.detail-block h5 { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 7px; font-weight: 800; }
.tier { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.tier:last-child { border-bottom: none; } .tier b { color: var(--ok); }
.retrieve-values { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.retrieve-line { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.retrieve-key { color: var(--muted); min-width: 72px; }
.retrieve-copy { padding: 2px 8px; font-size: 11px; }
.retrieve-note { margin-top: 8px; font-size: 11.5px; color: var(--muted); }

/* ── Cases dashboard toolbar ─────────────────────────────────────────────── */
.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.search { flex: 1; min-width: 220px; max-width: 440px; position: relative; }
.search input { width: 100%; padding: 10px 12px 10px 36px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow-sm); }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
.search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.status-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.status-tab { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; display: inline-flex; gap: 7px; align-items: center; box-shadow: var(--shadow-sm); }
.status-tab:hover { border-color: var(--faint); }
.status-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.status-tab .n { background: rgba(15,23,42,.08); border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.status-tab.active .n { background: rgba(255,255,255,.28); }
/* bulk action bar */
.bulkbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 11px 16px; background: var(--brand-50); border: 1px solid var(--brand-100); border-radius: var(--radius); margin-bottom: 14px; }
.bulkbar[hidden] { display: none; }
.bulkbar .sel-count { font-weight: 700; color: var(--brand-600); }
.check-cell { width: 34px; text-align: center; }
.check-cell input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }

/* Shared filter controls (cases + leads toolbars) */
.member-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.member-filters .filter-select { width: auto; min-width: 170px; margin: 0; font-size: 12.5px; padding: 8px 12px; }
.date-custom { display: inline-flex; align-items: center; gap: 6px; }
.date-custom[hidden] { display: none; }
.member-filters .filter-date-input { width: auto; min-width: 0; margin: 0; font-size: 12.5px; padding: 7px 10px; }
.date-dash { color: var(--faint); }

/* ── Leads page: collapsible intake panel ────────────────────────────────── */
.intake-card { margin-bottom: 20px; }
.intake-head-row { display: flex; align-items: stretch; gap: 10px; background: var(--surface-2); border-radius: var(--radius) var(--radius) 0 0; padding-right: 14px; }
.intake-head {
  display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left;
  padding: 15px 20px; background: none; border: none;
  font: inherit; cursor: pointer; color: var(--ink);
}
.intake-search { display: flex; align-items: center; align-self: center; position: relative; flex: 0 1 420px; min-width: 260px; }
.intake-search .ico { position: absolute; left: 11px; color: var(--faint); font-size: 13px; pointer-events: none; }
.intake-search input { width: 100%; padding: 8px 12px 8px 32px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: 12.5px; }
.intake-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); }
@media (max-width: 640px) { .intake-search { display: none; } }
.intake-title { font-size: 15px; font-weight: 800; letter-spacing: -.01em; }
.intake-hint { color: var(--muted); font-size: 12.5px; flex: 1; }
.intake-chevron { color: var(--ink-2); font-size: 26px; font-weight: 700; line-height: 1; display: inline-block; transition: transform .15s; }
.intake-chevron-btn { display: flex; align-items: center; justify-content: center; align-self: center; width: 40px; height: 40px; border: 1px solid var(--line); background: var(--surface); border-radius: 9px; cursor: pointer; }
.intake-chevron-btn:hover { background: var(--brand-50); border-color: var(--brand); }
.intake-chevron-btn:hover .intake-chevron { color: var(--brand); }
.intake-chevron-btn.collapsed .intake-chevron { transform: rotate(-90deg); }
.intake-body[hidden] { display: none; }
@media (max-width: 720px) { .intake-hint { display: none; } }

/* Intake as labelled cards (one lead per card, fields in a responsive grid) */
.lead-cards { display: flex; flex-direction: column; gap: 16px; padding: 16px 20px 4px; }
.lead-card { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.lead-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 18px; align-items: start; }
.lc-field { display: flex; flex-direction: column; min-width: 0; }
.lc-field.lc-full { grid-column: 1 / -1; }
.lc-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--faint); margin: 0 0 5px 1px; }
.lc-field .cell-input, .lc-field .cc-field, .lc-field .chan-select, .lc-field .wa-row { width: 100%; }
.lead-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.lead-card-foot .status { min-width: 0; }
.act-row { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.act-row .act-btn { width: auto; }
/* the address / vehicle textareas need less height inside the card */
.lead-card textarea.cell-multiline { min-height: 62px; }
.lead-card .detail-row, .lead-cards .detail-row { grid-column: 1 / -1; }

/* ── Leads page: saved-leads list ────────────────────────────────────────── */
.leads-list-card { margin-top: 6px; }
table.leads-list { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.leads-list th { background: var(--surface-2); padding: 10px 14px; text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); border-bottom: 1px solid var(--line); white-space: nowrap; }
table.leads-list td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.leads-list tbody tr:last-child td { border-bottom: none; }
table.leads-list tbody tr:hover { background: var(--brand-50); }
/* Quoted / not-quoted highlight down the left edge */
table.leads-list tbody tr.is-quoted td:first-child { box-shadow: inset 3px 0 0 var(--ok); }
table.leads-list tbody tr.is-unquoted td:first-child { box-shadow: inset 3px 0 0 var(--warn, #e8951c); }
.ll-name { font-weight: 700; color: var(--ink); }
.ll-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.ll-sub.mono { font-family: var(--mono); font-size: 11.5px; }
.q-badge { display: inline-block; white-space: nowrap; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .2px; }
.ll-wa, .ll-mail, .ll-phone { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 12.5px; margin-top: 3px; }
.ll-wa .channel-ic, .ll-mail .channel-ic, .ll-phone .channel-ic { flex-shrink: 0; }
.ll-phone:first-child, .ll-wa:first-child, .ll-mail:first-child { margin-top: 0; }
.ll-mail { word-break: break-all; }

/* Driver / Vehicle cell: name + vehicle at normal size, licence + VIN smaller/mono */
.ll-driver { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--ink); }
.ll-driver .ll-person { display: inline-flex; flex-shrink: 0; }
.ll-veh { display: flex; align-items: flex-start; gap: 6px; margin-top: 3px; color: var(--ink); }
.ll-veh .ll-person { flex-shrink: 0; margin-top: 1px; }
.ll-addr { margin-top: 3px; color: var(--ink-2); font-size: 12.5px; }

/* Fixed "+1" country-code prefix on the phone / WhatsApp inputs */
.cc-field { display: flex; align-items: stretch; width: 100%; }
.cc-field .cc-input {
  width: 46px; flex: 0 0 46px; text-align: center; padding: 9px 4px; font-size: 13px; font-weight: 600;
  color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--line); border-right: none; border-radius: 9px 0 0 9px;
}
.cc-field .cc-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); position: relative; z-index: 1; }
.cc-field .cell-input { border-top-left-radius: 0; border-bottom-left-radius: 0; min-width: 0; }
.q-badge.q-yes { background: #d1fae5; color: #065f46; }
.q-badge.q-no { background: #fef3c7; color: #92400e; }
.leads-list .muted { color: var(--faint); }

/* ── Drawer (case detail) ────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.45); display: flex; }
.overlay[hidden] { display: none; }
.drawer { width: min(560px, 100%); margin-left: auto; height: 100%; background: var(--surface); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slideIn .18s ease; }
@keyframes slideIn { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-head h2 { font-family: 'Plus Jakarta Sans', var(--font); font-size: 17px; font-weight: 800; }
.drawer-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; gap: 9px; flex-wrap: wrap; background: var(--surface-2); }
.close-x { margin-left: auto; background: none; border: none; font-size: 22px; line-height: 1; color: var(--faint); cursor: pointer; padding: 2px 6px; border-radius: 8px; }
.close-x:hover { background: var(--line-2); color: var(--ink); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 7px 14px; font-size: 13.5px; margin-bottom: 16px; }
.kv dt { color: var(--muted); } .kv dd { color: var(--ink); }
.sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); font-weight: 800; margin: 18px 0 9px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.timeline { list-style: none; }
.timeline li { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.timeline li:last-child { border-bottom: none; }
.timeline .when { color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.paylink { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 12.5px; word-break: break-all; margin-top: 6px; }
.readonly-note { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-size: 12.5px; color: var(--muted); flex: 1 1 100%; }

/* ── Modal / Settings panels ─────────────────────────────────────────────── */
.modal { background: var(--surface); border-radius: var(--radius); width: min(920px, 100%); max-height: min(88vh, 940px); margin: auto; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.overlay.center { align-items: center; justify-content: center; padding: 22px; }
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { font-family: 'Plus Jakarta Sans', var(--font); font-size: 17px; font-weight: 800; }
.modal-head .sub { font-size: 12px; color: var(--muted); }
.modal-body { padding: 20px 22px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 13px 22px; border-top: 1px solid var(--line); display: flex; gap: 9px; justify-content: flex-end; align-items: center; background: var(--surface-2); }
.modal-foot .note { margin-right: auto; font-size: 12px; color: var(--muted); }
.fieldgrid, .defaults-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 18px; }
.section-title, .sec-head { grid-column: 1/-1; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin: 16px 0 4px; }
.section-title:first-child, .sec-head:first-child { margin-top: 0; }

/* ── Repeating detail blocks (tickets / suspensions / claims) ─────────────── */
.section-hint { grid-column: 1/-1; font-size: 12px; color: var(--muted); margin: 2px 0 8px; line-height: 1.5; }
.field-full { grid-column: 1/-1; }

/* Live address autocomplete */
.addr-ac { position: relative; width: 100%; }
.addr-ac-menu {
  position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 30px rgba(15,23,42,.16); padding: 4px; max-height: 260px; overflow-y: auto;
}
.addr-ac-menu[hidden] { display: none; }
.addr-ac-item {
  display: block; width: 100%; text-align: left; border: none; background: none;
  font: inherit; font-size: 13.5px; color: var(--ink); padding: 8px 10px; border-radius: 7px; cursor: pointer;
}
.addr-ac-item:hover { background: var(--brand-50); }
.addr-ac-keep { color: var(--brand); font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 7px 7px; margin-top: 2px; }
.addr-ac-note { padding: 8px 10px; font-size: 12.5px; color: var(--muted); }
.repeater { grid-column: 1/-1; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 6px 0 14px; background: var(--surface-2); }
.repeater-head { display: flex; align-items: center; justify-content: space-between; }
.repeater-title { font-weight: 700; font-size: 13.5px; color: var(--ink); margin-bottom: 4px; }
.repeater-rows { display: flex; flex-direction: column; gap: 10px; margin: 8px 0 10px; }
.repeater-empty { font-size: 12.5px; color: var(--muted); font-style: italic; padding: 2px 0 4px; }
.repeater-row { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.repeater-row-num { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .6px; color: var(--brand-600); margin-bottom: 8px; }
.repeater-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 14px; }
.repeater-grid .field { margin-bottom: 8px; }
.repeater-row .btn-danger { margin-top: 2px; }

/* ── Settings tabs ───────────────────────────────────────────────────────── */
.set-tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.set-tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 14px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; margin-bottom: -1px; }
.set-tab:hover { color: var(--ink); }
.set-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.set-panel[hidden] { display: none; }

/* ── Toast & dialogs (see ui.js) ─────────────────────────────────────────── */
.toast-stack { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: 92vw; }
.toast { background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 9px; animation: toastIn .18s ease; }
.toast[hidden] { display: none; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.dlg-input { display: block; margin-top: 10px; }
.dlg-msg { font-size: 14px; color: var(--ink-2); line-height: 1.55; white-space: pre-line; }

/* ── Login ───────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--brand-50), var(--bg)); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; width: min(400px, 100%); padding: 34px 30px; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.login-brand .icon { width: 42px; height: 42px; border-radius: 11px; background: linear-gradient(135deg, var(--brand), #7c3aed); display: flex; align-items: center; justify-content: center; font-size: 21px; box-shadow: var(--shadow-sm); }
.login-brand h1 { font-family: 'Plus Jakarta Sans', var(--font); font-size: 18px; font-weight: 800; }
.login-brand p { font-size: 12.5px; color: var(--muted); }
.login-field { margin-bottom: 15px; }
.login-field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.login-field input { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.login-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-100); background: #fff; }
.login-btn { width: 100%; padding: 12px; border: none; border-radius: 10px; background: var(--brand); color: #fff; font-size: 14px; font-weight: 700; cursor: pointer; margin-top: 4px; box-shadow: var(--shadow-sm); }
.login-btn:hover:not(:disabled) { background: var(--brand-600); }
.login-btn:disabled { opacity: .6; cursor: not-allowed; }
.login-error { background: var(--danger-bg); color: var(--danger); border-radius: 10px; padding: 10px 13px; font-size: 13px; margin-bottom: 15px; }
.login-error[hidden] { display: none; }
.login-note { margin-top: 18px; font-size: 11.5px; color: var(--muted); text-align: center; line-height: 1.5; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .topbar { padding: 10px 14px; }
  .topbar-right { gap: 6px; }
  .topbar-right .topbar-sub { width: 100%; order: 5; margin: 2px 0 0; }
  .wrap, .set-shell { padding: 14px; }
  .form-row { grid-template-columns: 1fr; }
  .fieldgrid, .defaults-grid { grid-template-columns: 1fr 1fr; }
  .kv { grid-template-columns: 100px 1fr; }
  .drawer { width: 100%; }
  .footbar { flex-wrap: wrap; }
  .footbar .note-pii { display: none; }
}
@media (max-width: 520px) {
  .fieldgrid, .defaults-grid { grid-template-columns: 1fr; }
  .btn { padding: 9px 12px; }
  .topbar-title { font-size: 15px; }
  /* Keep every case column on small screens; the table scrolls sideways in its
     own container (.table-scroll) rather than dropping columns. */
}
[hidden] { display: none !important; }
