/* ==========================================================================
   AMERELLER CRM — design system & components
   Native CSS, no framework. Light + dark themes via custom properties.
   ========================================================================== */

@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/barlow-latin-400-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/barlow-latin-500-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/barlow-latin-600-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/barlow-latin-700-normal.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/barlow-latin-ext-400-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/barlow-latin-ext-500-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/barlow-latin-ext-600-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Barlow"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/barlow-latin-ext-700-normal.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

/* ---------------------------------------------------------------- tokens */
:root {
  color-scheme: light;
  --navy: #1f2a4d;
  --navy-2: #2b3a6b;
  --navy-3: #16203d;
  --orange: #eb6f0a;
  --orange-2: #f08a2e;
  --teal: #0e9aa7;
  --teal-2: #0b7f8a;

  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #eef0f5;
  --surface-hover: #f2f5fa;
  --surface-active: #e8f4f5;
  --border: #e3e6ee;
  --border-strong: #cfd4df;
  --grid-line: #eceef3;
  --text: #1f2433;
  --text-2: #464d61;
  --text-3: #6b7285;
  --text-inv: #ffffff;
  --link: #1a5dd6;
  --focus: #0e9aa7;
  --scrim: rgba(15, 20, 36, .42);
  --danger: #c62828;
  --danger-bg: #fdecea;
  --success: #2e7d32;
  --success-bg: #e7f5ea;
  --warn: #9a5b00;
  --warn-bg: #fff3dd;

  --shadow-xs: 0 1px 2px rgba(20, 28, 55, .06);
  --shadow-sm: 0 1px 3px rgba(20, 28, 55, .08), 0 1px 2px rgba(20, 28, 55, .04);
  --shadow-md: 0 6px 18px rgba(20, 28, 55, .10), 0 2px 6px rgba(20, 28, 55, .06);
  --shadow-lg: 0 18px 48px rgba(20, 28, 55, .18), 0 4px 12px rgba(20, 28, 55, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;

  /* Categorical chart palette (validated for CVD / contrast, light surface) */
  --c-blue: #3b4fa8; --c-orange: #eb6f0a; --c-teal: #0e9aa7; --c-gold: #e3a400;
  --c-magenta: #d6538a; --c-green: #2e8b3e; --c-violet: #8b5cc4; --c-red: #d9443f;
  --c-grey: #9aa1ae; --c-navy: #1f2a4d;
  --chart-grid: #e9ecf2; --chart-axis: #c8cdd8;

  /* Dropdown option pill tints */
  --o-blue: #e5e9f6; --o-orange: #fde9d8; --o-teal: #dcf1f3; --o-gold: #fbf0cc; --o-magenta: #f9e1eb;
  --o-green: #e0f0e3; --o-violet: #ece4f7; --o-red: #f9e0df; --o-grey: #edeff3; --o-navy: #dfe3ee;

  /* Row / cell highlights (mirror the Excel fills) */
  --h-blue: #e4eaf8; --h-green: #e4f2df; --h-yellow: #fff5cf; --h-red: #fbe4e2;
  --h-teal: #dcf0f2; --h-purple: #eee6f8; --h-orange: #fdecdd; --h-grey: #eef0f3;

  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --row-h: 38px;
  --header-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --navy: #1b2446; --navy-2: #2a3766; --navy-3: #0d1226;
    --bg: #0e1222; --surface: #151a2e; --surface-2: #1a2038; --surface-3: #222a47; --surface-hover: #1e2541; --surface-active: #17343d;
    --border: #283052; --border-strong: #3a4468; --grid-line: #232a47;
    --text: #e7eaf3; --text-2: #bdc3d6; --text-3: #8b92aa; --link: #86aaff; --focus: #2cc3cf; --scrim: rgba(0, 0, 0, .6);
    --danger: #ff8a80; --danger-bg: #3a1c1f; --success: #7fd08a; --success-bg: #173222; --warn: #ffc56b; --warn-bg: #3a2c12;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4); --shadow-md: 0 8px 22px rgba(0, 0, 0, .45); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
    --c-blue: #6076de; --c-orange: #d2690f; --c-teal: #0f969f; --c-gold: #c98500; --c-magenta: #d55181; --c-green: #1f8a2e; --c-violet: #9085e9; --c-red: #e66767; --c-grey: #6b7285; --c-navy: #8a97c9;
    --chart-grid: #252c4a; --chart-axis: #3a4468;
    --o-blue: rgba(96, 118, 222, .24); --o-orange: rgba(210, 105, 15, .26); --o-teal: rgba(15, 150, 159, .26); --o-gold: rgba(201, 133, 0, .26); --o-magenta: rgba(213, 81, 129, .26);
    --o-green: rgba(31, 138, 46, .28); --o-violet: rgba(144, 133, 233, .26); --o-red: rgba(230, 103, 103, .26); --o-grey: rgba(139, 146, 170, .2); --o-navy: rgba(138, 151, 201, .22);
    --h-blue: rgba(96, 118, 222, .16); --h-green: rgba(46, 160, 67, .15); --h-yellow: rgba(227, 164, 0, .15); --h-red: rgba(230, 103, 103, .15);
    --h-teal: rgba(15, 150, 159, .17); --h-purple: rgba(144, 133, 233, .16); --h-orange: rgba(235, 111, 10, .15); --h-grey: rgba(139, 146, 170, .12);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --navy: #1b2446; --navy-2: #2a3766; --navy-3: #0d1226;
  --bg: #0e1222; --surface: #151a2e; --surface-2: #1a2038; --surface-3: #222a47; --surface-hover: #1e2541; --surface-active: #17343d;
  --border: #283052; --border-strong: #3a4468; --grid-line: #232a47;
  --text: #e7eaf3; --text-2: #bdc3d6; --text-3: #8b92aa; --link: #86aaff; --focus: #2cc3cf; --scrim: rgba(0, 0, 0, .6);
  --danger: #ff8a80; --danger-bg: #3a1c1f; --success: #7fd08a; --success-bg: #173222; --warn: #ffc56b; --warn-bg: #3a2c12;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4); --shadow-md: 0 8px 22px rgba(0, 0, 0, .45); --shadow-lg: 0 20px 50px rgba(0, 0, 0, .6);
  --c-blue: #6076de; --c-orange: #d2690f; --c-teal: #0f969f; --c-gold: #c98500; --c-magenta: #d55181; --c-green: #1f8a2e; --c-violet: #9085e9; --c-red: #e66767; --c-grey: #6b7285; --c-navy: #8a97c9;
  --chart-grid: #252c4a; --chart-axis: #3a4468;
  --o-blue: rgba(96, 118, 222, .24); --o-orange: rgba(210, 105, 15, .26); --o-teal: rgba(15, 150, 159, .26); --o-gold: rgba(201, 133, 0, .26); --o-magenta: rgba(213, 81, 129, .26);
  --o-green: rgba(31, 138, 46, .28); --o-violet: rgba(144, 133, 233, .26); --o-red: rgba(230, 103, 103, .26); --o-grey: rgba(139, 146, 170, .2); --o-navy: rgba(138, 151, 201, .22);
  --h-blue: rgba(96, 118, 222, .16); --h-green: rgba(46, 160, 67, .15); --h-yellow: rgba(227, 164, 0, .15); --h-red: rgba(230, 103, 103, .15);
  --h-teal: rgba(15, 150, 159, .17); --h-purple: rgba(144, 133, 233, .16); --h-orange: rgba(235, 111, 10, .15); --h-grey: rgba(139, 146, 170, .12);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14.5px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "kern" 1;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(14, 154, 167, .25); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 1000; background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow-md); }
.skip-link:focus { top: 10px; }
.tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.sm { width: 15px; height: 15px; }
svg.icon.lg { width: 22px; height: 22px; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer;
  white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .08s;
  user-select: none; text-decoration: none;
}
.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.primary:hover { background: var(--navy-2); border-color: var(--navy-2); }
:root[data-theme="dark"] .btn.primary { background: var(--teal); border-color: var(--teal); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { background: var(--teal); border-color: var(--teal); } }
.btn.accent { background: var(--orange); border-color: var(--orange); color: #fff; }
.btn.accent:hover { background: #d86408; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; gap: 5px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12.5px; gap: 4px; border-radius: 6px; }
.btn.icon-only { width: 36px; padding: 0; }
.btn.sm.icon-only { width: 30px; }
.btn.xs.icon-only { width: 26px; }
.btn.is-active { background: var(--surface-active); border-color: var(--teal); color: var(--teal-2); }
:root[data-theme="dark"] .btn.is-active { color: var(--focus); }
.btn .badge { margin-left: 2px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge.accent { background: var(--orange); color: #fff; }
.badge.teal { background: var(--teal); color: #fff; }

/* ---------------------------------------------------------------- inputs */
.input, .select, .textarea {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.45; }
.select { padding-right: 32px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7285' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; cursor: pointer; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(14, 154, 167, .18); }
.input.sm, .select.sm { height: 30px; font-size: 13.5px; }
.input.invalid, .select.invalid, .textarea.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(198, 40, 40, .12); }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon > .input { padding-left: 34px; }
.input-icon > .clear-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.field > label, .field-label { font-weight: 600; font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.field .hint { font-size: 12.5px; color: var(--text-3); }
.field .error-text { font-size: 12.5px; color: var(--danger); font-weight: 600; }
.req { color: var(--danger); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.check input { width: 17px; height: 17px; accent-color: var(--teal); cursor: pointer; margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked + .track { background: var(--teal); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ----------------------------------------------------------------- pills */
.pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; height: 22px; padding: 0 9px 0 7px;
  border-radius: 999px; background: var(--o-grey); color: var(--text); font-size: 12.5px; font-weight: 600; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.pill > .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--c-grey); }
.pill > .txt { overflow: hidden; text-overflow: ellipsis; }
.pill.lg { height: 26px; font-size: 13px; padding: 0 11px 0 9px; }
.pill.muted { color: var(--text-3); }
.pill-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.o-blue { background: var(--o-blue); } .o-blue > .dot, .dot.o-blue, .sw-blue { background: var(--c-blue); }
.o-orange { background: var(--o-orange); } .o-orange > .dot, .dot.o-orange, .sw-orange { background: var(--c-orange); }
.o-teal { background: var(--o-teal); } .o-teal > .dot, .dot.o-teal, .sw-teal { background: var(--c-teal); }
.o-gold { background: var(--o-gold); } .o-gold > .dot, .dot.o-gold, .sw-gold { background: var(--c-gold); }
.o-magenta { background: var(--o-magenta); } .o-magenta > .dot, .dot.o-magenta, .sw-magenta { background: var(--c-magenta); }
.o-green { background: var(--o-green); } .o-green > .dot, .dot.o-green, .sw-green { background: var(--c-green); }
.o-violet { background: var(--o-violet); } .o-violet > .dot, .dot.o-violet, .sw-violet { background: var(--c-violet); }
.o-red { background: var(--o-red); } .o-red > .dot, .dot.o-red, .sw-red { background: var(--c-red); }
.o-grey { background: var(--o-grey); } .o-grey > .dot, .dot.o-grey, .sw-grey { background: var(--c-grey); }
.o-navy { background: var(--o-navy); } .o-navy > .dot, .dot.o-navy, .sw-navy { background: var(--c-navy); }
.hl-blue { --hl: var(--h-blue); } .hl-green { --hl: var(--h-green); } .hl-yellow { --hl: var(--h-yellow); } .hl-red { --hl: var(--h-red); }
.hl-teal { --hl: var(--h-teal); } .hl-purple { --hl: var(--h-purple); } .hl-orange { --hl: var(--h-orange); } .hl-grey { --hl: var(--h-grey); }
.swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; flex: none; padding: 0; }
.swatch.hl { background: var(--hl); border-radius: 5px; }
.swatch[aria-pressed="true"], .swatch.is-selected { box-shadow: 0 0 0 2px var(--teal); }
.swatch.none { background: linear-gradient(135deg, transparent 45%, var(--danger) 45%, var(--danger) 55%, transparent 55%), var(--surface); }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }

/* --------------------------------------------------------------- app shell */
.app-header {
  position: relative; z-index: 20; color: #fff;
  background: linear-gradient(100deg, var(--navy-3) 0%, var(--navy) 55%, var(--navy-2) 100%);
  border-top: 4px solid var(--orange);
}
.app-header-inner { display: flex; align-items: center; gap: 16px; min-height: var(--header-h); padding: 10px clamp(12px, 2.4vw, 28px); }
.brand { display: flex; flex-direction: column; min-width: 0; color: #fff; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-word { font-size: 22px; font-weight: 700; letter-spacing: .2em; line-height: 1.05; white-space: nowrap; }
.brand-word .slash { color: var(--orange); margin-right: 1px; font-style: italic; }
.brand-tag { font-size: 11.5px; opacity: .72; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.header-btn { text-decoration: none !important; height: 36px; min-width: 36px; padding: 0 10px; display: inline-flex; align-items: center; gap: 8px; border-radius: 9px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: #fff; cursor: pointer; font-weight: 600; font-size: 13.5px; }
.header-btn:hover { background: rgba(255,255,255,.14); }
.header-btn kbd { font: 600 11px var(--font); padding: 1px 6px; border-radius: 5px; background: rgba(255,255,255,.14); color: rgba(255,255,255,.85); }
.search-trigger { min-width: 220px; justify-content: flex-start; color: rgba(255,255,255,.8); }
.search-trigger .grow { text-align: left; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: rgba(255,255,255,.85); padding: 0 6px; }
.live .pulse { width: 9px; height: 9px; border-radius: 50%; background: #3ddc84; position: relative; }
.live .pulse::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid #3ddc84; opacity: 0; animation: pulse 2.4s infinite; }
.live.is-stale .pulse { background: #ffb74d; } .live.is-stale .pulse::after { border-color: #ffb74d; }
.live.is-off .pulse { background: #ef5350; } .live.is-off .pulse::after { animation: none; }
@keyframes pulse { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.6); opacity: 0; } }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--orange); color: #fff; font-weight: 700; font-size: 12.5px; display: inline-flex; align-items: center; justify-content: center; flex: none; letter-spacing: .02em; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }

.tabbar { position: sticky; top: 0; z-index: 15; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-xs); }
.tabbar-inner { display: flex; align-items: stretch; gap: 2px; padding: 0 clamp(8px, 2vw, 24px); overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; }
.tabbar-inner::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 7px; height: 48px; padding: 0 11px; border: 0; background: none;
  color: var(--text-2); font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap; border-radius: 0; text-decoration: none;
}
.tab:hover { color: var(--text); background: var(--surface-hover); text-decoration: none; }
.tab[aria-current="page"] { color: var(--text); }
.tab[aria-current="page"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: var(--tab-accent, var(--teal)); }
.tab .tab-ic { width: 24px; height: 24px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--tab-accent, var(--teal)); }
.tab .tab-ic svg { width: 15px; height: 15px; stroke-width: 2.1; }
.tab .count { font-size: 11.5px; font-weight: 700; color: var(--text-3); background: var(--surface-3); border-radius: 999px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.tab-sep { width: 1px; background: var(--border); margin: 12px 6px; flex: none; }
.tab.add { color: var(--text-3); }
.acc-blue { --tab-accent: var(--c-blue); } .acc-orange { --tab-accent: var(--c-orange); } .acc-teal { --tab-accent: var(--c-teal); } .acc-gold { --tab-accent: var(--c-gold); }
.acc-magenta { --tab-accent: var(--c-magenta); } .acc-green { --tab-accent: var(--c-green); } .acc-violet { --tab-accent: var(--c-violet); } .acc-red { --tab-accent: var(--c-red); }
.acc-grey { --tab-accent: #7a8296; } .acc-navy { --tab-accent: var(--navy-2); }

.app-main { padding: clamp(12px, 2vw, 24px) clamp(12px, 2.4vw, 28px) 40px; min-height: calc(100vh - 220px); }
.app-footer { text-align: center; padding: 22px 16px 28px; color: var(--text-3); font-size: 12px; border-top: 1px solid var(--border); margin: 0 clamp(12px, 2.4vw, 28px); }
.app-footer b { display: block; letter-spacing: .24em; color: var(--text-2); font-size: 12.5px; margin-bottom: 3px; }
body.embed-compact .app-header { display: none; }
body.embed-compact .app-footer { display: none; }

.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-title { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.page-desc { margin: 4px 0 0; color: var(--text-3); max-width: 900px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.eyebrow .bar { width: 3px; height: 14px; border-radius: 2px; background: var(--orange); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 18px 20px; }
.card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 13px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; }
.card-title::before { content: ""; width: 3px; height: 15px; border-radius: 2px; background: var(--orange); flex: none; }
.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .empty-ic { width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; background: var(--surface-3); display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 17px; }

/* -------------------------------------------------------------- dashboard */
.dash-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.dash-tabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: 10px; flex-wrap: wrap; }
.dash-tab { height: 32px; padding: 0 12px; border-radius: 7px; border: 0; background: transparent; color: var(--text-2); font-weight: 600; cursor: pointer; }
.dash-tab[aria-current="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; align-items: stretch; }
.w-sm { grid-column: span 3; } .w-md { grid-column: span 4; } .w-lg { grid-column: span 6; } .w-xl { grid-column: span 8; } .w-full { grid-column: 1 / -1; }
@media (max-width: 1180px) { .w-sm { grid-column: span 6; } .w-md { grid-column: span 6; } .w-xl { grid-column: 1 / -1; } }
@media (max-width: 760px) { .dash-grid > * { grid-column: 1 / -1 !important; } }
.kpi-strip { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.widget { position: relative; display: flex; flex-direction: column; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px 14px; transition: box-shadow .2s, transform .2s, border-color .2s; }
.widget:hover { box-shadow: var(--shadow-md); }
.widget-head { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; min-height: 22px; }
.widget-title { margin: 0; font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; display: flex; align-items: center; gap: 9px; }
.widget-title::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--orange); flex: none; }
.widget-sub { font-size: 12.5px; color: var(--text-3); margin: 2px 0 0 12px; }
.widget-actions { margin-left: auto; display: flex; gap: 2px; opacity: .55; transition: opacity .15s; }
.widget:hover .widget-actions, .widget:focus-within .widget-actions { opacity: 1; }
.widget-body { position: relative; flex: 1; min-height: 120px; }
.widget-error { color: var(--warn); background: var(--warn-bg); border-radius: 8px; padding: 12px; font-size: 13px; }
.widget.is-loading .widget-body { opacity: .55; transition: opacity .2s; }
.kpi { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 16px 18px 14px; border-top: 3px solid var(--kpi-accent, var(--teal)); cursor: default; display: flex; flex-direction: column; min-height: 118px; transition: transform .2s var(--ease), box-shadow .2s; text-align: left; color: inherit; font: inherit; }
button.kpi { cursor: pointer; }
button.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-value { font-size: 38px; font-weight: 700; line-height: 1; letter-spacing: -.02em; color: var(--text); }
.kpi-label { margin-top: 10px; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.kpi-sub { font-size: 12px; color: var(--teal); font-weight: 600; margin-top: 2px; }
:root[data-theme="dark"] .kpi-sub { color: var(--focus); }
.kpi-spark { position: absolute; right: 12px; top: 14px; width: 42%; max-width: 140px; height: 38px; opacity: .9; }
.kpi .kpi-actions { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 2px; }
.acc-kpi-teal { --kpi-accent: var(--c-teal); } .acc-kpi-orange { --kpi-accent: var(--c-orange); } .acc-kpi-navy { --kpi-accent: var(--navy); }
.acc-kpi-blue { --kpi-accent: var(--c-blue); } .acc-kpi-green { --kpi-accent: var(--c-green); } .acc-kpi-violet { --kpi-accent: var(--c-violet); }
.acc-kpi-gold { --kpi-accent: var(--c-gold); } .acc-kpi-red { --kpi-accent: var(--c-red); } .acc-kpi-magenta { --kpi-accent: var(--c-magenta); } .acc-kpi-grey { --kpi-accent: var(--c-grey); }
.dash-edit .widget, .dash-edit .kpi { outline: 2px dashed var(--border-strong); outline-offset: 3px; }
.dash-edit .widget[draggable="true"], .dash-edit .kpi[draggable="true"] { cursor: grab; }
.drag-over { outline: 2px solid var(--teal) !important; }
.is-dragging { opacity: .45; }
.edit-bar { display: flex; align-items: center; gap: 4px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.add-widget { border: 2px dashed var(--border-strong); background: transparent; border-radius: var(--radius); min-height: 118px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--text-3); font-weight: 700; cursor: pointer; grid-column: span 3; }
.add-widget:hover { border-color: var(--teal); color: var(--teal); background: var(--surface-active); }

/* ------------------------------------------------------------------ charts */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--font); fill: var(--text-3); font-size: 12px; }
.chart .axis-label { fill: var(--text-2); font-size: 12.5px; }
.chart .value-label { fill: var(--text); font-weight: 700; font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .gridline { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis { stroke: var(--chart-axis); stroke-width: 1; shape-rendering: crispEdges; }
.chart .mark { transition: opacity .15s; cursor: default; }
.chart .mark.clickable { cursor: pointer; }
.chart.has-hover .mark:not(.is-hover) { opacity: .45; }
.chart .hit { fill: transparent; }
.chart .hit.clickable { cursor: pointer; }
.chart .center-value { fill: var(--text); font-size: 26px; font-weight: 700; }
.chart .center-label { fill: var(--text-3); font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.chart .line-path { fill: none; stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round; }
.chart .area-path { opacity: .12; }
.chart .dot-mark { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--chart-axis); stroke-width: 1; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.chart-legend.vertical { flex-direction: column; gap: 7px; margin: 0; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; padding: 0; color: inherit; cursor: default; text-align: left; font: inherit; }
button.legend-item { cursor: pointer; } button.legend-item:hover .legend-label { text-decoration: underline; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-value { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; margin-left: auto; padding-left: 10px; }
.legend-pct { color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 38px; text-align: right; }
.donut-wrap { display: grid; grid-template-columns: minmax(150px, 220px) 1fr; gap: 18px; align-items: center; }
@media (max-width: 520px) { .donut-wrap { grid-template-columns: 1fr; } }
.chart-tooltip {
  position: fixed; z-index: 1000; pointer-events: none; background: var(--navy-3); color: #fff; border-radius: 8px; padding: 8px 10px;
  font-size: 12.5px; box-shadow: var(--shadow-md); max-width: 280px; opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
.chart-tooltip.show { opacity: 1; transform: none; }
.chart-tooltip .tt-title { font-weight: 700; margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.chart-tooltip .tt-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-hint { opacity: .7; font-size: 11.5px; margin-top: 4px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--grid-line); }
.data-table th { color: var(--text-3); font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.funnel-row { display: grid; grid-template-columns: minmax(80px, 130px) 1fr 64px; align-items: center; gap: 12px; padding: 5px 0; }
.funnel-label { font-weight: 600; color: var(--text-2); font-size: 13px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.funnel-track { height: 26px; background: var(--surface-3); border-radius: 6px; overflow: hidden; position: relative; }
.funnel-fill { height: 100%; border-radius: 6px; background: var(--c-blue); transform-origin: left; transition: width .7s var(--ease); min-width: 2px; }
.funnel-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.funnel-conv { font-size: 11.5px; color: var(--text-3); font-weight: 600; display: block; }
.funnel-row.clickable { cursor: pointer; border-radius: 8px; }
.funnel-row.clickable:hover .funnel-label { color: var(--text); text-decoration: underline; }
.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); font-weight: 700; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
.mini-table td { padding: 8px; border-bottom: 1px solid var(--grid-line); vertical-align: top; max-width: 320px; }
.mini-table tr.clickable { cursor: pointer; }
.mini-table tr.clickable:hover td { background: var(--surface-hover); }
.table-scroll { overflow: auto; max-height: 460px; border-radius: 8px; }
.note-body { white-space: pre-wrap; color: var(--text-2); }

/* ---------------------------------------------------------------- sheet */
.sheet-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.sheet-icon { width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--tab-accent, var(--teal)); flex: none; box-shadow: var(--shadow-sm); }
.sheet-icon svg { width: 22px; height: 22px; stroke-width: 2; }
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.insight { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; box-shadow: var(--shadow-xs); min-width: 0; }
.insight-value { font-size: 22px; font-weight: 700; line-height: 1.1; }
.insight-label { font-size: 12px; color: var(--text-3); font-weight: 600; margin-top: 2px; }
.insight.dist { grid-column: span 2; }
@media (max-width: 640px) { .insight.dist { grid-column: 1 / -1; } }
.dist-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; margin: 8px 0 7px; gap: 2px; background: var(--surface); }
.dist-bar > button { border: 0; padding: 0; height: 100%; cursor: pointer; transition: filter .15s, flex-grow .5s var(--ease); min-width: 3px; }
.dist-bar > button:hover { filter: brightness(1.15); }
.dist-legend { display: flex; flex-wrap: wrap; gap: 3px 12px; font-size: 12px; color: var(--text-2); }
.dist-legend button { background: none; border: 0; padding: 0; color: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font: inherit; }
.dist-legend button:hover { color: var(--text); text-decoration: underline; }
.dist-legend .dot { width: 8px; height: 8px; border-radius: 50%; }

.views-bar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 2px; }
.view-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; }
.view-chip:hover { border-color: var(--border-strong); color: var(--text); }
.view-chip[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
:root[data-theme="dark"] .view-chip[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); }
.view-chip .unsaved { width: 7px; height: 7px; border-radius: 50%; background: var(--orange); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.toolbar .search { width: 260px; max-width: 100%; }
@media (max-width: 720px) { .toolbar .search { width: 100%; flex: 1 1 100%; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 10px; background: var(--surface); border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
.chips:empty { display: none; }
.filter-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--surface-active); border: 1px solid rgba(14, 154, 167, .35); color: var(--text); font-size: 12.5px; font-weight: 600; }
.filter-chip button { border: 0; background: none; color: var(--text-2); cursor: pointer; padding: 3px; border-radius: 50%; display: inline-flex; }
.filter-chip button:hover { background: rgba(0,0,0,.08); color: var(--text); }
.filter-chip .chip-body { cursor: pointer; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-bar { display: flex; align-items: center; gap: 10px; padding: 7px 12px; font-size: 12.5px; color: var(--text-3); background: var(--surface-2); border: 1px solid var(--border); border-top: 0; border-bottom: 0; }
.bulk-bar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--navy); color: #fff; border-radius: 0; flex-wrap: wrap; animation: slideDown .2s var(--ease); }
.bulk-bar .btn { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.2); }
.bulk-bar .btn:hover { background: rgba(255,255,255,.2); }
@keyframes slideDown { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ------------------------------------------------------------------ grid */
.grid-wrap {
  position: relative; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
  max-height: calc(100vh - 150px); min-height: 280px; box-shadow: var(--shadow-sm); overscroll-behavior: contain;
}
body.embed .grid-wrap { max-height: calc(100vh - 110px); }
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; table-layout: fixed; font-size: 13.5px; }
.grid th, .grid td { border-right: 1px solid var(--grid-line); border-bottom: 1px solid var(--grid-line); padding: 0; text-align: left; vertical-align: top; background: var(--surface); }
.grid thead th { position: sticky; top: 0; z-index: 4; background: var(--surface-2); height: 40px; vertical-align: middle; font-weight: 700; color: var(--text-2); font-size: 12.5px; box-shadow: inset 0 -1px 0 var(--border); user-select: none; }
.th-inner { display: flex; align-items: center; gap: 6px; padding: 0 6px 0 10px; height: 40px; position: relative; }
.th-inner .th-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.th-inner .th-type { color: var(--text-3); display: inline-flex; }
.th-inner .th-type svg { width: 14px; height: 14px; }
.th-inner .th-sort { color: var(--teal); display: inline-flex; }
.th-inner .th-menu { opacity: 0; }
.grid th:hover .th-menu, .grid th:focus-within .th-menu { opacity: 1; }
.th-group-mark { width: 6px; height: 6px; border-radius: 50%; background: var(--c-violet); flex: none; }
.resizer { position: absolute; right: -4px; top: 0; bottom: 0; width: 8px; cursor: col-resize; z-index: 2; }
.resizer::after { content: ""; position: absolute; left: 3px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: transparent; }
.resizer:hover::after, .resizer.is-active::after { background: var(--teal); }
.grid .sticky-a { position: sticky; left: 0; z-index: 2; }
.grid .sticky-b { position: sticky; left: var(--fz0, 64px); z-index: 2; }
.grid .sticky-b.fz-1 { left: var(--fz1, 64px); }
.grid .sticky-b.fz-2 { left: var(--fz2, 64px); }
.grid .sticky-b.frozen-last { box-shadow: 1px 0 0 var(--border), 6px 0 8px -6px rgba(20,28,55,.12); }
.grid-wrap { scroll-padding-top: 40px; }
.grid thead .sticky-a, .grid thead .sticky-b { z-index: 6; }
.grid .col-ctl { width: 64px; }
.ctl-inner { display: flex; align-items: center; gap: 2px; padding: 0 4px 0 10px; min-height: calc(var(--row-h) - 1px); }
.ctl-inner .rownum { font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; min-width: 22px; text-align: right; }
.ctl-inner input { width: 15px; height: 15px; accent-color: var(--teal); cursor: pointer; margin: 0; }
.grid tr .open-btn { opacity: 0; }
.grid tr:hover .open-btn, .grid tr.is-selected .open-btn, .grid tr:focus-within .open-btn { opacity: 1; }
.grid tr .rownum-wrap { display: inline-flex; }
.grid tr:hover .rownum-wrap.has-check, .grid tr.is-selected .rownum-wrap.has-check { display: none; }
.grid tr .check-wrap { display: none; }
.grid tr:hover .check-wrap, .grid tr.is-selected .check-wrap, .grid tr .check-wrap:focus-within { display: inline-flex; }
.cell { padding: 8px 10px; min-height: calc(var(--row-h) - 1px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 20px; position: relative; outline: none; }
.grid.wrap .cell, .cell.wrap { white-space: normal; word-break: break-word; }
.cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.cell.empty::before { content: "—"; color: var(--border-strong); }
.cell.clamp { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; max-height: 58px; }
.grid.wrap .cell.clamp { -webkit-line-clamp: 6; max-height: none; }
.grid td[aria-selected="true"] { box-shadow: inset 0 0 0 2px var(--teal); z-index: 1; }
.grid td.sticky-b[aria-selected="true"] { z-index: 2; }
.grid td.frozen-last[aria-selected="true"] { box-shadow: inset 0 0 0 2px var(--teal), 1px 0 0 var(--border), 6px 0 8px -6px rgba(20,28,55,.12); }
.grid td.is-editable { cursor: cell; }
.grid td.t-danger .cell, .t-danger { color: var(--danger); font-weight: 600; }
.grid td.t-muted .cell { color: var(--text-3); }
.grid td.t-bold .cell { font-weight: 700; }
.grid td.t-strike .cell { text-decoration: line-through; color: var(--text-3); }
.grid tbody tr:hover > td, .grid tbody tr.group-hover > td { background: var(--surface-hover); }
.grid tr.row-hl > td { background: var(--hl); }
.grid tr.row-hl:hover > td { background: color-mix(in srgb, var(--hl) 80%, var(--text) 4%); }
.grid td.cell-hl { background: var(--hl) !important; }
.grid tr.is-selected > td { background: var(--surface-active) !important; }
.grid tr.is-flash > td { animation: flash 1.8s var(--ease); }
@keyframes flash { 0% { background: rgba(235, 111, 10, .28); } 100% { } }
.grid tr.child-row > td.col-ctl .ctl-inner { padding-left: 20px; }
.grid tr.child-row > td.col-ctl .ctl-inner::before { content: ""; position: absolute; left: 12px; top: 0; bottom: 50%; width: 8px; border-left: 2px solid var(--border-strong); border-bottom: 2px solid var(--border-strong); border-bottom-left-radius: 6px; }
.grid td.merged { vertical-align: top; }
.grid td.merged .cell { white-space: normal; }
.grid tr.group-row > td { background: var(--surface-2); position: sticky; top: 40px; z-index: 3; border-bottom: 1px solid var(--border); }
.grid tr.group-row.hl > td { background: var(--hl); }
.group-inner { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-weight: 700; position: sticky; left: 0; width: max-content; max-width: min(100vw - 60px, 1100px); }
.group-inner .toggle { border: 0; background: none; cursor: pointer; color: var(--text-2); display: inline-flex; padding: 3px; border-radius: 6px; transition: transform .2s; }
.group-inner .toggle:hover { background: var(--surface-3); }
.group-inner .toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.group-inner .gtitle { font-size: 13.5px; }
.group-inner .gdesc { font-weight: 500; color: var(--text-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 700px; }
.group-inner .gcount { font-size: 11.5px; font-weight: 700; color: var(--text-3); background: var(--surface-3); padding: 1px 8px; border-radius: 999px; }
.grid-foot { display: flex; align-items: center; justify-content: center; padding: 14px; color: var(--text-3); font-size: 13px; }
.grid-add-row td { background: var(--surface) !important; }
.grid-add-row button { display: flex; align-items: center; gap: 8px; padding: 9px 14px; border: 0; background: none; color: var(--text-3); cursor: pointer; font-weight: 600; width: 100%; }
.grid-add-row button:hover { color: var(--teal); background: var(--surface-hover); }
.compact { --row-h: 30px; }
.compact .cell { padding-top: 4px; padding-bottom: 4px; }
.compact .pill { height: 20px; }

.cell a.cell-link { color: var(--link); }
.cell .link-ic { display: inline-flex; vertical-align: -2px; margin-left: 4px; color: var(--text-3); }
.cell .ext-link { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; }
.cell .ext-link .dom { overflow: hidden; text-overflow: ellipsis; }
.fav { width: 16px; height: 16px; border-radius: 4px; background: var(--surface-3); color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 800; flex: none; text-transform: uppercase; }
.fav.li { background: #0a66c2; color: #fff; }
.primary-link { font-weight: 600; color: var(--text); cursor: pointer; }
.primary-link:hover { color: var(--link); text-decoration: underline; }
.check-cell { display: inline-flex; width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--border-strong); align-items: center; justify-content: center; }
.check-cell.on { background: var(--teal); border-color: var(--teal); color: #fff; }
.check-cell.on svg { width: 12px; height: 12px; stroke-width: 3.2; }

/* cell editor overlay */
.cell-editor { position: absolute; z-index: 30; background: var(--surface); border: 2px solid var(--teal); border-radius: 6px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; min-width: 180px; }
.cell-editor input, .cell-editor textarea { border: 0; outline: none; padding: 7px 9px; background: transparent; width: 100%; min-height: 34px; }
.cell-editor textarea { min-height: 110px; resize: both; line-height: 1.45; }
.cell-editor .hint { font-size: 11.5px; color: var(--text-3); padding: 4px 9px 6px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 4px 4px; }
.cell-editor.is-saving { opacity: .7; }
.listbox { max-height: 260px; overflow: auto; padding: 4px; }
.listbox [role="option"] { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.listbox [role="option"][aria-selected="true"], .listbox [role="option"].is-active { background: var(--surface-active); }
.listbox [role="option"]:hover { background: var(--surface-hover); }
.listbox .opt-check { margin-left: auto; color: var(--teal); }
.listbox-search { border-bottom: 1px solid var(--border); }

/* ------------------------------------------------------------ cards/board */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 12px; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); }
.rec-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow-xs); cursor: pointer; text-align: left; color: inherit; font: inherit; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; transition: box-shadow .15s, transform .15s; min-width: 0; }
.rec-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.rec-card.row-hl { box-shadow: inset 4px 0 0 var(--hl), var(--shadow-xs); background: linear-gradient(90deg, var(--hl), var(--surface) 55%); }
.rec-card .rc-title { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-card .rc-field { display: flex; gap: 8px; font-size: 13px; min-width: 0; }
.rec-card .rc-field .rc-label { color: var(--text-3); flex: none; width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-card .rc-field .rc-value { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-card .rc-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.board { display: flex; gap: 12px; overflow-x: auto; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); min-height: 420px; align-items: flex-start; }
.board-col { flex: 0 0 290px; width: 290px; min-width: 0; background: var(--surface-3); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); }
.board-col-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 8px; font-weight: 700; }
.board-col-body { display: flex; flex-direction: column; gap: 8px; padding: 4px 8px 10px; overflow-y: auto; min-height: 60px; border-radius: 10px; transition: background .15s; }
.board-col-body.drag-target { background: var(--surface-active); outline: 2px dashed var(--teal); outline-offset: -4px; }
.board .rec-card { cursor: grab; flex: none; width: 100%; }
.board-col-body > * { flex: none; }
.board .rec-card:active { cursor: grabbing; }
.board-more { text-align: center; padding: 6px; font-size: 12.5px; }

/* ---------------------------------------------------------- menus/popover */
.popover { position: fixed; z-index: 900; min-width: 200px; max-width: min(420px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; animation: pop .14s var(--ease); max-height: min(70vh, 560px); overflow: auto; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; border-radius: 7px; color: var(--text); cursor: pointer; text-align: left; font-size: 13.5px; font-weight: 500; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-hover); outline: none; }
.menu-item.danger { color: var(--danger); }
.menu-item .kbd { margin-left: auto; font-size: 11.5px; color: var(--text-3); }
.menu-item .sub-arrow { margin-left: auto; color: var(--text-3); }
.menu-item[aria-checked="true"]::after { content: "✓"; margin-left: auto; color: var(--teal); font-weight: 700; }
.menu-sep { height: 1px; background: var(--border); margin: 5px 4px; }
.menu-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 4px; }
.menu-swatches { display: flex; gap: 6px; padding: 6px 10px 8px; flex-wrap: wrap; }
.filter-pop { padding: 12px; width: 560px; max-width: calc(100vw - 16px); }
.filter-row { display: grid; grid-template-columns: 1.1fr 1fr 1.4fr auto; gap: 6px; align-items: start; margin-bottom: 8px; }
@media (max-width: 600px) { .filter-row { grid-template-columns: 1fr 1fr; } .filter-row > :nth-child(3) { grid-column: 1 / -1; } }
.checklist { max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
.checklist label { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.checklist label:hover { background: var(--surface-hover); }
.checklist .cnt { margin-left: auto; color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------- dialogs & drawer */
dialog { border: 0; padding: 0; background: transparent; color: var(--text); max-width: none; max-height: none; }
dialog::backdrop { background: var(--scrim); backdrop-filter: blur(2px); }
.modal { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: modalIn .2s var(--ease); }
.modal.wide { width: min(980px, calc(100vw - 24px)); }
.modal.xwide { width: min(1240px, calc(100vw - 24px)); }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
dialog.drawer-dialog { margin: 0 0 0 auto; height: 100%; max-height: 100vh; }
.drawer { width: min(640px, 100vw); height: 100vh; background: var(--surface); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: drawerIn .25s var(--ease); }
@keyframes drawerIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 14px 18px 0; border-bottom: 1px solid var(--border); background: var(--surface); }
.drawer-crumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-3); font-weight: 600; }
.drawer-title { margin: 8px 0 10px; font-size: 21px; font-weight: 700; line-height: 1.2; word-break: break-word; }
.drawer-tabs { display: flex; gap: 2px; }
.drawer-tabs button { border: 0; background: none; padding: 9px 12px; font-weight: 600; color: var(--text-3); cursor: pointer; border-bottom: 2px solid transparent; }
.drawer-tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--teal); }
.drawer-body { flex: 1; overflow: auto; padding: 18px; }
.drawer-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; background: var(--surface-2); font-size: 12.5px; color: var(--text-3); }
.rec-field { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--grid-line); align-items: start; }
.rec-field:last-child { border-bottom: 0; }
@media (max-width: 560px) { .rec-field { grid-template-columns: 1fr; gap: 4px; } }
.rec-field > .rf-label { font-size: 13px; font-weight: 600; color: var(--text-2); padding-top: 8px; display: flex; align-items: flex-start; gap: 6px; }
.rec-field > .rf-label .rf-shared { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--c-violet); background: var(--o-violet); padding: 1px 6px; border-radius: 999px; }
.rf-control { min-width: 0; position: relative; }
.rf-control .readonly { padding: 8px 0; word-break: break-word; white-space: pre-wrap; }
.rf-tools { display: flex; gap: 6px; margin-top: 4px; align-items: center; flex-wrap: wrap; }
.rf-fmt { opacity: 0; margin-left: auto; transition: opacity .15s; }
.rec-field:hover .rf-fmt, .rf-fmt:focus-visible, .rf-fmt.has-format { opacity: 1; }
.rf-status { position: absolute; right: -2px; top: -16px; font-size: 11px; font-weight: 700; color: var(--success); opacity: 0; transition: opacity .2s; }
.rf-status.show { opacity: 1; }
.rf-status.err { color: var(--danger); }
.rec-group { margin-top: 18px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.rec-group-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; }
.rec-child { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--grid-line); cursor: pointer; }
.rec-child:last-child { border-bottom: 0; }
.rec-child:hover { background: var(--surface-hover); }
.rec-child .rc-main { min-width: 0; flex: 1; }
.rec-child .rc-name { font-weight: 600; }
.rec-child .rc-meta { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.parent-banner { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--o-violet); border-radius: 10px; margin-bottom: 12px; font-size: 13px; }
.history-item { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--grid-line); }
.history-item .h-when { font-size: 12px; color: var(--text-3); }
.history-item .h-change { font-size: 12.5px; margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.history-item .h-from { text-decoration: line-through; color: var(--text-3); }
.history-item .h-to { font-weight: 600; }

/* ----------------------------------------------------------------- toast */
.toasts { position: fixed; z-index: 1100; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(560px, calc(100vw - 24px)); }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 12px; background: var(--navy-3); color: #fff; padding: 11px 12px 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; animation: toastIn .25s var(--ease); max-width: 100%; }
.toast.error { background: #8e1d1d; }
.toast.success .t-ic { color: #7ee2a8; }
.toast .t-msg { flex: 1; min-width: 0; }
.toast .t-action { background: rgba(255,255,255,.14); color: #fff; border: 0; border-radius: 7px; padding: 6px 10px; font-weight: 700; cursor: pointer; }
.toast .t-action:hover { background: rgba(255,255,255,.24); }
.toast .t-close { background: none; border: 0; color: rgba(255,255,255,.7); cursor: pointer; padding: 2px; display: inline-flex; }
.toast.out { animation: toastOut .2s forwards; }
@keyframes toastIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(8px); opacity: 0; } }

/* -------------------------------------------------------- command palette */
.palette { width: min(640px, calc(100vw - 24px)); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; margin-top: 12vh; animation: modalIn .18s var(--ease); }
dialog.palette-dialog { margin: 0 auto; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.palette-input input { border: 0; outline: none; background: transparent; font-size: 17px; flex: 1; }
.palette-list { max-height: 55vh; overflow: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 10px 10px 4px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.palette-item.is-active { background: var(--surface-active); }
.palette-item .pi-ic { width: 30px; height: 30px; border-radius: 8px; background: var(--surface-3); display: inline-flex; align-items: center; justify-content: center; color: var(--text-2); flex: none; }
.palette-item .pi-main { min-width: 0; flex: 1; }
.palette-item .pi-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .pi-sub { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); background: var(--surface-2); }
kbd { font: 600 11.5px var(--font); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); }

/* ----------------------------------------------------------------- admin */
.admin-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .admin-layout { grid-template-columns: 1fr; } }
.admin-nav { position: sticky; top: 64px; display: flex; flex-direction: column; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow-sm); }
@media (max-width: 900px) { .admin-nav { position: static; flex-direction: row; overflow-x: auto; } }
.admin-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.admin-nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.admin-nav a[aria-current="page"] { background: var(--surface-active); color: var(--teal-2); }
:root[data-theme="dark"] .admin-nav a[aria-current="page"] { color: var(--focus); }
.admin-section { display: flex; flex-direction: column; gap: 16px; }
.list-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.list-table th { text-align: left; font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.list-table td { padding: 9px 10px; border-bottom: 1px solid var(--grid-line); vertical-align: middle; }
.list-table tr:last-child td { border-bottom: 0; }
.list-table tr.drag-over td { box-shadow: inset 0 2px 0 var(--teal); }
.drag-handle { cursor: grab; color: var(--text-3); display: inline-flex; padding: 4px; border-radius: 6px; }
.drag-handle:hover { background: var(--surface-3); }
.flags { display: flex; flex-wrap: wrap; gap: 4px; }
.flag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); }
.flag.violet { background: var(--o-violet); } .flag.red { background: var(--o-red); } .flag.teal { background: var(--o-teal); } .flag.gold { background: var(--o-gold); }
.sheet-list-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; cursor: pointer; border: 1px solid transparent; }
.sheet-list-item:hover { background: var(--surface-hover); }
.sheet-list-item[aria-current="true"] { background: var(--surface-active); border-color: rgba(14,154,167,.35); }
.sheet-list-item .tab-ic { width: 28px; height: 28px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: #fff; background: var(--tab-accent); flex: none; }
.sheet-list-item .tab-ic svg { width: 15px; height: 15px; }
.choice-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.choice-row > .swatch, .choice-row > .row, .choice-row > .btn { margin-top: 4px; }
.choice-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.choice-main .choice-also { font-size: 12.5px; height: 28px; color: var(--text-2); background: var(--surface-2); }
.derive-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.th-auto-mark { color: var(--teal); display: inline-flex; }
.th-auto-mark svg { width: 13px; height: 13px; }
.rec-field > .rf-label .rf-auto { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--teal); background: color-mix(in srgb, var(--teal) 13%, transparent); padding: 1px 6px; border-radius: 999px; cursor: help; }
.rec-field.rf-flash { animation: flash 1.8s var(--ease); border-radius: 8px; }
.code-box { display: flex; gap: 8px; align-items: stretch; }
.code-box code, .code-box textarea { flex: 1; font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; word-break: break-all; color: var(--text); }
.steps { margin: 0; padding-left: 20px; } .steps li { margin: 6px 0; }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13.5px; }
.callout.warn { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.callout.info { background: var(--surface-active); border-color: rgba(14,154,167,.3); }
.dropzone { border: 2px dashed var(--border-strong); border-radius: 14px; padding: 36px 20px; text-align: center; background: var(--surface-2); transition: border-color .15s, background .15s; cursor: pointer; }
.dropzone.is-over { border-color: var(--teal); background: var(--surface-active); }
.map-table td { vertical-align: middle; }
.activity-item { display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--grid-line); align-items: start; }
.activity-item .a-ic { width: 32px; height: 32px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--text-2); }
.activity-item .a-when { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.activity-item .a-sum { font-weight: 500; }
.activity-item .a-who { font-size: 12.5px; color: var(--text-3); }
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (max-width: 640px) { .type-grid { grid-template-columns: repeat(2, 1fr); } }
.type-opt { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.type-opt:hover { border-color: var(--border-strong); }
.type-opt[aria-pressed="true"] { border-color: var(--teal); background: var(--surface-active); color: var(--text); box-shadow: 0 0 0 1px var(--teal); }
.builder { display: grid; grid-template-columns: 420px 1fr; gap: 0; min-height: 520px; }
.builder-form { padding: 18px 20px; border-right: 1px solid var(--border); overflow: auto; max-height: calc(100vh - 170px); }
.builder-preview { padding: 18px 20px; background: var(--surface-2); overflow: auto; max-height: calc(100vh - 170px); }
@media (max-width: 900px) { .builder { grid-template-columns: 1fr; } .builder-form { border-right: 0; border-bottom: 1px solid var(--border); } }
.stage-row { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 6px; margin-bottom: 6px; align-items: start; }

/* ----------------------------------------------------------------- login */
.login-wrap { min-height: calc(100vh - 160px); display: flex; align-items: center; justify-content: center; padding: 24px 12px; }
.login-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .brand-word { color: var(--navy); font-size: 20px; margin-bottom: 18px; display: block; }
:root[data-theme="dark"] .login-card .brand-word { color: #fff; }
.form-error { background: var(--danger-bg); color: var(--danger); border-radius: 8px; padding: 10px 12px; font-weight: 600; font-size: 13.5px; margin-bottom: 12px; }

/* --------------------------------------------------------------- loading */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.boot { min-height: 60vh; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px; color: var(--text-3); }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tip { position: fixed; z-index: 1200; background: var(--navy-3); color: #fff; font-size: 12px; padding: 5px 8px; border-radius: 6px; pointer-events: none; max-width: 260px; box-shadow: var(--shadow-md); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .search-trigger { min-width: 0; } .search-trigger .grow, .search-trigger kbd { display: none; }
  .brand-tag { display: none; }
}
@media (max-width: 640px) {
  :root { --header-h: 56px; }
  .brand-word { font-size: 18px; }
  .live .live-text { display: none; }
  .page-title { font-size: 20px; }
  .kpi-value { font-size: 32px; }
  .drawer { width: 100vw; }
  .tab { padding: 0 10px; } .tab .count { display: none; }
  .header-actions .hide-sm { display: none; }
}

/* ----------------------------------------------------------------- motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ----------------------------------------------------------------- print */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; }
  .app-header, .tabbar, .toolbar, .views-bar, .widget-actions, .dash-actions, .app-footer, .toasts, .edit-bar, .add-widget, .chips, .bulk-bar { display: none !important; }
  .app-main { padding: 0; }
  .widget, .kpi { box-shadow: none; break-inside: avoid; }
  .grid-wrap { max-height: none; overflow: visible; }
  .dash-grid { gap: 10px; }
}

@media (forced-colors: active) {
  .pill { border: 1px solid CanvasText; }
  .chart .mark { forced-color-adjust: none; }
}
