:root {
  --bg: #ffffff; --surface: #f7f5f6; --surface-2: #efebee; --ink: #1c171a; --muted: #6a6167; --line: #e5dfe3;
  --brand: #9b336f; --brand-ink: #ffffff; --brand-weak: #f6e6ee;
  --s-assets: #b7791f; --s-notstarted: #8a8f98; --s-progress: #2b6cb0; --s-approval: #8e4fd0; --s-edits: #d9480f; --s-done: #2f855a;
  --shadow: 0 1px 2px rgba(28, 23, 26, .06), 0 8px 24px rgba(28, 23, 26, .08);
  --r: 10px;
  color-scheme: light;
  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151113; --surface: #1d181b; --surface-2: #272024; --ink: #f3eef1; --muted: #a99fa5; --line: #362e33;
    --brand: #d9739f; --brand-ink: #1a0f15; --brand-weak: #3a2230;
    --s-assets: #b27c1e; --s-notstarted: #9aa0a8; --s-progress: #4f8fdb; --s-approval: #a070e6; --s-edits: #e06a33; --s-done: #3fa06a;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151113; --surface: #1d181b; --surface-2: #272024; --ink: #f3eef1; --muted: #a99fa5; --line: #362e33;
  --brand: #d9739f; --brand-ink: #1a0f15; --brand-weak: #3a2230;
  --s-assets: #b27c1e; --s-notstarted: #9aa0a8; --s-progress: #4f8fdb; --s-approval: #a070e6; --s-edits: #e06a33; --s-done: #3fa06a;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.4);
}
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.muted { color: var(--muted); }
.hide { display: none !important; }

/* status colours */
.st-assets { --c: var(--s-assets); } .st-notstarted { --c: var(--s-notstarted); } .st-progress { --c: var(--s-progress); }
.st-approval { --c: var(--s-approval); } .st-edits { --c: var(--s-edits); } .st-done { --c: var(--s-done); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-size: 12.5px; font-weight: 600; white-space: nowrap;
  color: color-mix(in srgb, var(--c) 78%, var(--ink)); background: color-mix(in srgb, var(--c) 13%, transparent); }
.chip i { font-style: normal; color: var(--c); font-size: 13px; line-height: 1; }
.cell { display: inline-block; width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.cell.hollow { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }

/* top bar */
.top { display: flex; align-items: center; gap: 20px; padding: 12px 24px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 20; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: 8px; }
.mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: var(--brand-ink); font-weight: 700; font-size: 15px; }
.brand b { display: block; font-size: 16px; letter-spacing: -.01em; line-height: 1.1; }
.brand small { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.tab:hover { background: var(--surface); color: var(--ink); }
.tab[aria-current="page"] { color: var(--brand); background: var(--brand-weak); }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.btn { border: 1px solid var(--line); background: var(--bg); padding: 7px 13px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--s-edits); }
.btn.small { padding: 3px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
h1 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.005em; }
.sub { color: var(--muted); margin: 0 0 22px; }

/* overview */
.strip { display: flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 28px; background: var(--bg); }
.kpi { flex: 1 1 170px; padding: 16px 20px; border-right: 1px solid var(--line); min-width: 150px; }
.kpi:last-child { border-right: 0; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .v small { font-size: 15px; color: var(--muted); font-weight: 500; }
.kpi .v small.blk { display: block; font-size: 13px; letter-spacing: 0; }
.bar { height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.bar > b { display: block; height: 100%; background: var(--s-done); border-radius: 3px; }
.kpi.alert .v { color: var(--s-edits); }
@media (max-width: 700px) { .kpi { border-right: 0; border-bottom: 1px solid var(--line); } .kpi:last-child { border-bottom: 0; } }

.grid2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 28px; align-items: start; }
@media (max-width: 980px) { .grid2 { grid-template-columns: 1fr; } }
section.block { margin-bottom: 32px; }
.mhead { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0 8px; }
.mhead b { font-size: 14px; } .mhead span { color: var(--muted); font-size: 13px; }
.wall { display: flex; flex-wrap: wrap; gap: 8px; }
.sku { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); min-width: 52px; text-align: left; }
.sku:hover { border-color: var(--brand); background: var(--brand-weak); }
.sku .n { font-size: 11.5px; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.sku .cells { display: flex; gap: 2px; }
.stack { display: flex; gap: 2px; height: 18px; margin-bottom: 14px; }
.stack > div { background: var(--c); border-radius: 4px; min-width: 4px; }
.leg { width: 100%; border-collapse: collapse; }
.leg td { padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.leg tr { cursor: pointer; } .leg tr:hover td { background: var(--surface); }
.mrow { display: grid; grid-template-columns: 96px 1fr 64px; gap: 12px; align-items: center; padding: 7px 0; font-size: 14px; }
.attn { list-style: none; margin: 0; padding: 0; }
.attn li { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.attn li:hover { background: var(--surface); }
.attn .t { flex: 1; min-width: 0; } .attn .t b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attn .t span { color: var(--muted); font-size: 13px; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--r); }

/* tracker */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar input[type=search], .toolbar select, .field input, .field select, .field textarea, .dt input, .dt select, .ix input, .ix select {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 10px; min-width: 0; }
.toolbar input[type=search] { width: 270px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--bg); padding: 7px 12px; font-weight: 600; font-size: 14px; color: var(--muted); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed=true] { background: var(--brand-weak); color: var(--brand); }
.seg small { opacity: .7; margin-left: 4px; font-weight: 500; }
.bulk { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 14px; background: var(--brand-weak); border-radius: var(--r); margin-bottom: 12px; font-size: 14px; }
.bulk select { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--bg); }
.tw { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); }
table.t { width: 100%; border-collapse: collapse; min-width: 760px; }
.t th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 9px 12px; background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr.row:hover td { background: var(--surface); }
.t td.no { color: var(--muted); width: 44px; font-variant-numeric: tabular-nums; }
.nm { border: 0; background: none; padding: 0; text-align: left; font-weight: 600; display: flex; gap: 8px; align-items: baseline; }
.nm .car { display: inline-block; width: 12px; color: var(--muted); transition: transform .15s; }
.nm[aria-expanded=true] .car { transform: rotate(90deg); }
.prog { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.prog .cells { display: flex; gap: 2px; }
tr.detail > td { background: var(--surface); padding: 14px 16px 18px 56px; }
@media (max-width: 700px) { tr.detail > td { padding-left: 12px; } }
.dt { width: 100%; border-collapse: collapse; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.dt th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dt td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.dt tr:last-child td { border-bottom: 0; }
.dt input[type=text] { width: 100%; min-width: 120px; padding: 5px 8px; }
.dt input.lb { min-width: 230px; } .dt input.sz { min-width: 124px; } .dt input.sl { width: 64px; } .dt input.nt { min-width: 150px; }
.dt select { padding: 5px 6px; }
.dt .kind { font-size: 12px; color: var(--muted); white-space: nowrap; }
.dt .dd { white-space: nowrap; color: var(--muted); font-size: 13px; }
.dt tr.ok td { background: color-mix(in srgb, var(--s-done) 5%, var(--bg)); }
.dact { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-top: 12px; }
.ix { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; font-size: 13px; color: var(--muted); }
.ix input[type=text] { width: 220px; }
.warn { color: var(--s-edits); font-size: 12.5px; }

/* invoice */
.cardt { width: 100%; border-collapse: collapse; margin-bottom: 22px; }
.cardt th, .cardt td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.cardt th { color: var(--muted); font-size: 12.5px; font-weight: 600; background: var(--surface); }
.cardt td.num, .cardt th.num { text-align: right; }
.cardt tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.rules { background: var(--surface); border-radius: var(--r); padding: 14px 18px; font-size: 14px; color: var(--muted); }
.rules b { color: var(--ink); }

/* activity */
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 150px 110px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log time { color: var(--muted); font-size: 13px; } .log .u { font-weight: 600; }
@media (max-width: 700px) { .log li { grid-template-columns: 1fr; gap: 2px; } }

/* modal, tip, toast */
#modal { position: fixed; inset: 0; background: rgba(20, 12, 17, .45); display: none; place-items: start center; padding: 6vh 16px; overflow: auto; z-index: 50; }
#modal.open { display: grid; }
.sheet { background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); width: min(640px, 100%); padding: 22px 24px; border: 1px solid var(--line); }
.sheet h2 { font-size: 19px; margin-bottom: 14px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; font-size: 13.5px; }
.field > span { color: var(--muted); font-weight: 600; }
.field textarea { min-height: 120px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.sheet .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.ut { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.ut td { padding: 5px 4px; border-bottom: 1px solid var(--line); } .ut input, .ut select { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; background: var(--bg); }
#tip { position: fixed; z-index: 60; pointer-events: none; background: var(--ink); color: var(--bg); padding: 8px 11px; border-radius: 8px; font-size: 13px; max-width: 300px; display: none; box-shadow: var(--shadow); }
#tip b { display: block; margin-bottom: 4px; } #tip div { display: flex; gap: 6px; align-items: center; } #tip .cell { width: 9px; height: 9px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px; display: none; z-index: 70; }
#toast.err { background: var(--s-edits); color: #fff; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth form { width: min(380px, 100%); }
.auth .mark { width: 40px; height: 40px; font-size: 20px; margin-bottom: 18px; }
.auth h1 { margin-bottom: 18px; }
.auth .field input { padding: 10px 12px; }
.auth .btn { width: 100%; padding: 11px; }
.err { color: var(--s-edits); font-size: 14px; min-height: 20px; margin: 4px 0 8px; }
.sync { font-size: 12px; color: var(--muted); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
