/* ================================================================
   EVAA — design system  ·  DARK (Night), EVAA Burgundy accent
   Apple-grade surfaces: near-black graphite, soft elevation, hairline
   borders, crisp mono numerals. The EVAA burgundy gradient
   (#7A2534 → #D0687C) is the single signature accent, used deliberately
   and sparingly on CTAs, primary actions and active states.
   Brand-specific details (logo, pill CTAs, dividers) live in evaa.css.
   Same class names as the light theme — only the palette changes.
   ================================================================ */

:root {
  /* --- neutral surfaces (graphite dark) --- */
  --bg: #090A0D;               /* app background */
  --bg-2: #0D0F13;             /* deeper wells / sidebar base */
  --panel: #121419;            /* elevated card / surface */
  --panel-2: #1A1D24;          /* hover / secondary surface */
  --panel-3: #181A20;          /* input field surface / elevated */
  /* Black sidebar matching the dark-mode app background, with high-contrast,
     easily readable text. Kept BLACK in both themes (light mode too). */
  --sidebar-bg: #0B0D11;
  --sidebar-bg-2: #070809;
  --sidebar-fg: #E6E8EC;
  --sidebar-fg-dim: #AAB0B8;
  --sidebar-fg-strong: #F5F6F8;   /* brand title + active/hover — always light (sidebar is black in both themes) */
  --sidebar-active: rgba(158, 52, 72, .30);

  /* --- signature EVAA burgundy accent --- */
  --evaa-gradient: linear-gradient(115deg, #7A2534 0%, #9E3448 45%, #B8475C 75%, #D0687C 100%);
  --primary: #9E3448;          /* EVAA burgundy — CTAs */
  --primary-600: #B03C52;
  --primary-ink: #ffffff;      /* text on the gradient */
  --accent: #D0687C;           /* links / selected (mint, lifted for dark) */
  --accent-2: #E8B4BD;
  --accent-soft: rgba(158, 52, 72, .14);
  --accent-glow: rgba(208, 104, 124, .30);

  /* --- text --- */
  --text: #F6F6F7;
  --text-strong: #FFFFFF;
  --muted: #A4A6AD;
  --muted-2: #6C6E76;

  /* --- hairline borders --- */
  --border: rgba(255, 255, 255, .09);
  --border-strong: rgba(255, 255, 255, .14);
  --border-faint: rgba(255, 255, 255, .055);

  /* --- semantic --- */
  --green: #34D399;
  --green-soft: rgba(52, 211, 153, .14);
  --red: #FB7185;
  --amber: #FBBF24;
  --purple: #A78BFA;
  --teal: #9E3448;             /* legacy alias → brand burgundy */

  /* --- radius scale --- */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  /* --- spacing scale --- */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;

  /* --- elevation --- */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35), 0 1px 3px rgba(0,0,0,.28);
  --shadow-md: 0 10px 30px rgba(0,0,0,.42);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.58);
  --glow: 0 0 0 1px rgba(158,52,72,.35), 0 10px 30px rgba(208,104,124,.20);

  /* --- motion (Apple spring feel) --- */
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --dur-fast: .12s;
  --dur: .2s;
  --dur-slow: .34s;

  --sidebar-w: 188px;   /* compact HubSpot-style rail (spec §14) */
  --topbar-h: 56px;
  --font: "Geist", -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  --mono: "Geist Mono", "SFMono-Regular", ui-monospace, "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(920px 500px at 82% -10%, rgba(158,52,72,.08), transparent 60%),
    radial-gradient(820px 520px at 6% 112%, rgba(208,104,124,.05), transparent 55%),
    var(--bg);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--accent-2); }
button { font-family: inherit; }
/* Global form-control defaults. Every input/select/textarea gets a dark
   surface + readable text even when it has no specific class, so controls are
   never light-text-on-white (the "letters/boxes not visible" bug). More
   specific rules (.field input, .global-search input, …) still override. */
input, select, textarea { font-family: inherit; font-size: 14px; color: var(--text); }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]),
select, textarea {
  background-color: var(--panel-3);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 8px 10px;
}
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}
/* Native option list renders in the OS palette on some browsers — force dark. */
select option, select optgroup { background: var(--panel); color: var(--text); }
::placeholder { color: var(--muted-2); }
::selection { background: rgba(158,52,72,.30); color: #fff; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,.2); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- App layout ---------------- */
#app { min-height: 100vh; }
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.main { display: flex; flex-direction: column; min-width: 0; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  border-right: 1px solid var(--border);
}
/* Logo left-aligned (pmt1_19Sept): logo anchors to the left of the sidebar,
   consistent with how the nav items are left-aligned. Not centered. */
.brand { display: flex; align-items: center; justify-content: flex-start; gap: 8px; padding: 12px 14px; height: 52px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand .logo { width: 28px; height: 28px; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 10px; overflow: hidden;
  /* Transparent tile so the mark sits on whatever the sidebar is — it adapts to
     the screen/theme instead of a fixed dark square (spec pmt3_16Sept). */
  background: transparent; display: grid; place-items: center; flex: none;
}
.brand .logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* fallback wordmark when no image */
.brand .logo.txt { color: #fff; font-weight: 800; font-size: 15px; background: var(--evaa-gradient); }
.brand .brand-text { font-weight: 700; color: var(--sidebar-fg-strong); font-size: 15px; letter-spacing: -.01em; }
/* "EVAA" wordmark beside the logo — Geist Mono, bold, to match the mark lettering
   (user request: exact same font as the image). */
.brand .brand-word { font-family: 'Geist Mono', ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace; font-weight: 700; font-size: 18px; letter-spacing: -.02em; color: var(--sidebar-fg-strong); line-height: 1; }
.brand .brand-sub { font-size: 11px; color: var(--sidebar-fg-dim); }

.nav { padding: 8px 8px; overflow-y: auto; flex: 1; }
.nav-section { margin: 11px 6px 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .09em; color: var(--sidebar-fg-dim); font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 6px 9px; border-radius: 8px;
  color: var(--sidebar-fg); cursor: pointer; font-size: 12.5px; font-weight: 500; margin-bottom: 1px;
  border: 1px solid transparent; user-select: none; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.04); color: var(--sidebar-fg-strong); text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-fg-strong); border-color: rgba(158,52,72,.22); }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--evaa-gradient); box-shadow: 0 0 10px var(--accent-glow); }
.nav-item .ico { flex: none; opacity: .9; }
.nav-item .count { margin-left: auto; font-size: 11px; color: var(--muted); background: rgba(255,255,255,.06); padding: 1px 7px; border-radius: 10px; }
/* Scan card — a rounded PILL in EVAA burgundy (pmt2_21Sept §4). Hidden on desktop
   (≥901px) since scanning is phone-only (§6); shows in the mobile drawer. */
.nav-item.scan { margin: 12px 8px 6px; padding: 12px 18px; font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; background: var(--evaa-gradient); color: #fff; border: none; border-radius: 999px; box-shadow: 0 6px 18px rgba(158,52,72,.34); justify-content: center; gap: 10px; }
.nav-item.scan span { font-size: 14.5px; }
.nav-item.scan:hover { color: #fff; filter: brightness(1.05); box-shadow: 0 8px 22px rgba(208,104,124,.4); }
@media (min-width: 901px) { .nav-item.scan { display: none; } }
.sidebar-foot { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-top: 1px solid rgba(255,255,255,.08); cursor: pointer; flex: none; }
.sidebar-foot:hover { background: rgba(255,255,255,.05); }
.sidebar-foot .avatar { width: 28px; height: 28px; font-size: 12px; flex: none; }
.sidebar-foot .sf-id { min-width: 0; flex: 1; }
.sidebar-foot .sf-name { font-size: 12.5px; font-weight: 600; color: var(--sidebar-fg-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .sf-role { font-size: 10.5px; color: var(--sidebar-fg-dim); text-transform: capitalize; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .sf-caret { color: var(--sidebar-fg-dim); flex: none; }

/* ---------------- Topbar ---------------- */
.topbar {
  height: var(--topbar-h); background: rgba(13,15,19,.72); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 18px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumbs { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.topbar .crumbs b { color: var(--text-strong); font-weight: 600; }
.global-search { margin-left: auto; position: relative; width: 320px; max-width: 40vw; }
.global-search input {
  width: 100%; padding: 8px 40px 8px 16px; border: 1px solid var(--border-strong);
  border-radius: 20px; background: var(--panel-3); outline: none; color: var(--text);
}
.global-search input::placeholder { color: var(--muted-2); }
.global-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.global-search .si {
  position: absolute; right: 14px; left: auto; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--muted-2); pointer-events: none;
}
.global-search .si svg { display: block; width: 16px; height: 16px; }
.user-chip { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; cursor: pointer; }
.user-chip:hover { background: var(--panel-2); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--evaa-gradient); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }

/* ---------------- Content ---------------- */
.content { padding: 18px 22px; flex: 1; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-title { font-size: 19px; font-weight: 700; margin: 0; display: flex; align-items: center; gap: 9px; color: var(--text-strong); }
.page-title .obj-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #04141a; }
.page-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.subtle { color: var(--muted); }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-xs);
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 13px;
  cursor: pointer; white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast), box-shadow var(--dur) var(--ease-out), transform var(--dur) var(--ease-spring), filter var(--dur);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--panel-3); border-color: rgba(255,255,255,.20); }
.btn:active { transform: scale(.97); }
/* Signature tactile CTA — EVAA burgundy gradient, spring press, soft glow */
.btn.primary, .btn.accent {
  background: var(--evaa-gradient); background-size: 160% 160%; background-position: 0% 50%;
  border-color: transparent; color: var(--primary-ink); font-weight: 650;
  box-shadow: 0 4px 16px rgba(158,52,72,.30), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn.primary:hover, .btn.accent:hover {
  transform: translateY(-1px); filter: brightness(1.03);
  background-image: var(--evaa-gradient); background-position: 100% 50%; color: var(--primary-ink);
  box-shadow: 0 8px 24px rgba(158,52,72,.42), inset 0 1px 0 rgba(255,255,255,.22);
}
.btn.primary:active, .btn.accent:active { transform: scale(.97); box-shadow: 0 2px 10px rgba(158,52,72,.3); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--panel-2); color: var(--text); }
.btn.danger { color: var(--red); border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.08); }
.btn.danger:hover { background: rgba(251,113,133,.16); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }
@media (prefers-reduced-motion: reduce) {
  .btn, .btn.primary, .btn.accent { transition: background var(--dur-fast), box-shadow var(--dur-fast); }
  .btn:active, .btn.primary:active, .btn.accent:active, .btn.primary:hover, .btn.accent:hover { transform: none; }
}

/* ---------------- Card / panel ---------------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card.pad { padding: 18px; }
/* Fully-clickable cards / rows — subtle spring lift on hover */
.card.clickable, .kpi.clickable, .row-click { cursor: pointer; transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease-out), border-color var(--dur); }
.card.clickable:hover, .kpi.clickable:hover, .row-click:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.card.clickable:active, .kpi.clickable:active, .row-click:active { transform: translateY(0) scale(.997); }
@media (prefers-reduced-motion: reduce) {
  .card.clickable, .kpi.clickable, .row-click { transition: box-shadow var(--dur-fast); }
  .card.clickable:hover, .kpi.clickable:hover, .row-click:hover, .card.clickable:active, .kpi.clickable:active, .row-click:active { transform: none; }
}

/* ---------------- Toolbar (index page) ---------------- */
/* overflow-x:auto lets many tabs scroll sideways, but CSS then forces overflow-y
   to `auto` too, which shows a stray VERTICAL scrollbar next to the search box
   (pmt1_23Sept). Pin overflow-y:hidden so only horizontal tab scroll is possible. */
.tabs { display: flex; align-items: flex-end; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; }
.tab {
  padding: 9px 14px; font-size: 13px; color: var(--muted); cursor: pointer; border: 1px solid transparent;
  border-bottom: none; border-top-left-radius: 8px; border-top-right-radius: 8px; white-space: nowrap; font-weight: 600;
  display: flex; align-items: center; gap: 7px; position: relative; top: 1px;
}
.tab:hover { color: var(--text); background: var(--panel-2); }
.tab.active { color: var(--text-strong); background: var(--panel); border-color: var(--border); border-bottom: 2px solid var(--primary); }
.tab .tcount { font-size: 11px; color: var(--muted-2); }
.tab.add { color: var(--muted-2); }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px 0; flex-wrap: wrap; }
.toolbar .search-mini { position: relative; }
.toolbar .search-mini input { padding: 7px 32px 7px 12px; border: 1px solid var(--border-strong); border-radius: 8px; width: 240px; background: var(--panel-3); }
.toolbar .search-mini input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.toolbar .search-mini .si { position: absolute; right: 11px; left: auto; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; display: inline-flex; align-items: center; }
.toolbar .search-mini .si svg { display: block; width: 15px; height: 15px; }
.spacer { flex: 1; }

.filter-row { display: flex; align-items: center; gap: 8px; padding: 4px 0 12px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 16px;
  border: 1px dashed var(--border-strong); background: var(--panel-2); color: var(--accent); font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip.solid { border-style: solid; background: var(--accent-soft); border-color: rgba(158,52,72,.35); }
.chip .x { color: var(--muted-2); font-weight: 700; }
.chip .x:hover { color: var(--red); }

/* ---------------- Table ---------------- */
/* The wrap is BOTH the vertical and horizontal scroll container, with a capped
   height so the horizontal scrollbar always sits inside the viewport (no need
   to scroll to the bottom of a 500-row table to reach it). The header row and
   the left identity columns are frozen with position:sticky. */
.table-wrap {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: auto; box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 300px); min-height: 260px;
}
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; }
table.grid th, table.grid td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
/* Frozen header row (vertical scroll). */
table.grid thead th {
  background: var(--panel-2); color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  cursor: pointer; white-space: nowrap;
  position: sticky; top: 0; z-index: 5;
}
/* Frozen left identity columns (horizontal scroll): checkbox, name. Scoped to
   the index records grid (inside .table-wrap) only — other .grid tables (Events,
   Segments, dashboard) must NOT get a sticky, opaque first column, or it paints
   over the next column and clips its content. */
.table-wrap table.grid th.col-check, .table-wrap table.grid td.col-check { position: sticky; left: 0; z-index: 3; background: var(--panel); }
.table-wrap table.grid td.name-cell, .table-wrap table.grid thead th.name-th { position: sticky; left: 38px; z-index: 3; background: var(--panel); }
/* Header corners of the frozen columns must sit above both axes. */
.table-wrap table.grid thead th.col-check, .table-wrap table.grid thead th.name-th { z-index: 7; background: var(--panel-2); }
/* Keep the frozen cells' colour in step with row hover / selection. */
.table-wrap table.grid tbody tr:hover td.col-check, .table-wrap table.grid tbody tr:hover td.name-cell { background: #191c22; }
.table-wrap table.grid tbody tr.selected td.col-check, .table-wrap table.grid tbody tr.selected td.name-cell { background: #2A1217; }
/* A subtle divider so the frozen name column reads as pinned when scrolled. */
.table-wrap table.grid td.name-cell, .table-wrap table.grid thead th.name-th { box-shadow: 1px 0 0 var(--border); }
/* Row actions (⋯) pinned to the RIGHT edge — always visible while the table
   scrolls horizontally (spec pmt4_16Sept). The flex spacer before it keeps it at
   the far right even when the columns don't fill the width. */
.table-wrap table.grid th.act-th, .table-wrap table.grid td.act-cell { position: sticky; right: 0; z-index: 3; background: var(--panel); box-shadow: -1px 0 0 var(--border); text-align: center; }
.table-wrap table.grid thead th.act-th { z-index: 7; background: var(--panel-2); }
.table-wrap table.grid tbody tr:hover td.act-cell { background: #191c22; }
.table-wrap table.grid tbody tr.selected td.act-cell { background: #2A1217; }
table.grid thead th:hover { color: var(--text); }
table.grid thead th .sort-ind { color: var(--accent); margin-left: 4px; }
table.grid tbody tr:hover { background: #191c22; }
table.grid tbody tr.selected { background: var(--accent-soft); }
table.grid td.name-cell a { font-weight: 600; color: var(--text-strong); }
table.grid td.name-cell a:hover { color: var(--accent-2); }
table.grid .col-check { width: 38px; min-width: 38px; max-width: 38px; padding-left: 0; padding-right: 0; text-align: center; }
table.grid .col-expand { width: 30px; text-align: center; color: var(--muted-2); cursor: pointer; }
.cell-muted { color: var(--muted-2); }
table.grid td.ed-cell { cursor: cell; }
table.grid td.ed-cell:hover { outline: 1px dashed var(--border-strong); outline-offset: -3px; background: rgba(158,52,72,.06); }
.expand-row td { background: #0e1015; padding: 0; }
.expand-inner { padding: 14px 20px 16px 60px; display: flex; gap: 30px; flex-wrap: wrap; align-items: flex-start; }
.exp-group { min-width: 190px; }
.exp-group-t { color: var(--muted-2); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; margin: 0 0 8px; }
.exp-kvs { display: grid; gap: 9px; }
.expand-inner .kv { font-size: 12.5px; color: var(--text); }
.expand-inner .kv b { color: var(--muted); font-weight: 600; display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 1px; }
.exp-assoc .kv b { display: flex; align-items: center; gap: 6px; }
.assoc-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.pill-primary { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--primary); background: var(--accent-soft); border-radius: 5px; padding: 1px 5px; margin-left: 3px; }

/* Per-row expander chevron (lives inside the sticky name cell). */
.row-exp { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; color: var(--muted-2); cursor: pointer; margin-right: 4px; vertical-align: middle; transition: transform .15s ease, background .15s, color .15s; flex: none; }
.row-exp:hover { background: var(--panel-2); color: var(--text); }
table.grid tbody tr.expanded .row-exp { transform: rotate(90deg); color: var(--primary); }
table.grid tbody tr.expanded td.name-cell a { color: var(--accent-2); }

/* Entry cell — the first column of the records list: expander + avatar + a link
   to the record showing that field's own value. Flows with the table; it is NOT
   frozen/sticky and is not a synthetic combined "Name" (spec pmt1_16Sept). */
table.grid td.entry-cell { white-space: nowrap; }
table.grid td.entry-cell a { font-weight: 600; color: var(--text-strong); }
table.grid td.entry-cell a:hover { color: var(--accent-2); }
table.grid tbody tr.expanded td.entry-cell a { color: var(--accent-2); }

/* Filter-surfaced columns (spec §7) — a subtle burgundy wash + filter dot so it's
   clear the column is here only because a filter is active on it. */
table.grid thead th.surfaced-th { color: var(--primary); }
.surfaced-dot { color: var(--primary); margin-right: 4px; vertical-align: middle; opacity: .8; }
table.grid td.surfaced-cell { background: var(--accent-soft); }
.avatar-sm { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; margin-right: 8px; vertical-align: middle; }

/* ---------------- Pagination ---------------- */
.pager { display: flex; align-items: center; gap: 8px; padding: 14px 2px; color: var(--muted); font-size: 13px; }
.pager .pages { display: flex; gap: 4px; }
.pager .pg { min-width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border); background: var(--panel-2); display: grid; place-items: center; cursor: pointer; padding: 0 6px; color: var(--text); }
.pager .pg:hover { border-color: var(--border-strong); }
.pager .pg.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.pager select { padding: 5px 8px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel-3); }

/* ---------------- Bulk bar ---------------- */
.bulk-bar {
  position: sticky; bottom: 16px; margin: 12px auto 0; background: rgba(20,23,30,.96); backdrop-filter: blur(10px);
  color: #fff; border: 1px solid var(--border-strong); border-radius: 12px; padding: 10px 16px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow-lg); width: fit-content;
}
.bulk-bar .btn { background: rgba(255,255,255,.06); color: #fff; border-color: rgba(255,255,255,.14); }
.bulk-bar .btn:hover { background: rgba(255,255,255,.12); }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600; background: rgba(255,255,255,.06); color: var(--muted); border: 1px solid transparent; }
/* Badge palette: varied, semantic, distinct. Green is reserved for the brand
   accent, so status badges lean on the wider neutral/cool/warm hue set. */
.badge.blue { background: rgba(56,189,248,.16); color: #7DD3FC; }    /* BD / prospect → sky */
.badge.green { background: rgba(52,211,153,.16); color: #6EE7B7; }   /* Customer / active → emerald */
.badge.orange { background: rgba(251,146,60,.16); color: #FDBA74; }  /* Supplier / vendor → amber */
.badge.purple { background: rgba(167,139,250,.18); color: #C4B5FD; } /* Partner → violet */
.badge.teal { background: rgba(208,104,124,.16); color: #E8B4BD; }    /* default → teal */
.badge.gray { background: rgba(148,163,184,.14); color: #b6bdca; }

/* Dashboard donut chart (contacts by type) */
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut { width: 130px; height: 130px; flex: 0 0 auto; }
.donut circle { transition: opacity .15s; }
.donut circle:hover { opacity: .82; }
.donut-total { fill: var(--text-strong); font-size: 22px; font-weight: 700; font-family: var(--mono); }
.donut-sub { fill: var(--muted); font-size: 9px; letter-spacing: .5px; text-transform: uppercase; }
.donut-legend { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 8px; }
.donut-leg { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.donut-leg .sw { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.donut-leg .lbl { color: var(--text); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-leg .val { font-family: var(--mono); font-weight: 700; color: var(--text-strong); }
.donut-leg .val .pct { color: var(--muted); font-weight: 500; margin-left: 6px; }

/* Resizable columns: fixed layout so per-column widths are respected; a grab
   handle on the right edge of each header cell drags to resize. Cells clip with
   an ellipsis so a narrowed column stays tidy. */
.table-wrap table.grid { table-layout: fixed; }
.table-wrap table.grid thead th { overflow: hidden; text-overflow: ellipsis; }
.table-wrap table.grid td.ed-cell, .table-wrap table.grid td.assoc-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.grid thead th .col-resize {
  position: absolute; top: 0; right: 0; width: 9px; height: 100%;
  cursor: col-resize; user-select: none; z-index: 8; touch-action: none;
}
table.grid thead th .col-resize::after {
  content: ""; position: absolute; top: 22%; right: 3px; height: 56%; width: 2px;
  background: transparent; border-radius: 2px; transition: background .12s;
}
table.grid thead th .col-resize:hover::after, table.grid thead th.resizing .col-resize::after { background: var(--accent); }
body.col-resizing, body.col-resizing * { cursor: col-resize !important; user-select: none !important; }

/* strength dots */
.strength { display: inline-flex; gap: 3px; align-items: center; }
.strength .d { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.12); }
.strength .d.on { background: var(--primary); box-shadow: 0 0 6px rgba(158,52,72,.5); }

/* ---------------- KPI cards ---------------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { background: linear-gradient(180deg, var(--panel), #14161c); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; transition: transform var(--dur) var(--ease-spring), box-shadow var(--dur) var(--ease-out), border-color var(--dur); }
.kpi:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; background: radial-gradient(circle, rgba(158,52,72,.10), transparent 70%); }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .k-val { font-size: 28px; font-weight: 800; margin-top: 6px; font-family: var(--mono); letter-spacing: -.5px; color: var(--text-strong); }
.kpi .k-ico { float: right; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #04141a; }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 20px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full, .form-grid > .full { grid-column: 1 / -1; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel-3); outline: none; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { min-height: 84px; resize: vertical; }
.field select option { background: var(--panel); color: var(--text); }
.form-group-title { grid-column: 1 / -1; font-size: 12px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; margin-top: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.form-group-title:first-child { border-top: none; margin-top: 0; padding-top: 0; }
/* Multi-select field (e.g. Type of Contact): one tickable chip per option, so
   a contact can be several types at once. Ticked chips fill in brand burgundy. */
.field .multiselect { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 0; }
.field .ms-opt {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 11px; border-radius: 16px;
  border: 1px solid var(--border-strong); background: var(--panel-3); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer;
  user-select: none; -webkit-user-select: none;
}
.field .ms-opt:hover { border-color: var(--accent); }
.field .ms-opt:has(input:checked) { background: var(--accent-soft); border-color: rgba(158,52,72,.45); color: var(--accent); font-weight: 600; }
.field .ms-opt input { width: 15px; height: 15px; margin: 0; padding: 0; accent-color: var(--primary); cursor: pointer; }
.field .ms-opt input:disabled { cursor: default; }
.field[hidden], .form-group-title[hidden] { display: none; }

/* ---------------- Modal / drawer ---------------- */
/* Modals sit ABOVE the settings overlay (z-index 900) so dialogs opened from
   inside Settings (Add field, Edit sub-field, delete confirm) are visible and
   clickable, not stuck behind it (pmt3_19Sept). */
.overlay { position: fixed; inset: 0; background: rgba(2,4,8,.66); backdrop-filter: blur(2px); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: var(--panel); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow-lg); width: 640px; max-width: 100%; max-height: 88vh; display: flex; flex-direction: column; overflow: hidden; }
.modal.wide { width: 900px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 16px; color: var(--text-strong); }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--muted-2); border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; }
.modal-head .x:hover { background: var(--panel-2); color: var(--text); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; background: var(--panel-2); }

.drawer-overlay { position: fixed; inset: 0; background: rgba(2,4,8,.66); backdrop-filter: blur(2px); z-index: 100; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 560px; max-width: 96vw; background: var(--panel); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); z-index: 101; display: flex; flex-direction: column; animation: slidein .18s ease; }
@keyframes slidein { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------------- Toast ---------------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 1200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: rgba(20,23,30,.97); border: 1px solid var(--border-strong); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; display: flex; align-items: center; gap: 9px; animation: slidein .18s ease; }
.toast.err { background: rgba(248,113,113,.95); border-color: transparent; }
.toast.ok { background: rgba(61,214,140,.95); border-color: transparent; color: #05231a; }

/* ---------------- Misc ---------------- */
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 8px; opacity: .4; }
.spin { width: 18px; height: 18px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: rot 0.7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading-full { display: grid; place-items: center; min-height: 300px; }
.hint { font-size: 12px; color: var(--muted-2); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.dropdown { position: absolute; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-md); z-index: 1100; min-width: 200px; overflow: hidden; }
.dropdown .dd-item { padding: 9px 13px; cursor: pointer; font-size: 13px; display: flex; align-items: center; gap: 9px; color: var(--text); }
.dropdown .dd-item:hover { background: var(--panel-2); }
.dropdown .dd-sep { height: 1px; background: var(--border); }
.checkbox { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 5px; font-family: var(--mono); font-size: 12px; color: var(--accent-2); }
pre { background: var(--panel-3) !important; border-color: var(--border) !important; color: var(--muted) !important; }
details summary { color: var(--muted); }

/* ---------------- Associations ---------------- */
.assoc-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.assoc-row a { color: var(--text-strong); font-weight: 500; }
.assoc-row a:hover { color: var(--accent-2); }
.assoc-star { margin-left: auto; cursor: pointer; color: var(--muted-2); display: inline-flex; }
.assoc-star:hover { color: var(--amber); }
.assoc-star.on { color: var(--amber); }
.assoc-star.on svg { fill: var(--amber); }
.assoc-rm { cursor: pointer; color: var(--muted-2); display: inline-flex; }
.assoc-rm:hover { color: var(--red); }

/* ---------------- Relationship graph ---------------- */
.graph-controls { margin-bottom: 14px; }
.graph-controls .gc-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.graph-controls .gc-row + .gc-row { margin-top: 10px; }
.gc-focus { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--panel-3); border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.seg button { border: none; background: transparent; color: var(--muted); padding: 7px 13px; font-size: 13px; font-weight: 600; cursor: pointer; }
.seg button:hover { color: var(--text); background: var(--panel-2); }
.seg button.on { background: var(--accent-soft); color: var(--accent-2); }
.gfilter { cursor: pointer; user-select: none; }
.gfilter.off { opacity: .4; text-decoration: line-through; }
.graph-search-res { position: relative; }
.graph-search-res .dd-item { border: 1px solid var(--border); border-top: none; }
.graph-search-res .dd-item:first-child { border-top: 1px solid var(--border); border-radius: 8px 8px 0 0; }
.graph-wrap { display: grid; grid-template-columns: 1fr 240px; gap: 14px; }
#cyGraph { height: calc(100vh - 260px); min-height: 420px; background:
  radial-gradient(700px 400px at 50% 40%, rgba(158,52,72,.06), transparent 60%), #0b0d11;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.graph-legend { align-self: start; }
@media (max-width: 900px) { .graph-wrap { grid-template-columns: 1fr; } #cyGraph { height: 62vh; } }

/* ---------------- Responsive ---------------- */
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: 260px; z-index: 90; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .global-search { width: auto; flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; padding-top: max(16px, env(safe-area-inset-top, 0px)); }
  /* the fixed index viewport starts below the notch and ends above the tab bar.
     Scoped to html.is-app .content.idx-scroll so it OUTWEIGHS `html.is-app .content`
     (which otherwise makes the whole content scroll, dragging the header/filters
     with it). overflow:hidden + flex column = header/filters frozen, only the
     record list scrolls (pmt1_23Sept). */
  html.is-app .content.idx-scroll {
    height: calc(100vh - 62px - env(safe-area-inset-bottom, 0px) - env(safe-area-inset-top, 0px));
    display: flex; flex-direction: column; flex: none; overflow: hidden;
    padding-top: max(12px, env(safe-area-inset-top, 0px)); padding-bottom: 0;
  }
  .scrim.show { display: block; }
}
/* Mobile drawer scrim — hidden until the sidebar is opened; tapping it closes
   the drawer (spec §10, Test 9). Never shown on desktop (menu toggle is hidden
   there, so .show is never applied). */
.scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 80; animation: scrimIn .18s ease; }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }

/* Plain grid modifier for small, non-scrolling tables (Events, Segments) that
   live inside a .table-wrap but must NOT get the index grid's frozen first
   column or fixed layout — those made the sticky, opaque name cell paint over
   the next column and clip its badge. */
.table-wrap table.grid.grid-plain { table-layout: auto; }
.table-wrap table.grid.grid-plain td.name-cell,
.table-wrap table.grid.grid-plain thead th.name-th { position: static; left: auto; box-shadow: none; background: transparent; z-index: auto; }

/* Data-model field tiers (Primary / Secondary / Tertiary) + drag-and-drop. */
.tier-sec { margin-bottom: 14px; }
.tier-head { display: flex; align-items: center; gap: 10px; margin: 4px 0 6px; flex-wrap: wrap; }
.tier-pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 3px 10px; border-radius: 999px; color: #fff; }
.tier-primary { background: var(--primary); }
.tier-secondary { background: #64748B; }
.tier-tertiary { background: #94A3B8; }
.tier-count { font-size: 12px; color: var(--muted-2); font-weight: 700; }
.tier-desc { flex: 1; min-width: 160px; }
.tier-drop { border: 1.5px dashed var(--border); border-radius: 10px; padding: 6px; min-height: 46px; transition: background .12s, border-color .12s; }
.tier-drop.drop-hover { border-color: var(--primary); background: var(--accent-soft); }
.tier-empty { color: var(--muted-2); font-size: 12.5px; text-align: center; padding: 12px 0; }
.tier-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; background: var(--panel); border: 1px solid var(--border); margin: 5px 0; }
.tier-row[draggable="true"] { cursor: grab; }
.tier-row.dragging { opacity: .45; }
.tier-row.is-disabled { opacity: .55; }
.tier-grip { color: var(--muted-2); display: inline-flex; flex: none; }
.tier-lbl { min-width: 150px; }
.tier-key { margin-left: auto; }
.tier-move { padding: 5px 26px 5px 9px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--panel-2); color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; flex: none; }
.tier-move:hover { border-color: var(--primary); }

/* Duplicate-resolution dialog (spec §26-27, Test 8). */
.dup-wrap { display: flex; flex-direction: column; gap: 10px; }
.dup-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--panel-2); }
.dup-new { border-color: rgba(158,52,72,.30); background: var(--accent-soft); }
.dup-h { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); font-weight: 700; margin-bottom: 5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dup-body { font-size: 13.5px; color: var(--text); }
.dup-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Global "+" create bottom sheet + scan submenu (spec §11-12). */
.sheet-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 120; animation: scrimIn .18s ease; }
.create-sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(520px, 100%); background: var(--panel); border: 1px solid var(--border); border-bottom: none; border-radius: 18px 18px 0 0; box-shadow: var(--shadow-lg); z-index: 121; padding: 8px 10px calc(12px + env(safe-area-inset-bottom, 0px)); animation: sheetUp .22s cubic-bezier(.2,.8,.2,1); }
@keyframes sheetUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet-title { text-align: center; font-weight: 700; font-size: 14px; padding: 10px 0 8px; color: var(--text); }
.sheet-list { display: flex; flex-direction: column; }
.sheet-item { display: flex; align-items: center; gap: 13px; padding: 13px 12px; background: none; border: none; border-radius: 10px; font-size: 15px; color: var(--text); cursor: pointer; text-align: left; width: 100%; }
.sheet-item:hover { background: var(--panel-2); }
.sheet-ic { display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.sheet-lbl { flex: 1; }
.sheet-chev { color: var(--muted-2); }
.sheet-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.sheet-cancel { width: 100%; justify-content: center; margin-top: 8px; padding: 12px; }
@media (min-width: 720px) {
  .create-sheet { bottom: auto; top: 50%; transform: translate(-50%, -50%); border-radius: 16px; border-bottom: 1px solid var(--border); animation: sheetPop .18s ease; }
  @keyframes sheetPop { from { transform: translate(-50%, -48%); opacity: 0; } to { transform: translate(-50%, -50%); opacity: 1; } }
}

/* ---------------- Card scanner (multi-image, crop, AI) ---------------- */
.scan-shots{display:flex;gap:10px;flex-wrap:wrap;margin:14px 0}
.scan-empty{color:var(--muted);font-size:13px;padding:14px;border:1px dashed var(--border);border-radius:10px;width:100%;text-align:center}
.scan-shot{width:150px;border:1px solid var(--border);border-radius:10px;overflow:hidden;background:var(--panel-2)}
.scan-shot img{width:100%;height:100px;object-fit:cover;display:block}
.scan-shot-bar{display:flex;align-items:center;gap:4px;padding:5px 6px}
.scan-role{font-size:11px;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.03em}
.scan-mini{border:1px solid var(--border);background:var(--panel);color:var(--muted);border-radius:6px;padding:3px 6px;cursor:pointer;line-height:0}
.scan-mini:hover{color:var(--text);border-color:var(--primary)}
.scan-add{display:flex;gap:12px;flex-wrap:wrap}
.scan-thumbs{display:flex;gap:8px;flex-wrap:wrap}
.scan-thumbs img{height:74px;border-radius:8px;border:1px solid var(--border);object-fit:cover}
.scan-progress{max-width:340px;height:6px;background:var(--panel-2);border-radius:4px;margin:12px auto 0;overflow:hidden}
.scan-progress>div{height:100%;width:0;background:var(--accent);transition:width .2s}
.scan-raw{white-space:pre-wrap;font-size:12px;color:var(--muted);background:var(--panel-2);padding:10px;border-radius:6px;border:1px solid var(--border)}
.scan-check{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--muted);cursor:pointer}
.crop-stage{position:relative;display:inline-block;max-width:100%;border-radius:10px;overflow:hidden;background:#0b0f14;touch-action:none}
.crop-stage canvas{display:block;max-width:100%}
.crop-box{position:absolute;border:2px solid var(--accent);box-shadow:0 0 0 9999px rgba(0,0,0,.5);cursor:move;box-sizing:border-box}
/* Rule-of-thirds guide — INTERIOR lines only (at 1/3 and 2/3), never at the
   0/100% edges, so no white line hugs the top-left corner under the handle
   (pmt2_21Sept: "top-left crop circle is white"). */
.crop-grid{position:absolute;inset:0;pointer-events:none;opacity:.45;
  background-image:
    linear-gradient(rgba(255,255,255,.35) 1px,transparent 1px),
    linear-gradient(90deg,rgba(255,255,255,.35) 1px,transparent 1px);
  background-repeat:no-repeat;
  background-position: 0 33.333%, 33.333% 0, 0 66.666%, 66.666% 0;
  background-size:100% 1px,1px 100%,100% 1px,1px 100%}
/* Big, easy-to-grab handles — 4 corners + 4 edge midpoints, sitting just INSIDE
   the frame edges (the stage's overflow:hidden then never clips one into a white
   sliver). Solid GREEN discs with a subtle dark ring — NO white border, which
   was reading as a "white circle" at the corners (pmt2_21Sept). */
.crop-h{position:absolute;width:20px;height:20px;background:var(--accent);border:2px solid rgba(4,20,16,.55);border-radius:50%;box-shadow:0 0 0 2px rgba(255,255,255,.28),0 1px 5px rgba(0,0,0,.4);touch-action:none;z-index:2}
.crop-h.tl{left:2px;top:2px;cursor:nwse-resize}
.crop-h.tr{right:2px;top:2px;cursor:nesw-resize}
.crop-h.bl{left:2px;bottom:2px;cursor:nesw-resize}
.crop-h.br{right:2px;bottom:2px;cursor:nwse-resize}
.crop-h.tm{left:50%;top:2px;transform:translateX(-50%);cursor:ns-resize}
.crop-h.bm{left:50%;bottom:2px;transform:translateX(-50%);cursor:ns-resize}
.crop-h.lm{left:2px;top:50%;transform:translateY(-50%);cursor:ew-resize}
.crop-h.rm{right:2px;top:50%;transform:translateY(-50%);cursor:ew-resize}
.crop-toolbar{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-top:12px}

/* ================================================================
   LIGHT THEME  ·  Wave B
   Purely additive. Default (no data-theme attr) = the original DARK
   look, unchanged. `<html data-theme="light">` remaps the semantic
   tokens below to a clean light palette and patches the handful of
   hard-coded dark values. `data-theme="dark"` needs no rules — it
   falls through to the :root dark defaults above.
   Scanner UI (crop stage / camera overlay) is intentionally left
   dark in both themes — its look and logic are untouched.
   ================================================================ */
:root[data-theme="light"] {
  /* Clean WHITE content background; the EVAA burgundy lives in the
     accent + icons, not a full-surface tint (spec pmt4_16Sept). */
  --bg: #FFFFFF;               /* white background */
  --bg-2: #F4F6F8;
  --panel: #FFFFFF;            /* elevated card / surface */
  --panel-2: #F1F3F5;          /* secondary surface / hover — neutral light */
  --panel-3: #FFFFFF;          /* input field surface */
  /* Sidebar stays BLACK even in light mode (matches the dark-mode app shell),
     with high-contrast light text. */
  --sidebar-bg: #0B0D11;
  --sidebar-bg-2: #070809;
  --sidebar-fg: #E6E8EC;
  --sidebar-fg-dim: #AAB0B8;
  --sidebar-active: rgba(158, 52, 72, .32);
  --evaa-gradient: linear-gradient(115deg, #7A2534 0%, #9E3448 45%, #B8475C 75%, #D0687C 100%);
  --primary: #9E3448;          /* EVAA burgundy CTA — same gradient in both themes */
  --primary-600: #8A2B3D;
  --primary-ink: #ffffff;
  --accent: #9E3448;           /* links / selected — deeper burgundy for contrast on white */
  --accent-2: #7A2534;
  --accent-soft: rgba(158, 52, 72, .12);
  --accent-glow: rgba(158, 52, 72, .22);
  --text: #17171A;
  --text-strong: #0A0A0C;
  --muted: #606169;
  --muted-2: #93949B;
  --border: rgba(20, 20, 24, .10);
  --border-strong: rgba(20, 20, 24, .16);
  --border-faint: rgba(20, 20, 24, .07);
  --green: #16A34A;
  --green-soft: rgba(22, 163, 74, .12);
  --red: #DC2626;
  --amber: #D97706;
  --purple: #7C3AED;
  --teal: #9E3448;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --shadow-md: 0 10px 30px rgba(16,24,40,.10);
  --shadow-lg: 0 24px 60px rgba(16,24,40,.16);
  --glow: 0 0 0 1px rgba(158,52,72,.28), 0 10px 30px rgba(158,52,72,.14);
}

/* body backdrop */
:root[data-theme="light"] body {
  /* Plain white — no full-page burgundy wash (the bottom gradient read as "ugly"). */
  background: var(--bg);
}

/* topbar glass — was a dark translucent slab */
:root[data-theme="light"] .topbar { background: rgba(255,255,255,.72); }

/* neutral button hover */
:root[data-theme="light"] .btn:hover { background: #ECECEF; border-color: rgba(20,20,24,.20); }
/* keep the burgundy gradient (and white label) on primary/accent hover — the neutral
   rule above is more specific than the base gradient, so without this the button
   would turn near-white with invisible text on hover. Applies in light AND dark. */
:root[data-theme="light"] .btn.primary:hover, :root[data-theme="light"] .btn.accent:hover,
:root:not([data-theme="light"]) .btn.primary:hover, :root:not([data-theme="light"]) .btn.accent:hover {
  background: var(--evaa-gradient); background-size: 160% 160%; background-position: 100% 50%;
  color: var(--primary-ink); border-color: transparent;
  box-shadow: 0 8px 24px rgba(158,52,72,.42), inset 0 1px 0 rgba(255,255,255,.24);
}
/* keep danger buttons red-tinted (not neutral-grey) on hover in light mode */
:root[data-theme="light"] .btn.danger:hover { background: rgba(220,38,38,.14); border-color: rgba(220,38,38,.42); color: var(--red); }
/* primary/accent keep the shared burgundy gradient (defined on the base .btn.primary),
   so no palette override is needed here — only a slightly lighter shadow on white. */
:root[data-theme="light"] .btn.primary,
:root[data-theme="light"] .btn.accent { box-shadow: 0 3px 12px rgba(158,52,72,.24), inset 0 1px 0 rgba(255,255,255,.25); }

/* table row hover / selected / expand — hard-coded dark greys */
:root[data-theme="light"] table.grid tbody tr:hover { background: #f2f5fa; }
:root[data-theme="light"] .table-wrap table.grid tbody tr:hover td.col-check,
:root[data-theme="light"] .table-wrap table.grid tbody tr:hover td.name-cell,
:root[data-theme="light"] .table-wrap table.grid tbody tr:hover td.act-cell { background: #eef3f9; }
:root[data-theme="light"] .table-wrap table.grid tbody tr.selected td.col-check,
:root[data-theme="light"] .table-wrap table.grid tbody tr.selected td.name-cell,
:root[data-theme="light"] .table-wrap table.grid tbody tr.selected td.act-cell { background: #e2f4fa; }
:root[data-theme="light"] .expand-row td { background: #f7f9fc; }

/* KPI card gradient bottom stop was near-black */
:root[data-theme="light"] .kpi { background: linear-gradient(180deg, #ffffff, #f5f8fc); }

/* sidebar "Scan card" pill */
/* Sidebar is black in light mode too, so the Scan pill keeps its bright
   on-black treatment (not the deep-burgundy-on-light it used to use). */
:root[data-theme="light"] .nav-item.scan { background: rgba(158,52,72,.14); color: #F2D3D9; border-color: rgba(158,52,72,.30); }
:root[data-theme="light"] .nav-item.scan:hover { background: rgba(158,52,72,.22); color: #fff; box-shadow: 0 0 16px rgba(208,104,124,.20); }

/* Dark-grey sidebar (light theme): white-alpha tints for hover/active/count/
   dividers, light brand text, and EVAA burgundy nav icons. */
:root[data-theme="light"] .sidebar { border-right-color: rgba(255,255,255,.10); }
:root[data-theme="light"] .nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
:root[data-theme="light"] .nav-item.active { background: var(--sidebar-active); color: #fff; border-color: rgba(158,52,72,.40); }
:root[data-theme="light"] .nav-item .count { background: rgba(255,255,255,.12); color: var(--sidebar-fg); }
:root[data-theme="light"] .brand { border-bottom-color: rgba(255,255,255,.10); }
:root[data-theme="light"] .brand .brand-text { color: #fff; }
:root[data-theme="light"] .brand .brand-word { color: #fff; }
:root[data-theme="light"] .sidebar-foot { border-top-color: rgba(255,255,255,.10); }
/* Icons in a burgundy shade: the section/tool nav icons (rendered as a direct SVG
   child; object icons keep their own colour via an inline-styled span). */
:root[data-theme="light"] .nav-item > svg { color: var(--primary); }

/* badges — pale text needs darker ink on white */
:root[data-theme="light"] .badge { background: rgba(15,23,42,.05); color: var(--muted); }
:root[data-theme="light"] .badge.blue   { background: rgba(37,99,235,.12);   color: #1D4ED8; }  /* BD / prospect → blue */
:root[data-theme="light"] .badge.green  { background: rgba(52,199,89,.14);  color: #1E7B34; }  /* Customer / active → green */
:root[data-theme="light"] .badge.orange { background: rgba(234,88,12,.12);   color: #C2410C; }  /* Supplier / vendor → orange */
:root[data-theme="light"] .badge.purple { background: rgba(124,58,237,.12);  color: #6D28D9; }  /* Partner → violet */
:root[data-theme="light"] .badge.teal   { background: rgba(13,148,136,.14);  color: #0F766E; }  /* default → teal */
:root[data-theme="light"] .badge.gray   { background: rgba(100,116,139,.14); color: #475569; }

/* scrollbars */
:root[data-theme="light"] ::-webkit-scrollbar-thumb { background: #cfcfd5; border: 2px solid var(--bg); }
:root[data-theme="light"] ::-webkit-scrollbar-thumb:hover { background: #b9b9c1; }

/* text selection */
:root[data-theme="light"] ::selection { background: rgba(158,52,72,.18); color: #2E0F14; }

/* logo tile stays dark in light mode so the rainbow mark keeps its punch */
:root[data-theme="light"] .brand .logo { box-shadow: 0 0 0 1px rgba(20,20,24,.10), 0 6px 16px rgba(158,52,72,.18); }

/* theme toggle button: give the icon a gentle idle tint */
.theme-toggle { color: var(--muted); }
.theme-toggle:hover { color: var(--text); }

/* ================================================================
   PHASE 2  ·  Command palette, transitions, skeletons, toasts
   Purely additive; later cascade so it refines earlier rules.
   ================================================================ */

/* --- keyboard-key pill --- */
.kbd { font: 600 11px/1 var(--mono); color: var(--muted); background: rgba(255,255,255,.07); border: 1px solid var(--border); border-radius: 6px; padding: 3px 6px; letter-spacing: .02em; }
:root[data-theme="light"] .kbd { background: rgba(20,20,24,.05); }

/* --- topbar search → command-palette launcher --- */
.global-search {
  margin-left: auto; display: flex; align-items: center; gap: 9px; width: 320px; max-width: 40vw;
  padding: 7px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-pill);
  background: var(--panel-3); color: var(--muted); cursor: text;
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
}
.global-search:hover { border-color: rgba(255,255,255,.22); }
:root[data-theme="light"] .global-search:hover { border-color: rgba(20,20,24,.22); }
.global-search:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.global-search .si { position: static; transform: none; color: var(--muted-2); display: inline-flex; width: auto; height: auto; }
.gs-placeholder { flex: 1; font-size: 13px; color: var(--muted-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gs-kbd { flex: none; }

/* --- ⌘K command palette --- */
.cmdk-overlay {
  position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 16px 16px; background: rgba(4,5,8,.5); backdrop-filter: blur(6px) saturate(140%);
  opacity: 0; transition: opacity .16s var(--ease-out);
}
:root[data-theme="light"] .cmdk-overlay { background: rgba(20,22,28,.28); }
.cmdk-overlay.in { opacity: 1; }
.cmdk-panel {
  width: 620px; max-width: 100%; background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; display: flex; flex-direction: column;
  max-height: 70vh; transform: translateY(-8px) scale(.98); transition: transform .18s var(--ease-spring);
}
.cmdk-overlay.in .cmdk-panel { transform: none; }
.cmdk-input-row { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-search-ico { color: var(--muted); display: inline-flex; }
.cmdk-input { flex: 1; border: none; background: transparent; outline: none; font-size: 16px; color: var(--text); padding: 0; }
.cmdk-input::placeholder { color: var(--muted-2); }
.cmdk-list { overflow-y: auto; padding: 6px; }
.cmdk-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted-2); font-weight: 700; padding: 10px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--radius-xs); cursor: pointer; color: var(--text); }
.cmdk-item.sel { background: var(--accent-soft); }
.cmdk-ico { color: var(--muted); display: inline-flex; flex: none; }
.cmdk-item.sel .cmdk-ico { color: var(--accent); }
.cmdk-lbl { flex: 1; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmdk-sub { color: var(--muted-2); font-size: 12px; margin-left: auto; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk-enter { color: var(--muted-2); font-size: 13px; margin-left: 8px; }
.cmdk-empty { padding: 28px 12px; text-align: center; color: var(--muted-2); font-size: 13px; }
.cmdk-foot { display: flex; align-items: center; gap: 16px; padding: 9px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted-2); }
.cmdk-foot .cmdk-brand { margin-left: auto; font-weight: 700; background: var(--evaa-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.cmdk-kbd { font: 600 11px/1 var(--mono); background: rgba(255,255,255,.07); border: 1px solid var(--border); border-radius: 5px; padding: 3px 5px; color: var(--muted); }
:root[data-theme="light"] .cmdk-kbd { background: rgba(20,20,24,.05); }
html.cmdk-lock, html.cmdk-lock body { overflow: hidden; }

/* --- page + nav transitions --- */
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.content.route-anim { animation: pageIn .32s var(--ease-out); }
.nav-item { transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast), transform var(--dur) var(--ease-spring); }
.nav-item:active { transform: scale(.98); }

/* --- skeleton loaders --- */
.sk { position: relative; overflow: hidden; background: var(--panel-2); border-radius: 8px; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); animation: shimmer 1.25s infinite; }
:root[data-theme="light"] .sk::after { background: linear-gradient(90deg, transparent, rgba(20,20,24,.05), transparent); }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.sk-line { height: 12px; }
.sk-title { height: 26px; width: 240px; border-radius: 10px; }
.sk-num { height: 30px; width: 64px; margin-top: 12px; border-radius: 8px; }
.sk-donut { height: 130px; width: 130px; border-radius: 50%; }
.sk-list { display: flex; flex-direction: column; gap: 14px; padding: 6px 2px; }
.sk-row { display: flex; align-items: center; gap: 18px; }
.sk-row .sk-line[data-lead] { height: 16px; }

/* --- refined toasts (glass + accent bar + spring entrance) --- */
.toasts { bottom: 24px; }
.toast {
  background: rgba(20,22,28,.9); backdrop-filter: blur(16px) saturate(180%); border: 1px solid var(--border-strong);
  border-radius: 12px; padding: 11px 15px 11px 16px; box-shadow: var(--shadow-lg); color: var(--text-strong);
  position: relative; overflow: hidden; animation: toastIn .34s var(--ease-spring);
}
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--evaa-gradient); }
.toast.ok { background: rgba(20,22,28,.9); color: var(--text-strong); }
.toast.ok::before { background: var(--green); }
.toast.ok svg { color: var(--green); }
.toast.err { background: rgba(20,22,28,.92); color: var(--text-strong); border-color: rgba(251,113,133,.4); }
.toast.err::before { background: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.96); } to { opacity: 1; transform: none; } }
:root[data-theme="light"] .toast { background: rgba(255,255,255,.92); color: var(--text-strong); }
:root[data-theme="light"] .toast.err { background: rgba(255,255,255,.95); }

@media (prefers-reduced-motion: reduce) {
  .cmdk-overlay, .cmdk-panel { transition: none; }
  .cmdk-overlay.in .cmdk-panel, .cmdk-panel { transform: none; }
  .content.route-anim { animation: none; }
  .nav-item:active { transform: none; }
  .sk::after { animation: none; }
  .toast { animation: none; }
}

/* ================================================================
   PHASE 3  ·  App-boot splash + scan-success flourish
   ================================================================ */
#splash {
  position: fixed; inset: 0; z-index: 500; display: grid; place-items: center;
  background: var(--bg); transition: opacity .5s var(--ease-out);
}
#splash.hide { opacity: 0; pointer-events: none; }
#splash .sp-in { display: flex; flex-direction: column; align-items: center; gap: 16px; }
#splash .sp-mark { position: relative; width: 96px; height: 96px; display: grid; place-items: center; animation: spFloat 5.5s ease-in-out infinite; }
#splash .sp-mark::before {
  content: ""; position: absolute; width: 184px; height: 184px; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, rgba(158,52,72,.45), rgba(56,189,248,.18) 45%, transparent 70%);
  filter: blur(24px); animation: spHalo 4.5s ease-in-out infinite;
}
#splash .sp-mark img { width: 88px; height: 88px; object-fit: contain; display: block;
  animation: spMarkIn 1s cubic-bezier(.2,.9,.25,1) both, spGlow 4.5s ease-in-out infinite 1s; }
#splash .sp-word { font-weight: 800; font-size: 25px; letter-spacing: -.02em;
  background: var(--evaa-gradient); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  opacity: 0; animation: spRise .6s var(--ease-out) .42s forwards; }
@keyframes spMarkIn { 0% { opacity: 0; transform: scale(.55) rotate(-8deg); } 60% { opacity: 1; } 100% { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes spFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes spHalo { 0%,100% { opacity: .55; transform: scale(1); } 50% { opacity: .9; transform: scale(1.12); } }
@keyframes spGlow {
  0%,100% { filter: drop-shadow(0 0 16px rgba(158,52,72,.55)) drop-shadow(0 0 34px rgba(208,104,124,.3)); }
  50%     { filter: drop-shadow(0 0 22px rgba(56,189,248,.5)) drop-shadow(0 0 48px rgba(232,180,189,.36)); }
}
@keyframes spRise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* scan-success flourish — a burgundy ring + checkmark bloom overlay */
.scan-success-burst { position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; z-index: 400; }
.scan-success-burst .ssb-ring {
  width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center;
  background: var(--evaa-gradient); color: #fff;
  box-shadow: 0 10px 40px rgba(158,52,72,.5); animation: ssbPop .5s cubic-bezier(.2,.9,.25,1) both;
}
.scan-success-burst .ssb-ring svg { width: 46px; height: 46px; stroke: #fff; stroke-width: 3; }
.scan-success-burst .ssb-halo { position: absolute; width: 92px; height: 92px; border-radius: 50%; border: 3px solid var(--primary); animation: ssbHalo .7s var(--ease-out) both; }
@keyframes ssbPop { 0% { opacity: 0; transform: scale(.4); } 60% { opacity: 1; transform: scale(1.08); } 100% { opacity: 1; transform: scale(1); } }
@keyframes ssbHalo { 0% { opacity: .8; transform: scale(1); } 100% { opacity: 0; transform: scale(2.1); } }

@media (prefers-reduced-motion: reduce) {
  #splash .sp-mark, #splash .sp-mark img, #splash .sp-mark::before { animation: none !important; }
  #splash .sp-mark img { filter: drop-shadow(0 0 18px rgba(158,52,72,.5)); }
  #splash .sp-word { opacity: 1 !important; animation: none !important; }
  .scan-success-burst .ssb-ring, .scan-success-burst .ssb-halo { animation: none !important; }
  .scan-success-burst .ssb-halo { display: none; }
}

/* ---------------- Contact / record profile (Phase 3) ---------------- */
.profile-hero { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 18px; }
.profile-hero::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 96px; background: linear-gradient(120deg, rgba(158,52,72,.14), rgba(208,104,124,.08) 55%, transparent); pointer-events: none; }
.ph-top { position: relative; display: flex; align-items: center; gap: 18px; }
.ph-avatar { width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 24px; flex: none; box-shadow: var(--shadow-md); }
.ph-id { min-width: 0; flex: 1; }
.ph-name { margin: 0 0 7px; font-size: 24px; font-weight: 750; letter-spacing: -.02em; color: var(--text-strong); }
.ph-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ph-sub { margin-top: 7px; color: var(--muted); font-size: 13.5px; }
.ph-quick { display: flex; gap: 8px; flex: none; align-self: flex-start; }
.ph-q { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--panel-2); border: 1px solid var(--border); color: var(--text); transition: transform var(--dur) var(--ease-spring), background var(--dur), border-color var(--dur), box-shadow var(--dur); }
.ph-q:hover { color: #fff; background: var(--evaa-gradient); border-color: transparent; transform: translateY(-2px); text-decoration: none; box-shadow: 0 6px 16px rgba(158,52,72,.32); }
/* HubSpot-style quick actions (Call / Email / Website / Note) under the name. */
.ph-quickrow { position: relative; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.ph-qbtn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); font-weight: 650; font-size: 13px; text-decoration: none; cursor: pointer; }
.ph-qbtn:hover { border-color: var(--primary); background: var(--panel-2); text-decoration: none; }
.ph-qbtn.accent { background: var(--accent-soft); border-color: rgba(158,52,72,.30); color: var(--primary); }
.ph-qbtn.accent:hover { background: rgba(158,52,72,.16); }
.ph-actions { position: relative; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.rec-h { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); }
/* Record detail: main column + right-side associations panel (spec pmt5_16Sept). */
.rec-grid { display: grid; grid-template-columns: minmax(0,1fr) 330px; gap: 16px; align-items: start; }
.rec-side { display: grid; gap: 14px; position: sticky; top: 72px; }
.rec-side-card .rec-side-h { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted-2); display: flex; align-items: center; gap: 7px; }
.assoc-row2 { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.assoc-row2:last-child { border-bottom: none; }
.assoc-row2 a { font-weight: 600; color: var(--text-strong); }
.assoc-row2 a:hover { color: var(--accent-2); }
@media (max-width: 900px) { .rec-grid { grid-template-columns: 1fr; } .rec-side { position: static; } }

/* activity / interaction timeline */
.tl { position: relative; }
.tl-item { position: relative; display: flex; gap: 14px; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ""; position: absolute; left: 11px; top: 26px; bottom: -2px; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { position: relative; z-index: 1; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; flex: none; box-shadow: 0 0 0 4px var(--panel); }
.tl-dot svg { width: 12px; height: 12px; }
.tl-body { flex: 1; min-width: 0; padding-top: 1px; }
.tl-head { display: flex; align-items: baseline; gap: 10px; }
.tl-title { font-weight: 650; font-size: 14px; color: var(--text-strong); }
.tl-when { margin-left: auto; font-size: 12px; color: var(--muted-2); font-family: var(--mono); white-space: nowrap; }
.tl-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.tl-note { margin-top: 8px; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; font-size: 13px; color: var(--text); white-space: pre-wrap; }
/* Timeline change entries — "Field: old → new" for each edit (spec pmt2_16Sept). */
.tl-changes { margin-top: 8px; display: grid; gap: 6px; }
.tl-change { font-size: 12.5px; color: var(--text); padding: 7px 10px; background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; }
.tl-change .tl-field { font-weight: 650; color: var(--muted); margin-right: 4px; }
.tl-change .tl-arrow { color: var(--muted-2); margin: 0 4px; }
@media (max-width: 900px) { .ph-quick { align-self: center; } .profile-hero { padding: 18px; } }
/* On phones the quick actions become big, near-half-width tap targets. */
@media (max-width: 767px) {
  .ph-top { align-items: flex-start; }
  .ph-qbtn { flex: 1 1 40%; justify-content: center; padding: 12px 12px; font-size: 14px; }
  .ph-actions { gap: 7px; }
  .ph-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* ================================================================
   PHASE 4  ·  Mobile polish — bottom nav, bottom sheets, touch, haptics
   ================================================================ */
.bottom-nav { display: none; }

@media (max-width: 900px) {
  /* bottom tab bar */
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    align-items: center; justify-content: space-around;
    height: 60px; padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(13,15,19,.86); backdrop-filter: saturate(180%) blur(18px);
    border-top: 1px solid var(--border);
  }
  :root[data-theme="light"] .bottom-nav { background: rgba(255,255,255,.86); }
  .bottom-nav { height: 62px; }
  .bn-item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--muted-2); font-size: 11px; font-weight: 600; cursor: pointer; background: none; border: none;
    height: 100%; -webkit-tap-highlight-color: transparent; user-select: none;
    transition: color var(--dur-fast);
  }
  .bn-item .bn-ic {
    display: grid; place-items: center; width: 46px; height: 30px; border-radius: 12px;
    transition: background var(--dur) var(--ease-out), transform var(--dur) var(--ease-spring);
  }
  .bn-item .bn-ic svg { width: 24px; height: 24px; }
  .bn-item:active .bn-ic { transform: scale(.9); }
  .bn-item.active { color: var(--accent); }
  .bn-item.active .bn-ic { background: var(--accent-soft); }
  .bn-item.active .bn-ic svg { filter: drop-shadow(0 0 5px var(--accent-glow)); }
  /* All five tabs are even (icon over label) — no raised centre button, matching a
     clean flat tab bar (spec: even it out, layout/UX only). */
  /* clear the bar so nothing hides behind it */
  .content { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .sidebar { z-index: 90; }

  /* bigger touch targets */
  .btn { min-height: 42px; }
  .btn.sm { min-height: 36px; }
  .btn-icon { width: 40px; height: 40px; }
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { font-size: 16px; } /* prevents iOS focus-zoom */
  .field input, .field select, .field textarea { min-height: 44px; }
  .nav-item { padding: 12px 12px; }
  .tab { padding: 12px 14px; }
}

/* bottom-sheet dialogs on phones */
@media (max-width: 680px) {
  .overlay { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { width: 100%; max-width: 100%; max-height: 92vh; border-radius: 20px 20px 0 0; animation: sheetUp .3s var(--ease-out); }
  .modal-head { position: relative; padding-top: 22px; }
  .modal-head::before, .drawer .modal-head::before {
    content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 38px; height: 4px; border-radius: 3px; background: var(--border-strong);
  }
  .modal-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  .drawer {
    top: auto; bottom: 0; left: 0; right: 0; width: 100%; max-width: 100%; height: auto; max-height: 92vh;
    border-left: none; border-top: 1px solid var(--border-strong); border-radius: 20px 20px 0 0;
    animation: drawerUp .3s var(--ease-out);
  }
  /* Distinct name: a plain translateY keyframe here previously ALSO redefined the
     create-sheet's `sheetUp` (keyframes are global even inside @media), dropping
     its translateX(-50%) centering — so the create sheet slid in from the side
     before snapping to the bottom (pmt4_22Sept). Renamed to keep them separate. */
  @keyframes drawerUp { from { transform: translateY(100%); } to { transform: none; } }
  /* command palette becomes a top sheet-ish full-width on tiny screens */
  .cmdk-overlay { padding: 8vh 10px 10px; }
  .cmdk-panel { max-height: 78vh; }
}

@media (prefers-reduced-motion: reduce) {
  .modal, .drawer { animation: none !important; }
  .bn-item:active { transform: none; }
}

/* ================================================================
   MOBILE RECORD CARDS  ·  the phone-facing object list (spec §8/§9)
   Below 768px the desktop table is replaced by compact record cards;
   both render off the same records, so the swap is pure CSS.
   ================================================================ */
.rec-cards { display: none; }
.rec-card {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 14px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-sm); text-decoration: none; color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--dur) var(--ease-out), transform var(--dur) var(--ease-spring);
}
.rec-card:active { transform: scale(.99); border-color: var(--border-strong); }
.rec-card .avatar {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
}
.rec-card .rc-body { flex: 1 1 auto; min-width: 0; }
.rec-card .rc-name {
  font-weight: 700; font-size: 15px; color: var(--text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rec-card .rc-line {
  font-size: 13px; color: var(--muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rec-card .rc-line .rc-k { color: var(--muted-2); font-weight: 600; }
.rec-card .rc-badge { flex: 0 0 auto; align-self: center; }

@media (max-width: 767px) {
  .table-wrap { display: none; }
  .rec-cards { display: flex; flex-direction: column; gap: 10px; }
  /* column editing & bulk-destructive testing tools don't apply to the card view */
  #btnColumns, #btnDeleteAll, #btnExport, #btnImport { display: none; }
}

/* ================================================================
   MOBILE APP-SHELL LOCK  ·  native-app feel (no page drag / overscroll)
   Scoped to html.is-app (the SPA only) so landing.html / login.html —
   which link this stylesheet but SHOULD scroll normally — are unaffected.
   Desktop (>900px) keeps normal body scroll; this is mobile-only.
   ================================================================ */
@media (max-width: 900px) {
  html.is-app, html.is-app body {
    height: 100%; overflow: hidden; overscroll-behavior: none;
    /* iOS: stop the whole document from being dragged/rubber-banded */
    position: relative;
  }
  html.is-app #app { position: fixed; inset: 0; height: 100vh; height: 100dvh; overflow: hidden; }
  html.is-app .layout { min-height: 0; height: 100vh; height: 100dvh; overflow: hidden; }
  html.is-app .main { min-height: 0; height: 100vh; height: 100dvh; overflow: hidden; }
  html.is-app .topbar { position: static; flex: 0 0 auto; }
  html.is-app .content {
    flex: 1 1 auto; min-height: 0;
    overflow-y: auto; overflow-x: hidden;
    overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  }
  html.is-app .sidebar { height: 100vh; height: 100dvh; }
}

/* =====================================================================
   Contacts (and every object) list — stacked field clusters + fixed
   viewport with a scroll-only record area (spec §22-26).
   ===================================================================== */
/* The index page is a flex column that fills the viewport: head / tabs /
   search / filters stay put, and ONLY the record list (.cluster-wrap) scrolls. */
/* flex:none is essential — the base .content rule is `flex:1`, which (flex-basis
   0%) would override this fixed height and let the whole page grow/scroll. Pinning
   flex:none makes the height authoritative so ONLY the records list scrolls. */
.content.idx-scroll { display: flex; flex-direction: column; flex: none; height: calc(100vh - var(--topbar-h)); padding-bottom: 0; overflow: hidden; }
.content.idx-scroll > .page-head,
.content.idx-scroll > .tabs,
.content.idx-scroll > .idx-tabsrow,
.content.idx-scroll > .idx-searchrow,
.content.idx-scroll > .idx-controls,
.content.idx-scroll > .toolbar,
.content.idx-scroll > .filter-row,
.content.idx-scroll > #idx-bulk,
.content.idx-scroll > #idx-pager { flex: none; }
/* Tabs row with the search on the same line (pmt1_21Sept §2) */
.idx-tabsrow { display: flex; align-items: flex-end; gap: 12px; }
.idx-tabsrow .tabs { flex: 1; min-width: 0; }
.idx-tabsrow .search-mini { position: relative; flex: none; padding-bottom: 4px; }
.idx-tabsrow .search-mini input { padding: 7px 36px 7px 14px; border: 1px solid var(--border-strong); border-radius: 8px; width: 260px; max-width: 42vw; background: var(--panel-3); color: var(--text); }
.idx-tabsrow .search-mini input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.idx-tabsrow .search-mini .si { position: absolute; right: 12px; left: auto; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; display: inline-flex; align-items: center; }
.idx-tabsrow .search-mini .si svg { display: block; width: 15px; height: 15px; }
.content.idx-scroll .cluster-wrap { flex: 1; min-height: 0; max-height: none; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel); box-shadow: none; }
.idx-head-row { margin-bottom: 8px; }
.idx-count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--panel-3); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; }
.sort-mini { display: flex; align-items: center; gap: 6px; }
.sort-mini select { padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel-3); color: var(--text); font-size: 12.5px; }

/* Search row (right-aligned, below + New) + controls row (filters left, sort
   right) — pmt2_19Sept §5-6. */
.idx-searchrow { display: flex; justify-content: flex-end; padding: 0 0 8px; }
.idx-searchrow .search-mini { position: relative; }
.idx-searchrow .search-mini input { padding: 7px 36px 7px 14px; border: 1px solid var(--border-strong); border-radius: 8px; width: 300px; max-width: 60vw; background: var(--panel-3); color: var(--text); }
.idx-searchrow .search-mini input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.idx-searchrow .search-mini .si { position: absolute; right: 12px; left: auto; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; display: inline-flex; align-items: center; }
.idx-searchrow .search-mini .si svg { display: block; width: 15px; height: 15px; }
.idx-controls { display: flex; align-items: center; gap: 12px; padding: 0 0 10px; }
.idx-controls .filter-row { flex: 1; min-width: 0; padding: 0; margin: 0; }

/* Single-header table; sub-field VALUES stack vertically in each field cell
   (pmt1_21Sept §5). Header shows only the field/column name. */
table.cluster-grid { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: auto; }
table.cluster-grid thead th.cl-th {
  position: sticky; top: 0; z-index: 5; background: var(--panel-2);
  text-align: left; padding: 9px 14px; font-size: 11px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.cluster-grid thead th.col-check { position: sticky; top: 0; z-index: 6; width: 34px; text-align: center; padding: 0; background: var(--panel-2); border-bottom: 1px solid var(--border); vertical-align: middle; }
table.cluster-grid td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 12.5px; }
table.cluster-grid td.col-check { width: 34px; text-align: center; padding-top: 12px; vertical-align: top; }
table.cluster-grid tbody tr:hover td { background: var(--row-hover, rgba(158,52,72,.05)); }
table.cluster-grid tbody tr.selected td { background: var(--accent-soft); }

/* Stacked value lines inside a field cell */
.cl-cell { max-width: 340px; }
.cl-cell .cl-line { line-height: 1.45; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
.cl-cell .cl-line + .cl-line { margin-top: 1px; }
.cl-cell .cl-name a { font-weight: 700; font-size: 13.5px; color: var(--text-strong); }
.cl-cell .cl-name a:hover { color: var(--accent-2); }
.cl-cell.cl-lead { min-width: 180px; }
.cl-cell .cl-co { color: var(--text); font-weight: 500; }
.cl-cell .cl-co:hover { color: var(--accent-2); }
.cl-cell .cl-dim { color: var(--muted); }
.cl-cell .cl-muted { color: var(--muted-2); }
.cl-cell .badge { margin: 1px 3px 1px 0; }

/* Bulk-action toolbar (sits ABOVE the table when 1+ selected) */
#idx-bulk.has-sel { margin: 0 0 8px; }
#idx-bulk .bulk-bar {
  position: static; width: auto; margin: 0; box-shadow: none;
  background: var(--accent-soft); border: 1px solid rgba(158,52,72,.30); color: var(--text);
  border-radius: 10px; padding: 8px 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
#idx-bulk .bulk-count { font-size: 13px; }
#idx-bulk .bulk-count b { color: var(--text-strong); }
#idx-bulk .bulk-sep { color: var(--muted-2); }
#idx-bulk .bulk-link { color: var(--accent-2); font-weight: 600; }
#idx-bulk .bulk-bar .btn { background: var(--panel-2); color: var(--text); border-color: var(--border-strong); }
#idx-bulk .bulk-bar .btn:hover { background: var(--panel-3); }
#idx-bulk .bulk-bar .btn.danger { color: var(--red); border-color: rgba(251,113,133,.35); background: rgba(251,113,133,.08); }
#idx-bulk .bulk-bar .btn.primary { background: var(--evaa-gradient); color: var(--primary-ink); border-color: transparent; }

/* =====================================================================
   Mobile bottom-nav — keep every icon fully inside the bar (spec §3).
   ===================================================================== */
@media (max-width: 900px) {
  .bottom-nav { overflow: hidden; align-items: stretch; }
  .bottom-nav .bn-item { height: 62px; justify-content: center; }
  .bottom-nav .bn-item .bn-ic { width: 40px; height: 28px; }
  .bottom-nav .bn-item span:not(.bn-ic) { line-height: 1; }
  /* the fixed index viewport must leave room for the bottom bar on mobile */
  .content.idx-scroll { height: calc(100vh - 62px - env(safe-area-inset-bottom, 0px)); }
  .cl-cell .cl-line { max-width: 60vw; }
}

/* On phones the cluster table is replaced by the stacked record cards already
   present (#idx-cards); hide the wide table, show the cards. The cluster-wrap is
   also a .table-wrap, so it must be kept visible against the global rule that
   hides .table-wrap on phones. */
@media (max-width: 767px) {
  .content.idx-scroll .cluster-wrap { display: flex; flex-direction: column; border: none; background: transparent; }
  .content.idx-scroll table.cluster-grid { display: none; }
  .content.idx-scroll #idx-cards { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
}
@media (min-width: 768px) { #idx-cards { display: none; } }

/* =====================================================================
   Settings Overlay  (pmt1_19Sept)
   Full-screen modal with left sidebar nav + content area.
   Close on: ✕ button, click outside the modal, Escape key.
   ===================================================================== */
.settings-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,.58); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  animation: settingsFadeIn var(--dur-fast) var(--ease-out);
}
@keyframes settingsFadeIn { from { opacity: 0; } to { opacity: 1; } }

.settings-modal {
  display: flex; width: min(1100px, 92vw); height: min(680px, 90vh); max-height: 90vh;
  background: var(--panel); border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  overflow: hidden; position: relative;
  animation: settingsSlideUp var(--dur) var(--ease-out);
}
@keyframes settingsSlideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Left sidebar */
.settings-side {
  width: 176px; flex: none;
  background: var(--bg-2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.settings-side-head {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.settings-title {
  font-size: 13px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.settings-nav { padding: 8px; overflow-y: auto; flex: 1; }
.s-nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--text); margin-bottom: 1px; user-select: none;
  border: 1px solid transparent;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.s-nav-item:hover { background: var(--panel-2); color: var(--text-strong); }
.s-nav-item.active {
  background: var(--accent-soft); color: var(--accent-2);
  border-color: rgba(158,52,72,.20);
}

/* Right content area — scrolls vertically only, never horizontally (§13). */
.settings-body {
  flex: 1; min-width: 0; overflow-y: auto; overflow-x: hidden; padding: 24px 28px;
}

/* Close button: fixed to the top-right corner of the modal, always visible while
   the body scrolls (pmt1_21Sept §1). The modal itself does not scroll — only
   .settings-body does — so an absolute button here never moves. */
.settings-close {
  position: absolute; top: 12px; right: 14px; z-index: 5;
  width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--panel-2); color: var(--text);
}
.settings-close:hover { color: var(--text-strong); background: var(--panel-3); border-color: var(--border-strong); }
:root[data-theme="light"] .settings-close { background: #fff; border-color: rgba(0,0,0,.15); color: #333; }

/* Panel header */
.settings-panel-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 18px;
}
.settings-panel-head h2 {
  margin: 0; font-size: 17px; font-weight: 700; color: var(--text-strong);
  flex: 1;
}

/* Section label + row */
.settings-section { margin-bottom: 20px; }
.settings-row {
  display: flex; align-items: flex-start; gap: 16px; padding: 14px 0;
  border-bottom: 1px solid var(--border-faint);
}
.settings-row:last-child { border-bottom: none; }
.settings-row-info { flex: 1; }
.settings-row-label { font-size: 13.5px; font-weight: 600; color: var(--text-strong); margin-bottom: 2px; }
.settings-row-sub { font-size: 12.5px; color: var(--muted); line-height: 1.4; }

/* Appearance — theme toggle buttons */
.settings-theme-btns { display: flex; gap: 8px; flex-shrink: 0; }
.theme-opt {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px;
  border-radius: 8px; border: 1px solid var(--border-strong);
  background: var(--panel-3); color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: all var(--dur-fast);
}
.theme-opt:hover { color: var(--text); border-color: var(--border-strong); background: var(--panel-2); }
.theme-opt.active {
  background: var(--accent-soft); border-color: rgba(158,52,72,.40);
  color: var(--accent-2);
}

/* Access panel — tab row */
.settings-access-tabs {
  display: flex; gap: 4px; margin-bottom: 18px;
  border-bottom: 1px solid var(--border); padding-bottom: 0;
}
.settings-access-tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  border: none; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600;
  cursor: pointer; border-bottom: 2px solid transparent; position: relative; top: 1px;
  transition: color var(--dur-fast), border-color var(--dur-fast);
}
.settings-access-tab:hover { color: var(--text); }
.settings-access-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Field Visibility panel */
.fv-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--border-faint);
}
.fv-row:last-child { border-bottom: none; }
.fv-label { font-size: 13px; font-weight: 600; color: var(--text); flex: 1; }
.fv-type { font-size: 11.5px; }
.fv-toggle { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }

/* Callout boxes in panels */
.callout { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-top: 8px; }
.callout.green { background: var(--green-soft); color: var(--green); border: 1px solid rgba(52,211,153,.25); }
.callout.red { background: rgba(251,113,133,.10); color: var(--red); border: 1px solid rgba(251,113,133,.25); }

/* Light theme overrides for settings overlay */
:root[data-theme="light"] .settings-modal { background: #fff; border-color: rgba(0,0,0,.12); }
:root[data-theme="light"] .settings-side { background: #F5F5F7; border-color: rgba(0,0,0,.10); }
:root[data-theme="light"] .s-nav-item { color: var(--text); }
:root[data-theme="light"] .s-nav-item:hover { background: rgba(0,0,0,.06); }
:root[data-theme="light"] .s-nav-item.active { background: rgba(158,52,72,.10); color: var(--primary); }
:root[data-theme="light"] .theme-opt { background: #fff; border-color: rgba(0,0,0,.15); color: #555; }
:root[data-theme="light"] .theme-opt.active { background: rgba(158,52,72,.12); color: var(--primary); }
:root[data-theme="light"] .settings-access-tab.active { color: var(--primary); }

/* Responsive: stack the settings modal on mobile */
@media (max-width: 680px) {
  .settings-modal { flex-direction: column; height: 96vh; width: 98vw; }
  .settings-side { width: 100%; height: auto; flex: none; }
  .settings-side-head { padding: 14px 14px 8px; }
  .settings-nav { display: flex; gap: 4px; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 8px; }
  .s-nav-item { white-space: nowrap; }
  .settings-body { padding: 16px; }
}

/* =====================================================================
   Settings sidebar — Data Model accordion (pmt2_19Sept §8)
   ===================================================================== */
.s-nav-parent { position: relative; }
.s-nav-caret { margin-left: auto; display: inline-flex; align-items: center; color: var(--muted-2); transition: transform var(--dur-fast); }
.s-nav-caret.open { transform: rotate(180deg); }
.s-nav-children { margin: 1px 0 4px; padding-left: 6px; border-left: 1px solid var(--border); margin-left: 14px; }
.s-nav-sub {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 7px;
  font-size: 12.5px; color: var(--muted); cursor: pointer; user-select: none;
}
.s-nav-sub:hover { background: var(--panel-2); color: var(--text); }
.s-nav-sub.active { background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
:root[data-theme="light"] .s-nav-sub:hover { background: rgba(0,0,0,.05); }
:root[data-theme="light"] .s-nav-sub.active { background: rgba(158,52,72,.10); color: var(--primary); }

/* =====================================================================
   Data Model — Field → Sub-field editor (pmt2/pmt3_19Sept)
   ===================================================================== */
/* Readable helper text (was too light — pmt3_19Sept). */
.dm-help { color: var(--text); opacity: .82; font-size: 12.5px; line-height: 1.5; margin: 0 0 14px; }
.settings-body .subtle { color: var(--text); opacity: .78; }

.dm-fields { display: flex; flex-direction: column; gap: 14px; }
.dm-field { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--panel); overflow: hidden; }
.dm-field-head {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: var(--panel-2); border-bottom: 1px solid var(--border);
}
.dm-field-name { font-weight: 700; font-size: 15px; color: var(--text-strong); }
.dm-field-count { font-size: 12px; color: var(--text); background: var(--panel-3); border: 1px solid var(--border-strong); border-radius: 999px; padding: 1px 9px; }
.dm-subs { display: flex; flex-direction: column; }
.dm-sub {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border-faint); flex-wrap: wrap;
}
.dm-sub:last-child { border-bottom: none; }
.dm-sub.editing { background: var(--accent-soft); }
.dm-sub-lbl { font-weight: 600; font-size: 13.5px; color: var(--text-strong); }
.dm-sub-empty { padding: 12px 14px; color: var(--text); opacity: .7; font-size: 12.5px; }
/* "Show as" / "Field" labelled selects on each sub-field. */
.dm-show { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.dm-tier, .dm-move { padding: 5px 9px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--panel-3); color: var(--text); font-size: 12px; text-transform: none; letter-spacing: 0; }
/* Bigger action buttons. Sub-field Edit/Delete are icon-only but large and
   clearly tappable (pmt1_21Sept §6). */
.dm-field-head .btn { font-size: 12.5px; }
.dm-iconbtn { width: 36px; height: 36px; padding: 0; border: 1px solid var(--border-strong); background: var(--panel-3); }
.dm-iconbtn:hover { background: var(--panel-2); border-color: var(--border-strong); }
.dm-sub .del-prop, .dm-field-head .dm-del-field { color: var(--red); }
.dm-sub .del-prop:hover, .dm-field-head .dm-del-field:hover { background: rgba(251,113,133,.12); }
/* Required marker: a red asterisk instead of a "required" badge (pmt1_21Sept §8). */
.dm-req { color: var(--red); font-weight: 800; margin-left: 3px; }
:root[data-theme="light"] .dm-iconbtn { background: #fff; border-color: rgba(0,0,0,.15); }

/* Inline sub-field editor tile (expands under the row) */
.dm-sub-edit { padding: 14px; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.dm-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dm-edit-f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--text); }
.dm-edit-f span { font-weight: 600; color: var(--muted); }
.dm-edit-f input, .dm-edit-f select, .dm-edit-f textarea { padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel-3); color: var(--text); font-size: 13px; }
.dm-edit-opts { margin-top: 10px; }
.dm-edit-opts textarea { min-height: 66px; resize: vertical; }
.dm-edit-checks { display: flex; gap: 18px; margin-top: 10px; font-size: 12.5px; color: var(--text); }
.dm-edit-checks label { display: inline-flex; align-items: center; gap: 6px; }
.dm-edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

/* Field Visibility — object picker + flat sections (pmt3_19Sept) */
.fv-objpick { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.fv-objpick select { padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--panel-3); color: var(--text); font-size: 13px; }
.fv-section { margin-bottom: 22px; }
.fv-h { margin: 0 0 6px; font-size: 14px; color: var(--text-strong); }
.fv-h .hint { font-weight: 400; }
.fv-matrix { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.fv-matrix th, .fv-matrix td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.fv-matrix thead th { color: var(--text); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.fv-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border-faint); }
.fv-row:last-child { border-bottom: none; }
.fv-label { font-size: 13px; font-weight: 600; color: var(--text-strong); }
.fv-grp { padding: 5px 9px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--panel-3); color: var(--text); font-size: 12px; }
.fv-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); }

/* Light-mode text contrast in Settings — the default muted greys read too faint
   on white (pmt1_21Sept §10). Darken helper text, labels and hints here. */
:root[data-theme="light"] .settings-body { color: #1c1e22; }
:root[data-theme="light"] .dm-help,
:root[data-theme="light"] .settings-body .subtle { color: #33363c; opacity: 1; }
:root[data-theme="light"] .settings-body .hint,
:root[data-theme="light"] .fv-h .hint { color: #4a4d54; }
:root[data-theme="light"] .dm-sub-lbl,
:root[data-theme="light"] .dm-field-name,
:root[data-theme="light"] .fv-label,
:root[data-theme="light"] .fv-h { color: #16181c; }
:root[data-theme="light"] .dm-show { color: #55585f; }
:root[data-theme="light"] .s-nav-item { color: #26282d; }
:root[data-theme="light"] .settings-title { color: #44474d; }
:root[data-theme="light"] .settings-body .tier-lbl,
:root[data-theme="light"] .settings-body .page-title { color: #16181c; }
:root[data-theme="light"] .settings-access-tab { color: #55585f; }
:root[data-theme="light"] .settings-access-tab.active { color: var(--primary); }

:root[data-theme="light"] .dm-field-head { background: #F5F5F7; }
:root[data-theme="light"] .dm-sub-edit { background: #F7F7F9; }
:root[data-theme="light"] .dm-tier, :root[data-theme="light"] .dm-move, :root[data-theme="light"] .fv-grp,
:root[data-theme="light"] .fv-objpick select, :root[data-theme="light"] .dm-edit-f input,
:root[data-theme="light"] .dm-edit-f select, :root[data-theme="light"] .dm-edit-f textarea { background: #fff; border-color: rgba(0,0,0,.15); }

/* On phones, drop the two-level table to the stacked cards already present. */
@media (max-width: 767px) {
  .idx-searchrow .search-mini input { width: 100%; max-width: none; }
  .dm-edit-grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   Live auto-detect scanner (iPhone Notes-style) — pmt2_21Sept
   ===================================================================== */
.scan-auto-btn{width:100%;justify-content:center;gap:10px;font-size:16px;font-weight:700;padding:16px 20px;border-radius:999px;margin:4px 0 2px;background:var(--evaa-gradient);color:#fff;border:none;box-shadow:0 6px 20px rgba(158,52,72,.34)}
.scan-auto-btn:hover{color:#fff;filter:brightness(1.05)}
.scan-or{display:flex;align-items:center;gap:10px;color:var(--muted-2);font-size:12px;margin:10px 0 8px;text-transform:uppercase;letter-spacing:.05em}
.scan-or::before,.scan-or::after{content:"";flex:1;height:1px;background:var(--border)}

.live-scan{position:fixed;inset:0;z-index:1300;background:#000;display:flex;flex-direction:column}
/* pmt6: stop iOS "Live Text" / text-selection from drawing its own boxes and the
   Copy·Look Up·Translate bubble over the camera. Kill selection + long-press
   callout across the scanner; the shutter/✓/✕ buttons stay clickable. */
.live-scan,.ls-stage,.ls-video,.ls-overlay{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
body.ls-open{overflow:hidden}
.ls-stage{position:relative;flex:1;min-height:0;overflow:hidden;background:#000;display:flex;align-items:center;justify-content:center}
/* pointer-events:none on the video so a long-press can't target it (Live Text
   triggers on a touch that lands on the video/image). Buttons sit above it. */
.ls-video{max-width:100%;max-height:100%;width:100%;height:100%;object-fit:contain;display:block;background:#000;pointer-events:none;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.ls-overlay{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.ls-hint{position:absolute;left:50%;top:calc(66px + env(safe-area-inset-top,0px));transform:translateX(-50%);background:rgba(0,0,0,.6);color:#fff;font-size:14px;font-weight:600;padding:8px 16px;border-radius:999px;white-space:nowrap;backdrop-filter:blur(6px);z-index:2}
.ls-hint.ok{background:rgba(158,52,72,.85)}
.ls-hint.warn{background:rgba(251,113,133,.85)}
.ls-flash{position:absolute;inset:0;background:#fff;opacity:0;pointer-events:none}
.ls-flash.go{animation:lsFlash .32s ease}
@keyframes lsFlash{0%{opacity:0}40%{opacity:.85}100%{opacity:0}}
.ls-bar{position:relative;display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:12px;padding:14px 18px calc(14px + env(safe-area-inset-bottom,0px));background:#0a0c10}
.ls-btn{background:transparent;border:none;color:#fff;font-size:15px;font-weight:600;cursor:pointer;padding:10px 6px}
.ls-btn.ls-done{color:#E8B4BD}
.ls-actions{display:flex;flex-direction:column;align-items:flex-end;gap:2px;justify-self:end}
.ls-shutter{width:72px;height:72px;border-radius:50%;border:5px solid #fff;background:transparent;cursor:pointer;display:grid;place-items:center;padding:0;justify-self:center}
.ls-shutter span{width:56px;height:56px;border-radius:50%;background:#fff;display:block;transition:transform .1s}
.ls-shutter:active span{transform:scale(.88)}
.ls-barspacer{width:56px;justify-self:end}
/* Apple-style top corners: ✕ (cancel, left) and ✓ (save & finish, right) */
.ls-corner{position:absolute;top:calc(12px + env(safe-area-inset-top,0px));width:44px;height:44px;border-radius:50%;border:none;display:grid;place-items:center;cursor:pointer;z-index:4;color:#fff;background:rgba(0,0,0,.5);backdrop-filter:blur(6px)}
.ls-corner.ls-x{left:16px}
.ls-corner.ls-tick{right:16px;background:#FACC15;color:#1a1a1a}
.ls-corner:active{transform:scale(.92)}
/* Capture "glimpse" that flies to the bottom-left thumbnail */
.ls-glimpse{position:absolute;left:50%;top:46%;width:64%;max-width:340px;border-radius:12px;box-shadow:0 12px 44px rgba(0,0,0,.6);opacity:0;pointer-events:none;display:none;transform:translate(-50%,-50%);z-index:3;
  transition:left .6s cubic-bezier(.4,0,.2,1),top .6s cubic-bezier(.4,0,.2,1),width .6s cubic-bezier(.4,0,.2,1),opacity .5s ease}
.ls-glimpse.show{opacity:1}
.ls-glimpse.fly{left:38px;top:calc(100% - 34px);width:52px;opacity:0}
/* Captured-card thumbnail (bottom-left, tappable → review gallery) */
.ls-thumbwrap{justify-self:start;width:56px;height:56px;border:none;background:transparent;padding:0;cursor:pointer;position:relative;border-radius:10px}
.ls-thumbwrap:empty,.ls-thumbwrap:not(.has){visibility:hidden}
.ls-thumbwrap img{width:56px;height:56px;object-fit:cover;border-radius:10px;border:2px solid #fff;box-shadow:0 2px 8px rgba(0,0,0,.5)}
.ls-thumb-badge{position:absolute;top:-6px;right:-6px;min-width:20px;height:20px;padding:0 5px;border-radius:999px;background:var(--primary,#9E3448);color:#fff;font-size:11px;font-weight:700;display:grid;place-items:center;box-shadow:0 1px 4px rgba(0,0,0,.5)}
/* Review gallery (hidden until the thumbnail is tapped — the [hidden] guard must
   beat the display:flex below, or the empty black panel covers the whole scanner) */
.ls-gallery{position:absolute;inset:0;z-index:2;background:#0a0c10;display:flex;flex-direction:column}
.ls-gallery[hidden]{display:none}
.ls-gal-head{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:calc(14px + env(safe-area-inset-top,0px)) 18px 12px;color:#fff;border-bottom:1px solid rgba(255,255,255,.12)}
.ls-gal-list{flex:1;min-height:0;overflow:auto;padding:14px 18px calc(18px + env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;gap:16px}
.ls-gal-item{display:flex;flex-direction:column;gap:8px;align-items:center}
.ls-gal-item img{max-width:100%;border-radius:10px;border:1px solid rgba(255,255,255,.18)}
.ls-gal-del{align-self:flex-end;background:rgba(251,113,133,.16);color:#FB7185;border:1px solid rgba(251,113,133,.4);border-radius:8px;padding:6px 14px;font-weight:600;cursor:pointer}

/* =====================================================================
   pmt1_22Sept — Access fixes + round New button
   ===================================================================== */
/* Round burgundy "+ New" button on object list headers (§1). Replaces the pill. */
.btn-add-round{width:40px;height:40px;border-radius:999px;display:inline-flex;align-items:center;justify-content:center;background:var(--evaa-gradient);color:#fff;border:none;cursor:pointer;box-shadow:0 6px 18px rgba(158,52,72,.34);padding:0;flex:none}
.btn-add-round:hover{color:#fff;filter:brightness(1.05);box-shadow:0 8px 22px rgba(208,104,124,.4)}
.btn-add-round:active{transform:translateY(1px)}
.btn-add-round svg{display:block}

/* Users table (Access ▸ Users) — plain table, no frozen/sticky columns, so the
   email column is never overlapped and shows in full (§3). */
.users-wrap{max-height:none}
.users-wrap table.grid th,.users-wrap table.grid td{white-space:nowrap}
.users-wrap table.grid td.u-name{display:flex;align-items:center;gap:8px}
.users-wrap table.grid td.u-email{color:var(--text)}

/* =====================================================================
   pmt3_22Sept — scanned card photo on the record page + Users role dropdown
   ===================================================================== */
/* Business-card photo container in the record side panel. */
.rec-cardphoto .rec-card-img{display:block;width:100%;height:auto;border-radius:10px;border:1px solid var(--border);background:var(--panel-3);object-fit:contain}
.rec-cardphoto a{display:block;line-height:0}
.rec-cardphoto a:hover .rec-card-img{border-color:var(--accent)}

/* Inline role picker in the Users table (Access ▸ Users). */
.users-wrap .u-role-sel{padding:5px 8px;border:1px solid var(--border-strong);border-radius:7px;background:var(--panel-3);color:var(--text);font-size:12.5px;font-weight:600;cursor:pointer;max-width:180px}
.users-wrap .u-role-sel:focus{border-color:var(--accent);box-shadow:0 0 0 3px var(--accent-soft);outline:none}

/* ==========================================================================
   Associations (rebuilt pmt1_25Sept) — Settings designer + record links panel
   Uses only existing tokens so it follows light/dark and the later restyle.
   ========================================================================== */
.ad-lead { margin: 0 0 14px; max-width: 640px; }
.ad-toolbar { display: flex; justify-content: flex-end; margin: 0 0 10px; }
.ad-canvas {
  position: relative; height: 380px; border-radius: var(--radius);
  background: var(--panel-3); border: 1px solid var(--border);
  overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
}
.ad-svg { position: absolute; inset: 0; pointer-events: none; }
.ad-line { fill: none; stroke: var(--border-strong); stroke-width: 2; }
.ad-live { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 6 6; }
.ad-node {
  position: absolute; transform: translate(-50%, -50%); z-index: 2;
  display: inline-flex; align-items: center; gap: 9px; padding: 9px 14px 9px 9px;
  border-radius: var(--radius-pill); background: var(--panel); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm); font-weight: 600; font-size: 14px; color: var(--text);
  transition: box-shadow var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out), border-color var(--dur) var(--ease-out);
  white-space: nowrap;
}
.ad-node.draggable { cursor: grab; }
.ad-node.dragging { cursor: grabbing; transform: translate(-50%, -50%) scale(1.04); box-shadow: var(--shadow-md); }
.ad-node.drop-target { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md); transform: translate(-50%, -50%) scale(1.06); }
.ad-node:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-soft); border-color: var(--accent); }
.ad-node-ic { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.ad-canvas.is-dragging .ad-node:not(.dragging):not(.drop-target) { opacity: .85; }
.ad-badges { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.ad-badge {
  position: absolute; transform: translate(-50%, -50%); pointer-events: auto; cursor: pointer;
  padding: 3px 9px; border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--panel); color: var(--text); font-family: inherit; font-weight: 600; font-size: 12px; line-height: 1.4; font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow-sm); transition: border-color var(--dur) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.ad-badge:hover { border-color: var(--accent); }
.ad-badge:active { transform: translate(-50%, -50%) scale(.96); }
.ad-hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); z-index: 4;
  padding: 6px 12px; border-radius: var(--radius-pill); background: var(--panel); border: 1px solid var(--border);
  font-size: 12.5px; color: var(--muted); box-shadow: var(--shadow-sm); pointer-events: none; white-space: nowrap;
}
.ad-list-h { margin: 22px 0 8px; font-size: 12px; font-weight: 600; color: var(--muted-2); }
.ad-list { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel); }
.ad-list:empty { display: none; }
.ad-empty { padding: 16px; color: var(--muted); font-size: 13.5px; }
.ad-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 14px; background: transparent; border: 0; color: var(--text); cursor: pointer; font: inherit;
  transition: background var(--dur-fast) var(--ease-out);
}
.ad-row + .ad-row { border-top: 1px solid var(--border); }
.ad-row:hover { background: var(--panel-2); }
.ad-row-dots { display: inline-flex; flex: none; }
.ad-row-dots i { width: 10px; height: 10px; border-radius: 50%; display: block; border: 2px solid var(--panel); }
.ad-row-dots i + i { margin-left: -4px; }
.ad-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ad-row-t { font-weight: 600; font-size: 14px; }
.ad-row-s { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-arrow { color: var(--muted-2); margin: 0 2px; }
.ad-chev { color: var(--muted-2); flex: none; }
.ad-legacy { margin-top: 22px; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel); }
.ad-legacy-t { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.ad-legacy .hint { margin: 0 0 10px; }
.ad-legacy-b { display: flex; gap: 8px; flex-wrap: wrap; }
/* create / edit sheet */
.ad-sheet .field { margin-bottom: 14px; }
.ad-pair { display: flex; align-items: flex-end; gap: 10px; }
.ad-pair .field { flex: 1; min-width: 0; }
.ad-pair-arrow { color: var(--muted-2); padding-bottom: 22px; }
.ad-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 3px; border-radius: var(--radius-sm); background: var(--panel-3); border: 1px solid var(--border); }
.ad-seg button {
  border: 0; border-radius: 9px; background: transparent; color: var(--text); cursor: pointer;
  padding: 8px 4px; font-family: inherit; font-weight: 600; font-size: 14px; line-height: 1.2; display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: background var(--dur) var(--ease-out);
}
.ad-seg button small { font-weight: 500; font-size: 11px; color: var(--muted); }
.ad-seg button[aria-checked="true"] { background: var(--panel); box-shadow: var(--shadow-sm); color: var(--accent-2); }
.ad-explain { margin-top: 10px; font-size: 13px; color: var(--muted); line-height: 1.5; }
.ad-labels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ad-sheet-note { margin: 0; }
.modal-foot .ad-del { margin-right: auto; }
@media (max-width: 640px) {
  .ad-canvas { height: 320px; }
  .ad-node { padding: 7px 11px 7px 7px; font-size: 13px; }
  .ad-node-ic { width: 24px; height: 24px; }
  .ad-labels { grid-template-columns: 1fr; }
  .ad-seg { grid-template-columns: repeat(2, 1fr); }
}
/* record page links panel */
.rl-card .rec-side-h .rl-add { margin-left: auto; text-transform: none; letter-spacing: 0; }
.rl-row { position: relative; }
.rl-rm {
  margin-left: auto; border: 0; background: transparent; color: var(--muted-2); cursor: pointer;
  width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.rl-rm:hover { background: var(--panel-2); color: var(--red); }
.rl-none { padding: 2px 0; }
.rl-picker .rl-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: var(--radius-sm); background: var(--panel-3); border: 1px solid var(--border-strong); color: var(--muted); }
.rl-picker .rl-search input { flex: 1; border: 0; background: transparent; color: var(--text); padding: 11px 0; font: inherit; outline: none; box-shadow: none; }
.rl-results { margin-top: 10px; max-height: 50vh; overflow: auto; display: flex; flex-direction: column; }
.rl-res {
  display: flex; align-items: center; gap: 10px; padding: 9px 8px; border: 0; border-radius: 10px; background: transparent;
  color: var(--text); font: inherit; text-align: left; cursor: pointer; min-height: 44px;
}
.rl-res:hover:not([disabled]) { background: var(--panel-2); }
.rl-res[disabled] { cursor: default; opacity: .6; }
.rl-res-n { flex: 1; font-weight: 600; font-size: 14px; }
@media (prefers-reduced-motion: reduce) {
  .ad-node, .ad-badge, .ad-row, .ad-seg button, .rl-rm { transition: none; }
}
.ad-end {
  position: absolute; transform: translate(-50%, -50%); pointer-events: none;
  padding: 1px 6px; border-radius: var(--radius-pill); background: var(--panel-3);
  font-size: 11px; font-weight: 600; color: var(--muted); line-height: 1.5;
}
/* Association sheet — link records by a matching column (pmt3_25Sept) */
.ad-match.off .ad-match-row { display: none; }
.ad-opt { margin-left: 6px; font-size: 12px; font-weight: 500; color: var(--muted-2); }
.ad-match-row { display: flex; align-items: flex-end; gap: 10px; }
.ad-match-cell { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.ad-match-cell select { width: 100%; }
.ad-match-obj { font-size: 12px; font-weight: 600; color: var(--muted); }
.ad-match-eq { padding-bottom: 9px; font-weight: 600; color: var(--muted-2); }
.ad-match-prev { margin-top: 8px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); }
.ad-match-prev .hint { margin-top: 4px; }
@media (max-width: 640px) { .ad-match-row { flex-direction: column; align-items: stretch; } .ad-match-eq { display: none; } }

/* ---- pmt1 25 Sept: multi-column matching, details to copy, detail reviews ---- */
.ad-match-row + .ad-match-row { margin-top: 8px; }
.ad-match-rm { flex: none; margin-bottom: 4px; }
.ad-match-side { display: flex; align-items: center; gap: 10px; margin: 2px 0 10px; }
.ad-match-side-l { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.ad-seg.ad-seg-sm { grid-template-columns: repeat(2, minmax(0, 1fr)); flex: 1; max-width: 360px; }
.ad-seg.ad-seg-sm button { padding: 6px 8px; font-size: 13px; }
.ad-match-more { margin-top: 8px; }
.ad-copy { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.ad-copy-l { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
/* pmt1 28 Sept: primary link fields + transfer fields */
.ad-sec-l { display: block; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.ad-copy .ad-copy-l { margin-bottom: 2px; }
.ad-sec-sub { font-size: 12.5px; line-height: 1.45; color: var(--muted); margin: 0 0 10px; }
.ad-sec-sub:empty { display: none; }
.ad-seg.ad-seg-sm button { white-space: normal; line-height: 1.25; }
@media (max-width: 640px) {
  .ad-match-side { flex-direction: column; align-items: stretch; gap: 6px; }
  .ad-seg.ad-seg-sm { max-width: none; }
}
.ad-review-box { margin-top: 22px; padding: 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--panel); }
.ad-review-h { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.ad-review-h .ico { color: var(--amber, #d97706); }
.ad-review-n { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--panel-3); color: var(--muted); }
.ad-review-box > .hint { margin: 6px 0 10px; }
.ad-review-bulk { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.rv-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.rv-card .rv-row:first-of-type { border-top: 0; }
.rv-main { flex: 1; min-width: 0; font-size: 13px; line-height: 1.45; }
.rv-t, .rv-s { overflow-wrap: anywhere; }
.rv-acts { display: flex; gap: 6px; flex: none; flex-wrap: wrap; justify-content: flex-end; max-width: 50%; }
.rv-acts .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-card .rec-side-h .ico { color: var(--amber, #d97706); }
.rv-card .rv-row { flex-direction: column; align-items: stretch; }
.rv-card .rv-acts { max-width: none; justify-content: flex-start; }
.rv-ask-item { padding: 10px 0; border-top: 1px solid var(--border); }
.rv-ask-item:first-of-type { border-top: 0; }
.rv-opt { display: flex; align-items: baseline; gap: 8px; margin-top: 6px; font-size: 14px; cursor: pointer; overflow-wrap: anywhere; }
.rv-opt input { flex: none; }
@media (max-width: 640px) { .rv-row { flex-direction: column; align-items: stretch; } .rv-acts { max-width: none; justify-content: flex-start; } }

/* ---- Scan card start screen + "why is this card empty" (pmt3_28Sept) ---- */
.scan-home{display:flex;flex-direction:column;align-items:center;text-align:center;gap:12px;padding:10px 4px 4px}
.scan-hero-ico{width:64px;height:64px;border-radius:20px;display:grid;place-items:center;color:#fff;background:var(--primary);box-shadow:0 8px 24px rgba(158,52,72,.28)}
.scan-hero-ico.warn{background:var(--amber);box-shadow:none}
.scan-home-title{margin:4px 0 0;font-size:20px;font-weight:700;letter-spacing:-.01em}
.scan-home-sub{margin:0;max-width:420px;color:var(--muted);font-size:14.5px;line-height:1.5}
.scan-home .scan-auto-btn{max-width:420px;margin-top:6px}
.scan-choose-btn{width:100%;max-width:420px;justify-content:center;gap:8px;padding:13px 18px;border-radius:999px;font-weight:600;cursor:pointer}
.scan-home-foot{margin:4px 0 0;color:var(--muted-2);font-size:12.5px;max-width:420px}
/* ---- Scan multiple cards (10 Nov 2026): one photo, many cards ---- */
.scan-multi-btn{width:100%;max-width:420px;justify-content:center;gap:9px;padding:14px 18px;border-radius:999px;font-weight:600;font-size:15px;cursor:pointer;border:1.5px solid var(--accent);color:var(--text)}
.scan-multi-btn:hover{background:var(--accent-soft)}
.scan-multi-hint{margin:-4px 0 2px;color:var(--muted);font-size:12.5px;line-height:1.45;max-width:380px}
.scan-multi{display:flex;flex-direction:column;align-items:center;text-align:center;gap:10px;padding:8px 0}
.scan-multi-photo{position:relative;display:inline-block;max-width:100%;line-height:0;border-radius:12px;overflow:hidden;box-shadow:0 2px 14px rgba(0,0,0,.18)}
.scan-multi-photo img{display:block;max-width:100%;max-height:min(52vh,460px);width:auto;height:auto}
.scan-multi-photo svg{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.scan-multi-photo .mk{fill:rgba(158,52,72,.12);stroke:var(--accent);stroke-width:2.5;stroke-linejoin:round}
.scan-multi-photo .mk.busy{fill:rgba(255,255,255,.18);stroke:#fff;stroke-dasharray:6 5;animation:mkDash 1s linear infinite}
.scan-multi-photo .mk.done{fill:rgba(48,209,88,.16);stroke:#30D158}
@keyframes mkDash{to{stroke-dashoffset:-22}}
.scan-multi-photo .mk-num{position:absolute;transform:translate(-50%,-50%);min-width:26px;height:26px;padding:0 7px;border-radius:999px;display:grid;place-items:center;font:600 13px/1 var(--font, inherit);color:#fff;background:var(--accent);box-shadow:0 2px 8px rgba(0,0,0,.35)}
.scan-multi-photo .mk-num.done{background:#248A3D}
.scan-multi-photo .mk-num.busy{background:#fff;color:#1D1D1F}
.scan-multi-stat{font-size:14.5px;font-weight:500;margin-top:4px}
@media (prefers-reduced-motion: reduce){.scan-multi-photo .mk.busy{animation:none}}
.scan-home-actions{display:flex;gap:10px;flex-wrap:wrap;justify-content:center;margin-top:4px}
.scan-home .scan-thumbs,.scan-reading .scan-thumbs{justify-content:center}
.scan-home .scan-thumbs img,.scan-reading .scan-thumbs img{height:120px;max-width:100%}
.scan-reading{text-align:center;padding:10px 0}
.scan-reason{display:flex;align-items:flex-start;gap:10px;width:100%;text-align:left;padding:12px 14px;border-radius:12px;font-size:13.5px;line-height:1.45;margin-bottom:10px}
.scan-reason.err{background:rgba(229,72,77,.09);border:1px solid rgba(229,72,77,.32)}
.scan-reason.warn{background:rgba(240,180,41,.11);border:1px solid rgba(240,180,41,.38)}
.scan-reason-ico{flex:none;margin-top:1px}
.scan-reason.err .scan-reason-ico{color:var(--red)}
.scan-reason.warn .scan-reason-ico{color:var(--amber)}
.scan-reason-txt{flex:1;min-width:0}
.scan-reason-btn{flex:none;align-self:center}
.scan-row-reason{font-size:12px;line-height:1.35;margin-top:3px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.scan-row-reason.err{color:var(--red)}
.scan-row-reason.warn{color:var(--amber)}
.scan-row-btns{display:flex;flex-direction:column;gap:6px;flex:none}
.scan-row,.scan-foot{flex-wrap:wrap}
@media (max-width:640px){
  .scan-row{row-gap:8px}
  .scan-row-btns{flex-basis:100%;flex-direction:row;justify-content:flex-end}
  .scan-row-btns .btn{flex:1;justify-content:center}
  .scan-foot .btn.primary{flex:1;justify-content:center}
}
@media (max-width:640px){
  .scan-reason{flex-wrap:wrap}
  .scan-reason-txt{flex:1 1 calc(100% - 40px)}
  .scan-reason-btn{margin-left:auto}
}

/* pmt1 29 Sept — Contacts search box: compact and aligned with the Sort control below it */
@media (min-width: 901px) {
  .idx-tabsrow .search-mini input { width: 190px; }
  .idx-controls .sort-mini { min-width: 190px; justify-content: flex-end; }
  .idx-controls .sort-mini select { flex: 1 1 auto; min-width: 0; }
}
/* view tab caret → Rename / Delete */
.tab .tab-menu { display: inline-flex; align-items: center; margin-left: 4px; opacity: .6; border-radius: 5px; }
.tab .tab-menu:hover { opacity: 1; background: var(--fill, rgba(0,0,0,.06)); }
.tab .tab-menu svg { display: block; }

/* pmt1 29 Sept — Network Map zoom controls (bottom-right of the map) */
.graph-wrap { position: relative; }
.graph-zoom { position: absolute; right: 14px; bottom: 14px; z-index: 6; display: flex; flex-direction: column; gap: 6px; }
.graph-zoom button { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border-strong); background: var(--panel); color: var(--text); border-radius: 10px; cursor: pointer; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.12)); }
.graph-zoom button:hover { background: var(--panel-2); color: var(--text-strong); }
.graph-zoom button:active { transform: scale(.94); }
