/* Multi Sourcing — design system */

:root {
  /* Multi Sourcing brand: sky blue #42B7F9 + ink #231F20 (from the logo) */
  --brand: #42b7f9;
  --brand-ink: #231f20;
  --bg: #f3f6f9;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --border: #e2e8ee;
  --border-strong: #cfd8e1;
  --text: #231f20;
  --text-2: #4b5157;
  --muted: #7d8794;
  --accent: #0b7fcb;
  --accent-2: #1b9be8;
  --accent-soft: #e6f5fe;
  --accent-text: #ffffff;
  --side-bg: #f7f9fb;
  --side-border: #e2e8ee;
  --side-text: #4b5157;
  --side-strong: #231f20;
  --side-muted: #8f98a3;
  --side-hover: rgba(0, 0, 0, .04);
  --seg-bg: #eaeff4;
  --seg-on: #ffffff;
  --logo: #42b7f9;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 24px 48px -12px rgba(16, 24, 40, .25);
  --radius: 12px;
  --radius-sm: 8px;

  --red: #dc2626; --red-bg: #fef2f2;
  --amber: #b45309; --amber-bg: #fffbeb;
  --green: #059669; --green-bg: #ecfdf5;
  --teal: #0f766e; --teal-bg: #f0fdfa;
  --blue: #2563eb; --blue-bg: #eff6ff;
  --sky: #0284c7; --sky-bg: #f0f9ff;
  --indigo: #0b6fb0; --indigo-bg: #e6f5fe;
  --violet: #7c3aed; --violet-bg: #f5f3ff;
  --slate: #475569; --slate-bg: #f1f5f9;

  --chart-in: #42b7f9;
  --chart-out: #cbd5e1;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a1016; --surface: #111a22; --surface-2: #0d151c; --border: #1f2b36; --border-strong: #2c3a47;
    --text: #eef2f6; --text-2: #b8c2cc; --muted: #7f8c99; --accent: #42b7f9; --accent-2: #1b9be8; --accent-soft: #0e2a3d; --accent-text: #0a1016;
    --side-bg: #0d151c; --side-border: #1f2b36; --side-text: #a9b4bf; --side-strong: #f3f6f9; --side-muted: #6c7885;
    --side-hover: rgba(255,255,255,.045); --seg-bg: #16212b; --seg-on: #22313e; --logo: #42b7f9;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-sm: none; --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.6);
    --red: #f87171; --red-bg: #2a1215; --amber: #fbbf24; --amber-bg: #2a1f0b; --green: #34d399; --green-bg: #0b2620;
    --teal: #2dd4bf; --teal-bg: #0a2523; --blue: #60a5fa; --blue-bg: #0e1d36; --sky: #38bdf8; --sky-bg: #0a2030;
    --indigo: #7dcbfa; --indigo-bg: #0e2a3d; --violet: #c4b5fd; --violet-bg: #211a3d; --slate: #a3adc2; --slate-bg: #1b2236;
    --chart-in: #42b7f9; --chart-out: #2c3a47;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #0a1016; --surface: #111a22; --surface-2: #0d151c; --border: #1f2b36; --border-strong: #2c3a47;
    --text: #eef2f6; --text-2: #b8c2cc; --muted: #7f8c99; --accent: #42b7f9; --accent-2: #1b9be8; --accent-soft: #0e2a3d; --accent-text: #0a1016;
    --side-bg: #0d151c; --side-border: #1f2b36; --side-text: #a9b4bf; --side-strong: #f3f6f9; --side-muted: #6c7885;
    --side-hover: rgba(255,255,255,.045); --seg-bg: #16212b; --seg-on: #22313e; --logo: #42b7f9;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-sm: none; --shadow-lg: 0 24px 48px -12px rgba(0,0,0,.6);
    --red: #f87171; --red-bg: #2a1215; --amber: #fbbf24; --amber-bg: #2a1f0b; --green: #34d399; --green-bg: #0b2620;
    --teal: #2dd4bf; --teal-bg: #0a2523; --blue: #60a5fa; --blue-bg: #0e1d36; --sky: #38bdf8; --sky-bg: #0a2030;
    --indigo: #7dcbfa; --indigo-bg: #0e2a3d; --violet: #c4b5fd; --violet-bg: #211a3d; --slate: #a3adc2; --slate-bg: #1b2236;
    --chart-in: #42b7f9; --chart-out: #2c3a47;
    color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
.ico { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-green { color: var(--green); }
.struck { text-decoration: line-through; color: var(--muted); }
.prewrap { white-space: pre-wrap; }
.grow { flex: 1; min-width: 0; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  border-radius: var(--radius-sm); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm); transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, .chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: #fff; box-shadow: 0 1px 2px rgba(11,127,203,.35), 0 4px 12px -4px rgba(66,183,249,.55), inset 0 1px 0 rgba(255,255,255,.18); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--red); border-color: transparent; color: #fff; }
.btn.danger-ghost { color: var(--red); }
.btn.danger-ghost:hover { background: var(--red-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon-only { padding: 0; width: 36px; justify-content: center; }
.btn-block { width: 100%; justify-content: center; height: 42px; }
.btn:disabled { opacity: .6; cursor: progress; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: var(--radius-sm); background: transparent; color: inherit; cursor: pointer; }
.icon-btn:hover { background: rgba(127,127,127,.12); }
.link { font-size: 13px; font-weight: 500; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tone-red { color: var(--red); background: var(--red-bg); }
.tone-amber { color: var(--amber); background: var(--amber-bg); }
.tone-green { color: var(--green); background: var(--green-bg); }
.tone-teal { color: var(--teal); background: var(--teal-bg); }
.tone-blue { color: var(--blue); background: var(--blue-bg); }
.tone-sky { color: var(--sky); background: var(--sky-bg); }
.tone-indigo { color: var(--indigo); background: var(--indigo-bg); }
.tone-violet { color: var(--violet); background: var(--violet-bg); }
.tone-slate { color: var(--slate); background: var(--slate-bg); }
.tone-bg-red { background: var(--red); } .tone-bg-amber { background: var(--amber); } .tone-bg-green { background: var(--green); }
.tone-bg-teal { background: var(--teal); } .tone-bg-blue { background: var(--blue); } .tone-bg-indigo { background: var(--indigo); }
.tone-bg-violet { background: var(--violet); } .tone-bg-slate { background: var(--slate); } .tone-bg-undefined { background: var(--slate); }

/* ---------- brand ---------- */
.logo { width: 34px; height: 34px; flex: none; color: var(--logo); }
.wordmark { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.wordmark > span { display: flex; flex-direction: column; min-width: 0; }
.wm-name { font-weight: 800; font-size: 16px; letter-spacing: .045em; text-transform: uppercase; color: var(--side-strong); line-height: 1.15; white-space: nowrap; }
.wm-tag { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--side-muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- shell & sidebar ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 268px; flex: none; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 12px;
  background: var(--side-bg); border-right: 1px solid var(--side-border); color: var(--side-text); padding: 20px 14px 14px; z-index: 40;
}
.side-brand { display: block; padding: 2px 6px 8px; text-decoration: none !important; }
.side-segs { display: flex; flex-direction: column; gap: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; padding: 3px; border-radius: 12px; background: var(--seg-bg); }
.seg button {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border: 0; border-radius: 9px;
  background: none; color: var(--side-text); font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--side-strong); }
.seg button.on { background: var(--seg-on); color: var(--side-strong); box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px var(--side-border); }
.seg .ico { width: 15px; height: 15px; }
.nav { flex: 1; overflow-y: auto; margin: 4px -6px 0; padding: 2px 6px; scrollbar-width: thin; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-label { font-size: 12.5px; color: var(--side-muted); padding: 2px 12px 6px; font-weight: 500; }
.nav-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 9px 12px; border-radius: 10px;
  color: var(--side-text); font-size: 15px; font-weight: 500; text-decoration: none !important; border: 1px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--side-hover); color: var(--side-strong); }
.nav-item.active { background: var(--seg-on); color: var(--side-strong); font-weight: 600; border-color: var(--side-border); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.nav-meta { font-family: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; font-weight: 400; color: var(--side-muted); white-space: nowrap; letter-spacing: -.01em; }
.nav-meta .warn { color: var(--red); }
.nav-subs { display: flex; flex-direction: column; margin: 4px 0 8px 18px; padding-left: 10px; border-left: 1px solid var(--side-border); }
.nav-subs a { padding: 6px 10px; border-radius: 8px; color: var(--side-muted); font-size: 13.5px; text-decoration: none !important; font-weight: 500; }
.nav-subs a:hover { color: var(--side-strong); background: var(--side-hover); }
.nav-subs a.on { color: var(--side-strong); background: var(--side-hover); }
.side-foot { border-top: 1px solid var(--side-border); padding-top: 10px; margin: 0 -2px; display: flex; flex-direction: column; gap: 6px; }
.side-foot .nav-item { justify-content: flex-start; align-items: center; }
.side-foot .nav-item .ico { width: 17px; height: 17px; }
.side-user { display: flex; align-items: center; gap: 8px; padding: 4px 6px 0; }
.side-user .icon-btn { color: var(--side-muted); width: 30px; height: 30px; }
.side-user .icon-btn:hover { background: var(--side-hover); color: var(--side-strong); }
.me { flex: 1; min-width: 0; }
.me-name { color: var(--side-strong); font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 11.5px; color: var(--side-muted); }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--side-strong); color: var(--side-bg); font-size: 12px; font-weight: 700;
}
.avatar.sm { width: 28px; height: 28px; font-size: 11px; background: var(--accent-soft); color: var(--accent); }
.avatar.sq { border-radius: 8px; }
.avatar.sm .ico { width: 15px; height: 15px; }
.filter-pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px 0 12px; border-radius: 999px; background: var(--text); color: var(--surface); font-size: 13px; font-weight: 500; text-decoration: none !important; }
.filter-pill .ico { width: 14px; height: 14px; opacity: .7; }
.bar-cell { width: 22%; min-width: 90px; }
.pbar { display: block; height: 8px; border-radius: 99px; background: var(--green); opacity: .75; min-width: 2px; }
.pbar.neg { background: var(--red); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; }
.gsearch { position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; }
.gsearch > .ico { position: absolute; left: 12px; color: var(--muted); width: 16px; height: 16px; }
.gsearch input {
  width: 100%; height: 38px; padding: 0 64px 0 36px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit; box-shadow: var(--shadow-sm);
}
.gsearch input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.gsearch kbd { position: absolute; right: 10px; font: 11px/1 inherit; color: var(--muted); border: 1px solid var(--border); border-radius: 5px; padding: 3px 6px; background: var(--surface-2); }
.gresults {
  position: absolute; top: 44px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; max-height: 420px; overflow-y: auto;
}
.gresults a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.gresults a:hover, .gresults a.sel { background: var(--accent-soft); }
.g-label { font-weight: 500; }
.g-empty { padding: 14px; color: var(--muted); text-align: center; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.quick { position: relative; }
.quick-menu {
  position: absolute; right: 0; top: 44px; width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50;
}
.quick-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; color: var(--text); font: inherit; border-radius: 8px; cursor: pointer; text-align: left; }
.quick-menu button:hover { background: var(--accent-soft); }
.quick-menu .ico { color: var(--muted); width: 16px; height: 16px; }
.scrim { display: none; }

.view { padding: 28px; max-width: 1440px; width: 100%; margin: 0 auto; }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-sub { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; justify-content: space-between; }
.toolbar > p { margin: 0; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box .ico { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--muted); }
.search-box input { height: 34px; width: 260px; padding: 0 12px 0 32px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.search-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-right: auto; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; }
.chip span { color: var(--muted); font-size: 12px; margin-left: 2px; }
.chip:hover { border-color: var(--border-strong); }
.chip.active { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip.active span { color: inherit; opacity: .7; }

/* ---------- panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.panel-flush { overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; }
.panel-head h3 { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.panel-head.pad { border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--slate-bg); color: var(--slate); font-size: 11px; font-weight: 600; }
.pad { padding: 0 18px 18px; }
.panel.narrow { max-width: 760px; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; user-select: none;
}
.table th[data-act] { cursor: pointer; }
.table th[data-act]:hover { color: var(--text); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href], .table tbody tr[data-edit], .table tbody tr[data-act] { cursor: pointer; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-main { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12px; color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel > .table-wrap .table th:first-child, .panel > .table-wrap .table td:first-child { padding-left: 18px; }
.stack .panel .table-wrap, .invoice-grid .panel .table-wrap { border-top: 1px solid var(--border); }
.stack .table td, .invoice-grid .table td { white-space: nowrap; }
.stack .table td, .stack .table th, .invoice-grid .table td, .invoice-grid .table th { padding-left: 12px; padding-right: 12px; }
.check { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty-state > .ico { width: 40px; height: 40px; padding: 9px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.empty-state h3 { color: var(--text); margin: 12px 0 4px; font-size: 16px; }
.empty-state p { margin: 0 0 16px; }
.empty-state.small { padding: 36px 20px; }
.empty-mini { margin: 0; padding: 4px 18px 18px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.empty-mini.ok .ico { color: var(--green); }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); overflow: hidden; }
.kpi::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--kc, var(--accent)); opacity: .85; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { color: var(--text-2); font-weight: 500; font-size: 13px; }
.kpi-ico { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--kbg, var(--accent-soft)); color: var(--kc, var(--accent)); }
.kpi-ico .ico { width: 16px; height: 16px; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-indigo { --kc: var(--indigo); --kbg: var(--indigo-bg); }
.kpi-amber { --kc: var(--amber); --kbg: var(--amber-bg); }
.kpi-green { --kc: var(--green); --kbg: var(--green-bg); }
.kpi-sky { --kc: var(--sky); --kbg: var(--sky-bg); }
.kpi-teal { --kc: var(--teal); --kbg: var(--teal-bg); }
.kpi-violet { --kc: var(--violet); --kbg: var(--violet-bg); }
.kpi-red { --kc: var(--red); --kbg: var(--red-bg); }
.kpi-slate { --kc: var(--slate); --kbg: var(--slate-bg); }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; margin-bottom: 18px; }
.dash-grid.three { grid-template-columns: repeat(3, 1fr); }
.dash-grid > .panel:only-child { grid-column: 1 / -1; }

.chart { width: 100%; height: auto; display: block; padding: 0 12px; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .bar-in { fill: var(--chart-in); }
.chart .bar-out { fill: var(--chart-out); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.lg-in { background: var(--chart-in); } .lg-out { background: var(--chart-out); }
.mini-stats { display: flex; gap: 24px; padding: 12px 18px 16px; border-top: 1px solid var(--border); align-items: center; flex-wrap: wrap; }
.mini-stats div { display: flex; flex-direction: column; }
.mini-stats span { font-size: 12px; color: var(--muted); }
.mini-stats strong { font-variant-numeric: tabular-nums; }
.mini-stats .link { margin-left: auto; }

.rem-list { list-style: none; margin: 0; padding: 0 10px 10px; }
.rem-list li { display: flex; align-items: flex-start; gap: 12px; padding: 10px 8px; border-radius: 10px; }
.rem-list li:hover { background: var(--surface-2); }
.rem-list li + li { border-top: 1px solid var(--border); }
.rem-list .check { margin-top: 6px; }
.rem-kind { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; flex: none; }
.rem-kind .ico { width: 15px; height: 15px; }
.rem-body { flex: 1; min-width: 0; }
.rem-title { font-weight: 500; }
.rem-title a { color: var(--text); }
.rem-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 3px; }
.rem-meta .badge { height: 19px; font-size: 11px; }
.more { padding: 0 18px 14px; margin: 0; }

.funnel { list-style: none; margin: 0; padding: 4px 18px 18px; display: flex; flex-direction: column; gap: 10px; }
.funnel li { display: grid; grid-template-columns: 116px 1fr 28px; align-items: center; gap: 10px; }
.funnel-bar { height: 8px; background: var(--slate-bg); border-radius: 99px; overflow: hidden; }
.funnel-bar .fill { display: block; height: 100%; border-radius: 99px; min-width: 2px; opacity: .85; }
.funnel-n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.people { list-style: none; margin: 0; padding: 0 18px 12px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.people li + li { border-top: 1px solid var(--border); }
.people li > a { flex: 1; color: var(--text); font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people .grow a { color: var(--text); font-weight: 500; }
.people strong { font-variant-numeric: tabular-nums; }

/* ---------- record page ---------- */
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; margin-bottom: 14px; font-size: 13px; }
.back .ico { width: 15px; height: 15px; }
.back:hover { color: var(--text); text-decoration: none; }
.record-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 18px; }
.record-title { display: flex; gap: 14px; align-items: center; min-width: 0; }
.record-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); flex: none; }
.record-ico .ico { width: 22px; height: 22px; }
.record-title h1 { font-size: 22px; font-weight: 700; }
.record-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.stat-value { font-size: 19px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-value small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.stat.warn .stat-value { color: var(--amber); }
.stat.bad .stat-value { color: var(--red); }
.stat.good .stat-value { color: var(--green); }
.record-grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 18px; align-items: start; }
.dl { margin: 0; padding: 0 18px 12px; }
.dl-row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.dl-row dt { color: var(--muted); font-size: 13px; }
.dl-row dd { margin: 0; word-break: break-word; }
.dl-full { grid-template-columns: 1fr; gap: 4px; }

/* ---------- invoice ---------- */
.invoice-grid { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.invoice-doc { position: relative; background: #fff; color: #111827; border: 1px solid var(--border); border-radius: var(--radius); padding: 40px 44px; box-shadow: var(--shadow); overflow: hidden; }
.invoice-doc .muted { color: #6b7280; }
.inv-top { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 24px; border-bottom: 2px solid #111827; }
.inv-brand { margin-bottom: 12px; }
.inv-brand .logo { width: 40px; height: 40px; }
.inv-brand .wm-name { font-size: 19px; }
.inv-from { color: #6b7280; font-size: 13px; }
.inv-meta { text-align: right; }
.inv-word { font-size: 28px; font-weight: 800; letter-spacing: .12em; color: #1597e0; margin-bottom: 8px; }
.inv-meta table { margin-left: auto; font-size: 13px; border-collapse: collapse; }
.inv-meta td { padding: 2px 0 2px 16px; }
.inv-meta td:first-child { color: #6b7280; }
.inv-meta td:last-child { font-weight: 600; }
.inv-to { padding: 22px 0; }
.inv-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; font-weight: 600; margin-bottom: 4px; }
.inv-items { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv-items th { text-align: left; padding: 10px 8px; background: #f3f4f6; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #4b5563; }
.inv-items td { padding: 11px 8px; border-bottom: 1px solid #e5e7eb; }
.inv-items .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-pays { margin-top: 22px; }
.inv-pays small { color: #6b7280; }
.inv-pays tr.bounced td { color: #b91c1c; text-decoration: line-through; }
.inv-bottom { display: flex; justify-content: space-between; gap: 24px; padding-top: 18px; }
.inv-notes { flex: 1; font-size: 13px; }
.inv-totals { border-collapse: collapse; min-width: 280px; font-size: 13px; }
.inv-totals td { padding: 6px 0; }
.inv-totals td:last-child { text-align: right; font-variant-numeric: tabular-nums; padding-left: 24px; }
.inv-total td { font-weight: 700; font-size: 15px; border-top: 1px solid #e5e7eb; padding-top: 10px; }
.inv-due td { font-weight: 700; color: #0b7fcb; font-size: 15px; border-top: 2px solid #111827; padding-top: 10px; }
.inv-foot { margin-top: 36px; padding-top: 16px; border-top: 1px solid #e5e7eb; text-align: center; color: #6b7280; font-size: 12px; }
.inv-stamp { position: absolute; top: 120px; right: 40px; transform: rotate(-14deg); border: 3px solid #059669; color: #059669; font-weight: 800; font-size: 26px; letter-spacing: .2em; padding: 4px 16px; border-radius: 8px; opacity: .55; }

/* ---------- statement (My Money) ---------- */
.month-nav { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 2px; box-shadow: var(--shadow-sm); }
.month-nav span { min-width: 92px; text-align: center; font-weight: 600; }
.statement { padding: 0 18px 18px; }
.st-head { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 14px 0 4px; }
.st-line { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.st-sub { border-top: 1px solid var(--border); font-weight: 600; }
.st-total { border-top: 2px solid var(--text); font-weight: 700; font-size: 15px; margin-top: 4px; padding-top: 9px; }
.st-note { margin-top: 14px; font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 8px; padding: 10px 12px; }

/* ---------- settings ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 14px; }
.cat-chip { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--slate-bg); font-size: 13px; }
.cat-chip button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.cat-chip button:hover { background: var(--red-bg); color: var(--red); }
.cat-chip .ico { width: 12px; height: 12px; }
.cat-add { display: flex; gap: 8px; padding: 0 18px 18px; }
.cat-add input { flex: 1; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 18px; }

/* ---------- forms & modal ---------- */
.modal { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
.modal-sm { width: min(440px, calc(100vw - 32px)); }
.modal::backdrop { background: rgba(10, 14, 28, .55); backdrop-filter: blur(3px); }
.modal[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.mform { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.modal:has(.mform-wide) { width: min(880px, calc(100vw - 32px)); }
.mhead { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.mhead h2 { font-size: 17px; font-weight: 600; }
.mbody { padding: 20px 22px; overflow-y: auto; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 16px 16px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full, .form-sec { grid-column: 1 / -1; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.req { color: var(--red); font-style: normal; }
.field input, .field select, .field textarea, .item-row input {
  height: 38px; padding: 0 11px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit; width: 100%; transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; padding: 9px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .item-row input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.hint { font-size: 12px; color: var(--muted); }
.check-field { flex-direction: row; align-items: center; gap: 10px; padding-top: 24px; }
.check-field input { width: 17px; height: 17px; accent-color: var(--accent); }
.form-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; padding-top: 6px; border-top: 1px solid var(--border); margin-top: 4px; }
.form-sec:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.ferr { display: flex; gap: 8px; align-items: center; margin-top: 14px; padding: 10px 12px; border-radius: 8px; background: var(--red-bg); color: var(--red); font-weight: 500; }
.ferr .ico { width: 16px; height: 16px; }
.confirm-body { display: flex; gap: 14px; }
.confirm-body h2 { font-size: 16px; margin-bottom: 4px; }
.confirm-body p { margin: 0; }
.confirm-ico { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--red-bg); color: var(--red); flex: none; }

.items { margin-top: 20px; border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-2); }
.items-title { font-weight: 600; margin-bottom: 10px; }
.items-head, .item-row { display: grid; grid-template-columns: 1fr 80px 120px 120px 34px; gap: 8px; align-items: center; }
.items-head { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 0 2px 6px; }
.items-head .num, .item-amt { text-align: right; font-variant-numeric: tabular-nums; }
.item-row { margin-bottom: 8px; }
.item-row input { height: 36px; }
.item-amt { font-weight: 500; }
.items-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.items-total { font-size: 15px; }
.items-total strong { margin-left: 8px; font-size: 17px; }

/* ---------- invoice editor with live preview ---------- */
.modal:has(.mform-live) { width: min(1340px, calc(100vw - 32px)); }
.mbody-live { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 22px; align-items: start; }
.live-form .items { margin-top: 18px; }
.live-preview { position: sticky; top: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px 14px; }
.live-label { display: flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 10px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #10b981; animation: live-pulse 1.8s ease-out infinite; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.55); } 70%, 100% { box-shadow: 0 0 0 7px rgba(16,185,129,0); } }
.live-preview .invoice-doc { zoom: .74; box-shadow: 0 1px 3px rgba(16,24,40,.08); }
@media (max-width: 1100px) {
  .mbody-live { grid-template-columns: 1fr; }
  .live-preview { position: static; }
  .live-preview .invoice-doc { zoom: .85; }
}
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }

/* ---------- access: login editor ---------- */
.ue-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; margin: 22px 0 10px; }
.ue-sec:first-child { margin-top: 0; }
.ue-sec small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.ue-sec-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.ue-quick { text-transform: none; letter-spacing: 0; font-weight: 500; display: flex; gap: 4px; align-items: center; }
.link-btn { border: 0; background: none; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 2px 6px; border-radius: 6px; }
.link-btn:hover { background: var(--accent-soft); }
.ue-hint { margin: -4px 0 10px; }
.ue-link { margin-top: 14px; }
.role-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.role-card { position: relative; display: flex; gap: 10px; padding: 12px; border: 1px solid var(--border-strong); border-radius: 12px; cursor: pointer; background: var(--surface); transition: border-color .15s, box-shadow .15s; }
.role-card input { position: absolute; opacity: 0; pointer-events: none; }
.role-card strong { display: block; font-size: 13.5px; }
.role-card small { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; margin-top: 2px; }
.role-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--slate-bg); color: var(--slate); flex: none; }
.role-ico .ico { width: 16px; height: 16px; }
.role-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.role-card:has(input:checked) .role-ico { background: var(--accent-soft); color: var(--accent); }
.role-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.perm-name strong { display: block; font-size: 13.5px; }
.perm-name small { color: var(--muted); font-size: 12px; }
.pseg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--seg-bg); flex: none; }
.pseg label { position: relative; cursor: pointer; }
.pseg input { position: absolute; opacity: 0; pointer-events: none; }
.pseg span { display: block; padding: 4px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--side-text); }
.pseg input:checked + span { background: var(--seg-on); color: var(--side-strong); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.pseg label:first-child input:checked + span { color: var(--muted); }
.pseg label:nth-child(2) input:checked + span { color: var(--blue); }
.pseg label:nth-child(3) input:checked + span { color: var(--green); }
.pseg input:focus-visible + span { outline: 2px solid var(--accent); }
.grant-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.grant-list p { margin: 0; }
.grant-chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 4px 0 10px; border-radius: 999px; background: var(--accent-soft); color: var(--text); font-size: 13px; }
.grant-chip b { color: var(--accent); font-weight: 600; }
.grant-chip button { display: grid; place-items: center; width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; }
.grant-chip button:hover { background: var(--red-bg); color: var(--red); }
.grant-chip .ico { width: 12px; height: 12px; }
.grant-add, .share-add { display: flex; gap: 8px; flex-wrap: wrap; }
.grant-add select, .share-add select { height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; min-width: 0; }
.grant-add #grant-rec, .share-add select { flex: 1; }
.mfoot-left { margin-right: auto; }
.view-only { gap: 5px; height: 30px; padding: 0 12px; }
.view-only .ico { width: 14px; height: 14px; }
.ghost-btn { border-color: transparent; box-shadow: none; color: var(--muted); }
.ghost-btn:hover { color: var(--red); background: var(--red-bg); }

/* ---------- share dialog & people picker ---------- */
.share-intro { margin: 0 0 14px; }
.share-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.share-row, .link-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; }
.share-row { border: 1px solid var(--border); }
.link-search { margin-bottom: 10px; }
.link-search input { width: 100%; }
.link-list { display: flex; flex-direction: column; max-height: 50vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; }
.link-row { cursor: pointer; border-radius: 0; }
.link-row + .link-row { border-top: 1px solid var(--border); }
.link-row:hover { background: var(--surface-2); }
.link-row .grow { display: flex; flex-direction: column; }

/* ---------- tracking cards & order timeline ---------- */
.shared-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 16px; align-items: start; }
.timeline li { padding: 0 3px; }
.shared-card .tl-label { font-size: 11px; }
.shared-head { display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px 6px; }
.shared-head h3 { font-size: 17px; }
.shared-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); font-weight: 600; }
.record-ico.sm { width: 38px; height: 38px; border-radius: 11px; }
.record-ico.sm .ico { width: 18px; height: 18px; }
.section-title { font-size: 17px; margin: 8px 0 -4px; }
.timeline-panel { padding: 18px 22px; margin-bottom: 18px; }
.timeline { list-style: none; margin: 6px 0 4px; padding: 0; display: flex; }
.timeline li { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; min-width: 0; }
.timeline li::before { content: ""; position: absolute; top: 11px; right: 50%; width: 100%; height: 2px; background: var(--border-strong); z-index: 0; }
.timeline li:first-child::before { display: none; }
.timeline li.done::before, .timeline li.now::before { background: var(--green); }
.tl-dot { position: relative; z-index: 1; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); color: #fff; }
.tl-dot .ico { width: 13px; height: 13px; stroke-width: 3; }
.timeline li.done .tl-dot { background: var(--green); border-color: var(--green); }
.timeline li.now .tl-dot { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-bg); }
.timeline li.now .tl-dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--green); }
.tl-label { font-size: 12px; color: var(--muted); font-weight: 500; line-height: 1.25; }
.timeline li.done .tl-label { color: var(--text-2); }
.timeline li.now .tl-label { color: var(--text); font-weight: 700; }
.timeline-cancel { display: flex; gap: 10px; align-items: center; color: var(--muted); }
@media (max-width: 860px) {
  .role-grid { grid-template-columns: 1fr 1fr; }
  .perm-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .tl-label { font-size: 10.5px; }
  .shared-grid { grid-template-columns: 1fr; }
}

/* ---------- orders: product lines ---------- */
.fgrid > .items { grid-column: 1 / -1; margin-top: 4px; }
.items-head.ord, .item-row.ord { grid-template-columns: minmax(110px, 1.1fr) minmax(120px, 1.5fr) 92px 92px 104px 136px 110px 34px; }
.item-row select { height: 36px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; width: 100%; min-width: 0; }
.item-row select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.item-row input { min-width: 0; }
.idate { display: flex; flex-direction: column; min-width: 0; }
.idate > span { display: none; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.idate input { width: 100%; }
.item-row input.date-late { border-color: var(--red, #dc2626); background: color-mix(in srgb, var(--red, #dc2626) 8%, var(--surface)); }
@media (max-width: 1000px) { .item-row.pur .idate > span { display: block; } }
@media (max-width: 760px) { .item-row.ord .idate > span { display: block; } }
.items-panel { margin-bottom: 18px; }
.items-panel .table td { vertical-align: top; }
.pad-top { padding-top: 14px; }
.nowrap { white-space: nowrap; }
.mini-items { list-style: none; margin: 0; padding: 0; }
.mini-items li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; align-items: baseline; }
.mini-items li + li { border-top: 1px solid var(--border); }
.portal-item { white-space: nowrap; line-height: 1.6; }
@media (max-width: 760px) {
  .items-head.ord { display: none; }
  .item-row.ord { grid-template-columns: 1fr 1fr 1fr 34px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
  .item-row.ord [data-i=product], .item-row.ord [data-i=details] { grid-column: 1 / -1; }
  .item-row.ord .item-amt { display: block; grid-column: 1 / -2; text-align: left; }
}

/* ---------- orders: sourcing ---------- */
.modal:has(.mform-xl) { width: min(1280px, calc(100vw - 32px)); }
.mform-xl .fgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.mform-xl .field.full, .mform-xl .form-sec { grid-column: 1 / -1; }
.items-head.pur, .item-row.pur { grid-template-columns: minmax(100px, 1fr) minmax(110px, 1.2fr) minmax(130px, 1.2fr) 80px 86px 92px 120px 136px 100px 34px; }
.items[data-kind="purchases"] { background: color-mix(in srgb, var(--amber-bg) 55%, var(--surface-2)); }
.items + .items { margin-top: 14px; }
.row-muted td { opacity: .55; }
.progress-cell { display: flex; align-items: center; gap: 8px; }
.progress { display: block; width: 64px; height: 6px; border-radius: 99px; background: var(--slate-bg); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 99px; }
.supplier-split { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.split-chip { display: inline-flex; gap: 6px; align-items: center; height: 28px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.split-chip b { font-weight: 600; }
.stars { color: #f59e0b; letter-spacing: 1px; }
.stars .muted { color: var(--border-strong); }
@media (max-width: 1100px) {
  .mform-xl .fgrid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1000px) {
  .items-head.pur { display: none; }
  .item-row.pur { grid-template-columns: 1fr 1fr 1fr 34px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
  .item-row.pur [data-i=item], .item-row.pur [data-i=details], .item-row.pur [data-i=supplier_id] { grid-column: 1 / -1; }
  .item-row.pur .item-amt { display: block; grid-column: 1 / -2; text-align: left; }
}
@media (max-width: 600px) {
  .mform-xl .fgrid { grid-template-columns: 1fr; }
}

/* ---------- orders: product cards with their own materials ---------- */
.fgrid > .pcards-wrap, .fgrid > .order-summary, .fgrid > .cost-summary, .fgrid > .lines-wrap { grid-column: 1 / -1; }
.item-row.chq { grid-template-columns: repeat(3, minmax(0, 1fr)) 28px; gap: 8px 10px; padding: 10px 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.item-row.chq .item-amt, .items-head[hidden] { display: none; }
.item-row.chq [data-act=rm-item] { grid-column: 4; grid-row: 1; align-self: end; }
.ilab { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ilab > span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.ilab input, .ilab select { width: 100%; min-width: 0; }
@media (max-width: 760px) {
  .items-head.chq { display: none; }
  .item-row.chq { grid-template-columns: repeat(2, minmax(0, 1fr)) 28px; }
  .item-row.chq [data-act=rm-item] { grid-column: 3; }
}
.items-head.cst, .item-row.cst { grid-template-columns: minmax(130px, 1.1fr) minmax(150px, 1.8fr) 96px 92px 100px 110px 34px; }
.cs { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.panel .cs { margin: 0 16px 16px; }
.cs-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.cs-row { display: grid; grid-template-columns: 1.2fr 1fr auto 40px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.cs-row .num { text-align: right; font-variant-numeric: tabular-nums; }
.cs-bar { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; }
.cs-bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.cs-totals { display: flex; flex-direction: column; gap: 6px; border-left: 1px solid var(--border); padding-left: 16px; }
.cs-totals > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-size: 13px; flex-wrap: wrap; }
.cs-totals span { color: var(--muted); }
.cs-totals strong { font-variant-numeric: tabular-nums; }
.cs-price { padding: 8px 10px; margin: 2px -10px; border-radius: 8px; background: color-mix(in srgb, var(--brand) 12%, transparent); }
.cs-price strong { font-size: 17px; color: var(--accent); }
.cs-price small { width: 100%; text-align: right; color: var(--muted); }
.cs-table .cs-group td { font-weight: 600; background: var(--bg); }
@media (max-width: 760px) {
  .cs { grid-template-columns: 1fr; }
  .cs-totals { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 10px; }
  .items-head.cst { display: none; }
  .item-row.cst { grid-template-columns: 1fr 1fr; }
}
.pcards-wrap { margin-top: 6px; }
.pcards-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-weight: 600; margin-bottom: 10px; }
.pcards { display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }
.pcard { border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; }
.pcard-head { display: grid; grid-template-columns: 30px minmax(130px, 1.2fr) minmax(150px, 1.7fr) 96px 96px 116px 140px 130px 34px; gap: 10px; align-items: end; padding: 14px 14px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.pcard-no { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.pfield { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pfield > span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.pfield input, .pfield select { height: 38px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; width: 100%; min-width: 0; }
.pfield [data-p=product] { font-weight: 600; }
.pfield input:focus, .pfield select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pf-amt strong { height: 38px; display: flex; align-items: center; justify-content: flex-end; font-size: 15px; font-variant-numeric: tabular-nums; }
.pcard-head > .icon-btn { margin-bottom: 2px; }
.pcard .items { margin: 0; border: 0; border-radius: 0; background: color-mix(in srgb, var(--amber-bg) 45%, var(--surface)); }
.pcard .items-title { font-size: 12.5px; color: var(--text-2); }
.pcard-foot { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 10px 14px; border-top: 1px dashed var(--border-strong); font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.pcard-foot:empty { display: none; }
.order-summary { display: grid; grid-template-columns: repeat(6, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin: 6px 0 4px; }
.order-summary > div { background: var(--surface-2); padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.order-summary span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.order-summary strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.order-summary .sum-margin { background: var(--green-bg); }
.order-summary small { font-size: 12px; font-weight: 500; }
.group-row td { background: var(--surface-2); font-size: 13px; padding-top: 9px; padding-bottom: 9px; }
.table tbody tr.group-row:hover td { background: var(--surface-2); }
@media (max-width: 1100px) {
  /* Product + details on the first row, then qty / unit / price / delivery date, then the amount. */
  .pcard-head { grid-template-columns: repeat(4, minmax(0, 1fr)) 34px; }
  .pcard-head > .pcard-no { display: none; }
  .pf-product { grid-column: 1 / 3; }
  .pf-details { grid-column: 3 / 5; }
  .pcard-head > .icon-btn { grid-column: 5; grid-row: 1; }
  .pf-amt { grid-column: 1 / 3; }
  .pf-amt strong { justify-content: flex-start; }
  .order-summary { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .pcard-head { grid-template-columns: 1fr 1fr 34px; }
  .pcard-no { display: none; }
  .pf-product, .pf-details { grid-column: 1 / 3; }
  .pcard-head > .icon-btn { grid-column: 3; }
  .order-summary { grid-template-columns: 1fr 1fr; }
}

/* ---------- bulk selection ---------- */
.table th.sel, .table td.sel { width: 40px; padding-left: 16px; padding-right: 4px; cursor: pointer; }
.table tbody tr.selected td { background: color-mix(in srgb, var(--accent-soft) 75%, var(--surface)); }
.bulk-bar { position: sticky; top: 72px; z-index: 20; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; padding: 8px 10px 8px 14px; border-radius: 12px; background: var(--brand-ink); color: #fff; box-shadow: var(--shadow-lg); animation: slide .15s ease-out; }
.bulk-bar .bulk-count { display: flex; align-items: center; gap: 6px; margin-right: auto; }
.bulk-bar .bulk-count .ico { width: 16px; height: 16px; color: var(--brand); }
.bulk-bar .btn { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #fff; box-shadow: none; }
.bulk-bar .btn:hover { background: rgba(255,255,255,.16); }
.bulk-bar .btn.danger-ghost { color: #fca5a5; }
.bulk-bar .ghost-btn { border-color: transparent; color: #cbd5e1; }
.bulk-intro { margin: 0 0 12px; }
.bulk-fields { display: flex; flex-direction: column; gap: 8px; }
.bulk-field { display: grid; grid-template-columns: 34px 1fr; align-items: end; gap: 6px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.bulk-field:has([data-bulk-on]:checked) { border-color: var(--accent); background: var(--accent-soft); }
.bulk-tick { display: grid; place-items: center; height: 38px; }
.bulk-field .check-field { padding-top: 0; height: 38px; }

/* ---------- roles ---------- */
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.role-card-view { display: flex; flex-direction: column; }
.role-card-view .panel-head { align-items: flex-start; }
.role-card-view .panel-head p { margin: 4px 0 0; }
.role-card-view .pad { flex: 1; }
.role-actions { display: flex; gap: 8px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.role-pages { display: flex; flex-wrap: wrap; gap: 6px; }
.rp { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; font-size: 13px; font-weight: 500; background: var(--slate-bg); color: var(--text-2); }
.rp small { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.rp-edit { background: var(--green-bg); color: var(--green); }
.rp-view { background: var(--accent-soft); color: var(--accent); }
.role-summary { margin: 2px 0 6px; }

/* ---------- live status ---------- */
.pdot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--border-strong); flex: none; }
.pdot.online { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.pdot.away { background: #f59e0b; }
.pdot.offline { background: #cbd5e1; }
.pdot.off { background: transparent; border: 1.5px solid var(--muted); }
:root[data-theme="dark"] .pdot.offline { background: #3b4a58; }
.pres { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.pres-online { color: var(--green); font-weight: 600; }
.pres-away { color: var(--amber); }
.live-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; margin: 0 0 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); font-size: 13.5px; }
.live-summary .pres { color: var(--text-2); font-weight: 500; }
.live-summary .pres strong { color: var(--text); }
.live-tag { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; font-size: 11px; }
.panel-head h3 .live-tag { margin-left: 8px; }
.online-pill { display: flex; align-items: center; gap: 8px; padding: 6px 12px; margin: 0 2px 2px; border-radius: 9px; font-size: 13px; font-weight: 500; color: var(--side-text); text-decoration: none !important; }
.online-pill:hover { background: var(--side-hover); color: var(--side-strong); }
.team-live { margin-bottom: 18px; }
.team-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 12px; padding: 0 18px 16px; }
.tm { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 10px; }
.tm .avatar { position: relative; }
.tm .avatar .pdot { position: absolute; right: -2px; bottom: -2px; width: 11px; height: 11px; border: 2px solid var(--surface); box-shadow: none; }
.tm strong { font-size: 13.5px; }
.sess-wrap { flex: none; overflow: visible; padding-top: 0; border-top: 1px solid var(--border); }
.sess-list { display: flex; flex-direction: column; gap: 6px; }
.sess { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.sess strong { font-size: 13.5px; }
.sess .muted { margin-left: auto; }

/* ---------- live avatars in the top bar (like a shared spreadsheet) ---------- */
.live-avatars { display: flex; align-items: center; padding-left: 8px; }
.live-avatars:empty { display: none; }
.la { position: relative; margin-left: -8px; text-decoration: none !important; }
.la-face { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--tone, var(--slate)); color: #fff; font-size: 12px; font-weight: 700; border: 2px solid var(--bg); box-shadow: 0 0 0 2px #10b981; transition: transform .15s; }
.la-away .la-face { box-shadow: 0 0 0 2px #f59e0b; opacity: .8; }
.la-more .la-face { background: var(--slate-bg); color: var(--text-2); box-shadow: none; }
.la:hover .la-face { transform: translateY(-2px); z-index: 2; position: relative; }
.la-tip { display: none; position: absolute; right: 0; top: 44px; z-index: 60; min-width: 220px; max-width: 300px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); color: var(--text); flex-direction: column; gap: 4px; white-space: normal; }
.la:hover .la-tip, .la:focus-visible .la-tip { display: flex; }
.la-tip strong { font-size: 13.5px; }
.la-tip .pres { font-size: 12.5px; }
.la-act { font-size: 12.5px; color: var(--text-2); padding-top: 4px; border-top: 1px solid var(--border); margin-top: 2px; }
.activity { color: var(--accent); font-weight: 500; }
@media (max-width: 860px) { .live-avatars .la:nth-child(n+3) { display: none; } }

/* ---------- dashboard (main screen) ---------- */
.dash { display: flex; flex-direction: column; gap: 18px; }
.dash > * { margin-bottom: 0 !important; }
.dash .dash-grid { align-items: start; }
.dash .rem-list { max-height: 430px; overflow-y: auto; }
.dash .feed { max-height: 520px; overflow-y: auto; }
.dash-hero {
  position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  padding: 22px 24px; border-radius: 16px; color: #fff;
  background: radial-gradient(700px 260px at 95% -40%, rgba(66,183,249,.55), transparent 60%), radial-gradient(500px 220px at -10% 140%, rgba(66,183,249,.25), transparent 60%), #1b1819;
  box-shadow: var(--shadow);
}
.dash-hero h1 { font-size: 26px; font-weight: 700; color: #fff; }
.hero-date { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: #9fd8fb; font-weight: 600; margin-bottom: 4px; }
.hero-sub { margin: 6px 0 0; color: #cfd8e1; font-size: 14.5px; }
.dash-hero .btn:not(.primary) { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); color: #fff; box-shadow: none; }
.dash-hero .btn:not(.primary):hover { background: rgba(255,255,255,.15); }
.ghost-plain .ico { transform: rotate(0deg); }

.attention { padding: 0; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.att {
  --c: var(--slate); --bgc: var(--slate-bg);
  display: grid; grid-template-columns: 38px 1fr; grid-template-rows: auto auto; column-gap: 10px; row-gap: 2px; align-items: center;
  padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c);
  box-shadow: var(--shadow-sm); color: var(--text); text-decoration: none !important; transition: transform .12s, box-shadow .12s;
}
.att:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.att-ico { grid-row: 1 / 3; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--bgc); color: var(--c); }
.att-ico .ico { width: 18px; height: 18px; }
.att-main { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.att-n { font-size: 22px; font-weight: 800; color: var(--c); font-variant-numeric: tabular-nums; line-height: 1.1; }
.att-label { font-weight: 600; font-size: 13.5px; }
.att-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-red { --c: var(--red); --bgc: var(--red-bg); }
.att-amber { --c: var(--amber); --bgc: var(--amber-bg); }
.att-blue { --c: var(--blue); --bgc: var(--blue-bg); }
.att-teal { --c: var(--teal); --bgc: var(--teal-bg); }
.att-violet { --c: var(--violet); --bgc: var(--violet-bg); }
.all-clear { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: 12px; background: var(--green-bg); color: var(--green); border: 1px solid color-mix(in srgb, var(--green) 25%, transparent); }
.all-clear .ico { width: 22px; height: 22px; }
.all-clear div { color: var(--text-2); }
.all-clear strong { color: var(--green); }

.kpi-link { color: inherit; text-decoration: none !important; transition: transform .12s, box-shadow .12s, border-color .12s; }
.kpi-link:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--kc, var(--brand)) 40%, var(--border)); }
.kpi-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.kpi-sep { width: 3px; height: 3px; border-radius: 50%; background: var(--border-strong); }
.trend { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.trend.good { color: var(--green); background: var(--green-bg); }
.trend.bad { color: var(--red); background: var(--red-bg); }
.trend.flat { color: var(--muted); background: var(--slate-bg); }

.funnel-row { display: grid; grid-template-columns: 116px 1fr 28px; align-items: center; gap: 10px; color: inherit; text-decoration: none !important; padding: 3px 4px; margin: -3px -4px; border-radius: 8px; }
.funnel-row:hover { background: var(--surface-2); }
.funnel li { display: block; }

.src-counts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 0 18px 12px; }
.src-c { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; color: var(--muted); text-decoration: none !important; text-align: center; line-height: 1.2; }
.src-c:hover { border-color: var(--accent); color: var(--accent); }
.src-n { font-size: 18px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.src-list { list-style: none; margin: 0; padding: 0 10px 12px; }
.src-list a { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; color: var(--text); text-decoration: none !important; }
.src-list a:hover { background: var(--surface-2); }
.src-list li + li a { border-top: 1px solid var(--border); border-radius: 0; }
.src-when { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

.feed { list-style: none; margin: 0; padding: 0 12px 10px; }
.feed-row { display: grid; grid-template-columns: 32px 1fr auto; gap: 10px; align-items: flex-start; padding: 9px 6px; }
.feed-row + .feed-row { border-top: 1px solid var(--border); }
.feed-ico { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; }
.feed-ico .ico { width: 15px; height: 15px; }
.feed-text { font-size: 13.5px; line-height: 1.45; }
.feed-text a { font-weight: 600; }
.feed-amt { display: inline-block; padding: 0 7px; border-radius: 999px; background: var(--slate-bg); color: var(--text-2); font-weight: 600; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.feed-amt.in { background: var(--green-bg); color: var(--green); }
.feed-detail { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.feed-time { font-size: 12px; color: var(--muted); white-space: nowrap; padding-top: 2px; }
.feed-day { position: sticky; top: 64px; z-index: 1; padding: 10px 18px 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--muted); background: var(--surface); border-bottom: 1px solid var(--border); }
.feed-page { padding-bottom: 6px; }
.feed-more { display: flex; justify-content: center; padding: 10px 0 14px; }
.dash-foot { text-align: center; margin: -4px 0 0; }
@media (max-width: 760px) {
  .dash-hero { padding: 18px; }
  .dash-hero h1 { font-size: 21px; }
  .src-counts { grid-template-columns: repeat(3, 1fr); }
  .feed-row { grid-template-columns: 30px 1fr; }
  .feed-time { grid-column: 2; padding-top: 0; }
}

/* ---------- update banner ---------- */
.update-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 120; display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 12px; background: #111827; color: #fff; box-shadow: var(--shadow-lg); font-weight: 500; animation: slide .2s ease-out; }
.update-bar .ico { width: 16px; height: 16px; color: #fbbf24; }

/* ---------- brand & UX polish ---------- */
h1, h2, h3, .wm-name, .inv-word, .auth-art h1 { font-family: Montserrat, Inter, "Segoe UI", system-ui, sans-serif; }
.page-head h1, .record-title h1 { font-weight: 700; letter-spacing: -.01em; }
::selection { background: rgba(66,183,249,.28); }
.logo { width: 38px; height: 38px; }
.wm-name { font-weight: 800; letter-spacing: .03em; }
.wm-tag { letter-spacing: .045em; font-size: 9px; }
.side-brand .wordmark { max-width: 100%; gap: 9px; }
.side-brand .logo { width: 34px; height: 34px; }
.side-brand .wm-tag { letter-spacing: .03em; }
.side-brand .wordmark > span { min-width: 0; }
.nav-item.active { box-shadow: inset 3px 0 0 var(--brand), 0 1px 2px rgba(0,0,0,.05); }
.nav-subs a.on { color: var(--accent); background: var(--accent-soft); }
.nav-subs { border-left-color: color-mix(in srgb, var(--brand) 40%, var(--side-border)); }
.seg button.on { color: var(--side-strong); }
.kpi::after { background: linear-gradient(90deg, var(--kc, var(--brand)), color-mix(in srgb, var(--kc, var(--brand)) 40%, transparent)); }
.kpi-value { font-family: Inter, system-ui, sans-serif; }
.chip.active, .filter-pill { background: var(--brand-ink); border-color: var(--brand-ink); color: #fff; }
:root[data-theme="dark"] .chip.active, :root[data-theme="dark"] .filter-pill { background: var(--accent); border-color: var(--accent); color: #0a1016; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.active, :root:not([data-theme="light"]) .filter-pill { background: var(--accent); border-color: var(--accent); color: #0a1016; } }
.tabs a.active { color: var(--accent); border-bottom-color: var(--brand); }
.empty-state > .ico { background: var(--accent-soft); color: var(--accent); }
.table tbody tr[data-href]:hover td, .table tbody tr[data-edit]:hover td { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }
.inv-logo { height: 92px; width: auto; display: block; margin: -6px 0 6px -6px; }
.brand-mobile .logo-full { height: 84px; }
.auth-form .logo-full { height: 96px; width: auto; align-self: flex-start; margin: -8px 0 4px -8px; }

/* thin progress bar while a page loads */
#busy { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 200; background: linear-gradient(90deg, var(--brand), var(--accent)); box-shadow: 0 0 10px rgba(66,183,249,.6); opacity: 0; transition: width .5s ease, opacity .3s; }
body.busy #busy { opacity: 1; width: 70%; transition: width 6s cubic-bezier(.1,.6,.2,1), opacity .1s; }

/* live order totals pinned in the form footer */
.mfoot-summary { margin-right: auto; display: flex; gap: 18px; align-items: center; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.mfoot-summary strong { color: var(--text); font-size: 14px; }
.mfoot-summary .text-green, .mfoot-summary .text-red { font-weight: 700; }
@media (max-width: 760px) { .mfoot-summary { display: none; } }

/* ---------- toasts ---------- */
#toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 10px; background: #111827; color: #fff; box-shadow: var(--shadow-lg); font-weight: 500; animation: slide .2s ease-out; transition: opacity .3s, transform .3s; }
.toast .ico { width: 16px; height: 16px; }
.toast-ok .ico { color: #34d399; }
.toast-err { background: #7f1d1d; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes slide { from { opacity: 0; transform: translateY(10px); } }

/* ---------- auth ---------- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-art { position: relative; overflow: hidden; background: radial-gradient(900px 520px at -5% -10%, rgba(66,183,249,.38) 0%, transparent 60%), radial-gradient(800px 480px at 110% 115%, rgba(66,183,249,.22) 0%, transparent 55%), #1a1718; color: #c7cde0; display: flex; align-items: center; padding: 64px; }
.auth-art::after { content: ""; position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px); background-size: 44px 44px; mask-image: radial-gradient(circle at 30% 40%, #000, transparent 75%); }
.auth-art-inner { position: relative; z-index: 1; max-width: 520px; }
.brand-lg { margin-bottom: 56px; }
.brand-lg .wordmark { --side-strong: #fff; --side-muted: #9fb4c4; --logo: #42b7f9; }
.brand-lg .logo { width: 44px; height: 44px; }
.brand-lg .wm-name { font-size: 20px; }
.auth-art h1 { color: #fff; font-size: 40px; line-height: 1.15; font-weight: 700; letter-spacing: -.03em; }
.auth-art p { font-size: 16px; margin: 16px 0 28px; }
.auth-points { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.auth-points li { display: flex; gap: 10px; align-items: center; }
.auth-points .ico { color: #34d399; }
.auth-form-wrap { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth-form h2 { font-size: 26px; font-weight: 700; }
.auth-form > p { margin: -6px 0 6px; }
.auth-form .hint { margin: -8px 0 0; }
.auth-foot { display: flex; align-items: center; gap: 6px; justify-content: center; color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.auth-foot .ico { width: 14px; height: 14px; }
.brand-mobile { display: none; margin-bottom: 10px; }

/* ---------- portal ---------- */
.portal { min-height: 100vh; }
.portal-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 28px; background: var(--side-bg); border-bottom: 1px solid var(--side-border); color: var(--side-text); }
.portal-me { display: flex; align-items: center; gap: 10px; }
.portal-me .me-name { margin-right: 6px; }
.portal-me .icon-btn { color: var(--side-muted); }
.portal-me .me-name { color: var(--side-strong); }
.portal-view { display: flex; flex-direction: column; gap: 18px; }
.portal-view .page-head, .portal-view .kpi-grid { margin-bottom: 0; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .dash-grid.three { grid-template-columns: 1fr 1fr; }
  .invoice-grid { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .dash-grid, .dash-grid.three, .record-grid { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .brand-mobile { display: flex; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sidebar.open ~ .scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .gsearch kbd { display: none; }
  .gsearch input { padding-right: 12px; }
  .view { padding: 20px 16px; }
  .quick .btn span { display: none; }
}
@media (max-width: 600px) {
  .fgrid { grid-template-columns: 1fr; }
  .search-box, .search-box input { width: 100%; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-value { font-size: 19px; }
  .page-head h1 { font-size: 21px; }
  .items-head { display: none; }
  .item-row { grid-template-columns: 1fr 1fr 34px; }
  .item-row input[data-i=description] { grid-column: 1 / -1; }
  .item-amt { display: none; }
  .invoice-doc { padding: 22px 18px; }
  .inv-top, .inv-bottom { flex-direction: column; }
  .inv-meta { text-align: left; }
  .inv-meta table { margin-left: 0; }
  .inv-meta td { padding: 2px 16px 2px 0; }
  .dl-row { grid-template-columns: 1fr; gap: 2px; }
  .portal-top { padding: 12px 16px; }
  .portal-me .me-name { display: none; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; border: 0; box-shadow: none; padding: 0; }
  .modal::backdrop { background: none; }
  .modal { box-shadow: none; position: static; max-height: none; }
  .inv-word { color: #1597e0 !important; }
  .inv-due td { color: #0b7fcb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv-items th { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.due-bad { color: var(--red); }
