:root {
  --ink: #14202e; --ink-2: #1d2d40; --ink-line: #2b3d52; --ink-text: #b9c6d6;
  --bg: #f3f4f1; --surface: #fff; --line: #dfe2dc; --line-soft: #ecefe9;
  --text: #17212b; --muted: #5f6b76; --accent: #0b6e5e; --accent-dark: #085447; --accent-soft: #e2f1ed;
  --ok: #17734a; --ok-bg: #e1f3e8; --warn: #8a5a00; --warn-bg: #fdf0d0; --bad: #a32c2c; --bad-bg: #fbe4e2;
  --info: #1f5c99; --info-bg: #e2eefa; --radius: 8px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; line-height: 1.25; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .8rem; margin: 0 0 .5rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
p { margin: 0 0 .75rem; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .nowrap { white-space: nowrap; }
.neg { color: var(--bad); } .pos { color: var(--ok); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--ink); color: var(--ink-text); padding: 0 0 2rem; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 1.1rem 1.15rem 1rem; color: #fff; font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; font-size: .85rem; color: #fff; }
.side h4 { margin: 1.1rem 1.15rem .3rem; font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #7f90a3; font-weight: 600; }
.side a { display: block; padding: .38rem 1.15rem; color: var(--ink-text); border-left: 3px solid transparent; font-size: .93rem; }
.side a:hover { background: var(--ink-2); color: #fff; text-decoration: none; }
.side a.on { background: var(--ink-2); color: #fff; border-left-color: #35c2a8; font-weight: 600; }
.side a.cta { margin: .4rem 1.15rem .2rem; padding: .55rem .8rem; background: var(--accent); color: #fff; border-radius: var(--radius); border: 0; font-weight: 600; text-align: center; }
.side a.cta:hover { background: #0d8573; }
.nav-toggle, .nav-toggle-label { display: none; }
.top { display: flex; align-items: center; gap: 1rem; justify-content: flex-end; padding: .6rem 1.75rem; background: var(--surface); border-bottom: 1px solid var(--line); }
.top form { margin: 0; display: flex; align-items: center; gap: .4rem; }
.top .who { font-size: .9rem; color: var(--muted); }
.content { padding: 1.5rem 1.75rem 3rem; max-width: 1320px; }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem; margin-bottom: 1.1rem; }
.head .grow { flex: 1 1 260px; min-width: 0; }
.head p { margin: .25rem 0 0; color: var(--muted); max-width: 70ch; }
.crumb { font-size: .82rem; color: var(--muted); margin-bottom: .15rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: .9rem 1.2rem 0; }
.grid { display: grid; gap: 1.1rem; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .95rem 1.1rem; }
.stat .label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.stat .value { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat .sub { font-size: .84rem; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1.25rem; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: .6rem .9rem; border-bottom: 1px solid var(--line); background: #fafbf8; white-space: nowrap; }
td { padding: .6rem .9rem; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fafbf8; }
tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; background: #fafbf8; }
td.tight, th.tight { width: 1%; white-space: nowrap; }
.empty { padding: 2.25rem 1rem; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: .2rem; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: .7rem .9rem; border-top: 1px solid var(--line); font-size: .9rem; color: var(--muted); }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=file], select, textarea {
  width: 100%; padding: .5rem .65rem; border: 1px solid #c4c9c1; border-radius: 6px; font: inherit; background: #fff; color: var(--text); min-height: 38px; }
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { margin-bottom: 1rem; }
.field .help { font-size: .83rem; color: var(--muted); margin-top: .25rem; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 500; margin-bottom: .45rem; }
.check input { margin-top: .3rem; width: 16px; height: 16px; flex: none; }
.form { max-width: 720px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .wide { grid-column: 1 / -1; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .9rem; }
.filters input, .filters select { width: auto; min-width: 150px; }
.filters input[type=search] { min-width: 240px; }
.inline { display: inline; margin: 0; }
td input[type=text], td input[type=number] { min-height: 34px; padding: .35rem .5rem; }
.w-sm { max-width: 110px; } .w-md { max-width: 180px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .48rem .95rem; min-height: 38px; border-radius: 6px; border: 1px solid #c4c9c1; background: #fff; color: var(--text); font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f4f6f2; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--bad); border-color: #e3b9b6; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.small { min-height: 30px; padding: .2rem .6rem; font-size: .84rem; }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0; min-height: 0; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.badge { display: inline-block; padding: .08rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.info { background: var(--info-bg); color: var(--info); }
.badge.muted { background: #eceee9; color: var(--muted); }
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; border: 1px solid; }
.flash.ok { background: var(--ok-bg); border-color: #b5dec5; color: #0f5435; }
.flash.error { background: var(--bad-bg); border-color: #efc1bd; color: #7d1f1f; }
.flash.info { background: var(--info-bg); border-color: #bcd5ef; color: #17477a; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: #f3f4f1; border: 1px dashed #b8beb4; padding: .6rem .8rem; border-radius: 6px; word-break: break-all; }

/* ---------- product picker ---------- */
.picker-cell { position: relative; min-width: 260px; }
.picker-menu { position: absolute; z-index: 20; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid #c4c9c1; border-radius: 6px; box-shadow: 0 8px 24px rgba(20, 32, 46, .14); max-height: 260px; overflow: auto; }
.picker-menu button { display: block; width: 100%; text-align: left; padding: .5rem .7rem; border: 0; background: none; font: inherit; cursor: pointer; }
.picker-menu button:hover, .picker-menu button:focus { background: var(--accent-soft); }
.picker-menu .none { padding: .5rem .7rem; color: var(--muted); }

/* ---------- chart ---------- */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: .5rem; }
.bars .bar { flex: 1; min-width: 4px; background: var(--accent); border-radius: 3px 3px 0 0; position: relative; min-height: 2px; }
.bars .bar.zero { background: var(--line); }
.bars .bar:hover { background: var(--accent-dark); }
.bars-axis { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); padding-top: .35rem; border-top: 1px solid var(--line); }
.meter { height: 6px; background: var(--line-soft); border-radius: 99px; overflow: hidden; min-width: 80px; }
.meter i { display: block; height: 100%; background: var(--accent); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.auth-side { background: var(--ink); color: #dfe7ef; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { color: #fff; font-size: 2rem; max-width: 16ch; }
.auth-side ul { padding: 0; margin: 1.5rem 0 0; list-style: none; }
.auth-side li { padding: .35rem 0 .35rem 1.4rem; position: relative; color: var(--ink-text); }
.auth-side li::before { content: ""; position: absolute; left: 0; top: .95em; width: 8px; height: 8px; border-radius: 2px; background: #35c2a8; }
.auth-main { display: grid; place-items: center; padding: 2rem 1.25rem; }
.auth-box { width: 100%; max-width: 460px; }
.auth-box h2 { font-size: 1.4rem; margin-bottom: .25rem; }

/* ---------- receipt ---------- */
.receipt { width: 302px; margin: 1rem auto; background: #fff; padding: 14px 12px; font: 12.5px/1.45 ui-monospace, Menlo, Consolas, monospace; color: #000; border: 1px solid var(--line); }
.receipt h1 { font-size: 15px; text-align: center; margin: 0 0 2px; }
.receipt .c { text-align: center; white-space: pre-line; }
.receipt hr { border: 0; border-top: 1px dashed #000; margin: 7px 0; }
.receipt table { font: inherit; } .receipt td { padding: 1px 0; border: 0; background: none !important; vertical-align: top; }
.receipt .tot td { font-weight: 700; font-size: 14px; padding-top: 4px; }
.print-bar { text-align: center; margin: 1rem; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { padding-bottom: 0; }
  .side nav { display: none; padding-bottom: 1rem; }
  .nav-toggle-label { display: block; position: absolute; right: 1rem; top: .95rem; color: #fff; border: 1px solid var(--ink-line); border-radius: 6px; padding: .2rem .7rem; cursor: pointer; font-weight: 600; font-size: .9rem; }
  .side { position: relative; }
  .nav-toggle:checked ~ nav { display: block; }
  .content, .top { padding-left: 1rem; padding-right: 1rem; }
  .cols-2, .cols-3, .cols-4, .split, .form-grid { grid-template-columns: 1fr; }
  .cols-4.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth { grid-template-columns: 1fr; } .auth-side { display: none; }
}
@media print {
  .side, .top, .print-bar, .no-print, .flash { display: none !important; }
  .shell { display: block; } .content { padding: 0; max-width: none; }
  body { background: #fff; } .receipt { border: 0; margin: 0; }
  .card { border: 0; padding: 0; }
}
