/* Support-dashboard — strak zakelijk, Gorgias-parity (3 kolommen).
   Ruim, blauw accent, crisp. Light + dark. */

:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #eef1f5;
  --border: #e2e6ec;
  --border-strong: #cfd5de;
  --text: #14181f;
  --text-2: #4c5563;
  --muted: #838b98;
  --accent: #2b59c3;
  --accent-soft: #e9f0fb;
  --accent-ring: rgba(43,89,195,.24);
  --primary: #2b59c3;
  --primary-text: #ffffff;
  --primary-hover: #244aa4;
  --green: #147a45; --green-soft: #e4f3ea;
  --amber: #a8680f; --amber-soft: #f7eddb;
  --red: #c8362b;   --red-soft: #fae7e5;
  --info: #2160c4;  --info-soft: #e7effb;
  --note-bg: #fdf6df; --note-border: #ecd9a0;
  --ch-created: #2b59c3; --ch-replied: #a8680f; --ch-closed: #147a45;
  --shadow-sm: 0 1px 2px rgba(20,24,31,.05);
  --shadow: 0 4px 16px rgba(20,24,31,.08), 0 1px 3px rgba(20,24,31,.05);
  --shadow-lg: 0 18px 48px rgba(20,24,31,.20);
  --r-sm: 6px; --r: 8px; --r-lg: 12px;
  --font: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Kolombreedtes — aanpasbaar door de scheidingslijnen te slepen (app.js initResizers) */
  --w-nav: 232px; --w-list: 384px; --w-side: 296px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f13; --surface: #15191f; --surface-2: #1d232c;
    --border: #262d38; --border-strong: #343d4a;
    --text: #e7eaef; --text-2: #a6adb9; --muted: #767e8b;
    --accent: #6f9bff; --accent-soft: #182338; --accent-ring: rgba(111,155,255,.30);
    --primary: #3f6fe0; --primary-text: #ffffff; --primary-hover: #345fc4;
    --green: #4cc98a; --green-soft: #16281f;
    --amber: #e0a24a; --amber-soft: #2a2113;
    --red: #f0776b;   --red-soft: #2c1918;
    --info: #6ba2f0;  --info-soft: #14233c;
    --note-bg: #2a2410; --note-border: #57491d;
    --ch-created: #3d70e0; --ch-replied: #b0781f; --ch-closed: #1f8f56;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 6px 20px rgba(0,0,0,.44), 0 1px 3px rgba(0,0,0,.3);
    --shadow-lg: 0 20px 52px rgba(0,0,0,.62);
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f13; --surface: #15191f; --surface-2: #1d232c;
  --border: #262d38; --border-strong: #343d4a;
  --text: #e7eaef; --text-2: #a6adb9; --muted: #767e8b;
  --accent: #6f9bff; --accent-soft: #182338; --accent-ring: rgba(111,155,255,.30);
  --primary: #3f6fe0; --primary-text: #ffffff; --primary-hover: #345fc4;
  --green: #4cc98a; --green-soft: #16281f;
  --amber: #e0a24a; --amber-soft: #2a2113;
  --red: #f0776b;   --red-soft: #2c1918;
  --info: #6ba2f0;  --info-soft: #14233c;
  --note-bg: #2a2410; --note-border: #57491d;
  --ch-created: #3d70e0; --ch-replied: #b0781f; --ch-closed: #1f8f56;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
  --shadow: 0 6px 20px rgba(0,0,0,.44), 0 1px 3px rgba(0,0,0,.3);
  --shadow-lg: 0 20px 52px rgba(0,0,0,.62);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; color: inherit; }
input, textarea, select { font: inherit; color: var(--text); }
::selection { background: var(--accent-soft); }
h1,h2,h3,h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 12.5px; }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }

input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }

/* ── Buttons / controls ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px;
  border: 1px solid var(--border); background: var(--surface); border-radius: var(--r-sm);
  color: var(--text); font-weight: 500; transition: background .13s, border-color .13s; }
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { transform: translateY(.5px); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { padding: 6px 11px; font-size: 12.5px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }

select.control, input.control { padding: 7px 11px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--surface); appearance: none; font-size: 13px; }
select.control { padding-right: 27px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23838b98' stroke-width='2.5'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 8px center; }

/* Nette checkbox */
.cb { display: inline-flex; align-items: center; cursor: pointer; }
.cb input { position: absolute; opacity: 0; width: 0; height: 0; }
.cb span { width: 17px; height: 17px; border: 1.5px solid var(--border-strong); border-radius: 5px;
  background: var(--surface); display: inline-block; position: relative; transition: background .12s, border-color .12s; }
.cb input:checked + span { background: var(--primary); border-color: var(--primary); }
.cb input:checked + span::after { content: ""; position: absolute; left: 4.5px; top: 1.5px;
  width: 4px; height: 8px; border: solid var(--primary-text); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.cbrow { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }

/* ── Topbar ── */
.topbar { display: flex; align-items: center; gap: 12px; height: 58px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; }
.brand .mark { width: 28px; height: 28px; border-radius: 7px; background: var(--primary);
  color: var(--primary-text); display: grid; place-items: center; font-size: 15px; font-weight: 800; }
.brand .name { font-size: 15.5px; }
.topbar .search { flex: 1; max-width: 430px; position: relative; }
.topbar .search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.topbar .search input { width: 100%; padding: 9px 14px 9px 37px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--bg); }
.topbar .spacer { flex: 1; }
.userchip { color: var(--text-2); font-size: 13px; white-space: nowrap; }
.iconbtn { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid transparent;
  background: transparent; border-radius: var(--r-sm); color: var(--text-2); }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }
.healthdot { width: 26px; height: 26px; border: none; background: transparent; border-radius: 50%; position: relative; }
.healthdot::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--muted); }
.healthdot.good::after { background: var(--green); }
.healthdot.bad::after { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }
.dnsbox { display: flex; flex-direction: column; gap: 4px; }
.dnsrow { font-size: 12px; }
.dnsrow code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 11.5px; }

/* ── Layout: 3 kolommen ── */
.layout { display: flex; height: calc(100vh - 58px); }

/* Kolom 1: views-navigatie */
.viewnav { width: var(--w-nav); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.viewnav .newticket { justify-content: center; margin-bottom: 12px; }
.viewnav .storesel { margin-bottom: 10px; width: 100%; }
.navsec { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  font-weight: 600; margin: 10px 4px 6px; }
.ownviews-head { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.navitem { display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px;
  border: none; background: transparent; border-radius: var(--r-sm); color: var(--text-2);
  font-weight: 500; text-align: left; transition: background .12s, color .12s; }
.navitem:hover { background: var(--surface-2); color: var(--text); }
.navitem.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.navitem .ic { width: 16px; display: grid; place-items: center; flex-shrink: 0; }
.navitem .lbl { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.navitem .count { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2);
  padding: 1px 8px; border-radius: 999px; min-width: 24px; text-align: center; font-variant-numeric: tabular-nums; }
.navitem.active .count { background: var(--accent); color: #fff; }
.navitem .del { display: none; border: none; background: none; color: var(--muted); padding: 0 2px; }
.navitem:hover .del { display: inline; }
.navitem .del:hover { color: var(--red); }
.navmore { border: none; background: none; color: var(--muted); font-size: 12.5px; padding: 7px 10px;
  text-align: left; border-radius: var(--r-sm); }
.navmore:hover { background: var(--surface-2); color: var(--text); }

/* Kolom 2: ticketlijst */
.listpane { width: var(--w-list); flex-shrink: 0; border-right: 1px solid var(--border);
  background: var(--surface); display: flex; flex-direction: column; }

/* Sleepbare kolom-scheiding: subtiel grijpstreepje, blauw op hover/slepen,
   dubbelklik = reset naar standaardbreedte */
.resizer { flex: 0 0 6px; cursor: col-resize; transition: background .12s; position: relative;
  background: transparent; }
.resizer::after { content: ""; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); width: 2px; height: 34px; border-radius: 2px;
  background: var(--border-strong); }
.resizer:hover, .resizer.dragging { background: var(--accent-ring); }
.resizer:hover::after, .resizer.dragging::after { background: var(--accent); }
body.col-resizing { cursor: col-resize; user-select: none; }
body.col-resizing iframe { pointer-events: none; }  /* iframe eet anders de muismoves op */
.listhead { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 13px 16px 10px; }
.viewtitle { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.bulkhead { display: flex; align-items: center; gap: 10px; padding: 8px 16px;
  border-bottom: 1px solid var(--border); min-height: 44px; flex-wrap: wrap; }
.bulklabel { color: var(--muted); font-size: 12.5px; }
.bulkacts { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.conv-list { overflow-y: auto; flex: 1; }
.conv { display: flex; gap: 11px; padding: 14px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; position: relative; transition: background .12s; align-items: flex-start; }
.conv:hover { background: var(--surface-2); }
.conv.selected { background: var(--accent-soft); }
.conv.selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.conv .cb { margin-top: 10px; }
.conv-main { min-width: 0; flex: 1; }
.conv .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv .who { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .time { color: var(--muted); font-size: 11.5px; white-space: nowrap; flex-shrink: 0; }
.conv .subj { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.conv .preview { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.conv .badges { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }

/* Avatars */
.avatar { width: 38px; height: 38px; border-radius: var(--r); flex-shrink: 0; display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px; letter-spacing: -.01em; margin-top: 2px; }
.avatar.sm { width: 30px; height: 30px; font-size: 11.5px; }

/* Badges */
.badge { font-size: 11px; padding: 2.5px 8px; border-radius: 5px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2); display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.st-open { background: var(--info-soft); color: var(--info); }             .st-open .dot { background: var(--info); }
.st-wacht_op_mens { background: var(--amber-soft); color: var(--amber); }  .st-wacht_op_mens .dot { background: var(--amber); }
.st-beantwoord { background: var(--green-soft); color: var(--green); }     .st-beantwoord .dot { background: var(--green); }
.st-gesloten { background: var(--surface-2); color: var(--muted); }        .st-gesloten .dot { background: var(--muted); }
.st-snoozed { background: var(--accent-soft); color: var(--accent); }      .st-snoozed .dot { background: var(--accent); }
.st-spam { background: var(--red-soft); color: var(--red); }               .st-spam .dot { background: var(--red); }
.st-prullenbak { background: var(--surface-2); color: var(--muted); }      .st-prullenbak .dot { background: var(--muted); }
.badge.intent { background: var(--accent-soft); color: var(--accent); }
.badge.label { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.badge.store { background: transparent; border: 1px solid var(--border-strong); color: var(--text-2); }
.badge.store .dot { background: var(--accent); }

/* Kolom 3: detail */
.detail { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); min-width: 0; }
.detail .empty { margin: auto; color: var(--muted); text-align: center; padding: 48px; }
.detail .empty .big { font-size: 16px; color: var(--text-2); margin-bottom: 4px; font-weight: 600; }
.detail-head { padding: 13px 20px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap; }
.detail-head h2 { font-size: 15.5px; }
.detail-head .sub { color: var(--muted); font-size: 12px; margin-top: 0; }
.detail-head .headspacer { flex: 1; }
.back-btn { display: none; }

.detail-cols { flex: 1; display: flex; min-height: 0; }
.thread-col { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.detail-body { flex: 1; overflow-y: auto; padding: 20px 22px; }
.thread { display: flex; flex-direction: column; gap: 14px; max-width: 860px; }
.msg { max-width: 78%; padding: 12px 16px; border-radius: var(--r-lg); white-space: pre-wrap;
  box-shadow: var(--shadow-sm); font-size: 14px; line-height: 1.6; }
.msg.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--accent-soft); border: 1px solid transparent; border-bottom-right-radius: 4px; }
.msg.note { align-self: stretch; max-width: none; background: var(--note-bg); border: 1px solid var(--note-border); }
.msg .meta { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
/* HTML-mails krijgen de volle threadbreedte (geen smalle bubbel met scrollbalken) */
.msg.htmlmail { max-width: none; align-self: stretch; }
.mailwrap { display: flex; flex-direction: column; gap: 6px; }
.mailhtml { width: 100%; height: 340px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; resize: vertical; overflow: auto; min-height: 70px; }
.imgtoggle { align-self: flex-start; }
.atts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.att { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 12.5px; text-decoration: none; color: var(--text); background: var(--surface); }
.att:hover { background: var(--surface-2); }
.att.disabled { color: var(--muted); border-style: dashed; cursor: default; }
.snoozebanner { background: var(--accent-soft); color: var(--accent); border-radius: var(--r);
  padding: 9px 14px; margin-bottom: 14px; font-size: 13px; font-weight: 500; }

/* Rechter zijpaneel */
.sidepanel { width: var(--w-side); flex-shrink: 0; border-left: 1px solid var(--border); background: var(--surface);
  overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.sp-sec h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 8px; }
.sp-sec .body { white-space: pre-wrap; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; line-height: 1.65; }
.ordercard { border: 1px solid var(--border); border-radius: var(--r); padding: 10px 12px; margin-bottom: 10px; font-size: 12.5px; }
.ordercard .ohead { font-size: 13px; }
.ordercard .ometa { color: var(--text-2); margin: 3px 0 6px; }
.oli { color: var(--text-2); padding: 1px 0; }
.orefund { color: var(--amber); margin-top: 3px; }
.otrack { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.otrack a { color: var(--accent); text-decoration: none; }
.otrack a:hover { text-decoration: underline; }
.oactions { display: flex; gap: 6px; margin-top: 9px; }
.sp-kv { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; }
.sp-kv .k { color: var(--muted); }
.sp-kv .v { text-align: right; word-break: break-all; }
.folderchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.folderchip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; cursor: pointer; }
.folderchip b { opacity: .6; }
.folderchip:hover b { opacity: 1; }

/* Composer */
.compose { border-top: 1px solid var(--border); background: var(--surface); padding: 0 20px 16px; }
.compose-tabs { display: flex; gap: 2px; }
.compose-tabs button { border: none; background: none; padding: 11px 14px; color: var(--muted);
  font-weight: 600; font-size: 13px; border-bottom: 2px solid transparent; }
.compose-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.compose-tabs button.note-tab.active { color: var(--amber); border-bottom-color: var(--amber); }
.macro-row { position: relative; margin: 10px 0 8px; }
.macro-row input { width: 100%; padding: 8px 12px 8px 32px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--bg); font-size: 13px; }
.macro-row .bolt { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.macro-results { position: absolute; left: 0; right: 0; bottom: calc(100% + 4px); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); max-height: 240px;
  overflow-y: auto; z-index: 30; display: none; }
.macro-results.open { display: block; }
.macro-hit { padding: 9px 13px; cursor: pointer; border-bottom: 1px solid var(--border); }
.macro-hit:last-child { border-bottom: none; }
.macro-hit:hover { background: var(--surface-2); }
.macro-hit .t { font-weight: 600; font-size: 13px; }
.macro-hit .b { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.compose textarea { width: 100%; min-height: 122px; resize: vertical; padding: 13px 15px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--bg); line-height: 1.6; font-size: 14px; }
.compose.notemode textarea { background: var(--note-bg); border-color: var(--note-border); }
.compose .actions { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.compose .actions .spacer { flex: 1; }

/* Dropdown-menu's (snooze, …) */
.menuwrap { position: relative; }
.menupanel { position: absolute; top: calc(100% + 6px); right: 0; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg);
  min-width: 200px; z-index: 40; padding: 6px; display: none; }
.menupanel.open { display: block; }
.menuitem { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 11px; border: none;
  background: none; border-radius: var(--r-sm); font-size: 13px; color: var(--text); text-align: left; }
.menuitem:hover { background: var(--surface-2); }
.menuitem.danger { color: var(--red); }
.menusep { height: 1px; background: var(--border); margin: 5px 4px; }
.snooze-custom { padding: 8px 11px; display: flex; flex-direction: column; gap: 7px; }
.snooze-custom input { padding: 7px 9px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg); font-size: 13px; }

/* ── Rapportage ── */
.analytics { height: calc(100vh - 58px); overflow-y: auto; padding: 24px 28px; }
.ana-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.ana-head h2 { font-size: 19px; }
.ana-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 22px; }
.ana-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.ana-card .n { font-size: 30px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ana-card .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.ana-card .who { color: var(--text-2); font-size: 12px; margin-top: 6px; line-height: 1.5; }
.ana-chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 18px 20px; box-shadow: var(--shadow-sm); }
.ana-chart-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.ana-chart-head h3 { font-size: 14.5px; }
.legend { display: flex; gap: 16px; flex: 1; flex-wrap: wrap; }
.legend .li { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }
.legend .sw { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
#chart-wrap svg { width: 100%; height: auto; display: block; }
#chart-wrap text { font-family: var(--font); fill: var(--muted); font-size: 11px; }
#chart-wrap .grid { stroke: var(--border); stroke-width: 1; }
#chart-wrap .axis { stroke: var(--border-strong); stroke-width: 1; }
.chart-tip { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  box-shadow: var(--shadow-lg); padding: 8px 11px; font-size: 12.5px; pointer-events: none; z-index: 90; display: none; }
.chart-tip .row { display: flex; align-items: center; gap: 6px; }
#chart-table table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
#chart-table th, #chart-table td { padding: 5px 9px; border-bottom: 1px solid var(--border); text-align: right;
  font-variant-numeric: tabular-nums; }
#chart-table th:first-child, #chart-table td:first-child { text-align: left; }

/* ── Modals / toast / login ── */
.modal-back { position: fixed; inset: 0; background: rgba(13,15,19,.5); backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center; z-index: 60; padding: 22px; }
.modal-back.open { display: flex; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  width: min(620px, 96vw); max-height: 86vh; overflow-y: auto; padding: 24px 26px; box-shadow: var(--shadow-lg); }
.modal h3 { font-size: 17px; margin-bottom: 16px; }
.modal .close { float: right; }
.field { margin-bottom: 12px; display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field input, .field textarea, .field select { padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--r-sm); background: var(--bg); }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.modal .sec-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 20px 0 10px; }
.varhelp { font-size: 12px; color: var(--muted); margin: -4px 0 12px; line-height: 2; }
.varchip { background: var(--accent-soft); color: var(--accent); padding: 2px 7px; border-radius: 5px;
  font-family: ui-monospace, monospace; font-size: 11.5px; cursor: pointer; white-space: nowrap; }
.varchip:hover { outline: 1px solid var(--accent); }
.mergeopt { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--r); margin-bottom: 8px; cursor: pointer; }
.mergeopt:hover { background: var(--surface-2); }
.mergeopt.sel { border-color: var(--accent); background: var(--accent-soft); }
.mergeopt .info { min-width: 0; flex: 1; }
.mergeopt .s { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(8px);
  background: var(--primary); color: var(--primary-text); padding: 12px 20px; border-radius: var(--r);
  box-shadow: var(--shadow-lg); z-index: 100; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; font-size: 13px; font-weight: 500; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); color: #fff; }

.login-wrap { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 22px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 38px 38px 32px; width: 372px; box-shadow: var(--shadow); }
.login-card .brand { margin-bottom: 22px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.login-card .field { margin-bottom: 15px; }
.login-card input { padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--bg); font-size: 15px; }
.login-card .err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 4px; }

/* ── Responsive ── */
@media (max-width: 1180px) { .sidepanel, .resizer[data-resize="side"] { display: none; } }
@media (max-width: 980px) { .viewnav, .resizer[data-resize="nav"] { display: none; } }
@media (max-width: 860px) {
  .resizer { display: none; }
  .listpane { width: 100%; min-width: 0; border-right: none; }
  .detail { display: none; }
  .layout.showing-detail .listpane { display: none; }
  .layout.showing-detail .detail { display: flex; }
  .back-btn { display: inline-flex; }
  .topbar .search { display: none; }
  .msg { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
