/* ECOM PORTAL – theme */
:root, [data-theme="dark"] {
  --bg: #0f172a; --panel: #1e293b; --panel-2: #172033; --line: #2c3a52; --line-2: #334155;
  --text: #e2e8f0; --muted: #a3b0c2; --faint: #8f9db2; --head: #f8fafc;
  --accent: #14b8a6; --accent-2: #2dd4bf; --accent-ink: #042f2e; --accent-soft: rgba(20,184,166,.14);
  /* text-safe tokens: every label on a coloured background uses these pairs (WCAG AA >= 4.5:1) */
  --link: #2dd4bf; --primary-bg: #14b8a6; --primary-hover: #2dd4bf; --primary-ink: #042f2e;
  --danger: #f87171; --warn: #fbbf24; --ok: #34d399; --info: #60a5fa;
  --badge-mix: #ffffff; --badge-strength: 62%;
  --shadow: 0 1px 2px rgba(0,0,0,.25), 0 8px 24px rgba(0,0,0,.18);
  --radius: 12px; --input: #0f172a;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #f3f6f9; --panel: #ffffff; --panel-2: #f7f9fb; --line: #e5eaf0; --line-2: #cfd8e3;
  --text: #1e293b; --muted: #4b5a6d; --faint: #5b6b7f; --head: #0f172a;
  --accent: #0f766e; --accent-2: #0d9488; --accent-ink: #ffffff; --accent-soft: rgba(13,148,136,.10);
  --link: #0f766e; --primary-bg: #0f766e; --primary-hover: #115e59; --primary-ink: #ffffff;
  --danger: #c62828; --warn: #92400e; --ok: #047857; --info: #1d4ed8;
  --badge-mix: #000000; --badge-strength: 58%;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 6px 18px rgba(15,23,42,.06);
  --input: #ffffff;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 Inter, "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
/* NOTE: never colour links with a theme-prefixed element selector ([data-theme] a) – it outranks .btn/.chip classes
   and painted button labels in the button colour (the "blank teal button" bug). Classes below set their own colours. */
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--head); margin: 0 0 .5rem; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.05rem; } h3 { font-size: .95rem; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
code { background: var(--panel-2); padding: .1em .35em; border-radius: 5px; font-size: .9em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* layout */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; z-index: 40; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1rem 1rem .9rem; border-bottom: 1px solid var(--line); color: var(--head); text-decoration: none !important; }
.brand img, .brand svg { width: 34px; height: 34px; flex: none; }
.brand .brand-logo-custom { width: auto; max-width: 150px; height: 34px; object-fit: contain; }
.wordmark { font-weight: 800; letter-spacing: .06em; font-size: 1.02rem; white-space: nowrap; color: var(--head); }
.wordmark b { color: var(--link); font-weight: 600; margin-left: .28em; }
.nav { padding: .6rem .5rem 1rem; flex: 1; }
.nav .sec { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: var(--faint); padding: .9rem .75rem .3rem; }
.nav a { display: flex; align-items: center; gap: .65rem; padding: .5rem .75rem; border-radius: 9px; color: var(--muted); font-weight: 500; text-decoration: none; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--link); }
.sidebar-foot { padding: .75rem 1rem; border-top: 1px solid var(--line); font-size: .8rem; color: var(--faint); }
.app.collapsed { grid-template-columns: 68px 1fr; }
.app.collapsed .wordmark, .app.collapsed .nav a span, .app.collapsed .nav .sec, .app.collapsed .sidebar-foot, .app.collapsed .brand-logo-custom { display: none; }
.app.collapsed .brand .icon-only { display: block !important; }
.app.collapsed .nav a { justify-content: center; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.topbar .title { font-weight: 650; color: var(--head); font-size: 1rem; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--muted); border-radius: 9px; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:hover { color: var(--text); background: var(--panel); }
.icon-btn svg { width: 18px; height: 18px; }
.user-chip { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .85rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--link); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.content { padding: 1.25rem; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; flex: 1; min-width: 180px; }
.menu-toggle { display: none; }
.backdrop { display: none; }

/* cards & grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; min-width: 0; }
.card > h2:first-child, .card-head { margin-bottom: .75rem; }
.card-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; flex: 1; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; display: block; color: inherit; text-decoration: none !important; position: relative; overflow: hidden; }
a.kpi:hover { border-color: var(--accent); }
.kpi .k-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.kpi .k-val { color: var(--head); font-size: 1.35rem; font-weight: 700; margin-top: .15rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .k-sub { color: var(--faint); font-size: .78rem; }
.kpi .spark { position: absolute; right: 0; bottom: 0; width: 45%; height: 30px; opacity: .5; }
.kpi .spark path { stroke: var(--accent); fill: none; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.delta { font-size: .75rem; font-weight: 600; margin-left: .25rem; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); } .delta.flat { color: var(--faint); }
.delta.inv.up { color: var(--danger); } .delta.inv.down { color: var(--ok); }
.period-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.period { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.period h3 { margin: 0 0 .6rem; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.period .rows { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem .75rem; }
.period .rows a, .period .rows div { display: block; color: inherit; text-decoration: none; }
.period .v { font-size: 1.15rem; font-weight: 700; color: var(--head); font-variant-numeric: tabular-nums; }
.period .l { font-size: .75rem; color: var(--faint); }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); padding: .5rem .85rem; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; line-height: 1.2; min-height: 36px; }
.btn:hover { border-color: var(--accent); }
.btn svg { width: 16px; height: 16px; }
.btn-primary, a.btn-primary, button.btn-primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-ink); }
.btn-primary:hover, a.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--primary-ink); }
.btn-primary svg { color: var(--primary-ink); }
.btn-secondary, a.btn-secondary { background: var(--panel); border-color: var(--line-2); color: var(--text); }
.btn-danger, a.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: var(--danger); }
.btn-ghost, a.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--panel-2); }
.btn-sm { padding: .3rem .6rem; min-height: 30px; font-size: .82rem; }
.btn-group { display: inline-flex; gap: .4rem; flex-wrap: wrap; }
label { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], input[type=url], input[type=search], input[type=file], select, textarea {
  width: 100%; background: var(--input); border: 1px solid var(--line-2); color: var(--text); border-radius: 9px; padding: .5rem .65rem; font: inherit; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -3px; }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; color: var(--text); font-size: .88rem; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .8rem 1rem; }
.form-grid .span2 { grid-column: span 2; } .form-grid .full { grid-column: 1 / -1; }
.field { min-width: 0; }
.hint { font-size: .76rem; color: var(--faint); margin-top: .2rem; }
.form-actions { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }
.inline-form { display: inline; }
.req::after { content: " *"; color: var(--danger); }

/* alerts */
.alert { padding: .65rem .9rem; border-radius: 10px; margin-bottom: .8rem; border: 1px solid; font-size: .9rem; }
.alert-success { background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.alert-error { background: color-mix(in srgb, var(--danger) 12%, transparent); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.alert-warn { background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.alert-info { background: color-mix(in srgb, var(--info) 10%, transparent); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.alert a { color: inherit; text-decoration: underline; font-weight: 600; }
.alert ul { margin: .3rem 0 0 1.1rem; padding: 0; }

/* badges */
.badge { --bc: #64748b; display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .74rem; font-weight: 650; white-space: nowrap;
  color: color-mix(in srgb, var(--bc) var(--badge-strength), var(--badge-mix)); background: color-mix(in srgb, var(--bc) 14%, transparent); border: 1px solid color-mix(in srgb, var(--bc) 30%, transparent); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--bc); }
.tag { display: inline-block; padding: .05rem .45rem; border-radius: 6px; font-size: .72rem; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.tag-demo { background: color-mix(in srgb, var(--warn) 12%, var(--panel)); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -1.1rem; padding: 0 1.1rem; }
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.t th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); font-weight: 650; padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0; }
.t td { padding: .6rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.t tbody tr:hover td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
.t .num, .t th.num { text-align: right; white-space: nowrap; }
.t tfoot td { font-weight: 700; color: var(--head); border-top: 2px solid var(--line-2); }
.t a.cell-link { color: inherit; border-bottom: 1px dashed var(--faint); text-decoration: none; }
.t a.cell-link:hover { color: var(--link); border-color: var(--link); }
.t .sel { width: 30px; }
.t tr.muted-row td { opacity: .55; }
.nowrap { white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.empty { text-align: center; color: var(--faint); padding: 2rem 1rem !important; }

/* filters / chips */
.filterbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.chips { display: inline-flex; flex-wrap: wrap; gap: .3rem; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; padding: .25rem; }
.chip { padding: .32rem .7rem; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: .82rem; text-decoration: none !important; white-space: nowrap; border: 0; background: none; cursor: pointer; font-family: inherit; }
.chip:hover { color: var(--text); background: var(--panel-2); }
.chip.on, a.chip.on { background: var(--primary-bg); color: var(--primary-ink); }
.range-custom { display: none; align-items: center; gap: .35rem; }
.range-custom.show { display: inline-flex; }
.range-custom input { width: 145px; min-height: 34px; padding: .3rem .5rem; }
.filterbar select { width: auto; min-height: 36px; padding: .35rem .6rem; }
.status-tabs { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .25rem; margin-bottom: .75rem; scrollbar-width: thin; }
.status-tabs a { flex: none; display: inline-flex; gap: .4rem; align-items: center; padding: .38rem .7rem; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-weight: 600; font-size: .82rem; text-decoration: none; }
.status-tabs a.on { border-color: var(--accent); color: var(--head); background: var(--accent-soft); }
.status-tabs .n { background: var(--panel-2); padding: 0 .4rem; border-radius: 6px; font-size: .75rem; }
.adv-filters { display: none; }
.adv-filters.show { display: block; }
.bulkbar { display: none; position: sticky; bottom: .75rem; z-index: 20; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: .6rem .8rem; box-shadow: var(--shadow); align-items: center; gap: .5rem; flex-wrap: wrap; margin-top: .75rem; }
.bulkbar.show { display: flex; }
.bulkbar select { width: auto; min-height: 34px; }
.pager { display: flex; gap: .35rem; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: .8rem; color: var(--muted); font-size: .85rem; }
.loading { opacity: .5; pointer-events: none; transition: opacity .15s; }

/* charts */
.chart-wrap { width: 100%; }
.chart { width: 100%; height: auto; display: block; min-height: 150px; }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .axis { fill: var(--faint); font-size: 11px; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart a:hover .bar { opacity: 1; fill: var(--accent-2); }
.chart .hit { fill: transparent; }
.chart a:hover .hit { fill: var(--accent-soft); }
.chart .line { stroke: #60a5fa; stroke-width: 2.25; vector-effect: non-scaling-stroke; }
.chart .line-axis { fill: #60a5fa; opacity: .8; }
.legend { display: flex; gap: .9rem; align-items: center; font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.lg-bar, .lg-line { display: inline-block; width: 12px; height: 10px; border-radius: 3px; background: var(--accent); margin-right: -.5rem; }
.lg-line { height: 3px; background: #60a5fa; margin-left: .5rem; }
.hbars { display: flex; flex-direction: column; gap: .35rem; }
.hb-row { --hb: var(--accent); display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; align-items: center; gap: .6rem; padding: .25rem .35rem; border-radius: 7px; color: inherit; text-decoration: none !important; font-size: .85rem; }
a.hb-row:hover { background: var(--panel-2); }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.hb-track { height: 9px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.hb-fill { display: block; height: 100%; background: var(--hb); border-radius: 99px; min-width: 2px; }
.hb-val { font-weight: 650; font-variant-numeric: tabular-nums; color: var(--head); white-space: nowrap; }

/* order form */
.items-table td { padding: .4rem .35rem; vertical-align: middle; }
.items-table input, .items-table select { min-height: 36px; }
.items-table .qty { width: 80px; } .items-table .price { width: 110px; }
.totals { margin-left: auto; max-width: 340px; display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; font-variant-numeric: tabular-nums; }
.totals .grand { font-size: 1.15rem; font-weight: 800; color: var(--head); border-top: 1px solid var(--line); padding-top: .4rem; }
.phone-info { margin-top: .35rem; font-size: .82rem; }
.phone-info .warn-box { border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); padding: .5rem .65rem; border-radius: 9px; }
.phone-info .bad-box { border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 12%, transparent); padding: .5rem .65rem; border-radius: 9px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.2rem; border-left: 2px solid var(--line); margin-left: .35rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline li:last-child { border-color: transparent; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .82rem; } .dl dd { margin: 0; word-break: break-word; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .85rem; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs a.on { color: var(--head); border-color: var(--accent); }
.stock-low { color: var(--warn); font-weight: 700; } .stock-out { color: var(--danger); font-weight: 700; }
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; border: 1px solid var(--line-2); }

/* auth */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; background:
  radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%), radial-gradient(900px 500px at 110% 110%, rgba(59,130,246,.10), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 2rem 1.75rem 1.5rem; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.auth-logo { display: flex; flex-direction: column; align-items: center; gap: .75rem; margin-bottom: 1.4rem; }
.auth-logo img.mark { width: 64px; height: 64px; filter: drop-shadow(0 8px 18px color-mix(in srgb, var(--accent) 35%, transparent)); }
.auth-logo .wordmark { font-size: 1.45rem; }
.auth-logo .tagline { color: var(--muted); font-size: .85rem; margin-top: -.35rem; }
.auth-card .field { margin-bottom: .85rem; }
.auth-foot { text-align: center; color: var(--faint); font-size: .78rem; margin-top: 1rem; }
.theme-float { position: fixed; top: 1rem; right: 1rem; }

/* print */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .sidebar, .topbar, .no-print, .bulkbar, .filterbar { display: none !important; }
  .app { display: block; } .content { padding: 0; max-width: none; }
  .print-only { display: block; }
  .invoice { page-break-after: always; border: 0 !important; box-shadow: none !important; }
  .invoice:last-child { page-break-after: auto; }
}
.invoice { background: #fff; color: #111827; border-radius: 12px; padding: 1.75rem; margin: 0 auto 1.25rem; max-width: 820px; box-shadow: var(--shadow); font-size: 13px; }
.invoice h1, .invoice h2, .invoice h3 { color: #111827; }
.invoice table { width: 100%; border-collapse: collapse; }
.invoice th, .invoice td { border-bottom: 1px solid #e5e7eb; padding: .45rem .4rem; text-align: left; }
.invoice .num { text-align: right; }
.invoice .inv-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 1.2rem; }
.invoice .inv-logo { height: 44px; max-width: 220px; object-fit: contain; }
.invoice .muted { color: #6b7280; }
.invoice .box { border: 1px solid #e5e7eb; border-radius: 8px; padding: .7rem .8rem; }
.invoice .cod-box { border: 2px solid #111827; border-radius: 8px; padding: .5rem .8rem; font-size: 1.1rem; font-weight: 800; display: inline-block; }
.invoice .slip-cut { border-top: 2px dashed #9ca3af; margin: 1.25rem 0; }

/* responsive */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-2-1 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .app, .app.collapsed { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .app.nav-open .sidebar { transform: none; }
  .app.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .app.collapsed .wordmark, .app.collapsed .nav a span, .app.collapsed .nav .sec, .app.collapsed .sidebar-foot { display: initial; }
  .menu-toggle { display: inline-flex; }
  .collapse-toggle { display: none !important; }
  .content { padding: .85rem; }
  .topbar { padding: .5rem .85rem; }
  .user-chip .uname { display: none; }
  .period-cards { grid-template-columns: 1fr; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid .span2 { grid-column: 1 / -1; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .k-val { font-size: 1.1rem; }
  /* tables -> cards */
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td, table.t.cards tfoot { display: block; width: 100%; }
  table.t.cards tr { border: 1px solid var(--line); border-radius: 12px; margin-bottom: .6rem; padding: .45rem .7rem; background: var(--panel-2); position: relative; }
  table.t.cards td { border: 0; padding: .22rem 0; display: flex; justify-content: space-between; gap: 1rem; text-align: right; }
  table.t.cards td::before { content: attr(data-label); color: var(--faint); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; text-align: left; flex: none; padding-top: .1rem; }
  table.t.cards td.sel { position: absolute; right: .6rem; top: .55rem; width: auto; display: block; }
  table.t.cards td.sel::before, table.t.cards td.card-title::before { content: none; }
  table.t.cards td.card-title { display: block; text-align: left; padding-right: 2rem; font-size: .95rem; }
  table.t.cards td.num { justify-content: space-between; }
  table.t.cards tbody tr:hover td { background: transparent; }
  table.t.cards tfoot tr { background: var(--panel); }
  .table-wrap { margin: 0; padding: 0; overflow: visible; }
  .card { padding: .85rem; }
  .hide-sm { display: none !important; }
  .range-custom input { width: 130px; }
  .filterbar > * { max-width: 100%; }
  .chips { overflow-x: auto; flex-wrap: nowrap; max-width: 100%; }
  .totals { max-width: none; }
  .items-table .qty { width: 64px; } .items-table .price { width: 90px; }
  .invoice { padding: 1rem; }
}
@media (max-width: 420px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Country workspace switcher ---------- */
.ws-switch{position:relative}
.ws-switch>summary{list-style:none;display:flex;align-items:center;gap:.5rem;cursor:pointer;padding:.4rem .75rem;border-radius:10px;
  border:1px solid color-mix(in srgb,var(--accent) 45%,var(--line));background:color-mix(in srgb,var(--accent) 12%,var(--panel));font-weight:600;white-space:nowrap;user-select:none}
.ws-switch>summary::-webkit-details-marker{display:none}
.ws-switch>summary:hover{border-color:var(--accent)}
.ws-switch .ws-flag{font-size:1.15rem;line-height:1}
.ws-switch .ws-cur{font-size:.72rem;font-weight:700;padding:.1rem .4rem;border-radius:6px;background:var(--primary-bg);color:var(--primary-ink)}
.ws-switch svg{width:16px;height:16px;opacity:.7}
.ws-menu{position:absolute;left:0;top:calc(100% + 6px);z-index:60;min-width:250px;background:var(--panel);border:1px solid var(--line);border-radius:12px;box-shadow:0 12px 32px rgba(0,0,0,.35);padding:.35rem}
.ws-menu a{display:flex;align-items:center;gap:.6rem;padding:.55rem .65rem;border-radius:8px;color:var(--text);text-decoration:none}
.ws-menu a:hover{background:var(--panel-2)}
.ws-menu a.on{background:color-mix(in srgb,var(--accent) 16%,transparent)}
.ws-menu a small{margin-left:auto;color:var(--muted);font-weight:600}
.ws-menu a.ws-all{border-top:1px solid var(--line);border-radius:0 0 8px 8px;color:var(--muted)}
@media (max-width:640px){.ws-switch .ws-name{display:none}.topbar .title{font-size:.95rem}}
.danger-zone{border-color:color-mix(in srgb,var(--danger,#ef4444) 50%,var(--line))}
.danger-zone h2{color:var(--danger,#ef4444)}
tr.row-err td{background:color-mix(in srgb,#ef4444 12%,transparent)}
tr.row-ok td:first-child{box-shadow:inset 3px 0 0 #22c55e}
td .cell-err{outline:1px dashed #ef4444;outline-offset:2px}
.ov-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:1rem}
.btn-primary-soft,a.btn-primary-soft{background:var(--accent-soft);border-color:var(--accent);color:var(--link);font-weight:600}
.btn-primary-soft:hover,a.btn-primary-soft:hover{background:var(--primary-bg);border-color:var(--primary-bg);color:var(--primary-ink)}
.import-group{gap:0}.import-group .btn:first-child{border-top-right-radius:0;border-bottom-right-radius:0}.import-group .btn:last-child{border-top-left-radius:0;border-bottom-left-radius:0;margin-left:-1px}
.import-preview td.import-result{min-width:220px;max-width:320px;white-space:normal}
.import-preview td{white-space:nowrap}
.import-preview td.import-result .neg{font-size:.82rem;line-height:1.35}
@media (max-width:760px){.import-preview td{white-space:normal}.import-preview td.import-result{min-width:0;max-width:none}}

/* ---------- v2: calm-focus layout (spacing scale 4/8/12/16/24/32, type 12/14/16/20/28) ---------- */
:root { --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; }
[data-theme="light"] .card, [data-theme="light"] .kpi { border-color: transparent; }
[data-theme="light"] .card { box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 14px rgba(15,23,42,.04); }
.card { padding: var(--s4) var(--s5); margin-bottom: var(--s5); }
.page-head { margin-bottom: var(--s5); }
.t td { border-bottom-color: color-mix(in srgb, var(--line) 70%, transparent); }
.fine { font-size: .78rem; margin: var(--s2) 0 0; }
.only-sm { display: none !important; }
.alert-slim { padding: .45rem .8rem; font-size: .85rem; }
.pill { display: inline-flex; align-items: center; justify-content: center; min-width: 1.5rem; height: 1.5rem; padding: 0 .45rem; border-radius: 999px; background: var(--primary-bg); color: var(--primary-ink); font-size: .75rem; font-weight: 700; }

/* dashboard header */
.dash-head { align-items: flex-end; }
.dash-hello h1 { font-size: 1.6rem; margin: 0; }
.dash-hello p { margin: .15rem 0 0; font-size: .9rem; }

/* primary KPI row: five big numbers */
.hero-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.hero-kpis .kpi { padding: var(--s4) var(--s4) var(--s4); border-radius: 14px; }
[data-theme="light"] .hero-kpis .kpi { box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 14px rgba(15,23,42,.04); }
.hero-kpis .kpi .k-label { font-size: .78rem; letter-spacing: .04em; }
.hero-kpis .kpi .k-val { font-size: 1.85rem; line-height: 1.15; margin-top: .3rem; font-weight: 750; }
.hero-kpis .kpi .k-sub { margin-top: .2rem; font-size: .8rem; }
.hero-kpis .delta { display: inline-block; vertical-align: middle; font-size: .72rem; }

/* action needed */
.action-card .card-head h2 { flex: 0 1 auto; }
.action-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.action-list a { display: grid; grid-template-columns: 2rem 1fr auto; align-items: center; gap: var(--s3); padding: .7rem .8rem; border-radius: 12px; background: var(--panel-2); color: var(--text); text-decoration: none !important; }
.action-list a:hover { background: var(--accent-soft); }
.action-list .ai { font-size: 1.2rem; text-align: center; }
.action-list .at b { display: block; color: var(--head); font-weight: 650; }
.action-list .at small { color: var(--muted); font-size: .82rem; }
.action-list .go { color: var(--faint); font-size: 1.4rem; line-height: 1; }
.action-list li.warn a { box-shadow: inset 3px 0 0 var(--warn); }
.action-list li.bad a { box-shadow: inset 3px 0 0 var(--danger); }
.all-clear { margin: 0; color: var(--muted); }
.lead-list { list-style: none; margin: var(--s2) 0 0; padding: 0; }
.lead-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: .6rem 0; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
.lead-list li:last-child { border-bottom: 0; }
.lead-list li > a:first-child { color: var(--text); text-decoration: none; min-width: 0; }

/* collapsible sections */
details.section > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: var(--s3); user-select: none; }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary::before { content: ""; width: .5rem; height: .5rem; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; margin-right: .1rem; position: relative; top: -.1rem; }
details.section[open] > summary::before { transform: rotate(45deg); }
details.section > summary h2 { margin: 0; font-size: 1.05rem; }
details.section > summary .muted { font-size: .82rem; margin-left: auto; text-align: right; }
details.section[open] > summary { margin-bottom: var(--s4); }
details.section.card { padding-top: var(--s4); padding-bottom: var(--s4); }
details.section.inner { margin-top: var(--s4); }
details.section.inner > summary { font-weight: 600; color: var(--muted); font-size: .88rem; }
details.section.inner[open] > summary { margin-bottom: 0; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--s3); margin-bottom: var(--s4); }
.stat-row .kpi { background: var(--panel-2); border-color: transparent; padding: .65rem .75rem; }
.stat-row .kpi .k-val { font-size: 1.15rem; }
.flat-grid h3 { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: var(--s2); }

/* dropdown menu (Export ▾ etc.) */
details.menu { position: relative; display: inline-block; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 210px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.22); padding: .35rem; display: grid; }
details.menu .menu-list a { display: flex; gap: .5rem; align-items: center; padding: .55rem .65rem; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
details.menu .menu-list a:hover { background: var(--panel-2); }
details.menu .menu-list svg { width: 16px; height: 16px; color: var(--muted); }

/* orders list: optional columns */
.t .col-extra { display: none; }
.show-extra .t .col-extra { display: table-cell; }

/* receivables */
.recv-courier summary { cursor: pointer; }
.owed-list { display: grid; gap: var(--s3); }
.owed { background: var(--panel-2); border-radius: 12px; padding: var(--s3) var(--s4); }
.owed-head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.owed-head .who { flex: 1; min-width: 150px; }
.owed-head .who b { color: var(--head); font-size: 1rem; }
.owed-head .amt { font-size: 1.25rem; font-weight: 750; color: var(--head); font-variant-numeric: tabular-nums; }
.owed details > summary { font-size: .85rem; color: var(--muted); margin-top: var(--s2); }
.owed table.t { margin-top: var(--s2); }

@media (max-width: 1100px) { .hero-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .only-sm { display: inline-flex !important; }
  .hero-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .hero-kpis .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .hero-kpis .kpi .k-val { font-size: 1.55rem; }
  .card { padding: var(--s4); margin-bottom: var(--s4); }
  .dash-hello h1 { font-size: 1.35rem; }
  .dash-head .btn { width: 100%; }
  .dash-head { gap: var(--s3); }
  details.section > summary .muted { display: none; }
  .filterbar > span.muted { display: none; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head .btn-group { width: 100%; }
}

/* couriers management */
.courier-list .courier { padding: var(--s4) var(--s5); }
.courier.is-off { opacity: .8; }
.courier-head { display: flex; gap: var(--s3); align-items: flex-start; flex-wrap: wrap; }
.courier-head .who { flex: 1; min-width: 200px; }
.courier-head h2 { margin: 0 0 .15rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.fee-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); margin: var(--s4) 0 0; }
.fee-grid > div { background: var(--panel-2); border-radius: 10px; padding: .55rem .7rem; }
.fee-grid dt { font-size: .74rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.fee-grid dd { margin: .1rem 0 0; font-weight: 650; color: var(--head); font-variant-numeric: tabular-nums; }
.btn[disabled] { opacity: .75; cursor: not-allowed; }
@media (max-width: 860px) { .fee-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.recv-breakdown { display: flex; gap: .35rem 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: .2rem; }
.recv-breakdown b { color: var(--text); font-weight: 650; }
.recon { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; padding: .7rem .9rem; border-radius: 10px; background: var(--panel-2); margin-top: var(--s3); font-variant-numeric: tabular-nums; }
.recon .ok { color: var(--ok); font-weight: 700; } .recon .bad { color: var(--danger); font-weight: 700; }
details.net-line { margin: -.4rem 0 var(--s4); font-size: .85rem; color: var(--muted); }
details.net-line > summary { cursor: pointer; display: inline-block; padding: .15rem 0; color: var(--muted); }
details.net-line[open] { display: flex; flex-wrap: wrap; gap: .3rem 1.25rem; align-items: baseline; }
details.net-line[open] > summary { flex-basis: 100%; }
details.net-line b:not(.pos):not(.neg) { color: var(--head); font-variant-numeric: tabular-nums; }
/* money values in the hero row must never clip */
.hero-kpis .kpi { min-width: 0; overflow: hidden; }
.hero-kpis .kpi .k-val { font-size: clamp(1.15rem, 1.9vw, 1.85rem); overflow-wrap: anywhere; }
.hero-kpis .kpi .k-val .pos, .hero-kpis .kpi .k-val .neg { white-space: normal; }
details.net-line > summary { list-style: none; }
details.net-line > summary::-webkit-details-marker { display: none; }
details.net-line > summary::before { content: "▸ "; }
details.net-line[open] > summary::before { content: "▾ "; }

/* ---------- v1.2.1: site identity (Settings → General → Site identity) ----------
   Accent presets override only the accent/link/primary tokens. Dark values sit on [data-accent=x] (beats :root/[data-theme=dark] by order),
   light values on [data-accent=x][data-theme="light"] (higher specificity). Every text pair stays >= 4.5:1 – checked in tests/run.php. */
[data-accent="indigo"] {
  --accent: #8b5cf6; --accent-2: #a78bfa; --accent-ink: #ffffff; --accent-soft: rgba(139,92,246,.16);
  --link: #a78bfa; --primary-bg: #7c3aed; --primary-hover: #6d28d9; --primary-ink: #ffffff;
}
[data-accent="indigo"][data-theme="light"] {
  --accent: #6d28d9; --accent-2: #7c3aed; --accent-ink: #ffffff; --accent-soft: rgba(109,40,217,.09);
  --link: #6d28d9; --primary-bg: #6d28d9; --primary-hover: #5b21b6; --primary-ink: #ffffff;
}
[data-accent="amber"] {
  --accent: #f59e0b; --accent-2: #fbbf24; --accent-ink: #451a03; --accent-soft: rgba(245,158,11,.14);
  --link: #fbbf24; --primary-bg: #f59e0b; --primary-hover: #fbbf24; --primary-ink: #451a03;
}
[data-accent="amber"][data-theme="light"] {
  --accent: #b45309; --accent-2: #d97706; --accent-ink: #ffffff; --accent-soft: rgba(180,83,9,.08);
  --link: #92400e; --primary-bg: #b45309; --primary-hover: #92400e; --primary-ink: #ffffff;
}
[data-accent="rose"] {
  --accent: #fb7185; --accent-2: #fda4af; --accent-ink: #4c0519; --accent-soft: rgba(251,113,133,.12);
  --link: #fda4af; --primary-bg: #fb7185; --primary-hover: #fda4af; --primary-ink: #4c0519;
}
[data-accent="rose"][data-theme="light"] {
  --accent: #be123c; --accent-2: #e11d48; --accent-ink: #ffffff; --accent-soft: rgba(190,18,60,.08);
  --link: #be123c; --primary-bg: #be123c; --primary-hover: #9f1239; --primary-ink: #ffffff;
}
.site-strip { display: flex; align-items: center; justify-content: center; gap: .5rem; min-height: 24px; padding: .2rem .75rem; background: var(--primary-bg); color: var(--primary-ink);
  font-size: .72rem; font-weight: 750; letter-spacing: .14em; text-transform: uppercase; line-height: 1.2; text-align: center; }
.site-strip span::before { content: "●"; margin-right: .5rem; font-size: .6rem; vertical-align: .1em; opacity: .8; }
.site-pill { display: inline-flex; align-items: center; padding: .14rem .55rem; border-radius: 999px; background: var(--primary-bg); color: var(--primary-ink);
  font-size: .68rem; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; line-height: 1.35; flex: none; }
.site-pill .lbl-short { display: none; }
.brand-site { padding: .55rem 1rem .6rem; border-bottom: 1px solid var(--line); background: var(--accent-soft); }
.app.collapsed .brand-site { padding: .5rem .3rem; text-align: center; }
.app.collapsed .brand-site .lbl-full { display: none; }
.app.collapsed .brand-site .lbl-short { display: inline; font-size: .58rem; letter-spacing: .02em; }
[data-site-label] .topbar { border-top: 3px solid var(--primary-bg); }
[data-site-label] .sidebar { border-right-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.auth-logo .site-pill { font-size: .78rem; padding: .25rem .8rem; margin-top: -.2rem; }
.site-adding { margin: calc(-1 * var(--s3)) 0 var(--s4); font-size: .85rem; color: var(--muted); display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
@media (min-width: 861px) { .site-pill.in-topbar { display: none; } }   /* desktop: the sidebar shows it */
@media (max-width: 860px) { .app.collapsed .brand-site .lbl-full { display: inline; } .app.collapsed .brand-site .lbl-short { display: none; } }
@media (max-width: 640px) { .site-pill.in-topbar .lbl-full { display: none; } .site-pill.in-topbar .lbl-short { display: inline; } .site-strip { font-size: .68rem; letter-spacing: .1em; } }
.accent-choices { display: flex; flex-wrap: wrap; gap: .5rem; }
.accent-choice { display: inline-flex; align-items: center; gap: .5rem; margin: 0; padding: .45rem .75rem; border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel-2); color: var(--text); font-weight: 600; font-size: .86rem; cursor: pointer; }
.accent-choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent); }
.accent-choice .swatch { width: 18px; height: 18px; border-radius: 50%; border: 0; }
[data-site-label] .theme-float { top: calc(24px + .75rem); }
[data-site-label] .auth-wrap { min-height: calc(100vh - 24px); }

/* =====================================================================
   v2.1 "Apple Glass" redesign layer (2026-11-30)
   Appended only – every rule above is unchanged, so removing this block restores v1.2.1 exactly.
   Two layers: glass ONLY on functional chrome (sidebar, topbar, menus, bulk bar, ⌘K palette);
   content (cards, KPIs, tables, forms) stays solid. Teal only on New order, Sign in, selected nav + its icons, status dots.
   System fonts only, no external requests (CSP default-src 'self').
   ===================================================================== */
:root, [data-theme="dark"] {
  --bg: #0a0a0c; --panel: #1c1c1e; --panel-2: #242426; --line: #38383a; --line-2: #48484a;
  --text: #f5f5f7; --muted: #aeaeb2; --faint: #8e8e93; --head: #f5f5f7; --input: #2c2c2e;
  --fill: rgba(120,120,128,.24); --fill-2: rgba(120,120,128,.16); --mono-bg: #f5f5f7; --mono-ink: #1c1c1e;
  --glass: rgba(44,44,50,.42); --glass-thick: rgba(34,34,40,.52); --glass-pop: rgba(38,38,44,.82);
  --rim: rgba(255,255,255,.13); --hi: rgba(255,255,255,.07); --dim: rgba(0,0,0,.45);
  --wash-1: color-mix(in srgb, var(--accent) 22%, transparent); --wash-2: rgba(94,92,230,.14);
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 0 0 .5px rgba(255,255,255,.06);
  --float: 0 12px 40px rgba(0,0,0,.45);
  --radius: 16px;
}
[data-theme="light"] {
  --bg: #f2f2f7; --panel: #ffffff; --panel-2: #f5f5f7; --line: #e5e5ea; --line-2: #d1d1d6;
  --text: #1d1d1f; --muted: #5e5e63; --faint: #6e6e73; --head: #1d1d1f; --input: #ffffff;
  --fill: rgba(120,120,128,.16); --fill-2: rgba(120,120,128,.10); --mono-bg: #1d1d1f; --mono-ink: #ffffff;
  --glass: rgba(255,255,255,.62); --glass-thick: rgba(250,250,252,.72); --glass-pop: rgba(252,252,254,.88);
  --rim: rgba(0,0,0,.07); --hi: rgba(255,255,255,.75); --dim: rgba(0,0,0,.18);
  --wash-1: color-mix(in srgb, var(--accent) 12%, transparent); --wash-2: rgba(94,92,230,.07);
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 2px 10px rgba(0,0,0,.035);
  --float: 0 12px 40px rgba(0,0,0,.14);
}
:root { --ease: cubic-bezier(.32,.72,0,1); --ease-out: cubic-bezier(.22,1,.36,1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }

@media screen {
  body { font-family: var(--font); font-size: 14px; letter-spacing: -.005em;
    background: radial-gradient(700px 620px at 0% 0%, var(--wash-1), transparent 70%), radial-gradient(800px 420px at 100% 0%, var(--wash-2), transparent 70%), var(--bg) fixed; }
  h1, h2, h3 { font-family: var(--font-display); letter-spacing: -.02em; font-weight: 650; }
  h1 { font-size: 1.75rem; } h2 { font-size: 1.05rem; }
  a:hover { text-decoration: none; }

  /* ---- glass recipe (functional layer only) ---- */
  .sidebar, .topbar, .ws-menu, details.menu .menu-list, .bulkbar, .ecd-k {
    -webkit-backdrop-filter: blur(28px) saturate(1.45); backdrop-filter: blur(28px) saturate(1.45);
    box-shadow: inset 0 0 0 .5px var(--rim), inset 0 1px 0 var(--hi), var(--float); border: 0; }
  .sidebar { background: var(--glass-thick); }
  .topbar { background: var(--glass); }
  .ws-menu, details.menu .menu-list, .ecd-k { background: var(--glass-pop); -webkit-backdrop-filter: blur(40px) saturate(1.6); backdrop-filter: blur(40px) saturate(1.6); }
  .bulkbar { background: var(--glass-thick); }

  /* ---- shell ---- */
  .sidebar { border-right: 0; }
  .brand { border-bottom: 0; padding: 1rem 1rem .6rem; }
  .brand img, .brand svg { width: 28px; height: 28px; border-radius: 7px; }
  .wordmark { letter-spacing: -.01em; font-weight: 650; font-size: .98rem; }
  .wordmark b { color: var(--head); }
  .nav .sec { text-transform: none; letter-spacing: 0; font-size: .74rem; font-weight: 600; color: var(--faint); padding: .9rem .75rem .25rem; }
  .nav a { padding: .42rem .7rem; border-radius: 10px; color: var(--text); font-weight: 500; margin: 1px 0; }
  .nav a svg { color: var(--link); opacity: 1; width: 17px; height: 17px; }
  .nav a:hover { background: var(--fill-2); color: var(--text); }
  .nav a.active { background: var(--accent-soft); color: var(--head); font-weight: 600; }
  .sidebar-foot { border-top: 0; font-size: .74rem; }
  .brand-site { border-bottom: 0; background: transparent; }
  .topbar { gap: .6rem; }
  .topbar .title { font-weight: 600; font-size: .95rem; }
  .icon-btn { border: 0; background: transparent; color: var(--muted); border-radius: 10px; }
  .icon-btn:hover { background: var(--fill-2); color: var(--text); }
  .avatar { background: var(--fill); color: var(--head); }
  .user-chip { color: var(--text); }
  .ws-switch > summary { border: 0; background: transparent; padding: .35rem .6rem; border-radius: 10px; }
  .ws-switch > summary:hover { background: var(--fill-2); }
  .ws-switch .ws-cur { background: var(--fill); color: var(--muted); }
  .ws-menu { border-radius: 14px; padding: 5px; animation: ecdPop 220ms var(--ease) both; }
  .ws-menu a, details.menu .menu-list a { border-radius: 8px; padding: .45rem .6rem; }
  .ws-menu a:hover, details.menu .menu-list a:hover { background: var(--fill-2); }
  .ws-menu a.on { background: var(--fill); }
  .ws-menu a.ws-all { border-top: .5px solid var(--line); border-radius: 0 0 8px 8px; }
  details.menu .menu-list { border-radius: 14px; padding: 5px; animation: ecdPop 220ms var(--ease) both; }
  .content { padding: 1.5rem 1.75rem 2.5rem; }

  /* ---- content layer: solid cards ---- */
  .card, .kpi, .period { background: var(--panel); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); }
  [data-theme="light"] .card, [data-theme="light"] .hero-kpis .kpi { box-shadow: var(--shadow); }
  a.kpi:hover { border-color: transparent; background: color-mix(in srgb, var(--panel) 92%, var(--text)); }
  .kpi .k-label, .hero-kpis .kpi .k-label { text-transform: none; letter-spacing: 0; font-size: .8rem; font-weight: 500; color: var(--muted); }
  .kpi .k-val { font-family: var(--font-display); letter-spacing: -.02em; }
  .kpi .k-sub { line-height: 1.35; }
  .kpi .spark { opacity: .35; } .kpi .spark path { stroke: var(--muted); }
  .stat-row .kpi { background: var(--fill-2); box-shadow: none; }
  .period h3, .flat-grid h3 { text-transform: none; letter-spacing: 0; font-size: .85rem; }
  .action-list a { background: var(--fill-2); border-radius: 12px; }
  .action-list a:hover { background: var(--fill); }
  .owed, .recon, .fee-grid > div { background: var(--fill-2); }
  .alert { border-radius: 12px; border: 0; box-shadow: inset 0 0 0 .5px var(--line); background: var(--panel); }
  .alert-success { box-shadow: inset 3px 0 0 var(--ok), inset 0 0 0 .5px var(--line); }
  .alert-error { box-shadow: inset 3px 0 0 var(--danger), inset 0 0 0 .5px var(--line); }
  .alert-warn { box-shadow: inset 3px 0 0 var(--warn), inset 0 0 0 .5px var(--line); }
  .alert-info { box-shadow: inset 3px 0 0 var(--info), inset 0 0 0 .5px var(--line); }
  .tag { background: var(--fill-2); border: 0; border-radius: 6px; }

  /* ---- buttons: monochrome by default; teal only for New order + Sign in ---- */
  .btn { border: 0; background: var(--fill); color: var(--text); border-radius: 10px; font-weight: 600; }
  .btn:hover { border-color: transparent; background: color-mix(in srgb, var(--fill) 100%, var(--text) 8%); }
  .btn-primary, a.btn-primary, button.btn-primary { background: var(--mono-bg); color: var(--mono-ink); border: 0; }
  .btn-primary:hover, a.btn-primary:hover { background: var(--mono-bg); color: var(--mono-ink); opacity: .88; }
  .btn-primary svg { color: var(--mono-ink); }
  .topbar .btn-primary, a.btn-primary[href*="orders/new"], .auth-card .btn-primary { background: var(--primary-bg); color: var(--primary-ink); }
  .topbar .btn-primary:hover, a.btn-primary[href*="orders/new"]:hover, .auth-card .btn-primary:hover { background: var(--primary-hover); color: var(--primary-ink); opacity: 1; }
  .topbar .btn-primary svg, a.btn-primary[href*="orders/new"] svg { color: var(--primary-ink); }
  .btn-primary-soft, a.btn-primary-soft { background: var(--fill); border: 0; color: var(--text); }
  .btn-primary-soft:hover, a.btn-primary-soft:hover { background: var(--fill); color: var(--text); opacity: .85; }
  .btn-secondary, a.btn-secondary { background: var(--fill); border: 0; }
  .btn-danger, a.btn-danger { background: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 35%, transparent); }
  .btn-ghost, a.btn-ghost { background: transparent; }

  /* ---- forms ---- */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=tel], input[type=url], input[type=search], input[type=file], select, textarea {
    background: var(--input); border: 0; box-shadow: inset 0 0 0 1px var(--line-2); border-radius: 10px; }
  input:focus, select:focus, textarea:focus { outline: 0; box-shadow: inset 0 0 0 1px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent); }
  label { font-weight: 500; }

  /* ---- filters, chips, tabs: monochrome segmented controls ---- */
  .chips { background: var(--fill-2); border: 0; border-radius: 10px; padding: 2px; }
  .chip { color: var(--text); font-weight: 500; border-radius: 8px; }
  .chip:hover { background: transparent; color: var(--head); }
  .chip.on, a.chip.on { background: var(--panel); color: var(--head); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.12), inset 0 0 0 .5px var(--rim); }
  .status-tabs { gap: 0; scrollbar-width: none; padding-right: 28px;
    -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
  .status-tabs a { border: 0; background: transparent; color: var(--muted); font-weight: 500; border-radius: 8px; padding: .35rem .6rem; }
  .status-tabs a:hover { background: var(--fill-2); color: var(--text); }
  .status-tabs a.on { background: var(--fill); color: var(--head); font-weight: 600; border-color: transparent; }
  .status-tabs .n { background: transparent; color: var(--faint); padding: 0; }
  .tabs { border-bottom: .5px solid var(--line); }
  .tabs a.on { border-color: var(--head); }

  /* ---- quiet status pills: coloured dot, neutral label ---- */
  .badge { background: transparent; border: 0; padding: .1rem 0; color: var(--text); font-weight: 500; }
  .badge::before { width: 7px; height: 7px; }
  h1 .badge { font-size: .8rem; vertical-align: middle; margin-left: .35rem; }

  /* ---- tables ---- */
  .t th { text-transform: none; letter-spacing: 0; font-size: .76rem; font-weight: 500; color: var(--faint); background: var(--panel); border-bottom: .5px solid var(--line); }
  .t td { border-bottom: .5px solid var(--line); }
  .t tbody tr:hover td { background: var(--fill-2); }

  /* ---- bulk bar: floating glass, morphs in, sits above the list ---- */
  .bulkbar { bottom: 12px; border-radius: 16px; padding: .45rem .5rem .45rem .9rem; }
  .bulkbar.show { animation: ecdMorph 420ms var(--ease) both; }

  /* ---- charts: neutral bars, label-colour line, status colours only as dots ---- */
  .chart .bar { fill: var(--line-2); opacity: 1; }
  .chart a:hover .bar { fill: var(--faint); }
  .chart a:hover .hit { fill: var(--fill-2); }
  .chart .line { stroke: var(--head); animation: ecdReveal 1100ms var(--ease-out) 200ms backwards; }
  .chart .line-axis { fill: var(--faint); }
  .lg-bar { background: var(--line-2); } .lg-line { background: var(--head); }
  .hb-track { background: var(--fill-2); }
  .hb-fill { background: var(--line-2); }
  .hb-label::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--hb); margin-right: .45rem; vertical-align: .05em; }

  /* ---- auth: quiet two-pane (desktop) using the existing markup ---- */
  .auth-wrap { background: var(--bg); }
  .auth-card { border: 0; box-shadow: var(--shadow); border-radius: 20px; }
  .auth-logo .wordmark { font-size: 1.3rem; }
  .auth-logo img.mark { filter: none; width: 56px; height: 56px; border-radius: 13px; }
  .theme-float { -webkit-backdrop-filter: blur(28px) saturate(1.45); backdrop-filter: blur(28px) saturate(1.45); background: var(--glass); box-shadow: inset 0 0 0 .5px var(--rim), var(--float); border-radius: 12px; }
  .pw-field { position: relative; }
  .pw-field input { padding-right: 2.6rem; }
  .pw-toggle { position: absolute; right: 4px; bottom: 3px; width: 34px; height: 32px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
  .pw-toggle:hover { background: var(--fill-2); color: var(--text); }
  .pw-toggle svg { width: 17px; height: 17px; }
  .caps-hint { display: none; margin: .3rem 0 0; font-size: .76rem; color: var(--warn); }
  .caps-hint.show { display: block; }
}
@media screen and (min-width: 861px) {
  .app { grid-template-columns: 246px minmax(0, 1fr); }
  .app.collapsed { grid-template-columns: 78px minmax(0, 1fr); }
  .sidebar { top: 10px; height: calc(100vh - 20px); margin: 10px 0 10px 10px; border-radius: 20px; }
  .topbar { top: 8px; margin: 10px 10px 0 12px; border-radius: 16px; padding: .5rem .75rem; }
  /* login: brand on the left, form on the right – CSS only, same markup */
  .auth-wrap { padding: 0; align-items: stretch; }
  .auth-card { max-width: none; min-height: 100vh; border-radius: 0; box-shadow: none; background: var(--bg); position: relative; padding: 2rem 2rem 2rem calc(50% + 2rem);
    display: flex; flex-direction: column; justify-content: center; }
  .auth-card > :not(.auth-logo) { width: 100%; max-width: 360px; margin-left: auto; margin-right: auto; }
  .auth-logo { position: absolute; left: 0; top: 0; bottom: 0; width: 50%; margin: 0; padding: 3rem; align-items: flex-start; justify-content: center; gap: 1rem;
    background: radial-gradient(70% 55% at 15% 100%, var(--wash-1), transparent 70%), var(--panel); box-shadow: inset -.5px 0 0 var(--line); }
  .auth-logo .tagline { margin: 0; font: 600 1.75rem/1.2 var(--font-display); letter-spacing: -.02em; color: var(--head); max-width: 14em; }
  [data-site-label] .auth-card { min-height: calc(100vh - 24px); }
}
@media screen and (max-width: 860px) {
  .sidebar { top: 8px; bottom: 8px; left: 8px; height: auto; width: 270px; border-radius: 20px; transform: translateX(calc(-100% - 20px)); transition: transform 360ms var(--ease); }
  .app.nav-open .backdrop { background: var(--dim); }
  .topbar { top: 6px; margin: 6px 8px 0; border-radius: 14px; }
  .content { padding: 1rem .85rem 2rem; }
  h1 { font-size: 1.4rem; }
  table.t.cards tr { background: var(--panel); border: 0; box-shadow: var(--shadow); border-radius: 14px; }
  table.t.cards td::before { text-transform: none; letter-spacing: 0; font-size: .78rem; }
  .bulkbar { bottom: 8px; }
  .ost-track b { font-size: .74rem; }
  .auth-wrap { align-items: flex-start; padding-top: 3.5rem; }
}

/* ---- status timeline on order detail (views/_status_track.php) ---- */
.ost { --ost-c: var(--accent); }
.ost-head { display: flex; align-items: baseline; gap: .6rem; margin-bottom: 1rem; }
.ost-head h2 { margin: 0; flex: 0 1 auto; }
.ost-note { margin-left: auto; font-size: .78rem; color: var(--faint); }
.ost-track { list-style: none; margin: 0; padding: 0; position: relative; display: grid; grid-template-columns: repeat(var(--ost-n), minmax(0, 1fr)); }
.ost-track::before, .ost-track::after { content: ""; position: absolute; top: 8px; height: 3px; border-radius: 3px; left: calc(50% / var(--ost-n)); }
.ost-track::before { right: calc(50% / var(--ost-n)); background: var(--fill, var(--line)); }
.ost-track::after { width: calc((100% - 100% / var(--ost-n)) * var(--ost-p)); background: var(--ost-c); transform-origin: left center; animation: ecdFill 900ms var(--ease-out) 200ms backwards; }
.ost-track li { position: relative; z-index: 1; text-align: center; padding: 0 .25rem; min-width: 0; }
.ost-track i { display: grid; place-items: center; width: 19px; height: 19px; margin: 0 auto .5rem; border-radius: 50%; background: var(--panel); box-shadow: inset 0 0 0 2px var(--line-2); color: #fff; font-style: normal; }
.ost-track i svg { width: 11px; height: 11px; }
.ost-track b { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); line-height: 1.25; overflow-wrap: anywhere; }
.ost-track small { display: block; margin-top: 2px; font-size: .72rem; color: var(--faint); line-height: 1.3; }
.ost-track .todo b { color: var(--faint); font-weight: 500; }
.ost-track .done i, .ost-track .cur i { background: var(--ost-c); box-shadow: none; animation: ecdDot 260ms var(--ease-out) var(--d, 200ms) backwards; }
.ost-track .cur b { color: var(--head); }
.ost-track .cur i { position: relative; transform: scale(1.18); box-shadow: 0 0 0 4px color-mix(in srgb, var(--ost-c) 22%, transparent); }
.ost-track .cur i::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--ost-c); opacity: 0; animation: ecdHalo 1400ms ease-out calc(var(--d, 200ms) + 250ms) 2; }
.ost-track .cur.end i { transform: none; }
@media print { .ost-track::after, .ost-track i, .ost-track i::after { animation: none !important; } }

/* ---- motion: purposeful, once ---- */
@keyframes ecdEnter { from { opacity: 0; transform: translateY(12px); } }
@keyframes ecdSoft { from { opacity: .35; } }
@keyframes ecdSide { from { opacity: 0; transform: translateX(-10px); } }
@keyframes ecdChrome { from { opacity: 0; transform: translateY(-6px); } }
@keyframes ecdPop { from { opacity: 0; transform: scale(.96) translateY(-4px); } }
@keyframes ecdMorph { from { opacity: 0; clip-path: inset(0 45% 0 45% round 16px); transform: translateY(8px); } to { opacity: 1; clip-path: inset(0 0 0 0 round 16px); transform: none; } }
@keyframes ecdReveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes ecdFill { from { transform: scaleX(0); } }
@keyframes ecdDot { from { background: var(--panel); box-shadow: inset 0 0 0 2px var(--line-2); transform: scale(.85); } }
@keyframes ecdHalo { 0% { opacity: .7; transform: scale(.9); } 100% { opacity: 0; transform: scale(1.9); } }
@keyframes ecdSheet { from { opacity: 0; transform: translate(-50%, 10px) scale(.97); } }
@media screen {
  /* content eases in on load and whenever pjax swaps #main-content for another section; same-section pjax (filters, paging) only fades */
  .content > * { animation: ecdEnter 520ms var(--ease-out) backwards; }
  .content > :nth-child(2) { animation-delay: 60ms; } .content > :nth-child(3) { animation-delay: 110ms; }
  .content > :nth-child(4) { animation-delay: 160ms; } .content > :nth-child(5) { animation-delay: 210ms; }
  .content > :nth-child(6) { animation-delay: 250ms; } .content > :nth-child(7) { animation-delay: 290ms; }
  .content > :nth-child(n+8) { animation-delay: 320ms; }
  .content.ecd-soft > * { animation: ecdSoft 220ms ease-out backwards; }
  .sidebar { animation: ecdSide 460ms var(--ease-out) backwards; }
  .topbar { animation: ecdChrome 420ms var(--ease-out) 40ms backwards; }
  .auth-card > * { animation: ecdEnter 520ms var(--ease-out) backwards; }
  .auth-card > :nth-child(2) { animation-delay: 80ms; } .auth-card > :nth-child(n+3) { animation-delay: 140ms; }
}

/* ---- ⌘K / Ctrl+K palette (built by app.js from the visible nav, so permissions are respected) ---- */
.ecd-search { display: inline-flex; align-items: center; gap: .45rem; height: 32px; padding: 0 .5rem 0 .6rem; border: 0; border-radius: 10px; background: var(--fill-2); color: var(--muted); font: inherit; font-size: .82rem; cursor: pointer; min-width: 190px; }
.ecd-search:hover { background: var(--fill); color: var(--text); }
.ecd-search svg { width: 15px; height: 15px; }
.ecd-search kbd, .ecd-k kbd { margin-left: auto; font: 600 .68rem/1 var(--font); padding: .2rem .35rem; border-radius: 5px; background: var(--panel); color: var(--muted); box-shadow: inset 0 0 0 .5px var(--line-2); }
.ecd-k-scrim { position: fixed; inset: 0; z-index: 90; background: var(--dim); display: none; }
.ecd-k-scrim.show { display: block; }
.ecd-k { position: fixed; z-index: 91; left: 50%; top: 14vh; width: 620px; max-width: calc(100vw - 24px); transform: translateX(-50%); border-radius: 18px; display: none; overflow: hidden; color: var(--text); }
.ecd-k.show { display: block; animation: ecdSheet 260ms var(--ease) both; }
.ecd-k-in { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border-bottom: .5px solid var(--line-2); }
.ecd-k-in svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.ecd-k-in input { flex: 1; border: 0 !important; box-shadow: none !important; background: transparent !important; font-size: 1.05rem; padding: 0; min-height: 28px; }
.ecd-k-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.ecd-k-grp { padding: .5rem .6rem .25rem; font-size: .7rem; font-weight: 600; color: var(--faint); }
.ecd-k-item { display: flex; align-items: center; gap: .6rem; min-height: 36px; padding: 0 .6rem; border-radius: 9px; color: var(--text); text-decoration: none !important; cursor: pointer; }
.ecd-k-item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.ecd-k-item small { margin-left: auto; color: var(--faint); font-size: .72rem; }
.ecd-k-item.on { background: var(--fill); }
.ecd-k-foot { display: flex; gap: 1rem; padding: .55rem .9rem; border-top: .5px solid var(--line-2); font-size: .72rem; color: var(--faint); }
@media (max-width: 860px) {
  .ecd-search { min-width: 0; background: transparent; padding: 0 .4rem; } .ecd-search .lbl, .ecd-search kbd { display: none; }
  .ecd-k { top: 8px; left: 8px; right: 8px; width: auto; transform: none; } .ecd-k.show { animation-name: ecdPop; }
  .ecd-k-foot { display: none; } .ecd-k-item { min-height: 44px; } .ecd-k-list { max-height: 70vh; }
}

/* ---- accessibility fallbacks ---- */
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (prefers-reduced-transparency: reduce) {
  .sidebar, .topbar, .ws-menu, details.menu .menu-list, .bulkbar, .ecd-k, .theme-float { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; background: var(--panel) !important; }
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sidebar, .topbar, .ws-menu, details.menu .menu-list, .bulkbar, .ecd-k { background: var(--panel); }
}
@media (prefers-contrast: more) {
  :root, [data-theme] { --line: var(--faint); --line-2: var(--muted); --muted: var(--text); --rim: var(--muted); }
  .sidebar, .topbar, .bulkbar, .ecd-k { background: var(--panel); }
  .card, .kpi { box-shadow: 0 0 0 1px var(--line-2); }
}
.content > .bulkbar.show { animation: ecdMorph 420ms var(--ease) both; animation-delay: 0ms; }
@media screen and (max-width: 640px) {
  /* phones: keep every topbar control on-screen (the Cmd/Ctrl+K search is keyboard-first; nav stays in the menu) */
  .topbar { gap: .4rem; padding: .45rem .6rem; }
  .topbar .ecd-search { display: none; }
}
.ecd-k-item[hidden], .ecd-k-grp[hidden] { display: none !important; }

/* ===== v2.1b: no site-label chrome, phone title, accent chooser ===== */
/* The site label strip/pills are no longer rendered by the layouts; this is only a safety net. */
.site-strip, .site-pill, .brand-site, .site-adding, [data-site-strip], [data-site-pill], [data-site-adding] { display: none !important; }
[data-site-label] .topbar { border-top: 0; }
[data-site-label] .auth-card { min-height: 100vh; }

@media screen and (max-width: 640px) {
  /* phones: flag + chevron only in the workspace switcher so the page title stays readable */
  .ws-switch .ws-cur { display: none; }
  .topbar .title { font-size: .94rem; font-weight: 650; letter-spacing: -.01em; min-width: 4.5em; }
  .ws-switch summary > svg { display: none; }
  .topbar .user-chip { flex: none; }
}

/* Settings → General → Site identity → Accent colour: large swatch cards, same radio inputs */
@media screen {
  .accent-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; max-width: 640px; }
  @media (max-width: 560px) { .accent-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
  .accent-choice { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: .7rem; padding: .9rem .9rem .8rem; border: 0; border-radius: 14px;
    background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); color: var(--text); font-weight: 600; font-size: .86rem; line-height: 1.25; cursor: pointer;
    transition: box-shadow 180ms var(--ease, ease), transform 180ms var(--ease, ease); }
  .accent-choice:hover { box-shadow: inset 0 0 0 1px var(--line-2, var(--line)), var(--shadow); }
  .accent-choice input[type=radio] { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
  .accent-choice .swatch { width: 44px; height: 44px; border-radius: 50%; border: 0; vertical-align: 0;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 2px 8px -2px rgba(0,0,0,.25); display: grid; place-items: center; }
  .accent-choice .swatch::after { content: ""; width: 16px; height: 9px; border: solid #fff; border-width: 0 0 2.5px 2.5px; transform: translateY(-2px) rotate(-45deg) scale(.4); opacity: 0;
    transition: opacity 160ms ease, transform 220ms var(--ease, ease); }
  .accent-choice:has(input:checked) { box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 18%, transparent); }
  .accent-choice:has(input:checked) .swatch::after { opacity: 1; transform: translateY(-2px) rotate(-45deg) scale(1); }
  .accent-choice:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
}
@media (prefers-reduced-motion: reduce) { .accent-choice, .accent-choice .swatch::after { transition: none; } }
@media (prefers-contrast: more) { .accent-choice { box-shadow: inset 0 0 0 1px var(--text); } }
@media screen and (max-width: 640px) {
  /* timeline on phones: break only between words, slightly smaller labels, tighter columns */
  .ost-track li { padding: 0 1px; }
  .ost-track b { font-size: .7rem; overflow-wrap: normal; word-break: normal; hyphens: manual; letter-spacing: -.01em; }
  .ost-track small { font-size: .66rem; max-width: 7.5ch; margin-left: auto; margin-right: auto; }
  .ost-note { font-size: .72rem; }
}

/* =====================================================================
   v2.2 "Lime" look (2026-11-30): one scheme – light grey page, white cards, ONE accent.
   Lime is the default accent; Settings → Site identity → Accent colour still switches every
   accent token below (primary buttons, featured KPI, selected nav icon, chart bars, focus rings).
   Order status colours are data and are left alone.
   ===================================================================== */
[data-accent="lime"] {
  --accent: #bef264; --accent-2: #d9f99d; --accent-ink: #1a2e05; --accent-soft: rgba(190,242,100,.14);
  --link: #d9f99d; --primary-bg: #c5f04a; --primary-hover: #d4f76a; --primary-ink: #1a2e05;
}
[data-accent="lime"][data-theme="light"] {
  --accent: #4d7c0f; --accent-2: #65a30d; --accent-ink: #ffffff; --accent-soft: rgba(163,230,53,.22);
  --link: #3f6212; --primary-bg: #c5f04a; --primary-hover: #b8e63a; --primary-ink: #1a2e05;
}
[data-theme="light"] {
  --bg: #efefed; --panel: #ffffff; --panel-2: #f6f6f4; --line: #e6e6e2; --line-2: #d6d6d1; --fill-2: rgba(110,110,100,.08); --fill: rgba(110,110,100,.13);
  --shadow: 0 1px 2px rgba(20,20,10,.04), 0 8px 24px -12px rgba(20,20,10,.10);
  --wash-1: color-mix(in srgb, var(--primary-bg) 30%, transparent); --wash-2: transparent;
}
:root, [data-theme="dark"] { --wash-2: transparent; }
:root { --radius: 20px; --lift: 0 18px 36px -18px rgba(20,20,10,.28); --nav-on-icon: var(--primary-bg); }

@media screen {
  /* chrome: pill top bar, quiet rail */
  .nav a svg { color: var(--muted); }
  .nav a.active { background: var(--mono-bg); color: var(--mono-ink); font-weight: 600; }
  .nav a.active svg { color: var(--nav-on-icon); }
  .btn { border-radius: 999px; }
  .chips { background: transparent; padding: 0; gap: 2px; }
  .chip { border-radius: 999px; }
  .chip.on, a.chip.on { background: var(--mono-bg); color: var(--mono-ink); box-shadow: none; }
  .card, .kpi, .period { border-radius: var(--radius); }

  /* greeting */
  .dash-eyebrow { display: flex; align-items: center; gap: .5rem; margin: 0 0 .55rem; font: 600 .68rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
  .live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary-bg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-bg) 30%, transparent); }
  .dash-hello h1 { font-size: clamp(1.7rem, 3vw, 2.45rem); font-weight: 600; letter-spacing: -.035em; line-height: 1.1; }
  .hello-name { font-family: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif; font-style: italic; font-weight: 500; letter-spacing: -.01em;
    background: linear-gradient(transparent 80%, color-mix(in srgb, var(--primary-bg) 75%, transparent) 80%, color-mix(in srgb, var(--primary-bg) 75%, transparent) 92%, transparent 92%); padding: 0 .08em; }

  /* KPI cards */
  .hero-kpis { gap: 14px; }
  .hero-kpis > .kpi { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l l" "v v" "s g"; align-content: start; column-gap: .75rem;
    min-height: 150px; padding: 18px 18px 16px; border-radius: 22px; overflow: hidden; text-decoration: none;
    transition: transform 280ms var(--ease-out), box-shadow 280ms var(--ease-out); }
  .hero-kpis > .kpi .k-label { grid-area: l; padding-right: 40px; color: var(--text); font-weight: 600; font-size: .84rem; }
  .hero-kpis > .kpi .k-val { grid-area: v; margin-top: .7rem; display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: clamp(1.45rem, 2.3vw, 2.15rem); font-weight: 700; color: var(--head); }
  .hero-kpis > .kpi .k-sub { grid-area: s; align-self: end; margin-top: .9rem; font-size: .74rem; color: var(--faint); }
  .hero-kpis > .kpi .spark { grid-area: g; align-self: end; width: 92px; height: 30px; margin-top: .9rem; opacity: 1; overflow: visible; }
  .hero-kpis > .kpi .spark path { fill: none; stroke: var(--head); stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
  .hero-kpis > a.kpi::after { content: "↗"; position: absolute; top: 14px; right: 14px; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
    font-size: .82rem; color: var(--text); background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); transition: transform 280ms var(--ease-out); }
  .hero-kpis > a.kpi:hover::after { transform: rotate(45deg); }
  .hero-kpis .k-val .pos { color: inherit; }
  .hero-kpis .delta { margin: 0; padding: .18rem .5rem; border-radius: 999px; font-size: .7rem; letter-spacing: 0; background: color-mix(in srgb, currentColor 13%, transparent); }
  .hero-kpis > .kpi:hover, .stat-row > .kpi:hover { transform: translateY(-4px); box-shadow: var(--lift); }
  a.kpi:hover { background: var(--panel); }
  .stat-row > .kpi { transition: transform 280ms var(--ease-out), box-shadow 280ms var(--ease-out); }

  /* featured (first) card follows the accent */
  .hero-kpis > .kpi:first-child { background: linear-gradient(150deg, color-mix(in srgb, var(--primary-bg) 62%, #ffffff) 0%, var(--primary-bg) 58%); color: var(--primary-ink);
    box-shadow: 0 12px 30px -16px color-mix(in srgb, var(--primary-bg) 85%, #000); }
  .hero-kpis > .kpi:first-child .k-label, .hero-kpis > .kpi:first-child .k-val, .hero-kpis > .kpi:first-child .k-val * { color: var(--primary-ink); }
  .hero-kpis > .kpi:first-child .k-sub { color: var(--primary-ink); opacity: .72; }
  .hero-kpis > .kpi:first-child .spark path { stroke: var(--primary-ink); }
  .hero-kpis > .kpi:first-child .delta { background: rgba(255,255,255,.5); }
  .hero-kpis > a.kpi:first-child::after { background: rgba(255,255,255,.5); box-shadow: none; color: var(--primary-ink); }
  .hero-kpis > a.kpi:first-child:hover { background: linear-gradient(150deg, color-mix(in srgb, var(--primary-bg) 62%, #ffffff) 0%, var(--primary-bg) 58%); }

  /* "Action needed" = the one dark insight panel (same links) */
  .action-card { background: #141414; color: #f2f2f2; box-shadow: 0 18px 40px -22px rgba(0,0,0,.55); }
  .action-card h2, .action-card .card-head h2 { color: #fff; }
  .action-card .pill { background: var(--primary-bg); color: var(--primary-ink); }
  .action-card .action-list a { background: rgba(255,255,255,.06); color: #f2f2f2; transition: transform 240ms var(--ease-out), background 240ms; }
  .action-card .action-list a:hover { background: rgba(255,255,255,.1); transform: translateX(3px); }
  .action-card .action-list .at b { color: #fff; }
  .action-card .action-list .at small, .action-card .action-list .go { color: rgba(255,255,255,.58); }
  .action-card .action-list .ai { filter: grayscale(1) brightness(1.5); }
  .action-card .action-list li.warn a { box-shadow: inset 3px 0 0 var(--primary-bg); }
  .action-card .action-list li.bad a { box-shadow: inset 3px 0 0 #f87171; }
  .action-card details summary, .action-card .all-clear { color: rgba(255,255,255,.75); }
  .action-card .lead-list a { color: #f2f2f2; } .action-card .lead-list .muted { color: rgba(255,255,255,.55); }
  .action-card .lead-list li { border-color: rgba(255,255,255,.08); }
  .action-card .btn-secondary { background: rgba(255,255,255,.1); color: #fff; border: 0; }

  /* charts: accent bars + ink line (status colours stay as data dots) */
  .chart .bar { fill: var(--primary-bg); opacity: .62; }
  .chart a:hover .bar { fill: var(--primary-bg); opacity: 1; }
  .lg-bar { background: var(--primary-bg); }

  /* settings chooser: dark check on light swatches */
  .accent-choice:has(input[value="lime"]) .swatch::after, .accent-choice:has(input[value="amber"]) .swatch::after { border-color: #1a2e05; }
}
@media screen and (min-width: 861px) {
  .topbar { border-radius: 999px; padding: .45rem .6rem .45rem .7rem; }
  .sidebar { border-radius: 24px; }
  .app.collapsed .nav a { padding: .55rem 0; margin: 2px 6px; }
  .app.collapsed .nav a.active { border-radius: 12px; }
}

/* staggered card entrance (replays on pjax because the nodes are new) */
@keyframes ecdCardIn { from { opacity: 0; transform: translateY(16px) scale(.975); } }
@keyframes ecdInner { from { opacity: 0; transform: translateY(4px); } }
@keyframes ecdDraw { from { stroke-dashoffset: 2000; } to { stroke-dashoffset: 0; } }
@media screen and (prefers-reduced-motion: no-preference) {
  .hero-kpis > .kpi { --kd: 140ms; animation: ecdCardIn 600ms var(--ease-out) var(--kd) backwards; }
  .hero-kpis > .kpi:nth-child(2) { --kd: 220ms; } .hero-kpis > .kpi:nth-child(3) { --kd: 300ms; }
  .hero-kpis > .kpi:nth-child(4) { --kd: 380ms; } .hero-kpis > .kpi:nth-child(5) { --kd: 460ms; } .hero-kpis > .kpi:nth-child(6) { --kd: 540ms; }
  .hero-kpis > .kpi > * { animation: ecdInner 420ms var(--ease-out) calc(var(--kd) + 240ms) backwards; }
  .hero-kpis > .kpi .spark path { stroke-dasharray: 2000; animation: ecdDraw 1400ms var(--ease-out) calc(var(--kd) + 420ms) backwards; }
  .action-card .action-list li { animation: ecdInner 420ms var(--ease-out) backwards; }
  .action-card .action-list li:nth-child(1) { animation-delay: 520ms; } .action-card .action-list li:nth-child(2) { animation-delay: 580ms; }
  .action-card .action-list li:nth-child(3) { animation-delay: 640ms; } .action-card .action-list li:nth-child(4) { animation-delay: 700ms; }
  .action-card .action-list li:nth-child(5) { animation-delay: 760ms; } .action-card .action-list li:nth-child(6) { animation-delay: 820ms; }
  .content.ecd-soft .hero-kpis > .kpi, .content.ecd-soft .hero-kpis > .kpi > *, .content.ecd-soft .action-card .action-list li { animation-duration: 220ms; animation-delay: 0ms; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-kpis > .kpi, .hero-kpis > .kpi > *, .hero-kpis > .kpi .spark path, .action-card .action-list li { animation: none !important; }
  .hero-kpis > .kpi:hover, .stat-row > .kpi:hover, .action-card .action-list a:hover { transform: none; }
}
@media (prefers-contrast: more) { .hero-kpis > .kpi { box-shadow: inset 0 0 0 1px var(--text); } }
@media screen {
  .hero-kpis > .kpi .spark { position: static; width: 78px; }
  .action-card .action-list .ai { filter: grayscale(1); opacity: .9; }
  .tag-demo { background: var(--fill); color: var(--muted); border-color: transparent; }
}
@media screen and (max-width: 860px) {
  /* phone drawer: the folded-rail default must not centre the labels */
  .app.collapsed .nav a { justify-content: flex-start; }
}
@media screen { .accent-choices { grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 720px; } }
@media screen and (max-width: 760px) { .accent-choices { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
