:root {
  color-scheme: light;
  --bg: #f3f2ee;
  --surface: #fcfcfb;
  --surface-2: #f0efea;
  --line: #e2e0d8;
  --ink: #16181d;
  --ink-2: #52514e;
  --ink-3: #85837c;
  --brand: #1f2a3c;          /* to'q ko'k-kulrang — beton zavod */
  --brand-ink: #ffffff;
  --accent: #e8a317;         /* sariq — ogohlantirish lentasi rangi */
  --accent-ink: #1b1400;
  --series-1: #2a78d6;
  --series-3: #1baf7a;
  --good: #1a7f37;
  --warn: #9a6700;
  --warn-bg: #fff4d6;
  --bad: #c4312f;
  --bad-bg: #fdecec;
  --focus: #2a78d6;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 2px 8px rgba(20, 20, 20, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121315; --surface: #1a1a19; --surface-2: #232321; --line: #33322f;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8f8d86;
    --brand: #0f141d; --accent: #e8a317; --series-1: #3987e5; --series-3: #199e70;
    --good: #4ac26b; --warn: #e3b341; --warn-bg: #3a2e0f; --bad: #f47067; --bad-bg: #3d1c1b;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121315; --surface: #1a1a19; --surface-2: #232321; --line: #33322f;
  --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #8f8d86;
  --brand: #0f141d; --accent: #e8a317; --series-1: #3987e5; --series-3: #199e70;
  --good: #4ac26b; --warn: #e3b341; --warn-bg: #3a2e0f; --bad: #f47067; --bad-bg: #3d1c1b;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 "IBM Plex Sans", "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.hide { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.num { text-align: right; white-space: nowrap; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.15fr 1fr; background: var(--bg); }
.login.hide { display: none; }
.login-hero { position: relative; color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  padding: 32px 40px; background: #1f2a3c url(/static/img/silos.jpg) center 45% / cover no-repeat; }
.login-hero::before { content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(14,19,28,.55) 0%, rgba(14,19,28,.05) 35%, rgba(14,19,28,.15) 60%, rgba(14,19,28,.85) 100%); }
.login-hero > * { position: relative; }
.lh-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 1.6px; font-size: 15px; }
.lh-title { font-size: 30px; font-weight: 600; line-height: 1.2; max-width: 460px; letter-spacing: -.3px; }
.lh-sub { margin-top: 10px; font-size: 14px; opacity: .85; letter-spacing: .2px; }
.login-side { display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; padding: 30px 26px;
  border: 1px solid var(--line); box-shadow: 0 12px 40px rgba(0,0,0,.08); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: 1.2px; }
.logo-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.login h1 { font-size: 24px; margin: 22px 0 4px; }
.login p { margin: 0 0 20px; color: var(--ink-2); }
@media (max-width: 820px) {
  .login { grid-template-columns: 1fr; grid-template-rows: 220px 1fr; }
  .login-hero { padding: 18px 18px; } .lh-title { font-size: 21px; } .lh-sub { font-size: 12.5px; }
  .login-card .logo { display: none; } .login h1 { margin-top: 0; }
}

/* ---------- zavod suratlari: yuqori panel va bo'limlarning orqa foni ---------- */
.top { isolation: isolate; background: #141b27 url(/static/img/hero.jpg) center 58% / cover no-repeat !important; }
.top::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, rgba(16,22,32,.94) 0%, rgba(16,22,32,.76) 45%, rgba(16,22,32,.45) 100%); }
.bg-photo { position: fixed; inset: 0; z-index: -1; pointer-events: none; opacity: 0; transition: opacity .4s;
  background: center / cover no-repeat; filter: grayscale(.35) contrast(.9);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 30%, #000 100%); mask-image: linear-gradient(180deg, transparent 0, #000 30%, #000 100%); }
.bg-photo.on { opacity: .10; }
:root[data-theme="dark"] .bg-photo.on { opacity: .07; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bg-photo.on { opacity: .07; } }
@media (max-width: 640px) { .bg-photo.on { opacity: .07; } }
@media print { .bg-photo { display: none; } }

/* ---------- form controls ---------- */
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.inp, select.inp, textarea.inp {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); outline: none;
}
textarea.inp { height: 64px; padding: 10px 12px; resize: vertical; }
.inp:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 18%, transparent); }
.inp.big { height: 52px; font-size: 20px; font-weight: 700; }
.row { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.btn { height: 42px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.pri { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
:root[data-theme="dark"] .btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } }
.btn.acc { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: none; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; height: 50px; font-size: 16px; }
.btn:disabled { opacity: .55; cursor: default; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 40px; min-width: 64px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); font-weight: 700; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
:root[data-theme="dark"] .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); } }
.chip.sm { height: 32px; min-width: 0; font-size: 13px; font-weight: 600; }
.err { color: var(--bad); font-weight: 600; min-height: 20px; margin-top: 8px; }

/* ---------- shell ---------- */
.top { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 14px;
  padding: 0 16px; background: var(--brand); color: #fff; }
.top .logo-mark { width: 30px; height: 30px; font-size: 15px; }
.top .co { font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; font-size: 14px; }
.top .who { margin-left: auto; font-size: 13px; opacity: .85; text-align: right; line-height: 1.2; }
.top .btn { background: rgba(255,255,255,.1); border-color: transparent; color: #fff; height: 34px; }
.nav { display: flex; gap: 2px; overflow-x: auto; padding: 0 12px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 19; scrollbar-width: none; }
.nav button { border: 0; background: none; padding: 13px 14px; font-weight: 600; color: var(--ink-2);
  border-bottom: 3px solid transparent; white-space: nowrap; }
.nav button.on { color: var(--ink); border-bottom-color: var(--accent); }
main { padding: 18px 16px 60px; max-width: 1320px; margin: 0 auto; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.2px; }
h2 { font-size: 20px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); }
.grid2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 480px) minmax(0, 1fr); align-items: start; }
.grid-auto { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.sec-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-head h2, .sec-head h3 { margin: 0; }
.sec-head .sp { flex: 1; }

/* ---------- shipment cards ---------- */
.sum-bar { display: flex; gap: 18px; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; background: var(--surface-2);
  margin-bottom: 12px; }
.sum-bar b { font-size: 20px; display: block; }
.sum-bar span { font-size: 12px; color: var(--ink-3); }
.ship { display: grid; grid-template-columns: 56px 1fr auto; gap: 4px 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.ship:last-child { border-bottom: 0; }
.ship .t { font-weight: 700; color: var(--ink-2); }
.ship .site { font-weight: 700; }
.ship .meta { grid-column: 2 / 4; color: var(--ink-2); font-size: 13px; }
.ship .q { text-align: right; font-weight: 700; font-size: 17px; }
.ship .acts { grid-column: 2 / 4; display: flex; gap: 6px; }
.ship.cancelled { opacity: .5; }
.ship.cancelled .site { text-decoration: line-through; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 6px;
  background: var(--surface-2); color: var(--ink-2); }
.tag.trip { background: color-mix(in srgb, var(--series-1) 14%, transparent); color: var(--ink); }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.note-line { font-size: 13px; padding: 8px 10px; border-radius: 8px; margin: 2px 0 12px; }
.note-line.ok { background: color-mix(in srgb, var(--good) 12%, transparent); }
.note-line.warn { background: var(--warn-bg); color: var(--warn); }
.quick { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
details.more summary { cursor: pointer; color: var(--ink-2); font-weight: 600; margin: 4px 0 12px; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .3px; color: var(--ink-3); font-weight: 700;
  background: var(--surface-2); position: sticky; top: 0; }
tbody tr:hover { background: var(--surface-2); }
tr.click { cursor: pointer; }
tfoot td { font-weight: 700; background: var(--surface-2); }
td.wrap { white-space: normal; min-width: 160px; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 10px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters label.f { margin: 0; min-width: 140px; flex: 1 1 140px; max-width: 220px; }
.filters .inp { height: 38px; }

/* ---------- dashboard ---------- */
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .l { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.kpi .v { font-size: 26px; font-weight: 700; margin-top: 2px; letter-spacing: -.3px; }
.kpi .v small { font-size: 14px; font-weight: 700; color: var(--ink-2); }
.kpi .d { font-size: 12.5px; margin-top: 2px; color: var(--ink-2); }
.kpi .d .up { color: var(--good); font-weight: 700; }
.kpi .d .down { color: var(--bad); font-weight: 700; }
.kpi.hero { background: var(--brand); color: #fff; border-color: var(--brand); }
.kpi.hero .l, .kpi.hero .d, .kpi.hero .v small { color: rgba(255,255,255,.75); }
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 300px; }
.bar-list .it { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 7px 0; }
.bar-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bar-list .vl { text-align: right; font-weight: 700; }
.bar-list .track { grid-column: 1 / 3; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar-list .fill { height: 100%; border-radius: 4px; background: var(--series-1); }
.bar-list .sub { grid-column: 1 / 3; font-size: 12px; color: var(--ink-3); }
.alert { padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); font-weight: 600; margin-bottom: 14px; }

/* ---------- recipes ---------- */
.rc-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.rc { display: flex; flex-direction: column; gap: 8px; }
.rc .gr { font-size: 22px; font-weight: 700; }
.rc .nm { color: var(--ink-2); font-size: 13px; }
.rc .cost { font-weight: 700; }
.mat-row { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; border-bottom: 1px dashed var(--line); }
.versions { font-size: 12.5px; color: var(--ink-3); }
.versions button { font-size: 12.5px; }

/* ---------- modal & toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(10, 12, 16, .5); display: none; align-items: flex-start;
  justify-content: center; padding: 40px 12px; z-index: 50; overflow-y: auto; }
.modal.show { display: flex; }
.modal .sheet { width: 100%; max-width: 560px; background: var(--surface); border-radius: 16px; padding: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .sheet.wide { max-width: 760px; }
.modal .acts { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--surface);
  padding: 12px 18px; border-radius: 12px; font-weight: 600; z-index: 60; max-width: 92vw; display: none;
  box-shadow: 0 8px 30px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); color: #fff; }
.choice { display: flex; flex-direction: column; gap: 6px; margin: 12px 0; }

@media (max-width: 900px) {
  .grid2 { grid-template-columns: 1fr; }
  .top .co small { display: none; }
}
@media (max-width: 520px) {
  main { padding: 14px 10px 60px; }
  .card { padding: 14px 12px; }
  .kpi .v { font-size: 22px; }
}
.pick { display: flex; gap: 6px; }
.pick select { flex: 1; min-width: 0; }
.pick .btn { flex: none; padding: 0 12px; }
select.inp:disabled { opacity: .55; }
.chip .tag { font-size: 10.5px; margin-left: 4px; }
.chip.on .tag { background: rgba(255,255,255,.2); color: inherit; }
.row.pickrow { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
@media (max-width: 520px) { .pick .wide { display: none; } .pick .btn { width: 44px; font-size: 18px; } }

/* ---------- 1-bosqich qo'shimchalari ---------- */
.money-box { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; border-radius: 10px;
  background: var(--surface-2); margin-bottom: 12px; font-size: 14px; }
.money-box .tot { font-weight: 700; font-size: 17px; border-top: 1px solid var(--line); padding-top: 6px; }
.money-box .num { font-weight: 700; }
.saved { border: 2px solid var(--good); border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
  background: color-mix(in srgb, var(--good) 8%, transparent); }
.saved .big-no { font-size: 26px; font-weight: 700; }
.saved .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.perm-grid th, .perm-grid td { text-align: center; }
.perm-grid th:first-child, .perm-grid td:first-child { text-align: left; white-space: normal; min-width: 220px; }
.perm-grid input { width: 18px; height: 18px; }
.perm-grid tr.grp td { background: var(--surface-2); font-weight: 700; text-align: left; }
.q-row select { min-width: 180px; height: 36px; }
.tag.ok { background: color-mix(in srgb, var(--good) 16%, transparent); color: var(--good); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.ship .money { grid-column: 2 / 4; font-size: 13px; color: var(--ink-2); }
.ship .acts { flex-wrap: wrap; }
.yol-box { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); margin-bottom: 12px; }
@media (max-width: 640px) {
  .filters label.f { max-width: none; flex: 1 1 45%; }
  .sec-head .chips { width: 100%; }
}
