/* ZMZY Trading DMS - brand: slate #0F172A, pink #F91E7C, teal #32D5B5 (from zmzytrading.com) */
:root {
  color-scheme: light;
  --brand-dark: #0f172a;
  --brand-dark-2: #1e293b;
  --brand-pink: #f91e7c;
  --brand-pink-ink: #c2125f;
  --brand-teal: #32d5b5;
  --brand-teal-ink: #0b7d69;
  --page: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --calc: #fff1f7;
  --ink: #0f172a;
  --ink-2: #454f5e;
  --muted: #7a8494;
  --line: #e4e8ef;
  --focus: #2a78d6;
  --good: #0a7d0a;
  --bad: #c62f2f;
  --warn-bg: #fff4d6;
  --warn-ink: #8a5a00;
  --bad-bg: #fdecec;
  --good-bg: #e7f6e7;
  /* chart palette - validated (CVD >= 8, contrast) with the dataviz validator */
  --series-1: #2a78d6;  /* Walmart */
  --series-2: #e0196f;  /* eBay (brand pink) */
  --series-3: #eda100;
  --series-4: #4a3aa7;
  --grid: #e7e9ee;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 12px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0b1220; --surface: #131b2e; --surface-2: #182238; --calc: #2b1624;
    --ink: #e8edf5; --ink-2: #b4bfcf; --muted: #8391a7; --line: #26324a;
    --warn-bg: #3a2f0c; --warn-ink: #f2c14e; --bad-bg: #3b1616; --good-bg: #10301a; --good: #3fbf3f; --bad: #ff7b72;
    --series-1: #3987e5; --series-2: #f0408a; --series-3: #c98500; --series-4: #9085e9; --grid: #243049;
    --brand-pink-ink: #ff5c9f; --brand-teal-ink: #32d5b5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b1220; --surface: #131b2e; --surface-2: #182238; --calc: #2b1624;
  --ink: #e8edf5; --ink-2: #b4bfcf; --muted: #8391a7; --line: #26324a;
  --warn-bg: #3a2f0c; --warn-ink: #f2c14e; --bad-bg: #3b1616; --good-bg: #10301a; --good: #3fbf3f; --bad: #ff7b72;
  --series-1: #3987e5; --series-2: #f0408a; --series-3: #c98500; --series-4: #9085e9; --grid: #243049;
  --brand-pink-ink: #ff5c9f; --brand-teal-ink: #32d5b5;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--page); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
a { color: var(--focus); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 18px; font-size: 13px; }
.num-t { font-variant-numeric: tabular-nums; }

/* buttons & inputs */
.btn { font: inherit; font-weight: 500; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 7px 13px; border-radius: 9px; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.primary:hover { background: var(--brand-dark-2); }
.btn.brand { background: var(--brand-pink); border-color: var(--brand-pink); color: #fff; font-weight: 600; }
.btn.brand:hover { background: var(--brand-pink-ink); border-color: var(--brand-pink-ink); }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 9px; font-size: 12px; }
.btn.icon-only { padding: 4px 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 7px 10px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
label { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 500; }

/* login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; background:
  radial-gradient(700px 420px at 12% 8%, rgba(50, 213, 181, .22), transparent 60%),
  radial-gradient(700px 420px at 92% 92%, rgba(249, 30, 124, .22), transparent 60%), var(--brand-dark); }
.login-card { width: min(420px, 100%); background: rgba(15, 23, 42, .72); border: 1px solid rgba(255, 255, 255, .08); color: #e8edf5;
  border-radius: 18px; padding: 32px; display: grid; gap: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); backdrop-filter: blur(8px); }
.login-card label { color: #b4bfcf; }
.login-card input { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); color: #fff; }
.login-card .btn.brand { padding: 10px; font-size: 15px; }
.login-card .muted { color: #8391a7; }
.login-card a { color: var(--brand-teal); }
.login-logo { height: 58px; width: auto; justify-self: start; }
.login-title { font-size: 20px; font-weight: 700; margin: 2px 0 0; }
.login-sub { color: #8391a7; font-size: 13px; margin: 0 0 6px; }

/* shell */
.shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100%; }
.sidebar { background: var(--brand-dark); color: #b4bfcf; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  border-right: 1px solid rgba(255, 255, 255, .04); }
.brand { display: grid; gap: 2px; padding: 18px 18px 14px; text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.brand img { height: 40px; width: auto; }
.brand small { color: #7f8ea8; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }
.brand-bar { height: 3px; border-radius: 3px; margin-top: 8px; background: linear-gradient(90deg, var(--brand-teal), var(--brand-pink)); width: 64px; }
nav { padding: 10px 10px; overflow-y: auto; flex: 1; }
nav .group { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 14px 10px 5px; font-weight: 600; }
nav a { display: flex; align-items: center; gap: 10px; color: #b4bfcf; text-decoration: none; padding: 8px 10px; border-radius: 9px; position: relative; }
nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
nav a.active { background: rgba(249, 30, 124, .14); color: #fff; font-weight: 600; }
nav a.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-pink); }
nav a .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07); display: grid; gap: 6px; }
.sidebar-foot .btn { color: #b4bfcf; border-color: rgba(255, 255, 255, .12); }
.whoami { font-size: 12px; color: #7f8ea8; }
.whoami b { color: #fff; display: block; font-size: 13px; }
.role-badge { display: inline-block; font-size: 10.5px; padding: 1px 7px; border-radius: 999px; background: rgba(50, 213, 181, .15); color: var(--brand-teal); margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }
.partner { font-size: 11px; color: #64748b; text-decoration: none; }
.partner:hover { color: var(--brand-teal); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 22px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 19px; margin: 0; flex: 1; letter-spacing: -.01em; }
.topbar h1 small { display: block; font-size: 12px; font-weight: 400; color: var(--muted); letter-spacing: 0; }
#menu-btn { display: none; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.user-actions { display: flex; gap: 6px; padding-left: 12px; border-left: 1px solid var(--line); }
.view { padding: 18px 22px 36px; min-width: 0; }

/* toolbar & tabs */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.toolbar .grow { flex: 1; }
.toolbar input[type=search] { min-width: 240px; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { font: inherit; background: none; border: none; padding: 9px 13px; cursor: pointer; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--brand-pink); font-weight: 600; }
.totals { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 11px; font-size: 12px; color: var(--ink-2); }
.chip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.chip.neg b { color: var(--bad); }
.legend-note { font-size: 12px; color: var(--muted); margin: 8px 2px 0; }
.legend-note .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; background: var(--calc);
  border: 1px solid var(--line); margin-right: 4px; }
.perm-note { font-size: 12px; background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 6px 10px; margin-bottom: 10px; }

/* grid */
.grid-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tabulator { font-size: 13px; border: none; background: var(--surface); }
.tabulator .tabulator-header { background: var(--surface-2); color: var(--ink); border-bottom: 1px solid var(--line); }
.tabulator .tabulator-header .tabulator-col { background: var(--surface-2); border-right: 1px solid var(--line); }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title { white-space: normal; font-weight: 600; font-size: 12px; }
.tabulator .tabulator-header .tabulator-col.calc-col { background: var(--calc); }
.tabulator .tabulator-header input, .tabulator .tabulator-header select { padding: 3px 6px; font-size: 12px; border-radius: 6px; }
.tabulator .tabulator-tableholder { background: var(--surface); }
.tabulator-row { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line); }
.tabulator-row.tabulator-row-even { background: var(--surface-2); }
.tabulator-row .tabulator-cell { border-right: 1px solid var(--line); padding: 5px 7px; }
.tabulator-row .tabulator-cell.calc { background: var(--calc); font-variant-numeric: tabular-nums; font-weight: 500; }
.tabulator-row .tabulator-cell.num { text-align: right; font-variant-numeric: tabular-nums; }
.tabulator-row .tabulator-cell.tabulator-editing { border: 2px solid var(--focus); }
.tabulator-row.tabulator-selectable:hover { background: color-mix(in srgb, var(--focus) 7%, var(--surface)); }
.tabulator-row.tabulator-selected { background: color-mix(in srgb, var(--focus) 16%, var(--surface)); }
.tabulator-row.row-muted { color: var(--muted); }
.tabulator-row.row-bad .tabulator-cell:first-child { box-shadow: inset 3px 0 0 var(--bad); }
.tabulator .tabulator-footer { background: var(--surface-2); color: var(--ink-2); border-top: 1px solid var(--line); }
.tabulator .tabulator-footer .tabulator-page { background: var(--surface); color: var(--ink); border-color: var(--line); }
.tabulator .tabulator-footer .tabulator-page.active { color: var(--brand-pink-ink); font-weight: 700; }
.tabulator-edit-list { background: var(--surface); color: var(--ink); border-color: var(--line); }
.tabulator-edit-list .tabulator-edit-list-item { color: var(--ink); }
.tabulator-edit-list .tabulator-edit-list-item.focused, .tabulator-edit-list .tabulator-edit-list-item:hover { background: var(--focus); color: #fff; }
.tabulator .tabulator-cell input, .tabulator .tabulator-cell textarea { background: var(--surface); color: var(--ink); }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); }
.pill.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.link-cell a { text-decoration: none; }

/* BI dashboard */
.bi-filters { position: sticky; top: 61px; z-index: 4; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(6px);
  padding: 10px 0 10px; margin: -6px 0 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: end; border-bottom: 1px solid var(--line); }
.bi-filters label select, .bi-filters label input { min-width: 120px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: var(--surface); }
.seg button { font: inherit; font-size: 12.5px; border: none; background: none; padding: 7px 11px; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--brand-dark); color: #fff; font-weight: 600; }
:root[data-theme="dark"] .seg button.active { background: var(--brand-pink); }
.drill { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 12px; min-height: 26px; }
.drill .lbl { font-size: 12px; color: var(--muted); }
.drill .tag { display: inline-flex; align-items: center; gap: 6px; background: rgba(249, 30, 124, .1); color: var(--brand-pink-ink); border-radius: 999px;
  padding: 3px 5px 3px 10px; font-size: 12px; font-weight: 600; }
.drill .tag button { border: none; background: rgba(249, 30, 124, .18); color: inherit; border-radius: 999px; width: 18px; height: 18px; cursor: pointer; line-height: 1; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi.hero::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--brand-teal), var(--brand-pink)); }
.kpi .label { color: var(--ink-2); font-size: 12px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.delta { font-size: 12px; font-weight: 600; margin-top: 4px; display: inline-flex; gap: 4px; align-items: center; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--muted); }
.delta .vs { color: var(--muted); font-weight: 400; }
.cards { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { margin: 0; font-size: 14px; letter-spacing: -.005em; }
.card .card-sub { color: var(--muted); font-size: 12px; margin: 2px 0 10px; }
.card .card-head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.card-tools { display: flex; gap: 4px; }
.span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; } .span-12 { grid-column: span 12; }
.chart-box { position: relative; height: 280px; }
.chart-box.tall { height: 320px; }
.chart-box.short { height: 220px; }
.table-scroll { max-height: 340px; overflow: auto; }
table.simple { width: 100%; border-collapse: collapse; font-size: 13px; }
table.simple th, table.simple td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.simple th { color: var(--ink-2); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: var(--surface); }
table.simple td.num, table.simple th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.simple tr.click { cursor: pointer; }
table.simple tr.click:hover td { background: color-mix(in srgb, var(--focus) 6%, var(--surface)); }
table.simple tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.bar-cell { position: relative; }
.bar-cell i { position: absolute; left: 0; top: 50%; height: 6px; margin-top: -3px; border-radius: 3px; background: color-mix(in srgb, var(--series-1) 30%, transparent); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend i.line { height: 2px; width: 14px; vertical-align: 3px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mini-stats div { background: var(--surface-2); border-radius: 9px; padding: 10px; }
.mini-stats b { display: block; font-size: 18px; margin-top: 2px; }
.mini-stats span { font-size: 11.5px; color: var(--muted); }

/* permission matrix */
.matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.matrix th, .matrix td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix thead th { font-size: 12px; color: var(--ink-2); background: var(--surface-2); }
.matrix thead tr.roles th { font-size: 13px; color: var(--ink); border-bottom: 2px solid var(--brand-pink); }
.matrix td.role-start, .matrix th.role-start { border-left: 2px solid var(--line); }
.matrix select { padding: 3px 5px; font-size: 12px; }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(2, 8, 20, .55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-card { background: var(--surface); border-radius: 14px; width: min(780px, 100%); max-height: 88vh; overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { margin: 0; font-size: 16px; }
#modal-body { padding: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--brand-dark); color: #fff; padding: 10px 14px; border-radius: 10px; z-index: 60;
  box-shadow: var(--shadow); max-width: 440px; border-left: 3px solid var(--brand-teal); }
.toast.err { border-left-color: var(--brand-pink); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 14px; }
.panel h3 { margin-top: 0; }

/* record form (add / edit) */
.modal-card.wide { width: min(1040px, 100%); }
.record-form { display: grid; gap: 14px; }
.record-form fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 14px; margin: 0; min-width: 0; }
.record-form legend { font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; padding: 0 6px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea, .dl input { width: 100%; }
.form-grid input:disabled, .form-grid select:disabled, .form-grid textarea:disabled { background: var(--surface-2); color: var(--ink-2); }
.dl { display: block; }
.form-grid label .btn.small { justify-self: start; margin-top: 2px; }
.form-foot { position: sticky; bottom: -16px; background: var(--surface); border-top: 1px solid var(--line); margin: 0 -16px -16px; padding: 12px 16px; display: grid; gap: 8px; }
.form-foot .form-actions { margin-top: 0; align-items: center; }
.preview { display: flex; flex-wrap: wrap; gap: 8px; }
.preview div { background: var(--surface-2); border-radius: 9px; padding: 6px 12px; display: grid; }
.preview span { font-size: 11px; color: var(--muted); }
.preview b { font-size: 15px; font-variant-numeric: tabular-nums; }

/* my work */
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.quick-actions .btn { padding: 9px 15px; }
.quick-actions .find { display: flex; gap: 6px; flex: 1; min-width: 260px; justify-content: flex-end; }
.quick-actions .find input { flex: 1; max-width: 420px; }
.kpis.today { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.task-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.task-tile { font: inherit; text-align: left; cursor: pointer; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  display: grid; gap: 2px; box-shadow: var(--shadow); color: var(--ink); transition: border-color .15s; }
.task-tile:hover { border-color: var(--muted); }
.task-tile.active { border-color: var(--brand-pink); box-shadow: 0 0 0 1px var(--brand-pink), var(--shadow); }
.task-tile .n { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.task-tile .t { font-weight: 600; }
.task-tile .s { font-size: 12px; color: var(--muted); }
.task-tile.done .n { color: var(--good); }
.task-panel { padding: 14px; }
.table-scroll.tall { max-height: calc(100vh - 420px); min-height: 240px; }
table.simple.tasks td { vertical-align: middle; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
label.check { display: flex; flex-direction: row; gap: 6px; align-items: center; font-size: 13px; }
.empty { display: grid; gap: 4px; place-items: center; padding: 40px 12px; text-align: center; }
.empty b { font-size: 16px; color: var(--good); }
.stage-seg { margin-bottom: 10px; flex-wrap: wrap; }

/* dashboard additions */
.attention { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; margin: -2px 0 14px; }
.attention-title { align-self: center; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin-right: 4px; }
.attention-item { display: flex; gap: 14px; align-items: center; justify-content: space-between; text-decoration: none; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--series-1); border-radius: 10px; padding: 8px 12px; flex: 1 1 220px; box-shadow: var(--shadow); }
.attention-item.hot { border-left-color: var(--warn-ink); }
.attention-item b { display: block; font-size: 13px; }
.attention-item small { color: var(--muted); font-size: 12px; }
.attention-item .go { font-size: 12px; font-weight: 600; color: var(--focus); white-space: nowrap; }
.attention-item:hover { border-color: var(--muted); }
.track-rows { display: grid; gap: 7px; }
.track-row { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 10px; align-items: center; font-size: 13px; }
.track-row .tl { color: var(--ink-2); line-height: 1.2; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.track-row .tl small { display: block; color: var(--muted); font-size: 11px; }
.track-row .tv { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; min-width: 64px; }
.track-row.strong .tl { color: var(--ink); font-weight: 600; }
.track { display: block; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; min-width: 40px; }
.track i { display: block; height: 100%; border-radius: 4px; background: var(--series-1); }
.track-row.strong .track i { background: var(--series-4); }
.track i.neg-bar { background: var(--bad); }
.share { display: inline-grid; grid-template-columns: minmax(40px, 90px) auto; gap: 8px; align-items: center; justify-content: end; width: 100%; }
.share > span:last-child { min-width: 58px; text-align: right; }
.mini-stats.two { grid-template-columns: 1fr 1fr; }
.mini-stats.four { grid-template-columns: repeat(4, 1fr); }
.mini-stats.four b { font-size: 16px; }
.mini-stats em { display: block; font-style: normal; font-size: 11.5px; margin-top: 2px; }
.chart-box.mini { height: 150px; }
.stage-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stage { display: grid; gap: 2px; text-decoration: none; background: var(--surface-2); border-radius: 9px; padding: 8px; color: var(--ink); }
.stage b { font-size: 18px; font-variant-numeric: tabular-nums; }
.stage span { font-size: 11px; color: var(--muted); line-height: 1.25; }
.stage:hover { outline: 1px solid var(--muted); }

@media (max-width: 1200px) { .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; } }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; width: 256px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  #menu-btn { display: inline-block; }
  .view { padding: 12px 16px 24px; }
  .topbar { padding: 12px 16px; }
  .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .mini-stats.four, .stage-row { grid-template-columns: 1fr 1fr; }
  .quick-actions .find { min-width: 100%; }
  .toolbar input[type=search] { min-width: 0; width: 100%; }
  .bi-filters { position: static; }
  .mini-stats { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- phones & tablets ---- */
.nav-backdrop { display: none; }
.bottom-nav { display: none; }
@media (max-width: 820px) {
  body { font-size: 14px; }
  input, select, textarea { font-size: 16px; } /* stops iOS zooming into fields */
  .shell { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
  .sidebar { top: 0; bottom: 0; height: 100dvh; box-shadow: 0 0 40px rgba(0, 0, 0, .4); }
  .nav-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(2, 8, 20, .45); z-index: 35; }
  .topbar { padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top)); gap: 8px; flex-wrap: wrap; }
  .topbar h1 { font-size: 17px; min-width: 0; }
  .topbar h1 small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .page-actions { width: 100%; order: 1; }
  .user-actions { padding-left: 0; border-left: 0; gap: 4px; }
  .page-actions:empty { display: none; }
  .view { padding: 12px 12px 20px; }

  /* bottom tab bar */
  nav.bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 18px rgba(15, 23, 42, .08); overflow: visible; }
  nav.bottom-nav a, nav.bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; border-radius: 10px;
    font: inherit; font-size: 11px; color: var(--ink-2); text-decoration: none; background: none; border: none; cursor: pointer; min-height: 48px; justify-content: center; }
  nav.bottom-nav a .ico, nav.bottom-nav button .ico { font-size: 18px; line-height: 1; width: auto; }
  nav.bottom-nav a.active { color: var(--brand-pink-ink); font-weight: 600; background: rgba(249, 30, 124, .08); }
  nav.bottom-nav a.active::before { display: none; }
  nav.bottom-nav a:hover { background: var(--surface-2); color: var(--ink); }

  /* bigger touch targets */
  .btn { padding: 9px 13px; }
  .btn.small { padding: 7px 11px; font-size: 13px; }
  .tabs, .seg { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .tabs button, .seg button { white-space: nowrap; flex: 0 0 auto; }
  .stage-seg { display: flex; }
  .toolbar { gap: 6px; }
  .toolbar > input[type=search], .toolbar .grow { flex: 1 1 100%; }
  .toolbar .grow { display: none; }
  .toolbar select { flex: 1 1 45%; }
  .perm-note, .legend-note { font-size: 11.5px; }

  /* modals become full-height sheets */
  .modal { padding: 0; place-items: end stretch; }
  .modal-card, .modal-card.wide { width: 100%; max-height: 94dvh; border-radius: 16px 16px 0 0; }
  .form-foot .form-actions { flex-wrap: wrap; }
  .form-foot .form-actions > p { flex: 1 1 100%; }
  .form-foot .form-actions .btn { flex: 1; }
  .toast { left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom)); max-width: none; }

  /* my work */
  .quick-actions .btn { flex: 1 1 auto; }
  .quick-actions .find { flex: 1 1 100%; }
  .quick-actions .find input { max-width: none; }
  .kpis, .kpis.today { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi { padding: 11px 12px; }
  .kpi .value { font-size: 21px; }
  .task-tiles { display: flex; overflow-x: auto; gap: 8px; margin: 0 -12px 12px; padding: 2px 12px 6px; scroll-snap-type: x mandatory; }
  .task-tile { flex: 0 0 72%; scroll-snap-align: start; }
  .task-panel { padding: 10px; }
  .table-scroll.tall { max-height: none; }
  table.cards-on-phone thead { display: none; }
  table.cards-on-phone, table.cards-on-phone tbody, table.cards-on-phone tr, table.cards-on-phone td { display: block; width: 100%; }
  table.cards-on-phone tr { border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; background: var(--surface); }
  table.cards-on-phone td { border: none; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.cards-on-phone td::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex: 0 0 auto; }
  table.cards-on-phone td.actions { justify-content: flex-end; padding-top: 8px; }
  table.cards-on-phone td.actions::before { display: none; }
  table.cards-on-phone td.actions .row-actions .btn { flex: 1; }
  table.cards-on-phone td.actions .row-actions { width: 100%; }

  /* grids: keep the data on screen */
  .perm-note { display: none; }
  .totals { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px 8px; padding: 0 12px; }
  .chip { flex: 0 0 auto; }

  /* dashboard */
  .main { overflow-x: hidden; }
  .card { overflow-x: auto; }
  .bi-filters { gap: 6px; }
  .bi-filters label { flex: 1 1 100%; min-width: 0; grid-template-columns: minmax(0, 1fr); }
  .bi-filters label select { width: 100%; }
  .cards { gap: 10px; }
  .card { padding: 12px; }
  .chart-box { height: 240px; }
  .chart-box.tall { height: 260px; }
  .attention-item { flex: 1 1 100%; }
  .track-row { grid-template-columns: minmax(96px, 40%) 1fr auto; }
  .mini-stats.two { grid-template-columns: 1fr 1fr; }
  .login-card { padding: 24px; }
}
@media (max-width: 380px) {
  .kpis, .kpis.today, .mini-stats.two, .mini-stats.four, .stage-row { grid-template-columns: 1fr; }
}
@media (display-mode: standalone) {
  .topbar { padding-top: max(14px, env(safe-area-inset-top)); }
}
