/* АгроОблік cabinet. Steel-grey warehouse console, design carried over from the prototype.
   No external fonts or CDNs: the Content-Security-Policy allows only this origin. */
:root {
  --bg:#e9edf0; --surface:#ffffff; --surface-2:#f4f6f8; --line:#d3dae0; --line-2:#e3e8ec;
  --fg:#17212b; --muted:#5b6977; --faint:#8794a0;
  --accent:#2347a6; --accent-fg:#ffffff; --accent-soft:#e3e9f8;
  --new:#2a5fc4; --new-soft:#e2ebfb; --used:#a86608; --used-soft:#fbefd9;
  --ok:#2b7d49; --ok-soft:#e1f2e6; --warn:#a87400; --warn-soft:#fbf1d6; --bad:#b83a26; --bad-soft:#fbe5e0;
  --shadow:0 1px 2px rgba(20,30,40,.06),0 6px 24px rgba(20,30,40,.08);
  --f-body:"Segoe UI",system-ui,-apple-system,"Helvetica Neue",Arial,sans-serif;
  --f-mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#11161b; --surface:#192027; --surface-2:#1f2830; --line:#2c3843; --line-2:#24303a;
    --fg:#e5eaee; --muted:#97a4b0; --faint:#6f7d89;
    --accent:#8aa6f5; --accent-fg:#0d1530; --accent-soft:#1f2b4a;
    --new:#86abf3; --new-soft:#1d2a44; --used:#e3a650; --used-soft:#3a2b14;
    --ok:#6fcb8f; --ok-soft:#173223; --warn:#e0b44a; --warn-soft:#352a10; --bad:#f08570; --bad-soft:#3b1c16;
    --shadow:0 1px 2px rgba(0,0,0,.3),0 8px 28px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box }
html, body { margin: 0; height: 100% }
body { background: var(--bg); color: var(--fg); font: 14px/1.45 var(--f-body) }
a { color: var(--accent) }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px }
.mono { font-family: var(--f-mono); font-size: .92em }
.num { font-variant-numeric: tabular-nums }
.r { text-align: right }
.muted, .note { color: var(--muted) }
.note { font-size: 12.5px }
.pad { padding: 24px }
.err, .validation-message { color: var(--bad); font-size: 12.5px }
h1 { font-size: 24px; font-weight: 700; margin: 4px 0 0; letter-spacing: -.01em }
h2 { font-size: 17px; font-weight: 600; margin: 0 }
h3 { font-size: 12.5px; margin: 0; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600 }

.app { display: grid; grid-template-columns: 236px minmax(0,1fr); min-height: 100% }
.rail { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; text-decoration: none; color: var(--fg) }
.brand b { display: block; font-size: 15px }
.brand small { display: block; color: var(--muted); font-size: 11.5px }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--fg); color: var(--bg); display: grid; place-items: center; font-weight: 700; font-size: 13px }
.brand-mark.lg { width: 48px; height: 48px; font-size: 17px; margin-bottom: 8px }
.nav { display: flex; flex-direction: column; gap: 2px }
.nav a { display: block; padding: 9px 10px; border-radius: 7px; color: var(--muted); font-weight: 500; text-decoration: none }
.nav a:hover { background: var(--surface-2); color: var(--fg) }
.nav a.active { background: var(--accent-soft); color: var(--accent) }
.whoami { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 6px }
.whoami small { display: block; color: var(--muted); font-size: 12px }
.whoami form { margin: 0 }
main { min-width: 0; padding: 24px 28px 60px }

.page-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px }
.eyebrow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 500 }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center }
.btn { border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; border-radius: 7px; font-weight: 500; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; text-decoration: none; color: var(--fg) }
.btn:hover { border-color: var(--faint) }
.btn:disabled { opacity: .5; cursor: not-allowed }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--accent-fg) }
.btn.sm { padding: 5px 10px; font-size: 13px }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted) }
.btn.danger { color: var(--bad) }
.btn.wide { width: 100% }
.banner { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; font-weight: 500; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap }
.banner form { margin: 0 }
.alert { border-radius: 8px; padding: 10px 14px; font-size: 13.5px }
.alert.ok { background: var(--ok-soft); color: var(--ok) }
.alert.bad { background: var(--bad-soft); color: var(--bad) }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px }
.panel-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap }
.panel-b { padding: 14px 16px }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px }
.kpi .lbl { font-size: 12.5px; color: var(--muted) }
.kpi .val { font-weight: 600; font-size: 22px; font-variant-numeric: tabular-nums }
.kpi .val.bad { color: var(--bad) }
.kpi .sub { font-size: 12.5px; color: var(--muted) }
/* a card that opens the list behind its number */
.kpi.click { cursor: pointer; font: inherit; color: inherit; text-align: left; text-decoration: none }
.kpi.click:hover, .kpi.click.on { border-color: var(--accent) }
.grid2 { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,1fr); gap: 16px; align-items: start }
.stack { display: flex; flex-direction: column; gap: 16px }

.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 5px; white-space: nowrap }
.chip.new { background: var(--new-soft); color: var(--new) }
.chip.used { background: var(--used-soft); color: var(--used) }
.chip.ok { background: var(--ok-soft); color: var(--ok) }
.chip.warn { background: var(--warn-soft); color: var(--warn) }
.chip.bad { background: var(--bad-soft); color: var(--bad) }
.chip.tg { background: var(--accent-soft); color: var(--accent) }
.chip.mut { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line-2) }
.dir { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase }
.dir.out { color: var(--bad) } .dir.in { color: var(--ok) }

.attn-i { display: flex; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); align-items: flex-start }
.attn-i:last-child { border-bottom: 0 }
.sev { width: 4px; align-self: stretch; border-radius: 2px; flex: none }
.sev.bad { background: var(--bad) } .sev.warn { background: var(--warn) } .sev.info { background: var(--accent) }
.attn-i .t { font-weight: 500 } .attn-i .d { font-size: 12.5px; color: var(--muted) }
.attn-i a { margin-left: auto; flex: none }
.bar { height: 10px; border-radius: 3px; background: var(--surface-2); display: flex; overflow: hidden }
.bar i { display: block; height: 100%; background: var(--new) }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px }
.inp { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 8px 10px; min-width: 0; width: 100% }
.inp:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent }
.search { width: 280px; max-width: 100% }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; flex-wrap: wrap }
.seg button { border: 0; background: transparent; padding: 6px 10px; border-radius: 6px; color: var(--muted); font-weight: 500; font-size: 13px }
.seg button.on { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.12) }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 16px; padding: 5px 12px; font-size: 13px; color: var(--muted) }
.chips button.on { background: var(--fg); color: var(--bg); border-color: var(--fg) }
/* client picker: search field with a drop-down of matches, or the chosen client with a clear button */
.picker { position: relative; min-width: 240px }
.picker-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto }
.picker-list li.note { padding: 8px 10px }
.picker-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 6px }
.picker-list button:hover { background: var(--accent-soft) }
.picker-chosen { display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 1px solid var(--line); background: var(--surface-2); border-radius: 7px; padding: 3px 3px 3px 10px; min-height: 38px }

.tbl-wrap { overflow-x: auto }
table { width: 100%; border-collapse: collapse; font-size: 13.5px }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface-2) }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top }
/* sortable column headers: a button inside the th, the arrow shows the current order */
th .sort { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 4px }
th .sort:hover, th .sort.on { color: var(--fg) }
th .sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px }
th .sort i { font-style: normal; font-size: 10px; color: var(--faint) }
th .sort.on i { color: var(--accent) }
tr.click { cursor: pointer }
tr.click:hover td { background: var(--surface-2) }
tr.opened td { background: var(--accent-soft) }
tr.exp > td { background: var(--surface-2); padding: 14px 16px }
tfoot td { font-weight: 600; background: var(--surface-2) }
.prod-n { font-weight: 500 }
.prod-s { font-size: 12.5px; color: var(--muted) }
.low { color: var(--bad); font-weight: 600 }
.zero { color: var(--faint) }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto }
.tabs button, .tabs a { border: 0; background: transparent; padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none }
.tabs .on { color: var(--fg); border-bottom-color: var(--accent) }

.scrim { position: fixed; inset: 0; background: rgba(10,16,22,.45); display: flex; justify-content: flex-end; z-index: 50 }
.sheet { background: var(--bg); width: min(780px, 100%); height: 100%; overflow-y: auto; box-shadow: var(--shadow); display: flex; flex-direction: column }
.sheet-h { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 20px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2 }
.sheet-h h2 span { display: block; font-size: 14px; color: var(--muted); margin-top: 4px; font-weight: 400 }
.sheet-b { padding: 20px 24px; display: flex; flex-direction: column; gap: 16px; flex: 1 }
.sheet-f { padding: 14px 24px; background: var(--surface); border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; position: sticky; bottom: 0; flex-wrap: wrap }
.x { border: 0; background: var(--surface-2); width: 34px; height: 34px; border-radius: 8px; font-size: 20px; line-height: 1; color: var(--muted); flex: none }
dl.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 0 }
dl.kv div { background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px }
dl.kv dt { font-size: 12px; color: var(--muted) }
dl.kv dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums }
.units { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px }
.unit { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 8px }
.unit.sold { opacity: .6 }
.unit .row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px }
.unit .row span:first-child { color: var(--muted) }
.thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px }
.thumbs img, .thumb { aspect-ratio: 1; width: 100%; object-fit: cover; border-radius: 5px; background: var(--surface-2) }

.form { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px 14px }
.form .full { grid-column: 1 / -1 }
.fld { display: flex; flex-direction: column; gap: 5px; min-width: 0 }
.fld > span { font-size: 12.5px; color: var(--muted); font-weight: 500 }
.fset { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; display: flex; flex-direction: column; gap: 12px }
.fset.own { border-color: var(--accent); border-style: dashed }
.calc { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-variant-numeric: tabular-nums }
.calc .ln { display: flex; justify-content: space-between; gap: 10px }
.calc .ln span:first-child { color: var(--muted) }
.calc .tot { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 600; font-size: 15px }
.dlv-box { display: flex; flex-direction: column; gap: 2px; background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 12px 14px }
.dlv-box b { font-size: 16px; color: var(--fg) }

.acc { background: var(--surface); border: 1px solid var(--line); border-radius: 10px }
.acc > summary { list-style: none; cursor: pointer; padding: 12px 16px; display: flex; align-items: center; gap: 8px; font-weight: 600 }
.acc > summary::-webkit-details-marker { display: none }
.acc > summary .cnt { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: auto }
.acc > summary::after { content: "▾"; color: var(--faint) }
.acc:not([open]) > summary::after { transform: rotate(-90deg) }
.acc-b { padding: 0 16px 14px; display: flex; flex-direction: column; gap: 10px }
.cl-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line-2) }
.cl-row:last-child { border-bottom: 0 }
.cl-row .grow { flex: 1; min-width: 0 }
.addrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; align-items: end; background: var(--surface-2); padding: 10px; border-radius: 8px }
.tl-i { display: grid; grid-template-columns: 90px minmax(0,1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line-2) }
.tl-i:last-child { border-bottom: 0 }
.tl-i .dt { font-size: 12.5px; color: var(--muted) }
.prev { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px }
.prev h4 { margin: 0 0 6px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted) }
.qrbox { background: #ffffff; padding: 12px; border-radius: 10px; width: fit-content }
.qrbox img { display: block; width: 176px; height: 176px; image-rendering: pixelated }
.inv-link { word-break: break-all; background: var(--surface-2); border-radius: 6px; padding: 8px 10px }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 90; box-shadow: var(--shadow) }

/* sign-in pages and account management */
.auth-card { max-width: 400px; margin: 8vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 10px }
.auth-card .stack { gap: 12px }
.or { text-align: center; color: var(--faint); font-size: 12px }
.subnav { list-style: none; padding: 0; margin: 0; display: flex; gap: 6px; flex-wrap: wrap }
.subnav a { display: block; padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--muted) }
.subnav a.active { background: var(--accent-soft); color: var(--accent) }
.text-danger { color: var(--bad) }
.form-control { border: 1px solid var(--line); background: var(--surface); border-radius: 7px; padding: 8px 10px; width: 100%; margin-bottom: 8px }
.btn-primary { background: var(--accent); border: 1px solid var(--accent); color: var(--accent-fg); padding: 8px 14px; border-radius: 7px }
/* Identity's floating-label markup without Bootstrap: the label goes above its field, as in .fld */
.form-floating { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px }
.form-floating > label { order: -1; font-size: 12.5px; color: var(--muted); font-weight: 500 }
.form-floating > .form-control { margin-bottom: 0 }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: var(--bad-soft); color: var(--bad); padding: 10px 20px; z-index: 1000 }
#blazor-error-ui .dismiss { cursor: pointer; float: right }

@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr }
  .rail { position: sticky; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 16px; z-index: 20; border-right: 0; border-bottom: 1px solid var(--line) }
  .brand small { display: none }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; order: 3 }
  .nav a { white-space: nowrap }
  .whoami { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; align-items: center }
  main { padding: 18px 16px 50px }
  .form { grid-template-columns: 1fr }
  .prev { grid-template-columns: 1fr }
}
