:root {
  --bg: #F7F5FC;
  --surface: #FFFFFF;
  --surface-2: #F9F7FE;
  --ink: #1E1530;
  --ink-2: #574C6E;
  --ink-3: #8A80A0;
  --line: #E3DDF0;
  --line-2: #EFEBF7;
  --moss: #6D3FD1;
  --moss-deep: #5328B0;
  --leaf: #C9B6F5;
  --leaf-soft: #EEE7FD;
  --ok: #2E7D4F;
  --ok-soft: #DFF1E6;
  --stamp: #C23A3A;
  --stamp-soft: #FBE4E4;
  --amber: #A86A06;
  --amber-soft: #F8ECD2;
  --sky: #2F62B0;
  --sky-soft: #E2EBFA;
  --side: #2A1758;
  --side-ink: #ECE6FB;
  --side-dim: #A898D6;
  --shadow: 0 1px 2px rgba(30, 21, 48, .05), 0 4px 16px rgba(30, 21, 48, .05);
  --f-display: 'Bai Jamjuree', 'IBM Plex Sans Thai', system-ui, sans-serif;
  --f-body: 'IBM Plex Sans Thai', 'Leelawadee UI', 'Tahoma', system-ui, sans-serif;
  --f-mono: 'IBM Plex Mono', ui-monospace, 'Consolas', monospace;
  --r: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #120D1C; --surface: #1A1428; --surface-2: #211A31; --ink: #ECE7F6; --ink-2: #B5AACB; --ink-3: #847A99;
    --line: #322849; --line-2: #282040; --moss: #B49AF5; --moss-deep: #CDB9FA; --leaf: #5B3FA8; --leaf-soft: #2A1F45;
    --ok: #6FCB94; --ok-soft: #17321F;
    --stamp: #EF7B7B; --stamp-soft: #3D1C22; --amber: #E2AB45; --amber-soft: #382B12; --sky: #8DB2EC; --sky-soft: #1B2640;
    --side: #0C0814; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #120D1C; --surface: #1A1428; --surface-2: #211A31; --ink: #ECE7F6; --ink-2: #B5AACB; --ink-3: #847A99;
  --line: #322849; --line-2: #282040; --moss: #B49AF5; --moss-deep: #CDB9FA; --leaf: #5B3FA8; --leaf-soft: #2A1F45;
  --ok: #6FCB94; --ok-soft: #17321F;
  --stamp: #EF7B7B; --stamp-soft: #3D1C22; --amber: #E2AB45; --amber-soft: #382B12; --sky: #8DB2EC; --sky-soft: #1B2640;
  --side: #0C0814; --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--f-body); }
a { color: var(--moss); }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.2; margin: 0; letter-spacing: -.005em; }
h1 { font-size: clamp(24px, 3vw, 32px); font-weight: 700; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.mono, .num { font-family: var(--f-mono); font-feature-settings: "tnum"; }
.num { text-align: right; white-space: nowrap; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
:focus-visible { outline: 2.5px solid var(--moss); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 22px 16px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; padding: 0 6px; }
.brand-mark { font: 700 17px/1 var(--f-display); letter-spacing: .04em; color: var(--side); background: var(--leaf); width: 42px; height: 48px; display: grid; place-items: center; border-radius: 4px 12px 4px 4px; position: relative; }
.brand-mark::after { content: ""; position: absolute; right: 0; top: 0; border-width: 0 12px 12px 0; border-style: solid; border-color: transparent var(--side) #9C85E0 transparent; }
.brand-text b { display: block; font: 600 16px/1.2 var(--f-display); }
.brand-text small { color: var(--side-dim); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { color: var(--side-ink); text-decoration: none; padding: 9px 12px; border-radius: 8px; font-size: 14.5px; border-left: 3px solid transparent; }
.nav a:hover { background: rgba(201, 182, 245, .08); }
.nav a.on { background: rgba(201, 182, 245, .14); border-left-color: var(--leaf); color: #fff; font-weight: 500; }
.theme-toggle { margin-top: auto; display: flex; align-items: center; gap: 10px; background: transparent; color: var(--side-dim); border: 1px solid rgba(201, 182, 245, .22); border-radius: 8px; padding: 9px 12px; font: 500 14px var(--f-body); cursor: pointer; }
.theme-toggle:hover { color: var(--side-ink); border-color: rgba(201, 182, 245, .5); }
.theme-toggle .i-sun { display: none; }
.theme-toggle.is-dark .i-sun { display: block; }
.theme-toggle.is-dark .i-moon { display: none; }
.side .theme-toggle + .btn-new { margin-top: 0; }
.side .btn-new { margin-top: auto; justify-content: center; background: #C9B6F5; color: #2A1758 !important; border-color: #C9B6F5; }
.side .btn-new:hover { background: #DACCFA; }
main { padding: 28px clamp(16px, 3vw, 40px) 64px; min-width: 0; outline: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: sticky; height: auto; z-index: 20; padding: 10px 16px; gap: 10px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand-text small { display: none; }
  .brand-mark { width: 34px; height: 38px; font-size: 14px; }
  .nav { order: 3; flex-direction: row; overflow-x: auto; width: 100%; gap: 4px; scrollbar-width: none; }
  .nav a { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; border-radius: 6px; padding: 6px 10px; font-size: 13.5px; }
  .nav a.on { border-bottom-color: var(--leaf); }
  .btn-new { margin: 0 0 0 auto; padding: 7px 12px; font-size: 13.5px; }
  .page-head > .btn.primary[href="#/new"] { display: none; }
  .theme-toggle { margin: 0 0 0 auto; padding: 7px 9px; }
  .theme-toggle .theme-label { display: none; }
  .side .theme-toggle + .btn-new { margin: 0; }
}

/* ---------- common ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.eyebrow { font: 600 12px/1 var(--f-display); letter-spacing: .12em; text-transform: uppercase; color: var(--moss); margin-bottom: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.card-head a { font-size: 13.5px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 1100px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); } }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 6px; font: 500 14px/1 var(--f-body); padding: 10px 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--moss); }
.btn.primary { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn.primary:hover { background: var(--moss-deep); }
:root[data-theme="dark"] .btn.primary { color: #120D1C; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #120D1C; } }
.btn.danger { color: var(--stamp); }
.btn.danger:hover { border-color: var(--stamp); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--moss); outline-offset: -1px; border-color: var(--moss); }
textarea { resize: vertical; min-height: 64px; }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.fields .wide { grid-column: 1 / -1; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font: 600 14px var(--f-display); color: var(--moss); margin-bottom: 12px; letter-spacing: .02em; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filters > * { width: auto; flex: 1 1 160px; }
.filters input[type=search] { flex: 2 1 240px; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
@media (max-width: 900px) { .tbl-wrap > table { min-width: 760px; } .tbl-wrap > table.items-edit { min-width: 860px; } }
th { text-align: left; font: 600 12px/1.3 var(--f-display); letter-spacing: .04em; color: var(--ink-2); background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; position: sticky; top: 0; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: var(--surface-2); }
th.num { text-align: right; }
tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--line); }
.doc-no { font: 600 13.5px var(--f-mono); color: var(--ink); white-space: nowrap; }
td.nw { white-space: nowrap; }
.cell-sub { display: block; font-size: 12.5px; color: var(--ink-3); }

/* status */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-ordered { color: var(--sky); background: var(--sky-soft); }
.s-partial { color: var(--amber); background: var(--amber-soft); }
.s-received { color: var(--ok); background: var(--ok-soft); }
.s-overdue { color: var(--stamp); background: var(--stamp-soft); }
.s-cancelled { color: var(--ink-3); background: var(--line-2); }
.due { font-size: 13px; white-space: nowrap; }
.due.late { color: var(--stamp); font-weight: 600; }
.due.soon { color: var(--amber); font-weight: 600; }

.stamp { display: inline-block; font: 700 15px/1 var(--f-display); letter-spacing: .14em; padding: 9px 14px 8px; border: 3px solid currentColor; border-radius: 6px; transform: rotate(-5deg); box-shadow: inset 0 0 0 2px var(--surface), inset 0 0 0 3px currentColor; opacity: .88; white-space: nowrap; }
.stamp small { display: block; font: 500 11px/1.4 var(--f-mono); letter-spacing: .02em; margin-top: 4px; text-align: center; }
.stamp.s-ordered, .stamp.s-partial, .stamp.s-received, .stamp.s-overdue, .stamp.s-cancelled { background: transparent; }

/* meter */
.meter { height: 6px; background: var(--line-2); border-radius: 9px; overflow: hidden; min-width: 60px; }
.meter i { display: block; height: 100%; background: var(--moss); border-radius: 9px; }
.meter.part i { background: var(--amber); }

/* ---------- dashboard ---------- */
.ledger { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 18px; box-shadow: var(--shadow); }
.ledger > div { padding: 16px 20px; border-left: 1px solid var(--line-2); }
.ledger > div:first-child { border-left: 0; }
.ledger dt { font-size: 13px; color: var(--ink-2); }
.ledger dd { margin: 4px 0 0; font: 600 22px/1.2 var(--f-mono); letter-spacing: -.02em; }
.ledger dd small { font: 400 12.5px var(--f-body); color: var(--ink-3); letter-spacing: 0; margin-left: 4px; }
.ledger .alert dd { color: var(--stamp); }
@media (max-width: 760px) { .ledger { grid-template-columns: 1fr 1fr; } .ledger > div:nth-child(3) { border-left: 0; } .ledger > div:nth-child(n+3) { border-top: 1px solid var(--line-2); } }

/* the signature: delivery lane */
.lane { padding: 22px 0 8px; }
.lane-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 0 22px 14px; flex-wrap: wrap; }
.lane-legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.lane-legend i { display: inline-block; width: 18px; height: 8px; border-radius: 4px; margin-right: 6px; vertical-align: middle; }
.lane-scale, .lane-row { display: grid; grid-template-columns: 250px 1fr 118px; gap: 0 14px; align-items: center; padding: 0 22px; }
.lane-scale { font: 500 11.5px var(--f-mono); color: var(--ink-3); height: 26px; }
.lane-scale .ticks { position: relative; height: 100%; }
.lane-scale .ticks span { position: absolute; top: 4px; transform: translateX(-50%); white-space: nowrap; }
.lane-body { position: relative; }
@media (max-width: 1200px) { .lane-scale .ticks span:is(:nth-child(1), :nth-child(3), :nth-child(5), :nth-child(7)) { display: none; } }
.lane-rows { background-image: repeating-linear-gradient(to bottom, transparent 0 51px, var(--line-2) 51px 52px); }
.lane-row { height: 52px; text-decoration: none; color: inherit; }
.lane-row:hover { background: color-mix(in srgb, var(--leaf-soft) 55%, transparent); }
.lane-label { min-width: 0; line-height: 1.25; }
.lane-label b { display: block; font: 600 13px var(--f-mono); }
.lane-label span { display: block; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track { position: relative; height: 100%; }
.bar { position: absolute; top: 50%; height: 12px; margin-top: -6px; border-radius: 6px; background: var(--leaf); }
.bar.part { background: linear-gradient(90deg, var(--moss) var(--p), var(--leaf) var(--p)); }
.bar.nodue { background: repeating-linear-gradient(90deg, var(--leaf) 0 8px, transparent 8px 13px); }
.bar.late { background: repeating-linear-gradient(-45deg, var(--stamp) 0 4px, color-mix(in srgb, var(--stamp) 55%, transparent) 4px 8px); border-radius: 0 6px 6px 0; }
.pin { position: absolute; top: 50%; width: 3px; height: 22px; margin: -11px 0 0 -1.5px; background: var(--ink); border-radius: 2px; }
.start-dot { position: absolute; top: 50%; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; background: var(--surface); border: 2px solid var(--moss); }
.today-line { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--moss); pointer-events: none; }
.lane-scale .ticks .today-mark { top: 2px; font: 700 11px var(--f-display); letter-spacing: .08em; color: #fff; background: var(--moss); padding: 2px 7px; border-radius: 4px; z-index: 1; }
:root[data-theme="dark"] .lane-scale .ticks .today-mark { color: #120D1C; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .lane-scale .ticks .today-mark { color: #120D1C; } }
.lane-tag { text-align: right; }
.lane-empty { padding: 30px 22px; color: var(--ink-2); }
@media (max-width: 760px) {
  .lane-scale { grid-template-columns: 1fr; padding: 0 16px; }
  .lane-scale > :first-child, .lane-scale > :last-child { display: none; }
  .lane-scale .ticks span:is(:nth-child(1), :nth-child(3), :nth-child(5), :nth-child(7), :nth-child(8)) { display: none; }
  .lane-row { grid-template-columns: 1fr auto; grid-template-rows: auto 22px; height: auto; padding: 8px 16px; gap: 2px 10px; }
  .lane-rows { background-image: none; }
  .lane-row { border-bottom: 1px solid var(--line-2); }
  .track { grid-column: 1 / -1; grid-row: 2; }
  .lane-head { padding: 0 16px 14px; }
}

.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 12px; font-size: 13.5px; text-decoration: none; color: inherit; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .val { font: 500 13px var(--f-mono); }
.hbar .meter { grid-column: 1 / -1; height: 8px; }
.hbar:hover .name { color: var(--moss); text-decoration: underline; }

.cols { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 18px; }
.col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.col i { width: 100%; max-width: 44px; background: var(--leaf); border-radius: 5px 5px 0 0; min-height: 2px; position: relative; }
.col.now i { background: var(--moss); }
.col b { font: 500 11px var(--f-mono); color: var(--ink-2); white-space: nowrap; }
.col span { font-size: 12px; color: var(--ink-3); }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { border-top: 1px solid var(--line-2); }
.mini-list li:first-child { border-top: 0; }
.mini-list a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; color: inherit; text-decoration: none; font-size: 13.5px; }
.mini-list a:hover b { color: var(--moss); }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 56px 20px; border: 2px dashed var(--line); border-radius: 14px; background: var(--surface); }
.empty h2 { margin-bottom: 8px; }
.empty p { color: var(--ink-2); max-width: 46ch; margin: 0 auto 18px; }

/* ---------- form / upload ---------- */
.intake { display: grid; grid-template-columns: minmax(300px, 0.85fr) 1.15fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .intake { grid-template-columns: minmax(0, 1fr); } }
.viewer { position: sticky; top: 20px; }
@media (max-width: 1100px) { .viewer { position: static; } }
.drop { display: block; border: 2px dashed var(--leaf); background: var(--surface-2); border-radius: 12px; padding: 34px 20px; text-align: center; cursor: pointer; transition: background .15s, border-color .15s; }
.drop.over { background: var(--leaf-soft); border-color: var(--moss); }
.drop b { display: block; font: 600 17px var(--f-display); margin: 10px 0 4px; }
.drop p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.drop svg { color: var(--moss); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.thumb { position: relative; width: 74px; height: 92px; border: 2px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--surface); cursor: pointer; padding: 0; display: grid; place-items: center; font: 600 12px var(--f-mono); color: var(--stamp); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.on { border-color: var(--moss); }
.thumb .x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; background: rgba(30,21,48,.75); color: #fff; font-size: 12px; line-height: 20px; border: 0; cursor: pointer; }
.preview { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); overflow: hidden; }
.preview img { display: block; width: 100%; height: auto; }
.preview iframe { display: block; width: 100%; height: 72vh; border: 0; }
.ai-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--ink-2); }

.items-edit td { padding: 6px 4px; vertical-align: middle; }
.items-edit th { padding: 8px 6px; }
.items-edit input, .items-edit select { padding: 6px 7px; font-size: 13.5px; }
.items-edit .c-code { width: 110px; } .items-edit .c-qty { width: 74px; } .items-edit .c-unit { width: 74px; } .items-edit .c-price { width: 104px; } .items-edit .c-amt { width: 110px; } .items-edit .c-cat { width: 150px; } .items-edit .c-x { width: 34px; }
.items-edit td.amt { font: 500 13.5px var(--f-mono); text-align: right; padding-right: 10px; }
.totals { display: grid; grid-template-columns: auto 140px; gap: 8px 14px; justify-content: end; align-items: center; margin-top: 14px; font-size: 14px; }
.totals input { text-align: right; font-family: var(--f-mono); }
.totals .grand { font: 700 20px var(--f-mono); color: var(--moss); text-align: right; }
.form-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(6px); padding: 14px 0; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 6px; z-index: 5; }

/* ---------- detail ---------- */
.doc-head { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: start; margin-bottom: 20px; }
.doc-head h1 { font-family: var(--f-mono); font-weight: 600; letter-spacing: -.02em; }
.doc-head .sup { font: 600 18px var(--f-display); margin-top: 6px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 0; margin: 0; border-top: 1px solid var(--line-2); }
.facts > div { padding: 12px 0; border-bottom: 1px solid var(--line-2); padding-right: 12px; }
.facts dt { font-size: 12.5px; color: var(--ink-3); }
.facts dd { margin: 2px 0 0; font-weight: 500; }
.doc-files { display: flex; flex-direction: column; gap: 10px; }
.doc-files a { display: block; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.doc-files img { display: block; width: 100%; max-height: 520px; object-fit: contain; background: #fff; }
.doc-files .pdf { padding: 18px; font: 600 14px var(--f-mono); color: var(--stamp); text-decoration: none; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 6px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: -25px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--moss); }
.timeline li.due::before { border-color: var(--amber); }
.timeline li.late::before { border-color: var(--stamp); background: var(--stamp); }
.timeline li.done::before { background: var(--moss); }
.receive-box { background: var(--leaf-soft); border-color: color-mix(in srgb, var(--moss) 30%, var(--line)); }
.receive-box input[type=number] { width: 90px; text-align: right; font-family: var(--f-mono); }

/* settings */
.code { font: 13px/1.55 var(--f-mono); background: var(--side); color: #E3D9FB; padding: 14px 16px; border-radius: 8px; overflow-x: auto; white-space: pre; margin: 8px 0 0; }
.ep { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 4px 12px; padding: 10px 0; border-top: 1px solid var(--line-2); font-size: 13.5px; }
.ep .m { font: 600 12px var(--f-mono); padding: 2px 0; border-radius: 4px; text-align: center; }
.ep .m.get { color: var(--sky); background: var(--sky-soft); }
.ep .m.post { color: var(--moss); background: var(--leaf-soft); }
.ep .m.del { color: var(--stamp); background: var(--stamp-soft); }
.ep code { font: 500 13px var(--f-mono); }
.ep p { grid-column: 2; margin: 0; color: var(--ink-2); }
.keybox { display: flex; gap: 8px; }
.keybox input { font-family: var(--f-mono); }

/* supplier cards */
.sup-card { display: flex; flex-direction: column; gap: 12px; }
.sup-card h3 { font-size: 16px; }
.sup-card .meta { font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.sup-card dl { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; gap: 8px; border-top: 1px solid var(--line-2); padding-top: 12px; }
.sup-card dt { font-size: 12px; color: var(--ink-3); }
.sup-card dd { margin: 0; font: 600 15px var(--f-mono); }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--ink-2); }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 9px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--stamp); color: #fff; }

.reveal { animation: rise .35s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.lane-row .bar { animation: grow .6s cubic-bezier(.2,.7,.2,1) both; transform-origin: left; animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes grow { from { transform: scaleX(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media print {
  .side, .form-actions, .no-print, .btn { display: none !important; }
  .shell { display: block; } main { padding: 0; } body { background: #fff; }
  .card { box-shadow: none; }
}

/* AI auto-read */
.ai-busy { display: inline-flex; align-items: center; gap: 10px; color: var(--moss); font-weight: 500; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--leaf); border-top-color: var(--moss); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
input.ai-filled, select.ai-filled, textarea.ai-filled { background: var(--leaf-soft); border-color: var(--leaf); }
form[aria-busy="true"] .stack { opacity: .55; pointer-events: none; transition: opacity .2s; }
@media (prefers-reduced-motion: reduce) { .spin { animation: spin 2s linear infinite !important; } }

/* project switcher */
.proj-pick { display: flex; flex-direction: column; gap: 4px; padding: 0 6px; font-size: 12px; color: var(--side-dim); letter-spacing: .04em; }
.proj-pick select { background: rgba(201, 182, 245, .1); color: var(--side-ink); border: 1px solid rgba(201, 182, 245, .3); font-weight: 600; font-size: 14px; padding: 8px 10px; }
.proj-pick select option { color: #1E1530; background: #fff; }
.proj-pick.on select { background: #C9B6F5; color: #2A1758; border-color: #C9B6F5; }
.proj-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 5px; background: var(--leaf-soft); color: var(--moss); white-space: nowrap; }
.proj-card { display: flex; flex-direction: column; gap: 12px; }
.proj-card.current { border-color: var(--moss); box-shadow: 0 0 0 1px var(--moss), var(--shadow); }
.proj-card h3 { font-size: 17px; }
.proj-card dl { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 12px; margin: 0; border-top: 1px solid var(--line-2); padding-top: 12px; }
.proj-card dt { font-size: 12px; color: var(--ink-3); }
.proj-card dd { margin: 0; font: 600 15px var(--f-mono); }
@media (max-width: 900px) { .proj-pick { order: 2; flex-direction: row; align-items: center; gap: 8px; width: 100%; padding: 0; } .proj-pick select { flex: 1; padding: 6px 8px; } }

/* login + user box */
.signed-out .shell { grid-template-columns: minmax(0, 1fr); }
.signed-out .side { display: none; }
.auth-wrap { min-height: calc(100vh - 92px); display: grid; place-items: center; }
.auth-card { width: min(400px, 100%); padding: 32px 28px; }
.auth-card h1 { margin: 16px 0 4px; }
.auth-card .brand-mark { color: #2A1758; background: #C9B6F5; }
.me-box { border-top: 1px solid rgba(201, 182, 245, .2); padding: 14px 6px 0; display: flex; flex-direction: column; gap: 8px; }
.me-name { display: flex; flex-direction: column; line-height: 1.35; }
.me-name b { color: #fff; font-size: 14px; }
.me-name small { color: var(--side-dim); font-size: 12px; }
.me-btn { background: transparent; border: 1px solid rgba(201, 182, 245, .25); color: var(--side-ink); border-radius: 6px; padding: 4px 8px; font: 500 12px var(--f-body); cursor: pointer; }
.me-btn:hover { border-color: rgba(201, 182, 245, .6); }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; margin-top: 10px; }
@media (max-width: 900px) { .me-box { order: 3; width: 100%; flex-direction: row; align-items: center; justify-content: space-between; padding-top: 8px; } }
[hidden] { display: none !important; }
