:root {
  /* Caperton brand: sage #9fb1ae, red #e15f47, yellow #d2cb47, orange #db8344. Deeper shades keep text readable. */
  --brand-sage: #9fb1ae;
  --brand-orange: #db8344;
  --ink: #2c3836;
  --ink-2: #3c4a47;
  --mist: #f3f5f5;
  --surface: #ffffff;
  --surface-2: #f7f9f9;
  --line: #dde3e4;
  --line-strong: #c5ced0;
  --text: #1b2730;
  --muted: #56656e;
  --faint: #7d8b92;
  --lagoon: #9e5a2b;
  --lagoon-ink: #ffffff;
  --lagoon-soft: #f8ebe1;
  --plum: #6b3d6e;
  --plum-soft: #f1e8f1;
  --amber: #8a5a0b;
  --amber-soft: #fbf1dc;
  --brick: #b3261e;
  --brick-soft: #fbe9e7;
  --ok: #2e6b3a;
  --ok-soft: #e5f2e7;
  --r-sm: 6px;
  --r: 10px;
  --font: "Avenir Next", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --mist: #12191e; --surface: #182229; --surface-2: #1d2931; --line: #2b3a43; --line-strong: #3a4c57;
    --text: #e6ecee; --muted: #a8b5bb; --faint: #84939a; --ink: #121816; --ink-2: #222b29;
    --lagoon: #e39a63; --lagoon-ink: #2a1606; --lagoon-soft: #3b2618; --plum: #c28bc5; --plum-soft: #33223a;
    --amber: #e3b35a; --amber-soft: #3a2e17; --brick: #f08b82; --brick-soft: #3d1f1c; --ok: #7cc58a; --ok-soft: #1b3321;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--mist); font-variant-numeric: tabular-nums; }
a { color: var(--lagoon); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; font-weight: 650; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: 0.95rem; font-weight: 650; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--lagoon) 55%, transparent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
@media (min-width: 901px) { .shell { background: linear-gradient(to right, var(--ink) 224px, transparent 224px); } }
.sidebar { background: var(--ink); color: #dfe7ea; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand-mark { width: 36px; height: 36px; flex: none; }
.brand strong { display: block; font-size: 1rem; }
.brand small { display: block; color: var(--brand-sage); font-size: 0.78rem; }
.nav { display: grid; gap: 2px; }
.nav a { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-sm); color: #d6dfdd; text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--ink-2); color: #fff; }
.nav a[aria-current="page"] { background: #3f4f4c; color: #fff; box-shadow: inset 3px 0 0 var(--brand-orange); }
.nav .count { font-size: 0.75rem; background: #4a5b58; color: #eef3f2; border-radius: 999px; padding: 0 7px; min-width: 22px; text-align: center; }
.nav .count.alert { background: #8d2d27; }
.sidebar-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid #415150; font-size: 0.85rem; color: #b9c7c4; }
.sidebar-foot strong { color: #e8eef0; display: block; }
.sidebar-foot button { margin-top: 8px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; gap: 12px; align-items: center; padding: 12px 28px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.topbar .search { flex: 1; max-width: 520px; }
.topbar .search input { width: 100%; }
.topbar .spacer { flex: 1; }
#view { padding: 24px 28px 60px; outline: none; max-width: 1480px; width: 100%; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 8px 12px; gap: 8px; }
  .brand { padding: 0 8px 0 0; }
  .brand small { display: none; }
  .nav { grid-auto-flow: column; overflow-x: auto; flex: 1; }
  .nav a { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .topbar { padding: 10px 14px; position: static; }
  #view { padding: 16px 14px 48px; }
}

/* ---------- Controls ---------- */
.btn { font: inherit; font-weight: 600; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; justify-content: center; min-height: 36px; padding: 6px 14px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: var(--faint); }
.btn-primary { background: var(--lagoon); border-color: var(--lagoon); color: var(--lagoon-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--lagoon) 88%, #000); border-color: transparent; }
.btn-danger { background: var(--brick); border-color: var(--brick); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn-sm { min-height: 30px; padding: 3px 10px; font-size: 0.82rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.sidebar .btn { background: transparent; color: #cfdade; border-color: #3a4f59; }
.link-btn { font: inherit; background: none; border: 0; padding: 0; color: var(--lagoon); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.icon-btn { font: inherit; font-size: 1.3rem; line-height: 1; background: none; border: 0; padding: 4px 8px; border-radius: var(--r-sm); cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--surface-2); }
input:not([type]), input[type="text"], input[type="email"], input[type="tel"], input[type="search"], input[type="password"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="number"], input[type="url"], select, textarea {
  font: inherit; font-size: 0.93rem; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 7px 10px; min-height: 36px; width: 100%;
}
input[type="color"] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); }
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus { border-color: var(--lagoon); outline: 2px solid color-mix(in srgb, var(--lagoon) 30%, transparent); outline-offset: 0; }
label { font-weight: 600; font-size: 0.86rem; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field .hint { font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; font-size: 0.9rem; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--lagoon); width: 16px; height: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.seg a, .seg button { font: inherit; font-size: 0.85rem; font-weight: 600; padding: 6px 12px; color: var(--muted); text-decoration: none; background: none; border: 0; cursor: pointer; }
.seg [aria-pressed="true"], .seg [aria-current="true"] { background: var(--lagoon-soft); color: var(--lagoon); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters select, .filters input { width: auto; min-width: 150px; }
.filters input[type="search"] { min-width: 220px; }

/* ---------- Page structure ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.page-head p { margin: 4px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; }
.panel.flush { padding: 0; }
.panel.flush .panel-head { padding: 14px 18px 0; }
.empty { color: var(--muted); padding: 10px 0; }
.notice { border-radius: var(--r-sm); padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--surface-2); }
.notice.warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 35%, transparent); }
.notice.danger { background: var(--brick-soft); border-color: color-mix(in srgb, var(--brick) 35%, transparent); }
.notice.info { background: var(--lagoon-soft); border-color: color-mix(in srgb, var(--lagoon) 30%, transparent); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 0.76rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge.danger { background: var(--brick-soft); color: var(--brick); border-color: transparent; }
.badge.info { background: var(--lagoon-soft); color: var(--lagoon); border-color: transparent; }
.badge.plum { background: var(--plum-soft); color: var(--plum); border-color: transparent; }
.avatar { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 0.7rem; font-weight: 700; background: var(--lagoon-soft); color: var(--lagoon); flex: none; }
.avatar.none { background: var(--amber-soft); color: var(--amber); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-size: 0.8rem; font-weight: 600; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
.table th button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:hover td { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; }
.table .name a { font-weight: 600; text-decoration: none; color: var(--text); }
.table .name a:hover { color: var(--lagoon); text-decoration: underline; }

/* ---------- Today ---------- */
.stat-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.stat-row a { background: var(--surface); padding: 14px 16px; text-decoration: none; color: var(--text); }
.stat-row a:hover { background: var(--surface-2); }
.stat-row .n { font-size: 1.7rem; font-weight: 650; display: block; line-height: 1.1; }
.stat-row .l { font-size: 0.84rem; color: var(--muted); }
.stat-row .alert .n { color: var(--brick); }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
.today-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: 0; }
.rows .grow { flex: 1; min-width: 0; }
.rows .title { font-weight: 600; }
.rows .title a { color: var(--text); text-decoration: none; }
.rows .title a:hover { color: var(--lagoon); text-decoration: underline; }
.rows .meta { font-size: 0.83rem; color: var(--muted); }
.rows input[type="checkbox"] { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--lagoon); cursor: pointer; }
.due-overdue { color: var(--brick); font-weight: 600; }
.due-today { color: var(--amber); font-weight: 600; }

/* ---------- Pipeline board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: start; }
.kcol { background: color-mix(in srgb, var(--surface-2) 70%, var(--mist)); border: 1px solid var(--line); border-radius: var(--r); min-height: 180px; display: flex; flex-direction: column; }
.kcol.drop { outline: 2px dashed var(--lagoon); outline-offset: -4px; background: var(--lagoon-soft); }
.kcol-head { padding: 10px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; border-top: 4px solid var(--stage, var(--line-strong)); border-radius: var(--r) var(--r) 0 0; }
.kcol-head h2 { font-size: 0.88rem; }
.kcol-head .n { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.kcol-body { padding: 4px 8px 10px; display: grid; gap: 8px; }
.kcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 11px; cursor: grab; display: grid; gap: 5px; }
.kcard:hover { border-color: var(--line-strong); }
.kcard.dragging { opacity: 0.45; }
.kcard .top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.kcard .nm { font-weight: 600; color: var(--text); text-decoration: none; }
.kcard .nm:hover { color: var(--lagoon); text-decoration: underline; }
.kcard .sub { font-size: 0.8rem; color: var(--muted); }
.kcard .foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 0.78rem; }
.kcard .move { font-size: 0.78rem; }
.kcol-more { font-size: 0.8rem; color: var(--muted); text-align: center; padding: 6px; }

/* ---------- Contact record ---------- */
.back { font-size: 0.88rem; text-decoration: none; display: inline-block; margin-bottom: 6px; }
.contact-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.contact-sub { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.journey { display: flex; padding: 0; list-style: none; margin: 4px 0 20px; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.journey li { list-style: none; flex: 1; min-width: 0; position: relative; }
.journey button { font: inherit; width: 100%; height: 100%; border: 0; background: transparent; padding: 10px 8px 9px 18px; text-align: left; cursor: pointer; color: var(--faint); font-size: 0.78rem; font-weight: 600; line-height: 1.25; }
.journey li + li button { border-left: 1px solid var(--line); }
.journey .past button { color: var(--lagoon); background: color-mix(in srgb, var(--lagoon-soft) 60%, var(--surface)); }
.journey .current button { color: #fff; background: var(--plum); }
.journey .side button { color: var(--muted); }
.journey .side.current button { background: var(--ink-2); color: #fff; }
.journey button:hover { text-decoration: underline; }
.journey button span { display: block; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) { .journey { flex-wrap: wrap; } .journey li { flex: 1 1 33%; } }
.contact-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
@media (max-width: 1100px) { .contact-grid { grid-template-columns: 1fr; } }
.ownerbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.ownerbar .k { font-size: 0.8rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
@media (max-width: 700px) { .ownerbar { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 0.9rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chips button { font: inherit; font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--muted); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink-2); border-color: var(--ink-2); color: #fff; }

/* Timeline: a vertical rail with a node per event, coloured by kind */
.timeline { list-style: none; margin: 0; padding: 0 0 0 4px; }
.tl { position: relative; padding: 0 0 18px 26px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: -2px; width: 2px; background: var(--line); }
.tl:last-child::before { display: none; }
.tl::after { content: ""; position: absolute; left: 0; top: 5px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--node, var(--line-strong)); }
.tl.k-inbound { --node: var(--plum); }
.tl.k-outbound { --node: var(--lagoon); }
.tl.k-stage { --node: var(--ink-2); }
.tl.k-appt { --node: var(--amber); }
.tl.k-task { --node: var(--faint); }
.tl.k-note { --node: #9b8a3e; }
.tl.k-system { --node: var(--line-strong); }
.tl-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; }
.tl-sum { font-weight: 600; }
.tl-when { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.tl-by { font-size: 0.8rem; color: var(--muted); }
.tl-body { margin-top: 6px; white-space: pre-wrap; font-size: 0.9rem; background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; border: 1px solid var(--line); }
.tl-fields { margin-top: 6px; display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 0.86rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; }
.tl-fields dt { color: var(--muted); }
.tl-fields dd { margin: 0; overflow-wrap: anywhere; }
.tl-ctx { margin-top: 4px; font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.task-list { list-style: none; padding: 0; margin: 0; }
.task-list li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--line); }
.task-list li:first-child { border-top: 0; }
.task-list li > div { flex: 1; min-width: 0; }
.task-list .done { color: var(--faint); text-decoration: line-through; }

/* ---------- Forms builder ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr); gap: 18px; align-items: start; }
@media (max-width: 1100px) { .builder { grid-template-columns: 1fr; } }
.preview-pane { position: sticky; top: 76px; }
.preview-frame { width: 100%; height: 72vh; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
.preview-tools { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 8px; }
.fcard { border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface); margin-bottom: 8px; }
.fcard.open { border-color: var(--lagoon); box-shadow: 0 0 0 1px var(--lagoon); }
.fcard-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; }
.fcard-head .lbl { flex: 1; min-width: 0; font-weight: 600; background: none; border: 0; text-align: left; font: inherit; cursor: pointer; color: var(--text); padding: 4px 0; }
.fcard-head .lbl small { display: block; font-weight: 500; color: var(--muted); font-size: 0.78rem; }
.fcard-body { padding: 4px 12px 12px; border-top: 1px solid var(--line); }
.add-field { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button, .tabs a { font: inherit; font-weight: 600; font-size: 0.9rem; padding: 8px 12px; border: 0; background: none; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; text-decoration: none; white-space: nowrap; }
.tabs [aria-selected="true"], .tabs [aria-current="page"] { color: var(--text); border-bottom-color: var(--lagoon); }
pre.code { background: var(--ink); color: #dfeaec; padding: 12px 14px; border-radius: var(--r-sm); overflow-x: auto; font-size: 0.82rem; white-space: pre-wrap; word-break: break-all; margin: 6px 0 10px; }

/* ---------- Reports ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi .n { font-size: 1.6rem; font-weight: 650; line-height: 1.15; }
.kpi .l { font-size: 0.84rem; color: var(--muted); }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; align-items: start; }
@media (max-width: 520px) { .report-grid { grid-template-columns: 1fr; } }
.bars { display: grid; gap: 7px; }
.bar { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 44px; gap: 10px; align-items: center; font-size: 0.87rem; }
.bar .track { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bar .fill { display: block; height: 100%; background: var(--lagoon); border-radius: 999px; }
.bar .v { text-align: right; font-weight: 600; }
.funnel { display: grid; gap: 8px; }
.funnel .step { display: grid; grid-template-columns: 160px 1fr 90px; gap: 10px; align-items: center; font-size: 0.88rem; }
.funnel .track { display: block; }
.funnel .fill { display: block; height: 22px; border-radius: 4px; background: var(--plum); }
details.defs summary { cursor: pointer; font-weight: 600; }
details.defs dl { margin: 10px 0 0; display: grid; gap: 8px; }
details.defs dt { font-weight: 600; }
details.defs dd { margin: 0; color: var(--muted); }

/* ---------- Modals, toasts, login ---------- */
dialog.modal { border: 0; border-radius: var(--r); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--surface); color: var(--text); box-shadow: 0 18px 50px rgba(10, 20, 25, 0.35); }
dialog.modal.wide { width: min(860px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(15, 25, 30, 0.45); }
.modal-form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-error { margin: 0 18px 12px; color: var(--brick); background: var(--brick-soft); padding: 8px 12px; border-radius: var(--r-sm); font-weight: 500; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r) var(--r); }
#toasts { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r-sm); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); max-width: 360px; font-weight: 500; }
.toast.error { background: var(--brick); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--ink); }
.login { width: min(400px, 100%); background: var(--surface); border-radius: var(--r); padding: 28px; }
.login h1 { margin-bottom: 4px; }
.login-logo { display: block; width: 200px; height: auto; margin: 0 auto 20px; }
.login .btn { width: 100%; margin-top: 6px; }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 10px; text-decoration: none; background: #fff; color: #1f1f1f; border: 1px solid #747775; font-weight: 600; }
.btn-google:hover { background: #f2f4f3; }
.login-or { display: flex; align-items: center; gap: 10px; margin: 18px 0 6px; }
.login-or::before, .login-or::after { content: ''; flex: 1; border-top: 1px solid var(--line, #d6dcdb); }
.dup-box { border: 1px solid color-mix(in srgb, var(--amber) 40%, transparent); background: var(--amber-soft); border-radius: var(--r-sm); padding: 10px 12px; margin-bottom: 12px; font-size: 0.9rem; }
.compare { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.compare th, .compare td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.compare td label { font-weight: 400; display: flex; gap: 6px; align-items: flex-start; }
.loading { color: var(--muted); padding: 30px 0; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Help assistant ---------- */
.help-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 40; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(10, 20, 25, 0.18); }
.help-panel[hidden] { display: none; }
.help-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 3px solid var(--brand-orange); }
.help-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.help-note { margin: 0; padding: 10px 16px; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.help-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.help-empty p { color: var(--muted); }
.help-suggest { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.help-suggest .btn { white-space: normal; text-align: left; font-weight: 500; }
.help-msg { max-width: 92%; padding: 8px 12px; border-radius: var(--r); font-size: 0.92rem; overflow-wrap: anywhere; }
.help-msg p { margin: 0 0 6px; }
.help-msg p:last-child { margin-bottom: 0; }
.help-msg ul, .help-msg ol { margin: 4px 0 6px; padding-left: 20px; }
.help-msg code { font-size: 0.85em; background: color-mix(in srgb, var(--text) 8%, transparent); padding: 1px 4px; border-radius: 4px; }
.help-msg.me { align-self: flex-end; background: var(--lagoon-soft); }
.help-msg.bot { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); }
.help-msg.err { border-color: color-mix(in srgb, var(--brick) 40%, transparent); background: var(--brick-soft); }
.help-form { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.help-form textarea { width: 100%; min-height: 60px; }
.help-actions { display: flex; justify-content: space-between; margin-top: 8px; }
