:root {
  --bg: #f7f9fa; --panel: #fff; --panel-2: #f1f5f6; --ink: #0d2b33; --text: #14262b; --muted: #647a81; --line: #e1e8ea;
  --teal: #0e6e7e; --teal-h: #0a5864; --on-teal: #fff; --spark: #f2a81d;
  --ok: #17703f; --ok-bg: #e4f4ea; --warn: #7d5200; --warn-bg: #fff2d4; --err: #a5271f; --err-bg: #fbe6e3; --info: #0b5e73; --info-bg: #e0f1f5;
  --font: "Inter var", Inter, "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a171b; --panel: #0f2127; --panel-2: #132a31; --text: #e3eef0; --muted: #8ea6ac; --line: #1f363d;
    --teal: #3dbccd; --teal-h: #62cddb; --on-teal: #04242a;
    --ok: #6fd69b; --ok-bg: #123524; --warn: #f2c35b; --warn-bg: #3a2c08; --err: #ff8e84; --err-bg: #3d1713; --info: #7fd6e0; --info-bg: #0f3139;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.02em; font-weight: 650; }
h2 { font-size: 17px; letter-spacing: -.01em; font-weight: 650; }
h3 { font-size: 15px; font-weight: 600; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
.ico { width: 18px; height: 18px; flex: none; }
.muted { color: var(--muted); }
.part { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; background: var(--panel-2); color: var(--text); transition: background .15s; }
.btn.primary { background: var(--teal); color: var(--on-teal); }
.btn.primary:hover { background: var(--teal-h); }
.btn.danger { background: var(--err); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.danger { color: #2b0805; } }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.big { padding: 13px 20px; font-size: 16px; width: 100%; justify-content: center; }
.btn.small { padding: 6px 12px; font-size: 13px; }
.btn[disabled] { opacity: .4; cursor: not-allowed; }

/* login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; overflow: hidden; background: radial-gradient(120% 90% at 20% 100%, #12606d 0%, var(--ink) 55%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.login-art .plume { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-brand { position: relative; display: flex; align-items: center; gap: 12px; font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.login-claim { position: relative; max-width: 15em; font-size: clamp(30px, 3.6vw, 46px); line-height: 1.1; letter-spacing: -.03em; font-weight: 650; text-wrap: balance; }
.login-card { display: flex; flex-direction: column; padding: 24px 32px; background: var(--bg); }
.login-box { margin: auto; width: min(380px, 100%); display: grid; gap: 14px; }
.login-box p { color: var(--muted); }
.login-box .fine { font-size: 13px; text-align: center; }
.logo { width: 36px; height: 36px; flex: none; }
.logo-bg { fill: var(--ink); }
.login-art .logo-bg { fill: rgb(255 255 255 / .1); }

/* ribbon (login only) */
.rib { fill: none; stroke: url(#pg); stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.4s .15s cubic-bezier(.2, .7, .2, 1) forwards; }
.rib.r1 { stroke-width: 5; }
.rib.r2 { stroke-width: 2.5; opacity: .7; animation-delay: .35s; }
.rib.r3 { stroke-width: 1.5; opacity: .5; animation-delay: .55s; }
.plume-spark { opacity: 0; transform-box: fill-box; transform-origin: center; animation: pop .7s 2s cubic-bezier(.2, .9, .3, 1.4) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) {
  .rib { animation: none; stroke-dashoffset: 0; }
  .plume-spark { animation: none; opacity: 1; }
  .spin { animation: none !important; }
}

/* shell: light, quiet sidebar */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 22px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-size: 18px; font-weight: 650; letter-spacing: -.02em; padding: 0 6px; }
.brand .logo { width: 30px; height: 30px; }
.rail nav { display: grid; gap: 2px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 550; }
.nav:hover { background: var(--panel-2); color: var(--text); }
.nav.on { background: var(--panel-2); color: var(--text); box-shadow: inset 2px 0 0 var(--teal); }
.rail-foot { margin-top: auto; display: grid; gap: 12px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--info-bg); color: var(--info); display: grid; place-items: center; font-weight: 650; font-size: 13px; flex: none; }
.who-t { display: grid; min-width: 0; line-height: 1.25; font-size: 13px; }
.who-t strong, .who-t small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-t small { color: var(--muted); }
.main { padding: 36px clamp(20px, 4vw, 48px) 64px; max-width: 1100px; width: 100%; }

/* home */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-bottom: 36px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: grid; gap: 6px; text-decoration: none; align-content: start; transition: border-color .15s; }
.card:hover { border-color: var(--teal); }
.card p { color: var(--muted); }
.card-ico { color: var(--teal); margin-bottom: 4px; }
.card-ico .ico { width: 22px; height: 22px; }
.card-go { display: inline-flex; align-items: center; gap: 6px; color: var(--teal); font-weight: 600; margin-top: 6px; }
.sub { margin: 4px 0 12px; }

/* stock list */
.stock-list { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.srow { display: grid; grid-template-columns: minmax(180px, 1.1fr) 1.3fr minmax(190px, auto); gap: 20px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.srow:last-child { border-bottom: 0; }
.sname { display: grid; min-width: 0; }
.snum { text-align: right; white-space: nowrap; }
.snum strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.flag { margin-left: 10px; font-size: 12.5px; font-weight: 600; }
.flag.err { color: var(--err); } .flag.warn { color: var(--warn); }
.srow.missing { grid-template-columns: minmax(180px, 1.1fr) 2.5fr; }
.smsg { display: flex; gap: 8px; align-items: flex-start; color: var(--warn); font-weight: 550; }
.all { margin-top: 14px; }
.all summary { cursor: pointer; padding: 8px 0; font-weight: 600; color: var(--muted); }
.all[open] { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 4px 18px 8px; }
.barcell { width: 160px; }
.bar { display: block; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar-fill { display: block; height: 100%; width: var(--pct, 0%); background: var(--teal); border-radius: 3px; }
.bar-fill.full { background: var(--err); }

/* task pages */
.page-head { display: grid; gap: 4px; margin-bottom: 22px; }
.page-head p { color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; display: grid; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend { font-size: 13px; color: var(--muted); font-weight: 600; padding: 0; margin-bottom: 6px; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 9px; padding: 3px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { padding: 7px 16px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg input:checked + label { background: var(--panel); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.seg input:focus-visible + label { outline: 2px solid var(--teal); outline-offset: 2px; }
.target { display: flex; align-items: center; gap: 28px; padding: 2px 0 2px 14px; border-left: 2px solid var(--teal); }
.target-info { display: grid; gap: 1px; }
.target-free { display: grid; line-height: 1.1; }
.target-free strong { font-size: 34px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.target-free span { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.target-free.zero strong { color: var(--err); }
.target-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field { display: grid; gap: 2px; font-weight: 600; }
.field small { font-weight: 400; color: var(--muted); }
textarea { width: 100%; resize: vertical; min-height: 140px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 12px 14px; font: 14px/1.5 ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; }
textarea:focus { outline: 2px solid var(--teal); outline-offset: 0; border-color: transparent; }
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--teal); }
.meta { display: flex; gap: 8px; flex-wrap: wrap; min-height: 26px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
#out { display: grid; gap: 16px; margin-top: 22px; }

/* chips, tiles, banners */
.chip { display: inline-flex; align-items: center; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 550; background: var(--panel-2); color: var(--text); margin: 1px 0; }
.chip.ok, .chip.add { background: var(--ok-bg); color: var(--ok); }
.chip.err, .chip.rm { background: var(--err-bg); color: var(--err); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.info { background: var(--info-bg); color: var(--info); }
.chip.dim { color: var(--muted); }
.tiles { display: flex; flex-wrap: wrap; gap: 14px 40px; padding: 2px 0; }
.tile { display: grid; }
.tile b { font-size: 26px; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: 13px; font-weight: 550; }
.tile.ok b { color: var(--ok); } .tile.err b { color: var(--err); }
.seats { display: flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 550; }
.seats.warn { color: var(--warn); }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; border-radius: 8px; font-weight: 550; }
.banner.err { background: var(--err-bg); color: var(--err); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }
.note { color: var(--muted); }
ul.bad { margin: 6px 0 0; padding-left: 18px; font-weight: 450; }
ul.bad code { font: 13px ui-monospace, Consolas, monospace; }
.errmsg { color: var(--err); font-size: 13px; margin-top: 2px; }
.working { display: flex; align-items: center; gap: 12px; color: var(--muted); font-weight: 550; padding: 16px 2px; }
.spark { width: 22px; height: 22px; color: var(--spark); }
.spin { animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tables */
.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 11px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th.num { text-align: right; }
.tbl td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.all .tbl td { padding: 9px 8px; }

/* dialog */
.dlg { border: 0; border-radius: 14px; padding: 24px; width: min(440px, 92vw); background: var(--panel); color: var(--text); box-shadow: 0 24px 60px -20px rgb(0 0 0 / .45); }
.dlg::backdrop { background: rgb(8 21 26 / .5); }
.dlg form { display: grid; gap: 10px; }
.dlg p { color: var(--muted); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-art { min-height: 240px; padding: 28px; }
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail nav { display: flex; order: 3; width: 100%; overflow-x: auto; }
  .nav span { white-space: nowrap; }
  .rail-foot { margin: 0 0 0 auto; display: flex; align-items: center; }
  .who-t { display: none; }
  .srow, .srow.missing { grid-template-columns: 1fr; gap: 8px; }
  .snum { text-align: left; }
}

/* idle warning */
.idle { position: fixed; right: 20px; bottom: 20px; z-index: 20; display: flex; align-items: center; gap: 16px; background: var(--panel); border: 1px solid var(--warn); color: var(--text); border-radius: 12px; padding: 12px 16px; box-shadow: 0 12px 32px -12px rgb(0 0 0 / .35); font-weight: 550; }
