:root {
  --bg: #fbfbfa;
  --panel: #ffffff;
  --ink: #1a1a1e;
  --ink-soft: #5b5b66;
  --ink-faint: #9a9aa6;
  --line: #ececef;
  --line-strong: #e0e0e4;
  --accent: #5b59d6;
  --accent-soft: #efeffc;
  --accent-strong: #4a48c4;
  --green: #1f9d6b;
  --green-soft: #e6f6ee;
  --amber: #b7791f;
  --amber-soft: #fbf2e2;
  --red: #c0392b;
  --red-soft: #fbeae8;
  --gray-soft: #f1f1f3;
  --panel-2: #fcfcfc;
  --row-hover: #fafaff;
  --scrim: rgba(20, 20, 30, 0.3);
  --on-accent: #ffffff;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 20, 30, 0.04), 0 4px 16px rgba(20, 20, 30, 0.06);
  --shadow-lg: 0 10px 40px rgba(20, 20, 30, 0.16);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-ui: var(--sans);
  --font-display: var(--sans);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--sidebar-bg, var(--panel));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  font-weight: 800; font-size: 15px;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-soft); text-decoration: none;
  font-weight: 500; font-size: 13.5px;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--gray-soft); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink-faint); transition: background 0.12s ease;
}
.nav-item.active .nav-dot { background: var(--accent); }

.sidebar-foot { margin-top: auto; }
.mode-badge {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--amber-soft); color: var(--amber);
  font-size: 12px; font-weight: 600;
}
.mode-badge::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--amber);
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg, var(--panel));
  backdrop-filter: blur(6px);
  position: sticky; top: 0; z-index: 5;
}
.topbar-titles h1 { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { color: var(--ink-faint); font-size: 13px; margin-top: 1px; }
.topbar-actions { display: flex; gap: 8px; }

.view { padding: 28px 40px 60px; max-width: 1600px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: transform 0.06s ease, background 0.12s ease, border 0.12s ease;
}
.btn:active { transform: translateY(1px); }
.btn-icon { font-size: 11px; line-height: 1; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(0.94); }
.btn-danger:disabled { opacity: 0.6; cursor: default; }
.confirm-msg { margin: 0; line-height: 1.55; color: var(--ink-soft); }
.btn-ghost { background: var(--panel); color: var(--ink-soft); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--gray-soft); color: var(--ink); }

.icon-btn {
  width: 30px; height: 30px; border-radius: 7px; border: none;
  background: transparent; color: var(--ink-faint);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.icon-btn:hover { background: var(--gray-soft); color: var(--ink); }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.stat-label { color: var(--ink-faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; margin-top: 8px; }

/* ---------- Section + table ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin: 8px 0 14px; }
.section-head h2 { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.section-head .muted { color: var(--ink-faint); font-size: 13px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--ink-faint);
  padding: 11px 18px; border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}
tbody td { padding: 13px 18px; border-bottom: 1px solid var(--line); font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background 0.1s ease; }
tbody tr:hover { background: var(--row-hover); }
.cell-strong { font-weight: 600; }
.cell-mono { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }
.cell-muted { color: var(--ink-faint); }
.cell-truncate { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-new { animation: flashRow 1.6s ease; }
@keyframes flashRow { 0% { background: var(--accent-soft); } 100% { background: transparent; } }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge-completed { background: var(--green-soft); color: var(--green); }
.badge-progress { background: var(--amber-soft); color: var(--amber); }
.badge-failed { background: var(--red-soft); color: var(--red); }
.badge-neutral { background: var(--gray-soft); color: var(--ink-soft); }

/* ---------- Empty / loading ---------- */
.empty { padding: 60px 24px; text-align: center; }
.empty-emoji { font-size: 30px; }
.empty h3 { margin-top: 12px; font-size: 16px; }
.empty p { color: var(--ink-faint); margin: 6px 0 18px; }
.skeleton { padding: 40px; text-align: center; color: var(--ink-faint); font-size: 13px; }

/* ---------- Drawer ---------- */
.overlay {
  position: fixed; inset: 0; background: var(--scrim);
  z-index: 40; opacity: 0; transition: opacity 0.18s ease;
}
.overlay.show { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 440px; max-width: 92vw;
  background: var(--panel); z-index: 50; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
.drawer.show { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 22px 24px 16px; border-bottom: 1px solid var(--line);
}
.drawer-eyebrow { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin-bottom: 4px; }
.drawer-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.drawer-body { padding: 20px 24px 40px; overflow-y: auto; }

.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; margin-bottom: 24px; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
.field-value { font-size: 14px; font-weight: 500; word-break: break-word; }
.field-value.mono { font-family: var(--mono); font-size: 13px; }
.field-full { grid-column: 1 / -1; }

.drawer-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin: 8px 0 14px; }

/* Transcript bubbles */
.transcript { display: flex; flex-direction: column; gap: 12px; }
.bubble-row { display: flex; }
.bubble-row.caller { justify-content: flex-end; }
.bubble {
  max-width: 80%; padding: 9px 13px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.45;
}
.bubble-row.assistant .bubble { background: var(--gray-soft); border-bottom-left-radius: 4px; }
.bubble-row.caller .bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bubble-row.system { justify-content: center; }
.bubble-row.system .bubble { background: transparent; color: var(--ink-faint); font-size: 12px; font-style: italic; }
.bubble-who { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.6; margin-bottom: 3px; }

/* Mini call list inside contact drawer */
.mini-call { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line); }
.mini-call:last-child { border-bottom: none; }
.mini-call .mini-reason { font-size: 13px; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-call .mini-date { font-size: 12px; color: var(--ink-faint); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 22px; right: 22px; z-index: 60; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 9px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 9px;
  animation: toastIn 0.22s cubic-bezier(0.32, 0.72, 0, 1);
}
.toast.error { background: var(--red); }
.toast .toast-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.toast.error .toast-dot { background: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Entrance animation ---------- */
.fade-in { animation: fadeIn 0.32s ease both; }
.stagger > * { animation: fadeIn 0.34s ease both; }
.stagger > *:nth-child(1) { animation-delay: 0.02s; }
.stagger > *:nth-child(2) { animation-delay: 0.06s; }
.stagger > *:nth-child(3) { animation-delay: 0.10s; }
.stagger > *:nth-child(4) { animation-delay: 0.14s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 860px) {
  .sidebar { width: 64px; padding: 16px 8px; }
  .brand-name, .nav-item span:not(.nav-dot), .mode-badge { display: none; }
  .nav-item { justify-content: center; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .view, .topbar { padding-left: 18px; padding-right: 18px; }
}

/* ======================================================================
   PHASE 4 — SaaS shell, auth, tables/filters, settings, modals, portals
   ====================================================================== */

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 5px; padding: 4px 8px 22px; }
.brand-row { display: flex; align-items: center; gap: 10px; }
.brand-logo { max-height: 34px; max-width: 160px; width: auto; height: auto; object-fit: contain; display: block; }
.brand-logo-preview { max-height: 56px; max-width: 220px; width: auto; height: auto; object-fit: contain; display: block; border-radius: 6px; }
.brand-attribution { font-size: 10px; line-height: 1.2; color: var(--ink-faint); letter-spacing: 0.02em; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-user { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.user-avatar { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11.5px; color: var(--ink-faint); }

.top-left { display: flex; align-items: center; gap: 14px; }
.top-right { display: flex; align-items: center; gap: 8px; }
.page-title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.content { padding: 28px 40px 60px; max-width: 1600px; }
.back-link { color: var(--ink-soft); text-decoration: none; font-size: 13px; font-weight: 600; }
.back-link:hover { color: var(--ink); }
.context-banner { font-size: 13px; color: var(--ink-faint); padding-left: 14px; border-left: 1px solid var(--line-strong); }
.gear { font-size: 18px; text-decoration: none; display: grid; place-items: center; }

/* ---------- Buttons (additions) ---------- */
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; margin-bottom: 10px; }

/* ---------- Inputs ---------- */
.input {
  width: 100%; font-family: var(--font-ui); font-size: 14px;
  padding: 10px 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--panel); color: var(--ink);
  margin-bottom: 14px;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; }

/* ---------- Auth screens ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 32px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 22px; }
.auth-title { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.auth-sub { color: var(--ink-faint); font-size: 13.5px; margin: 6px 0 20px; }
.auth-form { display: flex; flex-direction: column; }
.auth-form .field-label { display: block; margin-bottom: 6px; margin-top: 2px; }
.auth-link { text-align: center; color: var(--accent); text-decoration: none; font-size: 13px; font-weight: 600; display: block; margin-top: 4px; }
.auth-link:hover { text-decoration: underline; }

/* ---------- Page actions ---------- */
.page-actions { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 14px; }

/* ---------- Table toolbar + search + filters ---------- */
.table-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.toolbar-left { display: flex; align-items: center; gap: 10px; padding-left: 18px; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.search-input { width: 260px; max-width: 46vw; font-family: var(--font-ui); font-size: 13px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--panel); }
.search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.filter-chips { display: flex; gap: 6px; }
.chip { background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }

.table-layout { display: flex; gap: 16px; align-items: flex-start; }
.table-area { flex: 1; min-width: 0; }
.filter-rail { width: 0; overflow: hidden; flex-shrink: 0; transition: width 0.18s ease; }
.filter-rail.open { width: 264px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.rail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.rail-title { font-weight: 700; font-size: 13px; }
.rail-clear { background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; }
.rule { border: 1px solid var(--line); border-radius: 8px; padding: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.rule-field, .rule-op, .rule-val { width: 100%; font-size: 12px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); font-family: var(--font-ui); color: var(--ink); }
.rule-remove { align-self: flex-end; background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 16px; line-height: 1; }
.rule-remove:hover { color: var(--red); }
.rail-add { width: 100%; background: var(--gray-soft); border: 1px dashed var(--line-strong); border-radius: 8px; padding: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); cursor: pointer; }
.rail-add:hover { background: var(--accent-soft); color: var(--accent); }

/* sortable / filterable headers */
.th-wrap { display: flex; align-items: center; gap: 6px; }
.th-label { cursor: pointer; }
.th-label:hover { color: var(--ink); }
.th-caret { font-size: 9px; color: var(--accent); }
.th-filter { background: none; border: none; color: var(--ink-faint); cursor: pointer; font-size: 11px; padding: 0 2px; opacity: 0.55; }
.th-filter:hover, .th-filter.active { color: var(--accent); opacity: 1; }
.table-wrap .table-count { padding: 10px 18px; font-size: 12px; color: var(--ink-faint); border-top: 1px solid var(--line); }

/* per-column popover */
.col-popover { position: absolute; z-index: 70; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 8px; width: 220px; display: flex; flex-direction: column; gap: 4px; }
.pop-item { text-align: left; background: none; border: none; padding: 7px 9px; border-radius: 6px; font-size: 13px; cursor: pointer; color: var(--ink); }
.pop-item:hover { background: var(--gray-soft); }
.pop-sep { height: 1px; background: var(--line); margin: 4px 0; }
.pop-input { font-size: 13px; padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 6px; font-family: var(--font-ui); }
.pop-input:focus { outline: none; border-color: var(--accent); }

/* ---------- Settings ---------- */
.settings-page { display: flex; flex-direction: column; gap: 18px; max-width: 1600px; }
.settings-card { padding: 22px; }
.settings-h { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.settings-grid { display: grid; grid-template-columns: 160px 1fr; gap: 12px 16px; align-items: center; margin-bottom: 16px; }
.settings-grid .input { margin-bottom: 0; }
.settings-card .field-label { display: block; }
.add-user { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.add-user .input { margin-bottom: 0; flex: 1; min-width: 120px; }
.mini-table { width: 100%; margin-bottom: 14px; }
.mini-table thead th { padding: 8px 10px; }
.mini-table tbody td { padding: 9px 10px; }
.link-danger { background: none; border: none; color: var(--red); font-size: 12.5px; font-weight: 600; cursor: pointer; }
.link-danger:hover { text-decoration: underline; }
.muted-link { color: var(--ink-faint); font-size: 13px; text-decoration: none; }
.muted-link:hover { color: var(--accent); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: var(--scrim); z-index: 80; display: grid; place-items: center; padding: 24px; animation: fadeIn 0.15s ease; }
.modal { width: 100%; max-width: 460px; max-height: 88vh; overflow: auto; background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px 22px 24px; }
.modal-body .field-label { display: block; margin-bottom: 5px; margin-top: 2px; }
.map-grid { display: grid; grid-template-columns: 140px 1fr; gap: 10px 14px; align-items: center; margin: 8px 0 16px; }
.map-grid .input { margin-bottom: 0; }
.map-grid .field-label { margin: 0; }

/* ---------- Master portal grid ---------- */
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(244px, 1fr)); gap: 14px; }
.portal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.portal-card-head { display: flex; align-items: center; justify-content: space-between; }
.portal-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 16px; }
.portal-name { font-weight: 700; font-size: 15px; }
.portal-type { color: var(--ink-faint); font-size: 12.5px; margin-top: -6px; }
.portal-metrics { display: flex; gap: 14px; font-size: 12px; color: var(--ink-soft); padding: 10px 0; border-top: 1px solid var(--line); }
.portal-metrics strong { color: var(--ink); }
.portal-actions { display: flex; gap: 8px; }
.portal-actions .btn { flex: 1; justify-content: center; }

/* ---------- Responsive overrides ---------- */
@media (max-width: 860px) {
  .sidebar { width: 210px; }
  .brand-name { display: inline; }
  .table-layout { flex-direction: column; }
  .filter-rail.open { width: 100%; }
  .search-input { width: 180px; }
  .content { padding-left: 18px; padding-right: 18px; }
}

/* ---------- Saved filters dropdown (Phase: filters/export) ---------- */
.saved-wrap { position: relative; display: inline-block; }
.saved-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 70; min-width: 240px; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; }
.saved-menu.hidden { display: none; }
.saved-item { display: flex; align-items: center; justify-content: space-between; border-radius: 6px; }
.saved-item:hover { background: var(--gray-soft); }
.saved-name { flex: 1; text-align: left; background: none; border: none; padding: 8px 10px; font-size: 13px; cursor: pointer; color: var(--ink); }
.saved-del { background: none; border: none; color: var(--ink-faint); font-size: 15px; cursor: pointer; padding: 4px 8px; }
.saved-del:hover { color: var(--red); }
.saved-empty { padding: 8px 10px; font-size: 12.5px; color: var(--ink-faint); }
.saved-save { width: 100%; text-align: left; background: none; border: none; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--accent); cursor: pointer; border-radius: 6px; }
.saved-save:hover { background: var(--accent-soft); }

/* ---------- Export dialog ---------- */
.rule-editor { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.ex-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-bottom: 12px; }
.ex-field { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink); cursor: pointer; }
.ex-field input { width: auto; margin: 0; }

/* ---------- Filter rule extras (AND/OR, between, previous) ---------- */
.rule-conj { width: 100%; font-size: 11px; font-weight: 700; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--accent-soft); color: var(--accent); margin-bottom: 2px; }
.rule-and { font-size: 12px; color: var(--ink-faint); text-align: center; }
.rule-num { max-width: 80px; }

/* ---------- Export history ---------- */
.ex-history-head { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--line); }
.ex-history { display: flex; flex-direction: column; gap: 8px; }
.ex-hist-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.ex-hist-name { font-weight: 600; font-size: 13px; }
.ex-hist-meta { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

/* ---------- Horizontal scroll for wide tables ---------- */
.table-wrap { overflow-x: auto; }
.table-wrap table { min-width: 820px; }

/* ---------- Fields tab ---------- */
.field-list { display: flex; flex-direction: column; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--panel); }
.field-row:last-child { border-bottom: none; }
.field-row.dragging { opacity: 0.5; background: var(--accent-soft); }
.field-row-left { display: flex; align-items: center; gap: 12px; }
.drag-handle { cursor: grab; color: var(--ink-faint); font-size: 16px; user-select: none; }
.field-row-label { font-weight: 600; font-size: 14px; }
.field-row-type { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
.field-row-actions { display: flex; align-items: center; gap: 10px; }
.field-locked { opacity: 0.5; }

/* ---------- Field editor (contact form) ---------- */
.field-editor { display: flex; flex-direction: column; gap: 14px; margin: 4px 0 8px; }
.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.form-label .req { color: var(--red); }
.form-static { font-size: 14px; color: var(--ink); padding: 6px 0; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.form-check input { width: auto; margin: 0; }
.form-multi { display: flex; flex-direction: column; gap: 6px; }
.form-percent { display: flex; align-items: center; gap: 8px; }
.form-percent .input { margin: 0; }
.form-suffix { color: var(--ink-faint); }
.form-image { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.form-img-preview { max-width: 120px; max-height: 120px; border-radius: 8px; border: 1px solid var(--line); object-fit: cover; }
.field-editor .input { margin-bottom: 0; }
.drawer-meta { display: flex; gap: 8px; font-size: 12px; color: var(--ink-faint); margin-bottom: 16px; }
.drawer-save-bar { margin: 8px 0 20px; }

/* ---------- Contact profile page ---------- */
.contact-page .back-link { display: inline-block; margin-bottom: 14px; }
.contact-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.contact-avatar { width: 48px; height: 48px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.contact-name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.contact-sub { color: var(--ink-faint); font-size: 13.5px; margin-top: 2px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab { background: none; border: none; padding: 10px 14px; font-size: 14px; font-weight: 600; color: var(--ink-faint); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-body .card { padding: 22px; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.tl-item:last-child { border-bottom: none; }
.tl-icon { width: 28px; height: 28px; border-radius: 8px; background: var(--gray-soft); display: grid; place-items: center; flex-shrink: 0; }
.tl-summary { font-weight: 600; font-size: 14px; }
.tl-meta { font-size: 12px; color: var(--ink-faint); margin-top: 1px; }
.tl-changes { margin-top: 6px; font-size: 12.5px; display: flex; flex-direction: column; gap: 3px; }
.tl-field { font-weight: 600; }
.tl-from { color: var(--ink-faint); text-decoration: line-through; }
.tl-to { color: var(--ink); font-weight: 600; }

/* ---------- Email composer ---------- */
.email-meta { font-size: 13px; color: var(--ink-soft); margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.email-toolbar { display: flex; gap: 4px; margin-bottom: 8px; }
.email-toolbar button { background: var(--panel); border: 1px solid var(--line-strong); border-radius: 6px; padding: 5px 10px; font-size: 13px; cursor: pointer; color: var(--ink); }
.email-toolbar button:hover { background: var(--gray-soft); }
.email-body { min-height: 180px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; line-height: 1.5; outline: none; }
.email-body:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Composer extras ---------- */
.compose-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; }
.email-toolbar.wrap { flex-wrap: wrap; }
.tb-select { font-size: 12.5px; padding: 4px 6px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); font-family: var(--font-ui); color: var(--ink); }
.tb-color { width: 30px; height: 30px; padding: 0; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); cursor: pointer; }
.sms-body { resize: vertical; }
.sms-count { font-size: 12px; margin-top: 4px; }
.email-header-img { border-radius: 6px; }

/* ---------- Quill editor ---------- */
.composer-editor .ql-container { min-height: 180px; font-family: var(--font-ui); font-size: 14px; }
.composer-editor .ql-editor { min-height: 180px; }
.ql-toolbar.ql-snow, .ql-container.ql-snow { border-color: var(--line-strong); }
.ql-toolbar.ql-snow { border-top-left-radius: var(--radius-sm); border-top-right-radius: var(--radius-sm); }
.ql-container.ql-snow { border-bottom-left-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
.ql-font-arial { font-family: Arial; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="arial"]::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value="arial"]::before { content: "Arial"; font-family: Arial; }
.ql-font-georgia { font-family: Georgia; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="georgia"]::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value="georgia"]::before { content: "Georgia"; font-family: Georgia; }
.ql-font-times-new-roman { font-family: 'Times New Roman', serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="times-new-roman"]::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value="times-new-roman"]::before { content: "Times New Roman"; font-family: 'Times New Roman', serif; }
.ql-font-courier-new { font-family: 'Courier New', monospace; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="courier-new"]::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value="courier-new"]::before { content: "Courier New"; font-family: 'Courier New', monospace; }
.ql-font-verdana { font-family: Verdana; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="verdana"]::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value="verdana"]::before { content: "Verdana"; font-family: Verdana; }
.ql-font-tahoma { font-family: Tahoma; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="tahoma"]::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value="tahoma"]::before { content: "Tahoma"; font-family: Tahoma; }
.ql-font-trebuchet-ms { font-family: 'Trebuchet MS', sans-serif; }
.ql-snow .ql-picker.ql-font .ql-picker-label[data-value="trebuchet-ms"]::before, .ql-snow .ql-picker.ql-font .ql-picker-item[data-value="trebuchet-ms"]::before { content: "Trebuchet MS"; font-family: 'Trebuchet MS', sans-serif; }

/* ---------- Reports ---------- */
.reports-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.reports-bar-left { display: flex; align-items: center; gap: 10px; }
.reports-bar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.reports-select { margin: 0; min-width: 200px; }
.widget-grid { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: auto; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .widget-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .widget-grid { grid-template-columns: 1fr; } }
/* widget width (column span) + height presets, set via data attributes */
.widget-card[data-w="1"] { grid-column: span 1; }
.widget-card[data-w="2"] { grid-column: span 2; }
.widget-card[data-w="3"] { grid-column: span 3; }
.widget-card[data-w="4"] { grid-column: span 4; }
@media (max-width: 1100px) { .widget-card[data-w="3"], .widget-card[data-w="4"] { grid-column: span 2; } }
@media (max-width: 640px) { .widget-card[data-w] { grid-column: span 1; } }
.widget-card[data-h="s"] { height: 180px; }
.widget-card[data-h="m"] { height: 260px; }
.widget-card[data-h="t"] { height: 380px; }
.widget-card.dragging { opacity: 0.5; outline: 2px dashed var(--accent); }
.widget-card.drop-before { box-shadow: inset 3px 0 0 var(--accent); }
.widget-card.drop-after { box-shadow: inset -3px 0 0 var(--accent); }
.widget-card .drag-handle { cursor: grab; opacity: 0.35; transition: opacity 0.12s; }
.widget-card:hover .drag-handle { opacity: 0.7; }
.widget-card .drag-handle:active { cursor: grabbing; }
.widget-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; overflow: hidden; }
.widget-kpi { min-height: 150px; }
.widget-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.widget-title { font-weight: 700; font-size: 14.5px; }
.widget-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.12s; flex: none; align-items: center; }
.widget-card:hover .widget-actions { opacity: 1; }
.widget-body { position: relative; flex: 1; min-height: 0; }
.widget-kpi .widget-body { min-height: 60px; }
.kpi { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 8px 0 4px; }
.kpi-value { font-size: 44px; font-weight: 800; letter-spacing: -0.03em; color: var(--accent); line-height: 1; }
.kpi-label { font-size: 13px; color: var(--ink-faint); margin-top: 8px; }
.heatmap-wrap { overflow: auto; max-height: 240px; }
.heatmap { border-collapse: collapse; font-size: 12px; }
.heatmap th { padding: 5px 8px; text-align: left; color: var(--ink-faint); font-weight: 600; position: sticky; white-space: nowrap; }
.heatmap thead th { top: 0; background: var(--panel); }
.hm-cell { padding: 6px 10px; text-align: center; border-radius: 4px; font-weight: 600; min-width: 38px; }
.modal-wide { max-width: 640px; width: 92vw; }
.w-row { display: flex; gap: 8px; }
.w-row .input { margin-bottom: 12px; }
.w-preview-label { font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.04em; margin: 14px 0 8px; }
.w-preview { height: 220px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 16px; position: relative; }

/* ---------- Reports: edit mode + dim editor ---------- */
.reports-hint { font-size: 13px; color: var(--ink-soft); background: var(--accent-soft); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 14px; }
.widget-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.widget-title-wrap .widget-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-size-select { font-size: 12px; padding: 3px 5px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); color: var(--ink); margin-right: 4px; }
.dim-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.dim-row { display: flex; gap: 8px; align-items: center; }
.dim-row .input { margin-bottom: 0; }
.dim-row select:first-child { flex: 1; }

/* ---------- Home dashboard host ---------- */
.home-dashboard { margin-bottom: 10px; min-height: 80px; }
.widget-size { display: inline-flex; gap: 4px; margin-right: 4px; }
.w-size-select { font-size: 11px; padding: 2px 4px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--panel); color: var(--ink); }

.section-divider { border-top: 2px solid var(--line); margin: 22px 0 26px; }

/* ---------- Automations ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.subnav-item { background: none; border: none; padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-faint); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav-item:hover { color: var(--ink); }
.subnav-item.active { color: var(--accent); border-bottom-color: var(--accent); }

.auto-card { padding: 16px 18px; margin-bottom: 12px; }
.auto-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.auto-card-main { min-width: 0; }
.auto-name { font-weight: 700; font-size: 15px; }
.auto-meta { color: var(--ink-soft); font-size: 12.5px; margin-top: 3px; }
.auto-actions-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.auto-card-foot { display: flex; align-items: center; gap: 6px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.auto-card-foot .link-danger { margin-left: auto; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent); }
.pill.success { background: var(--green-soft); color: var(--green); }
.pill.failed { background: var(--red-soft); color: var(--red); }
.pill.skipped { background: var(--amber-soft); color: var(--amber); }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 auto; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch-track { position: absolute; inset: 0; background: var(--line-strong); border-radius: 999px; transition: background 0.15s; }
.switch-track::before { content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform 0.15s; box-shadow: var(--shadow); }
.switch input:checked + .switch-track { background: var(--green); }
.switch input:checked + .switch-track::before { transform: translateX(16px); }

/* editor */
.cond-wrap, .actions-wrap { margin-bottom: 14px; }
.action-row { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; background: var(--accent-soft); }
.action-row-head { display: flex; gap: 8px; align-items: center; }
.action-row-head .input { margin-bottom: 0; }
.action-cfg { margin-top: 8px; }
.action-cfg .input { margin-bottom: 8px; }
.action-cfg textarea.input { min-height: 70px; resize: vertical; }
.cfg-label { font-size: 11.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 3px; }
.modal-savebar { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* logs */
.log-list { display: flex; flex-direction: column; gap: 8px; }
.log-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--panel); }
.log-line { display: flex; align-items: center; gap: 8px; font-size: 13px; flex-wrap: wrap; }
.log-time { margin-left: auto; color: var(--ink-faint); font-size: 12px; }
.log-results { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.log-err { color: var(--red); font-size: 12px; margin-top: 6px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--ink-faint); flex: 0 0 auto; }
.status-dot.success { background: var(--green); }
.status-dot.failed { background: var(--red); }
.status-dot.skipped { background: var(--amber); }
.test-out { margin-top: 14px; }
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state p { margin: 4px 0; }

/* ============================================================
   THEMES — each preset overrides the :root tokens via a
   body[data-theme="<id>"] block. Adding a 7th preset = add a
   block here + an entry in src/theme/themes.ts. Custom themes
   set --bg/--ink/--font-ui inline (see public/js/theme.js).
   ============================================================ */

/* ---- Dark (basic) ---- */
body[data-theme="dark"] {
  --bg: #15151a; --panel: #1e1e26; --panel-2: #22222b;
  --ink: #e9e9f0; --ink-soft: #a9a9b8; --ink-faint: #71717f;
  --line: #2a2a34; --line-strong: #3a3a46;
  --accent: #8482f5; --accent-soft: #26263a; --accent-strong: #9a98ff;
  --green: #34c98a; --green-soft: #16281f; --amber: #d8a23c; --amber-soft: #2a2113; --red: #e0685a; --red-soft: #2c1715;
  --row-hover: #23232f; --scrim: rgba(0,0,0,0.55); --on-accent: #fff;
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.6);
}
body[data-theme="dark"] .brand-mark { background: var(--accent); color: #fff; }

/* ---- Neutral / professional (basic) ---- */
body[data-theme="neutral"] {
  --bg: #f5f6f7; --panel: #ffffff; --panel-2: #f9fafb;
  --ink: #22282e; --ink-soft: #586069; --ink-faint: #949ba3;
  --line: #e6e8ea; --line-strong: #d6d9dd;
  --accent: #2f6f8f; --accent-soft: #e9f1f5; --accent-strong: #255a73;
  --row-hover: #f1f5f7;
}

/* ---- Frutiger Aero (fun, flagship) ---- */
body[data-theme="aero"] {
  --bg: #cfeeff;
  --panel: rgba(255,255,255,0.66); --panel-2: rgba(255,255,255,0.52);
  --ink: #0c3a52; --ink-soft: #2b6480; --ink-faint: #62a0bb;
  --line: rgba(255,255,255,0.85); --line-strong: rgba(90,170,205,0.6);
  --accent: #0aa6e6; --accent-soft: rgba(255,255,255,0.6); --accent-strong: #0b86c4;
  --green: #10b97e; --green-soft: rgba(205,255,232,0.7); --amber: #e0900f; --amber-soft: rgba(255,244,210,0.8); --red: #ec5648; --red-soft: rgba(255,220,216,0.8);
  --row-hover: rgba(255,255,255,0.55); --on-accent: #fff;
  --topbar-bg: rgba(222,246,255,0.55);
  --font-ui: "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-display: "Nunito", "Segoe UI", system-ui, sans-serif;
  --radius: 18px; --radius-sm: 13px;
  --shadow: 0 6px 22px rgba(20,110,160,0.16), inset 0 1px 0 rgba(255,255,255,0.85);
  background: url("/themes/bubbles.svg") repeat, radial-gradient(120% 90% at 50% -10%, #b6f3ff 0%, rgba(182,243,255,0) 55%), linear-gradient(165deg, #36b6f5 0%, #6fd6ff 28%, #a7efe2 62%, #c8ffdd 100%) fixed;
}
/* glassy frosted surfaces */
body[data-theme="aero"] .card,
body[data-theme="aero"] .sidebar,
body[data-theme="aero"] .modal,
body[data-theme="aero"] .settings-card {
  backdrop-filter: blur(16px) saturate(1.7);
  -webkit-backdrop-filter: blur(16px) saturate(1.7);
  border: 1px solid rgba(255,255,255,0.85);
  box-shadow: 0 8px 30px rgba(20,100,150,0.18), inset 0 1px 0 rgba(255,255,255,0.95);
}
/* glossy candy buttons with a glassy top highlight */
body[data-theme="aero"] .btn-primary {
  background: linear-gradient(180deg, #5cd0ff 0%, #11a6e6 50%, #0b86c4 100%);
  color: #fff; border: none; border-radius: 13px; position: relative; overflow: hidden;
  box-shadow: 0 4px 12px rgba(10,130,190,0.45), inset 0 1px 0 rgba(255,255,255,0.85);
}
body[data-theme="aero"] .btn-primary::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.7), rgba(255,255,255,0.05));
  pointer-events: none;
}
body[data-theme="aero"] .brand-mark {
  background: linear-gradient(180deg, #5cd0ff, #0aa6e6); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 2px 6px rgba(10,130,190,0.4);
}

/* ---- Neon Dusk (fun, synthwave) ---- */
body[data-theme="dusk"] {
  --bg: #0d0a26; --panel: #171336; --panel-2: #1d1842;
  --ink: #f3ecff; --ink-soft: #bcb1ee; --ink-faint: #8579c2;
  --line: #2f2566; --line-strong: #443a86;
  --accent: #ff3df0; --accent-soft: #281a5c; --accent-strong: #ff5cf3;
  --green: #22e0ff; --green-soft: #10283a; --amber: #ffcf4d; --amber-soft: #2a2410; --red: #ff5d7a; --red-soft: #2c1320;
  --row-hover: #211a52; --scrim: rgba(5,2,20,0.7); --on-accent: #0f0c29;
  --topbar-bg: #140f33;
  --font-ui: "Poppins", "Segoe UI", system-ui, sans-serif;
  --font-display: "Orbitron", "Poppins", system-ui, sans-serif;
  --shadow: 0 0 0 1px rgba(255,61,240,0.10), 0 4px 18px rgba(0,0,0,0.55);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.7);
  background:
    radial-gradient(120% 70% at 50% 120%, rgba(255,61,240,0.28) 0%, rgba(255,61,240,0) 55%),
    radial-gradient(90% 60% at 50% -10%, rgba(34,224,255,0.18) 0%, rgba(34,224,255,0) 60%),
    linear-gradient(180deg, #0d0a26 0%, #1a1145 60%, #241b4d 100%) fixed;
}
body[data-theme="dusk"] .brand-mark { background: var(--accent); color: #0f0c29; box-shadow: 0 0 14px rgba(255,61,240,0.8); }
body[data-theme="dusk"] .page-title,
body[data-theme="dusk"] .settings-h,
body[data-theme="dusk"] .brand-name { font-family: var(--font-display); letter-spacing: 0.03em; text-shadow: 0 0 14px rgba(255,61,240,0.45); }
body[data-theme="dusk"] .btn-primary {
  background: #1a1145; color: #22e0ff; border: 1px solid #22e0ff;
  box-shadow: 0 0 14px rgba(34,224,255,0.6), inset 0 0 10px rgba(34,224,255,0.22);
}
body[data-theme="dusk"] .nav-item.active { box-shadow: 0 0 14px rgba(255,61,240,0.5); border: 1px solid rgba(255,61,240,0.5); }
body[data-theme="dusk"] .card,
body[data-theme="dusk"] .settings-card { border: 1px solid var(--line-strong); }

/* ---- Cottage Warm (fun, cottagecore) ---- */
body[data-theme="cottage"] {
  --bg: #f4ecdd; --panel: #fbf6ec; --panel-2: #f1e8d6;
  --ink: #4a3f33; --ink-soft: #7a6c59; --ink-faint: #a89a84;
  --line: #e4d8c3; --line-strong: #d6c6ab;
  --accent: #7c9473; --accent-soft: #eaf0e4; --accent-strong: #697f61;
  --green: #6f9a5e; --green-soft: #e9f0e2; --amber: #c8843c; --amber-soft: #f6ead7; --red: #bb6a5a; --red-soft: #f3e3de;
  --row-hover: #f1e8d6; --on-accent: #fff;
  --font-ui: "Segoe UI", Candara, "Trebuchet MS", system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --radius: 12px; --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(120,90,50,0.06), 0 6px 18px rgba(120,90,50,0.10);
}
body[data-theme="cottage"] .page-title,
body[data-theme="cottage"] .settings-h { font-family: var(--font-display); font-weight: 600; }
body[data-theme="cottage"] .btn-primary { background: var(--accent); color: #fff; }
body[data-theme="cottage"] .brand-mark { background: var(--accent); color: #fff; }

/* ---- Theme picker (Appearance settings) ---- */
.theme-group-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); margin: 14px 0 8px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.theme-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; cursor: pointer; background: var(--panel); text-align: left; transition: border-color .12s, box-shadow .12s; }
.theme-card:hover { border-color: var(--accent); }
.theme-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.theme-swatches { display: flex; gap: 4px; margin-bottom: 8px; }
.theme-swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid rgba(0,0,0,0.08); }
.theme-card-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.theme-dd-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.theme-dd { max-width: 340px; flex: 0 0 auto; margin-bottom: 0; }
.theme-dd-swatches { display: flex; gap: 4px; }
.theme-custom { margin-top: 14px; display: grid; gap: 12px; max-width: 420px; }
.theme-custom-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.theme-custom-row label { font-size: 13px; color: var(--ink-soft); }
.theme-custom input[type="color"] { width: 48px; height: 30px; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; padding: 0; }
.theme-custom select.input { max-width: 220px; }

/* ============================================================
   ADDITIONAL PRESETS (round 2). Each is a palette block; a few
   fun ones add a bundled background texture. Panels stay opaque
   or frosted so text/forms remain readable over any background.
   ============================================================ */

/* ---- Basic: Warm Light ---- */
body[data-theme="warm"] {
  --bg: #fbf8f3; --panel: #fffdf9; --panel-2: #f6f1e8;
  --ink: #2b2722; --ink-soft: #5f584e; --ink-faint: #9c9387;
  --line: #efe9df; --line-strong: #e3dccf;
  --accent: #5b59d6; --accent-soft: #efeffc; --accent-strong: #4a48c4;
  --gray-soft: #f4efe7; --row-hover: #f8f4ec;
}

/* ---- Basic: Slate ---- */
body[data-theme="slate"] {
  --bg: #eef1f4; --panel: #ffffff; --panel-2: #f6f8fa;
  --ink: #2b3440; --ink-soft: #5a6675; --ink-faint: #97a1ad;
  --line: #e1e6eb; --line-strong: #cfd6de;
  --accent: #4a6076; --accent-soft: #e7edf2; --accent-strong: #3c4f62;
  --gray-soft: #eef1f4; --row-hover: #f1f4f7;
}

/* ---- Basic: Steel Blue ---- */
body[data-theme="steel"] {
  --bg: #f4f6f9; --panel: #ffffff; --panel-2: #f5f8fb;
  --ink: #1f2733; --ink-soft: #51607a; --ink-faint: #93a0b2;
  --line: #e2e7ee; --line-strong: #ccd5e0;
  --accent: #2a4d7a; --accent-soft: #e6edf6; --accent-strong: #1f3c61;
  --gray-soft: #eef2f7; --row-hover: #eef3f9;
}

/* ---- Basic: Sand ---- */
body[data-theme="sand"] {
  --bg: #f3ecdf; --panel: #fbf6ec; --panel-2: #f0e7d6;
  --ink: #43392b; --ink-soft: #6f6453; --ink-faint: #a3957f;
  --line: #e6dcc8; --line-strong: #d8cbb0;
  --accent: #a9763e; --accent-soft: #f1e6d5; --accent-strong: #8c5f2e;
  --amber: #b07a25; --amber-soft: #f5e8d2; --gray-soft: #efe6d6; --row-hover: #f3ead9;
}

/* ---- Basic: High Contrast (accessibility-friendly) ---- */
body[data-theme="contrast"] {
  --bg: #ffffff; --panel: #ffffff; --panel-2: #f2f2f2;
  --ink: #000000; --ink-soft: #1d1d1d; --ink-faint: #474747;
  --line: #1c1c1c; --line-strong: #000000;
  --accent: #0b5bd3; --accent-soft: #d6e4fb; --accent-strong: #08409a;
  --green: #0a7a3f; --green-soft: #d8f0e2; --amber: #8a5a00; --amber-soft: #f6e6c8;
  --red: #b00000; --red-soft: #ffd9d9; --gray-soft: #ededed; --row-hover: #eef3fc; --on-accent: #ffffff;
}
body[data-theme="contrast"] .input { border-width: 2px; }
body[data-theme="contrast"] .input:focus { box-shadow: 0 0 0 3px #0b5bd3; border-color: #0b5bd3; }
body[data-theme="contrast"] .card, body[data-theme="contrast"] .settings-card { border: 2px solid var(--line-strong); }
body[data-theme="contrast"] .btn-primary:disabled { opacity: 0.55; }

/* ---- Basic: Graphite (dim) ---- */
body[data-theme="graphite"] {
  --bg: #2b2d31; --panel: #34373c; --panel-2: #3a3d43;
  --ink: #e7e8ea; --ink-soft: #b3b6bc; --ink-faint: #82868d;
  --line: #3f4248; --line-strong: #4b4f56;
  --accent: #8a88f0; --accent-soft: #2f3140; --accent-strong: #9d9bf5;
  --green: #46c98f; --green-soft: #1c2e26; --amber: #d6a23a; --amber-soft: #2a2414; --red: #df6f61; --red-soft: #2a1614;
  --gray-soft: #383b41; --row-hover: #393c42; --scrim: rgba(0,0,0,0.5); --on-accent: #15151a;
  --shadow: 0 1px 2px rgba(0,0,0,0.25), 0 4px 16px rgba(0,0,0,0.35);
}

/* ---- Basic: Midnight (deep true-dark) ---- */
body[data-theme="midnight"] {
  --bg: #07070b; --panel: #101018; --panel-2: #14141e;
  --ink: #e6e7ee; --ink-soft: #9fa1b0; --ink-faint: #63667a;
  --line: #1e1f2b; --line-strong: #2c2e3d;
  --accent: #6f6df0; --accent-soft: #181830; --accent-strong: #8482f5;
  --green: #2fbf86; --green-soft: #0f241b; --amber: #cf9a3a; --amber-soft: #241d10; --red: #df6557; --red-soft: #281312;
  --gray-soft: #14141e; --row-hover: #15151f; --scrim: rgba(0,0,0,0.65); --on-accent: #fff;
  --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.5);
}

/* ---- Fun: Vaporwave (bg: grid over gradient) ---- */
body[data-theme="vaporwave"] {
  --bg: #1a1130; --panel: #281a4d; --panel-2: #311f59;
  --ink: #f6ecff; --ink-soft: #cdb9ec; --ink-faint: #9a86c2;
  --line: #43306e; --line-strong: #58418c;
  --accent: #ff6ad5; --accent-soft: #321f55; --accent-strong: #ff8fe0;
  --green: #6be1ff; --green-soft: #15243a; --amber: #ffcf6a; --amber-soft: #2a2412; --red: #ff6a8f; --red-soft: #2a1320;
  --gray-soft: #2d1f50; --row-hover: #2d1f50; --scrim: rgba(12,6,28,0.7); --on-accent: #1a1130;
  --topbar-bg: #1f1442;
  --font-ui: "Poppins", "Segoe UI", system-ui, sans-serif;
  --font-display: "Poppins", system-ui, sans-serif;
  --radius: 16px; --radius-sm: 11px;
  background:
    url("/themes/vapor-grid.svg") repeat,
    radial-gradient(90% 70% at 15% 10%, rgba(255,106,213,0.35) 0%, rgba(255,106,213,0) 55%),
    radial-gradient(90% 70% at 85% 90%, rgba(107,225,255,0.30) 0%, rgba(107,225,255,0) 55%),
    linear-gradient(160deg, #3a1a63 0%, #4a1f7a 45%, #2b1b4d 100%) fixed;
}
body[data-theme="vaporwave"] .page-title, body[data-theme="vaporwave"] .settings-h { text-transform: lowercase; letter-spacing: 0.01em; text-shadow: 0 0 12px rgba(255,106,213,0.4); }
body[data-theme="vaporwave"] .card, body[data-theme="vaporwave"] .settings-card { box-shadow: 0 0 0 1px rgba(255,106,213,0.22), 0 8px 26px rgba(0,0,0,0.45); }
body[data-theme="vaporwave"] .btn-primary { box-shadow: 0 0 14px rgba(255,106,213,0.5); }

/* ---- Fun: Deep Woods / Forest (bg: leaves) ---- */
body[data-theme="forest"] {
  --bg: #1c2a22; --panel: #243a2e; --panel-2: #2a4435;
  --ink: #eef0e6; --ink-soft: #bcc7b4; --ink-faint: #889a82;
  --line: #2f4a3a; --line-strong: #3c5c49;
  --accent: #7fae6a; --accent-soft: #1f3327; --accent-strong: #94c47e;
  --green: #8fc47a; --green-soft: #1f3327; --amber: #d2a24a; --amber-soft: #2a2414; --red: #d98a6a; --red-soft: #2c1c16;
  --gray-soft: #21342a; --row-hover: #21342a; --scrim: rgba(8,16,12,0.6); --on-accent: #1c2a22;
  --font-ui: "Segoe UI", Candara, system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  background: url("/themes/leaves.svg") repeat, #1c2a22 fixed;
}
body[data-theme="forest"] .page-title, body[data-theme="forest"] .settings-h { font-family: var(--font-display); }

/* ---- Fun: Golden Hour / Sunset (warm gradient, no image) ---- */
body[data-theme="sunset"] {
  --bg: #fbe3cf; --panel: rgba(255,250,245,0.9); --panel-2: rgba(255,244,234,0.85);
  --ink: #3a2a33; --ink-soft: #6e5560; --ink-faint: #a98f99;
  --line: #f0d9c8; --line-strong: #e6c3ab;
  --accent: #e8743c; --accent-soft: #fbe6d6; --accent-strong: #cf5f2c;
  --amber: #d98a1f; --amber-soft: #fbe6cf; --green: #5aa17a; --green-soft: #e2f0e8; --red: #d8504a; --red-soft: #fbe0de;
  --gray-soft: #f7e6d8; --row-hover: rgba(255,240,228,0.8); --on-accent: #fff;
  --font-ui: "Nunito", "Segoe UI", system-ui, sans-serif;
  --radius: 14px; --radius-sm: 10px;
  background: linear-gradient(160deg, #ffd9a8 0%, #ffb98f 35%, #f5907a 65%, #b98fd0 100%) fixed;
}

/* ---- Fun: Brutalist / Monochrome (high contrast, hard edges) ---- */
body[data-theme="mono"] {
  --bg: #ffffff; --panel: #ffffff; --panel-2: #f2f2f2;
  --ink: #000000; --ink-soft: #222222; --ink-faint: #555555;
  --line: #111111; --line-strong: #000000;
  --accent: #0040ff; --accent-soft: #dfe6ff; --accent-strong: #0030c0;
  --green: #008040; --green-soft: #d6f0e0; --amber: #9a6b00; --amber-soft: #f6e8c8; --red: #d00000; --red-soft: #ffdada;
  --gray-soft: #ededed; --row-hover: #eaeefc; --on-accent: #ffffff;
  --radius: 2px; --radius-sm: 2px;
  --font-display: "Poppins", "Arial Black", system-ui, sans-serif;
  --shadow: none; --shadow-lg: 0 0 0 2px #000;
}
body[data-theme="mono"] .card, body[data-theme="mono"] .settings-card { border: 2px solid #000; }
body[data-theme="mono"] .input { border-width: 2px; }
body[data-theme="mono"] .page-title, body[data-theme="mono"] .settings-h { font-family: var(--font-display); font-weight: 700; }
body[data-theme="mono"] .btn-primary:disabled { opacity: 0.5; }

/* ---- Fun: Deep Sea / Ocean (bg: depth waves, frosted glass) ---- */
body[data-theme="ocean"] {
  --bg: #052033; --panel: rgba(20,66,88,0.62); --panel-2: rgba(20,66,88,0.48);
  --ink: #ecfaff; --ink-soft: #b6dde8; --ink-faint: #80b6c6;
  --line: rgba(120,210,230,0.28); --line-strong: rgba(120,210,230,0.46);
  --accent: #2fe0d8; --accent-soft: #0e4250; --accent-strong: #57f0e8;
  --green: #3fe0b0; --green-soft: #0e3a30; --amber: #e0b24a; --amber-soft: #2a2410; --red: #ef6f6a; --red-soft: #2c1614;
  --gray-soft: #0e4250; --row-hover: rgba(255,255,255,0.07); --scrim: rgba(2,15,25,0.65); --on-accent: #052033;
  --topbar-bg: rgba(8,40,58,0.55);
  --font-ui: "Poppins", "Segoe UI", system-ui, sans-serif;
  background:
    url("/themes/ocean-depth.svg") repeat-x bottom,
    radial-gradient(90% 60% at 50% 0%, rgba(47,224,216,0.22) 0%, rgba(47,224,216,0) 55%),
    linear-gradient(180deg, #052033 0%, #093e54 55%, #0c6076 100%) fixed;
}
body[data-theme="ocean"] .card, body[data-theme="ocean"] .sidebar, body[data-theme="ocean"] .modal, body[data-theme="ocean"] .settings-card {
  backdrop-filter: blur(13px) saturate(1.5); -webkit-backdrop-filter: blur(13px) saturate(1.5);
  border: 1px solid rgba(120,210,230,0.32);
  box-shadow: 0 8px 28px rgba(0,20,30,0.4), inset 0 1px 0 rgba(180,240,255,0.25);
}
body[data-theme="ocean"] .btn-primary { box-shadow: 0 0 14px rgba(47,224,216,0.45), inset 0 1px 0 rgba(255,255,255,0.25); }
body[data-theme="ocean"] .brand-mark { box-shadow: 0 0 12px rgba(47,224,216,0.55); }

/* ---- Fun: Cherry Blossom / Sakura (soft, elegant, no image) ---- */
body[data-theme="sakura"] {
  --bg: #fdf4f7; --panel: #fffafc; --panel-2: #fbeef3;
  --ink: #4a3a42; --ink-soft: #7c6a72; --ink-faint: #b39da7;
  --line: #f3dde6; --line-strong: #ead0db;
  --accent: #d96a93; --accent-soft: #fbe6ee; --accent-strong: #c2557e;
  --green: #7aab86; --green-soft: #e6f0e8; --amber: #d39a4a; --amber-soft: #f7ead2; --red: #d8607a; --red-soft: #fbe2e8;
  --gray-soft: #fbeef3; --row-hover: #fbeef3; --on-accent: #fff;
  --font-ui: "Segoe UI", Candara, system-ui, sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --radius: 16px; --radius-sm: 12px;
}
body[data-theme="sakura"] .page-title, body[data-theme="sakura"] .settings-h { font-family: var(--font-display); font-weight: 500; }

/* ---- Fun: Terminal / Hacker (bg: scanlines, mono) ---- */
body[data-theme="terminal"] {
  --bg: #050805; --panel: #0a0f0a; --panel-2: #0d140d;
  --ink: #5fff9f; --ink-soft: #43c47a; --ink-faint: #2f8a56;
  --line: #143a1f; --line-strong: #1f5a30;
  --accent: #39ff14; --accent-soft: #0d240d; --accent-strong: #7dff5c;
  --green: #39ff14; --green-soft: #0d240d; --amber: #ffb000; --amber-soft: #241a05; --red: #ff5f5f; --red-soft: #2a0f0f;
  --gray-soft: #0c1a0c; --row-hover: #0c1a0c; --scrim: rgba(0,5,0,0.7); --on-accent: #050805;
  --font-ui: var(--mono); --font-display: var(--mono);
  --shadow: 0 0 0 1px rgba(57,255,20,0.12), 0 4px 18px rgba(0,0,0,0.6);
  background: url("/themes/scanlines.svg") repeat, #050805 fixed;
}
body[data-theme="terminal"] .btn-primary { background: #0a0f0a; color: #39ff14; border: 1px solid #39ff14; box-shadow: 0 0 8px rgba(57,255,20,0.4); }
body[data-theme="terminal"] .card, body[data-theme="terminal"] .settings-card { border: 1px solid var(--line-strong); box-shadow: 0 0 0 1px rgba(57,255,20,0.08); }

/* ---------- Row selection ---------- */
th.sel-col, td.sel-col { width: 36px; text-align: center; padding-left: 10px; padding-right: 6px; }
th.sel-col input, td.sel-col input { cursor: pointer; width: 15px; height: 15px; accent-color: var(--accent); }
tbody tr.row-selected { background: var(--accent-soft); }

/* ---------- Bulk actions ---------- */
.bulk-wrap { position: relative; display: inline-flex; align-items: center; gap: 8px; }
.bulk-menu { position: absolute; top: 100%; left: 0; margin-top: 4px; min-width: 180px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 40; padding: 5px; }
.bulk-menu.hidden { display: none; }
.bulk-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--ink); cursor: pointer; }
.bulk-item:hover { background: var(--gray-soft); }
.bulk-empty { padding: 8px 10px; font-size: 13px; color: var(--ink-soft); }
.bulk-count { font-size: 12.5px; color: var(--ink-soft); }

/* ---------- Manage columns ---------- */
.mc-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; }
.mc-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); cursor: grab; }
.mc-row.dragging { opacity: 0.5; }
.mc-drag { color: var(--ink-faint); cursor: grab; }
.mc-label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px 18px; border-top: 1px solid var(--line); }

/* ---------- Recycle bin ---------- */
.recycle-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 10px; border-radius: var(--radius-sm); color: var(--ink-soft); text-decoration: none; font-weight: 500; font-size: 13.5px; border: 1px solid var(--line); }
.recycle-link:hover { background: var(--gray-soft); color: var(--ink); }
.recycle-link.active { background: var(--accent-soft); color: var(--accent); }
.rb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.rb-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.rb-countdown { font-size: 11.5px; color: var(--amber); margin-top: 2px; }

/* ---------- Today dashboard ---------- */
.today-head { margin-bottom: 18px; }
.today-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi-card { display: block; text-decoration: none; color: inherit; padding: 18px 20px; transition: border-color .12s, box-shadow .12s; }
.kpi-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.today-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .today-cols { grid-template-columns: 1fr; } }
.today-card { padding: 18px 20px; }
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; text-align: left; background: none; border: none; border-top: 1px solid var(--line); padding: 11px 2px; cursor: pointer; color: var(--ink); }
.mini-row:first-child { border-top: none; }
.mini-row:hover { background: var(--row-hover); }
.mini-main { min-width: 0; }
.mini-when { font-size: 12px; color: var(--ink-faint); white-space: nowrap; }
.today-foot { margin-top: 18px; }

/* ---------- Learning Center ---------- */
.learn-head { margin-bottom: 16px; }
.learn-title { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.learn-layout { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
@media (max-width: 860px) { .learn-layout { grid-template-columns: 1fr; } }
.learn-nav { position: sticky; top: 84px; }
.learn-search { width: 100%; margin-bottom: 12px; }
.learn-nav-list { display: flex; flex-direction: column; gap: 2px; max-height: 70vh; overflow: auto; }
.learn-cat { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); margin: 14px 0 4px; }
.learn-cat:first-child { margin-top: 0; }
.learn-link { display: block; width: 100%; text-align: left; background: none; border: none; border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13.5px; color: var(--ink-soft); cursor: pointer; }
.learn-link:hover { background: var(--gray-soft); color: var(--ink); }
.learn-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.learn-article { padding: 26px 30px; max-width: none; }
.learn-eyebrow { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); margin-bottom: 6px; }
.learn-article-title { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 14px; }
.learn-p { color: var(--ink-soft); line-height: 1.65; margin: 0 0 14px; }
.learn-steps { margin: 0 0 16px; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.learn-steps li { color: var(--ink); line-height: 1.55; }
.learn-shot { border: 2px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--panel-2); color: var(--ink-faint); font-size: 13px; font-style: italic; padding: 22px 16px; text-align: center; margin: 0 0 16px; }
.learn-tip { background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px; padding: 10px 14px; font-size: 13.5px; color: var(--ink); margin: 0 0 16px; line-height: 1.5; }

/* ---------- Contact create / mass-update forms ---------- */
.form-row { margin-bottom: 14px; }
.form-row .field-label { display: block; margin-bottom: 5px; }
.ms-box { display: flex; flex-wrap: wrap; gap: 10px; }
.ms-opt { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--ink); }

/* ---------- Merge ---------- */
.merge-grid { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; margin: 12px 0; }
.merge-field { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); }
.merge-field:first-child { border-top: none; }
.merge-key { font-weight: 600; font-size: 13px; color: var(--ink-soft); }
.merge-vals { display: flex; flex-direction: column; gap: 6px; }
.merge-opt { display: flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.merge-kept { font-size: 13.5px; color: var(--ink); }
.merge-warn { background: var(--amber-soft, #fff7ed); border-left: 3px solid var(--amber, #d97706); border-radius: 6px; padding: 11px 14px; font-size: 13px; color: var(--ink); line-height: 1.5; margin-top: 8px; }

/* ---------- Toggle row ---------- */
.toggle-row { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.toggle-row input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Super-admin: per-portal identity rule ---------- */
.portal-rule { margin: 0; }
.portal-rule .input { padding: 6px 8px; font-size: 13px; }

/* Fields page: object-type selector bar */
.fields-typebar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.fields-typebar-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.fields-typebar-select { width: auto; min-width: 160px; margin-bottom: 0; }

/* Records: linked-parents (candidates) + linked-jobs UI */
.link-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.link-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); }
.link-name { flex: 1 1 auto; font-weight: 600; color: var(--ink); }
.link-ptype { font-weight: 400; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; margin-left: 6px; }
.link-stage { width: auto; margin-bottom: 0; flex: 0 0 auto; }
.link-add { position: relative; }
.link-search { margin-bottom: 0; }
.link-results { position: absolute; left: 0; right: 0; top: 100%; z-index: 20; background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); margin-top: 4px; box-shadow: 0 8px 24px rgba(0,0,0,.12); max-height: 240px; overflow: auto; }
.link-result { display: block; width: 100%; text-align: left; padding: 9px 12px; background: none; border: none; color: var(--ink); cursor: pointer; font-size: 14px; }
.link-result:hover { background: var(--accent-soft); }
.linked-jobs-card { margin-top: 16px; }

/* Two-column grouped field layout (profiles: contact + record detail) */
.field-section { margin-bottom: 6px; }
.field-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 12px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; align-items: start; }
.field-grid .form-row { margin: 0 0 14px; }
.field-grid .form-row--wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .field-grid { grid-template-columns: 1fr; } }

/* Fields page: section management */
.fields-section-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 12px; background: var(--panel-2); }
.fields-section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.fields-section-name { font-weight: 700; font-size: 14px; }
.fields-section-tools { display: flex; gap: 4px; margin-left: auto; }
.field-move-sel { width: auto; min-width: 130px; margin-bottom: 0; font-size: 12px; padding: 4px 8px; }

/* Detail pages (contact + job): outer spacing + inner card padding so content
   doesn't hug the edges, plus tidier vertical rhythm. Applied to both pages. */
/* Detail pages fill the full content width like every other page (Item 1 fix);
   the breathing room comes from the content padding + the card padding below. */
.contact-page > .card { padding: 18px 22px; }
.contact-page > .card + .card { margin-top: 16px; }
.contact-page .field-editor { margin: 2px 0 0; }
.contact-page .field-grid .form-row { margin: 0 0 12px; }
.contact-page .field-section:last-child { margin-bottom: 0; }
.contact-page .field-section:last-child .field-grid .form-row:last-child { margin-bottom: 0; }
.contact-page .drawer-save-bar { margin: 14px 0 0; }

/* Cleaner linked-item rows (candidates on a job; jobs on a contact) — simple
   separators instead of boxed borders, consistent across both detail pages. */
.link-list { gap: 0; margin-bottom: 10px; }
.link-row { border: none; border-bottom: 1px solid var(--line); border-radius: 0; background: transparent; padding: 10px 0; }
.link-row:last-child { border-bottom: none; }

/* Pipeline-stage management rows on the Fields page (mirrors section rows). */
.stage-list { display: flex; flex-direction: column; }
.stage-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.stage-row:last-child { border-bottom: none; }
.stage-name { font-weight: 600; }

/* Job-type blocks inside the central "Job types & pipelines" manager. */
.subtype-block { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 12px; background: var(--panel-2, transparent); }
.subtype-block .stage-row { padding: 6px 0; }

/* Candidates: List | Board toggle + kanban (inherits the active theme tokens) */
.cand-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.seg-toggle { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg-btn { appearance: none; border: 0; background: var(--panel); color: var(--ink-faint); font: inherit; font-size: 13px; font-weight: 600; padding: 5px 14px; cursor: pointer; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line-strong); }
.seg-btn.seg-on { background: var(--accent-soft); color: var(--accent); }

.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; align-items: flex-start; }
.kanban-col { flex: 0 0 240px; width: 240px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; display: flex; flex-direction: column; max-height: 64vh; }
.kanban-col--review { background: var(--accent-soft); border-color: var(--accent); }
.kanban-col--over { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent-soft); }
.kanban-col-head { background: inherit; border-bottom: 1px solid var(--line); padding: 9px 12px; border-radius: 10px 10px 0 0; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.kanban-col-name { font-weight: 700; color: var(--ink); }
.kanban-dot { color: var(--ink-faint); }
.kanban-count { color: var(--ink-faint); font-weight: 600; }
.kanban-cards { padding: 10px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 48px; }
.kanban-empty { color: var(--ink-faint); font-size: 12.5px; text-align: center; padding: 10px 0; opacity: 0.7; }
.kanban-card { position: relative; background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px; padding: 9px 26px 9px 11px; cursor: grab; transition: transform 0.08s ease, box-shadow 0.08s ease; }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: 0.5; transform: scale(0.99); box-shadow: 0 4px 12px rgba(0,0,0,0.10); }
.kanban-card-name { font-weight: 600; color: var(--ink); font-size: 13.5px; line-height: 1.3; }
.kanban-card-sub { color: var(--ink-faint); font-size: 12px; margin-top: 1px; }
.kanban-card-x { position: absolute; top: 6px; right: 6px; width: 18px; height: 18px; line-height: 16px; text-align: center; border: 0; border-radius: 5px; background: transparent; color: var(--ink-faint); cursor: pointer; font-size: 15px; opacity: 0; transition: opacity 0.12s ease; }
.kanban-card:hover .kanban-card-x { opacity: 1; }
.kanban-card-x:hover { background: var(--line); color: var(--ink); }
/* Contact-side swimlane board: one lane per linked policy, each lane a sibling
   of the policy board (reuses .kanban / .kanban-col / .kanban-card). */
.swimlanes { display: flex; flex-direction: column; gap: 18px; }
.swimlane-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.swimlane-title { font-weight: 700; color: var(--ink); font-size: 14px; }
.swimlane-type { flex: 0 0 auto; }
.kanban-col--current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.kanban-col--current .kanban-col-name { color: var(--accent); }
/* List/table dashboard widget + its column picker */
.w-list-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; max-height: 180px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.w-list-col { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.widget-list { overflow: auto; max-height: 100%; }
.widget-list table { width: 100%; border-collapse: collapse; font-size: 13px; }
.widget-list th { text-align: left; font-weight: 600; color: var(--ink-soft); padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.widget-list td { padding: 6px 8px; border-bottom: 1px solid var(--line); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.widget-list-more { padding: 6px 8px; color: var(--ink-faint); font-size: 12px; }
/* Settings → Labels: two-group layout + Pages & navigation editor */
.settings-sub { font-size: 15px; font-weight: 600; margin: 24px 0 4px; color: var(--ink); }
.settings-sub:first-of-type { margin-top: 2px; }
.lbl-group { margin-bottom: 6px; }
.nav-edit-list { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.nav-edit-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.nav-edit-row.dragging { opacity: 0.5; }
.nav-edit-hidden { opacity: 0.55; }
.nav-edit-row .mc-drag { cursor: grab; color: var(--ink-faint); user-select: none; }
.nav-edit-input { flex: 1; }
.nav-edit-label-fixed { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.nav-edit-note { font-size: 11.5px; color: var(--ink-faint); font-style: italic; }
.nav-edit-pill { font-size: 12px; color: var(--ink-faint); padding: 4px 10px; border: 1px dashed var(--line); border-radius: 999px; white-space: nowrap; }
.nav-edit-toggle { min-width: 64px; }
/* Per-row nav hamburger (admin shortcut onto the same nav config) */
.nav-item--editable { position: relative; padding-right: 30px; }
.nav-burger { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; line-height: 20px; text-align: center; border-radius: 6px; color: var(--ink-faint); font-size: 17px; cursor: grab; opacity: 0.4; transition: opacity .12s ease, background .12s ease, color .12s ease; touch-action: none; user-select: none; }
.nav-item--editable:hover .nav-burger, .nav-burger:focus { opacity: 1; }
.nav-burger:hover { background: rgba(128, 128, 128, 0.2); color: var(--ink); }
.nav-burger:active { cursor: grabbing; }
.nav-item.nav-dragging { opacity: 0.5; }
.nav-item.nav-drop-target { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }
.nav-burger-menu { position: fixed; z-index: 1200; min-width: 150px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.nav-burger-item { text-align: left; background: none; border: none; padding: 8px 10px; border-radius: 7px; font-size: 13.5px; color: var(--ink); cursor: pointer; }
.nav-burger-item:hover { background: rgba(128, 128, 128, 0.16); }
.nav-burger-danger { color: var(--danger, #d9534f); }
/* Impersonation (Batch B): banner, controls, dropdown */
.imp-banner { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 8px 14px; background: #7a3b00; color: #fff; font-size: 13.5px; font-weight: 600; border-bottom: 2px solid #ffae57; }
.imp-banner-text { letter-spacing: 0.2px; }
.imp-banner-exit { background: #fff; color: #7a3b00; border: none; font-weight: 700; }
.imp-banner-exit:hover { background: #ffe9d2; }
.imp-exit-btn { background: #7a3b00; color: #fff; border: none; font-weight: 600; }
.imp-exit-btn:hover { background: #934700; }
.imp-menu { z-index: 1200; min-width: 260px; max-width: 340px; max-height: 70vh; overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 34px rgba(0, 0, 0, 0.3); padding: 6px; }
.imp-menu-sec { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-faint); padding: 10px 10px 4px; }
.imp-menu-item { display: block; width: 100%; text-align: left; background: none; border: none; padding: 8px 10px; border-radius: 7px; font-size: 13px; color: var(--ink); cursor: pointer; }
.imp-menu-item:hover:not([disabled]) { background: rgba(128, 128, 128, 0.16); }
.imp-menu-item[disabled] { opacity: 0.45; cursor: not-allowed; }
.imp-menu-empty { padding: 6px 10px; color: var(--ink-faint); font-size: 12.5px; }

/* ======================================================================
   Settings sub-shell — two-pane layout inside the settings view only.
   Tokens only (theme-safe). Collapses to stacked tabs on narrow screens.
   ====================================================================== */
.settings-shell { display: flex; gap: 22px; align-items: flex-start; }
.settings-subnav {
  flex: 0 0 196px; position: sticky; top: 0;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 10px; box-shadow: var(--shadow);
}
.settings-subnav-title {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-faint); padding: 4px 10px 8px;
}
.settings-subnav-item {
  display: block; padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-soft); text-decoration: none; font-weight: 500; font-size: 13.5px;
  transition: background 0.12s ease, color 0.12s ease;
}
.settings-subnav-item:hover { background: var(--gray-soft); color: var(--ink); }
.settings-subnav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.settings-panel {
  flex: 1 1 auto; min-width: 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow);
}
.settings-reserved {
  text-align: center; padding: 38px 20px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--panel-2);
}
.settings-reserved-mark { font-size: 34px; margin-bottom: 8px; }
.settings-reserved h3 { margin: 0 0 6px; font-size: 16px; color: var(--ink); }
@media (max-width: 760px) {
  .settings-shell { flex-direction: column; }
  .settings-subnav { flex: none; width: 100%; flex-direction: row; overflow-x: auto; position: static; }
  .settings-subnav-title { display: none; }
  .settings-subnav-item { white-space: nowrap; }
  .settings-panel { width: 100%; }
}

/* Labels editor (settings → Labels) */
.lbl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; margin-bottom: 8px; }
.lbl-row .input { margin-bottom: 0; }
.lbl-head { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); font-weight: 700; margin-bottom: 2px; }
@media (max-width: 560px) { .lbl-row { grid-template-columns: 1fr 1fr; gap: 6px; } }

/* Feedback ticket conversation thread */
.fb-thread { margin: 14px 0 6px; display: flex; flex-direction: column; gap: 10px; }
.fb-msg { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; max-width: 80%; align-self: flex-start; }
.fb-msg--mine { align-self: flex-end; background: var(--accent-soft); border-color: transparent; }
.fb-msg-meta { font-size: 11.5px; color: var(--ink-faint); margin-bottom: 4px; }
.fb-msg-body { white-space: pre-wrap; font-size: 14px; }
