:root{
  --bg:#f2f5f8; --surface:#ffffff; --surface-2:#f7f9fb; --ink:#13202d; --muted:#586677;
  --line:#d8dee5; --line-strong:#bfc9d4; --navy:#0f2742; --on-navy:#ffffff;
  --accent:#1c8a4a; --accent-hover:#167340; --on-accent:#ffffff; --focus:#2563c9;
  --danger:#b93a26; --pos:#19793f; --warn:#8a5a00;
  --st-stock:#245fa8; --st-stock-bg:#e4eefb; --st-listed:#19793f; --st-listed-bg:#e2f4e8;
  --st-pending:#8a5a00; --st-pending-bg:#fbefd2; --st-sold:#586677; --st-sold-bg:#e9edf1;
  --flash:rgba(28,138,74,.22);
  color-scheme: light;
  box-sizing:border-box;
  padding-top:env(safe-area-inset-top,0px);
  padding-bottom:env(safe-area-inset-bottom,0px);
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#0d141c; --surface:#151f2a; --surface-2:#1a2633; --ink:#e5ecf3; --muted:#95a4b4;
    --line:#26354a; --line-strong:#364a62; --navy:#2a4566; --on-navy:#f2f6fa;
    --accent:#3cb56d; --accent-hover:#52c67f; --on-accent:#08170e; --focus:#6aa2f0;
    --danger:#f08a78; --pos:#5fd08a; --warn:#e5b350;
    --st-stock:#8fbaf2; --st-stock-bg:#1b2e47; --st-listed:#72d79a; --st-listed-bg:#173626;
    --st-pending:#e8bd63; --st-pending-bg:#3a2e12; --st-sold:#a3b1c0; --st-sold-bg:#222f3d;
    --flash:rgba(60,181,109,.3); color-scheme: dark;
  }
}
:root[data-theme="dark"]{
  --bg:#0d141c; --surface:#151f2a; --surface-2:#1a2633; --ink:#e5ecf3; --muted:#95a4b4;
  --line:#26354a; --line-strong:#364a62; --navy:#2a4566; --on-navy:#f2f6fa;
  --accent:#3cb56d; --accent-hover:#52c67f; --on-accent:#08170e; --focus:#6aa2f0;
  --danger:#f08a78; --pos:#5fd08a; --warn:#e5b350;
  --st-stock:#8fbaf2; --st-stock-bg:#1b2e47; --st-listed:#72d79a; --st-listed-bg:#173626;
  --st-pending:#e8bd63; --st-pending-bg:#3a2e12; --st-sold:#a3b1c0; --st-sold-bg:#222f3d;
  --flash:rgba(60,181,109,.3); color-scheme: dark;
}
html{ scroll-padding-top:env(safe-area-inset-top,0px); }
*,*::before,*::after{ box-sizing:border-box; }
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:"Barlow",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  font-size:15px; line-height:1.4; -webkit-text-size-adjust:100%;
}
button,input,select{ font:inherit; color:inherit; }
button{ cursor:pointer; }
:focus-visible{ outline:2px solid var(--focus); outline-offset:2px; }
.sr{ position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }

/* top bar */
.top{
  position:sticky; top:env(safe-area-inset-top,0px); z-index:30;
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:12px 16px; background:var(--bg); border-bottom:1px solid var(--line);
}
.brand{ display:flex; align-items:baseline; gap:12px; min-width:0; flex-wrap:wrap; }
h1{ margin:0; font-family:"Barlow Condensed","Barlow",system-ui,sans-serif; font-weight:700; font-size:26px; letter-spacing:.01em; }
.sync{ display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--muted); }
.sync::before{ content:""; width:8px; height:8px; border-radius:50%; background:var(--muted); }
.sync[data-s="shared"]::before{ background:var(--accent); }
.sync[data-s="local"]::before{ background:var(--warn); }
.sync[data-s="error"]::before{ background:var(--danger); }
.actions{ display:flex; gap:8px; flex-shrink:0; }
.btn{ height:40px; padding:0 16px; border-radius:8px; border:1px solid var(--line-strong); background:var(--surface); font-weight:500; }
.btn:hover{ border-color:var(--ink); }
.btn.primary{ background:var(--accent); border-color:var(--accent); color:var(--on-accent); font-weight:600; }
.btn.primary:hover{ background:var(--accent-hover); border-color:var(--accent-hover); }
.btn[disabled]{ opacity:.55; cursor:default; }

main{ padding:16px; max-width:1800px; margin:0 auto; }

/* figures */
.figures{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); background:var(--surface); border:1px solid var(--line); border-radius:10px; }
.fig{ padding:14px 18px; border-left:1px solid var(--line); min-width:0; }
.fig:first-child{ border-left:0; }
.fig b{ display:block; font-family:"Barlow Condensed","Barlow",sans-serif; font-weight:600; font-size:34px; line-height:1.1; font-variant-numeric:tabular-nums; }
.fig span{ display:block; font-size:13.5px; color:var(--muted); }
.fig small{ display:block; font-size:12.5px; color:var(--muted); margin-top:2px; }
.fig b.neg{ color:var(--danger); }
@media (max-width:720px){
  .figures{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  .fig:nth-child(3){ border-left:0; }
  .fig:nth-child(n+3){ border-top:1px solid var(--line); }
  .fig b{ font-size:30px; }
}

/* toolbar */
.tools{ display:flex; flex-wrap:wrap; gap:8px; margin:16px 0 10px; align-items:center; }
.tools input[type=search],.tools select{
  height:40px; border:1px solid var(--line-strong); border-radius:8px; background:var(--surface); padding:0 10px; font-size:15px; min-width:0;
}
.tools input[type=search]{ flex:1 1 220px; max-width:340px; }
.tools select{ flex:0 1 auto; }
.seg{ display:inline-flex; border:1px solid var(--line-strong); border-radius:8px; overflow:hidden; background:var(--surface); }
.seg button{ height:38px; padding:0 14px; border:0; background:transparent; font-weight:500; color:var(--muted); }
.seg button+button{ border-left:1px solid var(--line); }
.seg button[aria-pressed="true"]{ background:var(--navy); color:var(--on-navy); }
.meta{ display:flex; align-items:center; gap:12px; margin:0 0 8px; font-size:13.5px; color:var(--muted); min-height:24px; }
.link{ border:0; background:none; padding:0; color:var(--focus); text-decoration:underline; font-size:13.5px; }

/* table */
.wrap{ background:var(--surface); border:1px solid var(--line); border-radius:10px; overflow:auto; max-height:calc(100dvh - 290px); min-height:260px; }
table{ border-collapse:separate; border-spacing:0; table-layout:fixed; }
th,td{ border-bottom:1px solid var(--line); padding:0; background:var(--surface); }
thead th{ position:sticky; top:0; z-index:5; background:var(--surface-2); border-bottom:1px solid var(--line-strong); text-align:left; height:42px; }
th.num,td.num{ text-align:right; }
.sort{ width:100%; height:42px; padding:0 8px; border:0; background:transparent; font-weight:600; font-size:13.5px; display:flex; align-items:center; gap:4px; text-align:left; white-space:nowrap; }
th.num .sort{ justify-content:flex-end; }
.sort:hover{ background:var(--line); }
.arr{ font-size:9px; opacity:0; }
.sort:hover .arr{ opacity:.35; }
th[aria-sort="ascending"] .arr,th[aria-sort="descending"] .arr{ opacity:1; color:var(--accent); }
td.id,th.id{ position:sticky; left:0; z-index:4; border-right:1px solid var(--line); }
thead th.id{ z-index:7; }
td.act,th.act{ position:sticky; right:0; z-index:4; border-left:1px solid var(--line); text-align:center; }
thead th.act{ z-index:7; }
td.id{ padding:0 10px; }
.tag{
  display:inline-flex; align-items:center; gap:7px; height:26px; padding:0 11px 0 8px; background:var(--navy); color:var(--on-navy);
  font-family:"Barlow Condensed","Barlow",sans-serif; font-weight:600; font-size:15px; letter-spacing:.05em; border-radius:4px 12px 12px 4px; font-variant-numeric:tabular-nums;
}
.tag::before{ content:""; width:6px; height:6px; border-radius:50%; background:var(--surface); opacity:.9; }
.cell{
  width:100%; height:40px; padding:0 9px; border:1px solid transparent; border-radius:0; background:transparent; font-size:14.5px;
  text-overflow:ellipsis; font-variant-numeric:tabular-nums;
}
td.num .cell{ text-align:right; }
.cell:hover{ background:var(--surface-2); }
.cell:focus{ outline:none; background:var(--surface); border-color:var(--focus); box-shadow:inset 0 0 0 1px var(--focus); }
select.cell{ padding-right:4px; }
select.cell[data-k="status"]{ font-weight:600; }
select.cell[data-status="In stock"]{ color:var(--st-stock); background:var(--st-stock-bg); }
select.cell[data-status="Listed"]{ color:var(--st-listed); background:var(--st-listed-bg); }
select.cell[data-status="Pending sale"]{ color:var(--st-pending); background:var(--st-pending-bg); }
select.cell[data-status="Sold"]{ color:var(--st-sold); background:var(--st-sold-bg); }
.ro{ display:block; padding:0 10px; line-height:40px; font-size:14.5px; font-variant-numeric:tabular-nums; color:var(--ink); background:var(--surface-2); }
.ro.neg{ color:var(--danger); font-weight:600; }
.ro.low{ color:var(--warn); font-weight:600; }
.ro.pos{ color:var(--pos); font-weight:600; }
.ro.strong{ font-weight:600; }
.del{ width:40px; height:40px; border:0; background:transparent; color:var(--muted); display:inline-flex; align-items:center; justify-content:center; font-size:12.5px; font-weight:600; }
.del:hover{ color:var(--danger); background:var(--surface-2); }
.del.armed{ width:auto; padding:0 8px; color:var(--on-accent); background:var(--danger); }
tr.flash td{ animation:flash 1.8s ease-out; }
@keyframes flash{ from{ background:var(--flash); } to{ background:transparent; } }
@media (prefers-reduced-motion:reduce){ tr.flash td{ animation:none; } }
.empty{ padding:48px 20px; text-align:center; color:var(--muted); }
.empty h2{ margin:0 0 6px; font-family:"Barlow Condensed","Barlow",sans-serif; font-size:24px; color:var(--ink); }
.empty p{ margin:0 0 16px; }
body.readonly .cell{ pointer-events:none; }
body.readonly .ro-hide{ display:none; }

/* dialogs */
dialog{
  border:0; padding:0; border-radius:14px; width:min(720px,calc(100% - 24px)); max-height:calc(100dvh - 24px);
  background:var(--surface); color:var(--ink); box-shadow:0 20px 60px rgba(0,0,0,.35);
}
dialog[open]{ display:flex; flex-direction:column; }
dialog::backdrop{ background:rgba(8,16,26,.55); }
.dh{ padding:16px 20px 12px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
.dh h2{ margin:0; font-family:"Barlow Condensed","Barlow",sans-serif; font-size:24px; font-weight:700; }
.dh p{ margin:2px 0 0; font-size:13.5px; color:var(--muted); }
.x{ width:36px; height:36px; border:0; border-radius:8px; background:transparent; font-size:22px; line-height:1; color:var(--muted); }
.x:hover{ background:var(--surface-2); color:var(--ink); }
.strip{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); background:var(--surface-2); border-bottom:1px solid var(--line); }
.strip div{ padding:9px 14px; border-left:1px solid var(--line); }
.strip div:first-child{ border-left:0; }
.strip span{ display:block; font-size:12.5px; color:var(--muted); }
.strip b{ font-family:"Barlow Condensed","Barlow",sans-serif; font-size:21px; font-weight:600; font-variant-numeric:tabular-nums; }
.strip b.neg{ color:var(--danger); }
.db{ padding:6px 20px 18px; overflow:auto; flex:1; overscroll-behavior:contain; }
.db h3{ margin:18px 0 10px; font-size:16px; font-weight:600; padding-bottom:6px; border-bottom:1px solid var(--line); }
.grid{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px 14px; }
.span2{ grid-column:span 2; }
.fld label{ display:block; font-size:13.5px; font-weight:500; color:var(--muted); margin-bottom:4px; }
.fld input,.fld select{ width:100%; height:44px; border:1px solid var(--line-strong); border-radius:8px; background:var(--surface); padding:0 11px; font-size:16px; }
.fld input:focus,.fld select:focus{ outline:2px solid var(--focus); outline-offset:-1px; border-color:var(--focus); }
.fld.bad input,.fld.bad select{ border-color:var(--danger); }
.fld .err{ display:none; color:var(--danger); font-size:13px; margin-top:3px; }
.fld.bad .err{ display:block; }
.money{ position:relative; }
.money::before{ content:"$"; position:absolute; left:11px; top:50%; transform:translateY(-50%); color:var(--muted); pointer-events:none; }
.money input{ padding-left:24px; }
.df{ display:flex; justify-content:flex-end; align-items:center; gap:8px; padding:12px 20px calc(12px + env(safe-area-inset-bottom,0px)); border-top:1px solid var(--line); }
.df .note{ margin-right:auto; font-size:13px; color:var(--muted); }
@media (max-width:640px){
  dialog{ width:100%; max-width:100%; height:100dvh; max-height:100dvh; margin:0; border-radius:0; }
  .dh{ padding-top:calc(14px + env(safe-area-inset-top,0px)); }
  .strip b{ font-size:18px; }
  .strip div{ padding:8px 10px; }
}
#toast{
  position:fixed; left:50%; transform:translateX(-50%); bottom:calc(18px + env(safe-area-inset-bottom,0px)); z-index:100;
  background:var(--ink); color:var(--bg); padding:10px 16px; border-radius:8px; font-size:14.5px; max-width:calc(100% - 32px);
  opacity:0; pointer-events:none; transition:opacity .15s;
}
#toast.on{ opacity:1; }

:root{ --a-ok:#1c8a4a; --a-watch:#d99200; --a-stale:#c8402a; --danger-bg:#fbe3de; }
@media (prefers-color-scheme: dark){ :root:not([data-theme="light"]){ --a-ok:#3cb56d; --a-watch:#e8b23a; --a-stale:#ef6b53; --danger-bg:#3d1d18; } }
:root[data-theme="dark"]{ --a-ok:#3cb56d; --a-watch:#e8b23a; --a-stale:#ef6b53; --danger-bg:#3d1d18; }
.tabs{ display:flex; gap:4px; border-bottom:1px solid var(--line); margin:0 0 16px; }
.tabs button{ border:0; background:none; height:44px; padding:0 18px; font-weight:600; font-size:16px; color:var(--muted); border-bottom:3px solid transparent; margin-bottom:-1px; }
.tabs button[aria-current="page"]{ color:var(--ink); border-bottom-color:var(--accent); }
.tabs button:hover{ color:var(--ink); }
.dhead{ display:flex; justify-content:space-between; align-items:flex-end; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.dhead h2,.panel h2{ margin:0; font-family:"Barlow Condensed","Barlow",sans-serif; font-size:24px; font-weight:700; }
.dhead p,.panel .sub{ margin:2px 0 0; font-size:13.5px; color:var(--muted); }
.kpis{ display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:1px; background:var(--line); border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.kt{ background:var(--surface); padding:14px 18px; min-width:0; }
.kt.lotk{ background:var(--surface-2); }
.kt span{ display:block; font-size:13.5px; color:var(--muted); }
.kt b{ display:block; font-family:"Barlow Condensed","Barlow",sans-serif; font-weight:600; font-size:32px; line-height:1.15; font-variant-numeric:tabular-nums; }
.kt small{ display:block; font-size:12.5px; color:var(--muted); margin-top:1px; }
.kt.hero{ grid-column:span 2; padding:20px 22px; }
.kt.hero b{ font-size:62px; line-height:1.05; }
.kt b.pos,.pos{ color:var(--pos); } .kt b.neg,.neg{ color:var(--danger); }
.dnote{ margin:10px 0 0; font-size:13px; color:var(--muted); }
.mix{ margin-top:16px; }
.mixbar{ display:flex; height:14px; border-radius:7px; overflow:hidden; background:var(--line); }
.mixbar i{ display:block; height:100%; }
.legend{ display:flex; flex-wrap:wrap; gap:6px 18px; margin-top:8px; font-size:13.5px; color:var(--muted); }
.legend span::before{ content:""; display:inline-block; width:10px; height:10px; border-radius:3px; background:var(--c); margin-right:6px; vertical-align:-1px; }
.legend b{ color:var(--ink); font-weight:600; }
.panel{ background:var(--surface); border:1px solid var(--line); border-radius:10px; padding:16px 18px; margin-top:16px; min-width:0; }
.dgrid{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.dgrid .panel{ margin-top:16px; }
.lot{ display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; margin-top:12px; }
.lc{ border:1px solid var(--line); border-top:4px solid var(--c); border-radius:8px; background:var(--surface-2); min-width:0; }
.lc.ok{ --c:var(--a-ok); } .lc.watch{ --c:var(--a-watch); } .lc.stale{ --c:var(--a-stale); }
.lh{ display:flex; justify-content:space-between; gap:8px; padding:10px 12px 8px; }
.lh b{ display:block; font-size:16px; } .lh span{ display:block; font-size:12.5px; color:var(--muted); }
.lcount{ text-align:right; } .lcount b{ font-family:"Barlow Condensed","Barlow",sans-serif; font-size:30px; line-height:1; color:var(--c); font-variant-numeric:tabular-nums; }
.lrows{ max-height:300px; overflow:auto; padding:0 8px 8px; }
.lr{ display:block; width:100%; text-align:left; border:1px solid var(--line); background:var(--surface); border-radius:6px; padding:7px 9px; margin-top:6px; }
.lr:hover{ border-color:var(--c); }
.lr .l1,.lr .l2{ display:flex; justify-content:space-between; align-items:center; gap:8px; }
.lr .l1 em{ font-style:normal; font-weight:600; font-size:14px; font-variant-numeric:tabular-nums; }
.lr .l2{ margin-top:4px; font-size:13.5px; color:var(--muted); }
.lr .l2 span:first-child{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.none{ margin:10px 4px; font-size:13.5px; color:var(--muted); }
.tag.sm{ height:22px; font-size:13px; padding:0 9px 0 7px; }
.tag.sm::before{ width:5px; height:5px; }
.br{ display:grid; grid-template-columns:minmax(96px,34%) 1fr auto; gap:10px; align-items:center; margin-top:10px; }
.bl{ min-width:0; font-size:13.5px; } .bl .tag{ margin-right:6px; }
.bl .nm{ display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-top:2px; color:var(--muted); }
.bt{ position:relative; height:22px; background:var(--surface-2); border-radius:4px; }
.bt .bar{ position:absolute; top:3px; height:16px; border-radius:3px; min-width:2px; }
.bt .zero{ position:absolute; top:0; bottom:0; width:1px; background:var(--line-strong); }
.bt .cbar{ position:absolute; left:0; top:2px; height:8px; border-radius:2px; background:var(--navy); }
.bt .abar{ position:absolute; left:0; top:12px; height:8px; border-radius:2px; background:var(--accent); }
.bv{ font-size:13.5px; font-weight:600; text-align:right; font-variant-numeric:tabular-nums; min-width:76px; }
.bv small{ display:block; font-weight:400; color:var(--muted); font-size:12px; }
.bv.low{ color:var(--warn); }
.key{ display:flex; gap:16px; font-size:13px; color:var(--muted); margin-top:10px; }
.key span::before{ content:""; display:inline-block; width:10px; height:10px; border-radius:2px; background:var(--c); margin-right:6px; }
.chip{ display:inline-block; padding:2px 9px; border-radius:999px; font-size:12.5px; font-weight:600; white-space:nowrap; }
.chip.st0{ color:var(--st-stock); background:var(--st-stock-bg); } .chip.st1{ color:var(--st-listed); background:var(--st-listed-bg); }
.chip.st2{ color:var(--st-pending); background:var(--st-pending-bg); } .chip.st3{ color:var(--st-sold); background:var(--st-sold-bg); }
.chip.al0{ color:var(--st-listed); background:var(--st-listed-bg); } .chip.al1{ color:var(--st-pending); background:var(--st-pending-bg); }
.chip.al2{ color:var(--danger); background:var(--danger-bg); }
.dtw{ overflow:auto; margin-top:10px; border:1px solid var(--line); border-radius:8px; }
.dt{ border-collapse:collapse; table-layout:fixed; }
.dt th{ background:var(--surface-2); height:40px; }
.dt td{ padding:0 10px; height:40px; font-size:14.5px; font-variant-numeric:tabular-nums; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.dt td.num{ text-align:right; }
.dt tr:hover td{ background:var(--surface-2); }
.dt .est{ color:var(--muted); font-style:italic; }
.dt button.idb{ border:0; background:none; padding:0; }
.dfoot{ margin:8px 0 0; font-size:12.5px; color:var(--muted); }
@media (max-width:820px){ .dgrid,.lot{ grid-template-columns:minmax(0,1fr); } }
@media (max-width:720px){
  .kpis{ grid-template-columns:repeat(2,minmax(0,1fr)); }
  .kt.hero b{ font-size:52px; } .kt b{ font-size:28px; } .kt{ padding:12px 14px; }
  .br{ grid-template-columns:1fr auto; } .br .bt{ grid-column:1 / -1; grid-row:2; }
}
.bt.tri{ height:32px; }
.bt.tri i{ position:absolute; left:0; height:6px; border-radius:2px; }
.bt.tri .cb{ top:3px; background:var(--navy); } .bt.tri .lb{ top:13px; background:var(--muted); opacity:.55; } .bt.tri .sb{ top:23px; background:var(--a-ok); }
.bv small+small{ margin-top:0; }
.pos{ color:var(--pos); }
.fld .hint{ font-size:13px; color:var(--muted); margin-top:4px; }
.salenote{ margin:14px 0 0; padding:10px 12px; background:var(--surface-2); border:1px solid var(--line); border-radius:8px; font-size:14px; color:var(--muted); }

[hidden]{ display:none !important; }
body.locked .top, body.locked main{ display:none; }
body.noDel td.act, body.noDel th.act{ display:none; }
.auth{ position:fixed; inset:0; z-index:200; background:var(--bg); display:flex; align-items:center; justify-content:center; padding:calc(20px + env(safe-area-inset-top,0px)) 20px calc(20px + env(safe-area-inset-bottom,0px)); overflow:auto; }
.authcard{ width:min(400px,100%); background:var(--surface); border:1px solid var(--line); border-radius:14px; padding:28px 24px; display:grid; gap:14px; }
.authcard h1{ font-size:30px; }
.authsub{ margin:-6px 0 0; color:var(--muted); font-size:14.5px; }
.authmsg{ margin:0; min-height:0; font-size:14px; color:var(--danger); }
.authmsg.ok{ color:var(--pos); }
.authmsg:empty{ display:none; }
.authlinks{ display:flex; justify-content:center; }
