:root {
  --bg: #faf6f0; --card: #ffffff; --ink: #2b1a12; --muted: #8a7566; --line: #ece3d8;
  --brand: #2b1a12; --brand-ink: #f6e9d2; --gold: #b8893b; --gold-soft: #f3e6cb;
  --ok: #2f7d4f; --bad: #b3372b; --warn: #b8760b; --shadow: 0 1px 2px rgba(43,26,18,.06), 0 6px 18px rgba(43,26,18,.05);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #17100c; --card: #241912; --ink: #f3e9dc; --muted: #a89684; --line: #3a2b20;
    --brand: #d9ab5c; --brand-ink: #1c120c; --gold: #d9ab5c; --gold-soft: #3a2b18; --shadow: none; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: .01em; }
h2 { font-size: 22px; } h3 { font-size: 17px; }
.muted { color: var(--muted); } .small { font-size: 13px; }

/* kirish */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(circle at 50% 0%, var(--gold-soft), var(--bg) 60%); }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.logo { text-align: center; margin-bottom: 8px; }
.logo b { font-family: var(--serif); font-size: 44px; letter-spacing: .28em; padding-left: .28em; display: block; }
.logo span { font-size: 11px; letter-spacing: .42em; text-transform: uppercase; color: var(--gold); }
.logo i { display: block; width: 36px; height: 1px; background: var(--gold); margin: 10px auto; }

/* kontrol */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 14px; padding: 12px 18px; min-height: 48px; cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.gold { background: var(--gold); color: #fff; border-color: transparent; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; } .btn.sm { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; }
input, select, textarea { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-height: 48px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.err { color: var(--bad); font-size: 14px; min-height: 1.3em; }

/* ramka */
header.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--brand); color: var(--brand-ink); }
header.top h1 { flex: 1; font-size: 19px; letter-spacing: .22em; }
header.top small { opacity: .75; letter-spacing: .02em; font-size: 12px; font-family: inherit; }
.iconbtn { background: transparent; border: 0; color: inherit; font-size: 20px; min-width: 44px; min-height: 44px; border-radius: 12px; position: relative; cursor: pointer; }
.dot { position: absolute; top: 6px; right: 6px; background: var(--bad); color: #fff; font-size: 11px; border-radius: 9px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; }
main { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(96px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); overflow-x: auto; }
nav.tabs button { flex: 1; min-width: 0; padding-left: 0; padding-right: 0; border: 0; background: transparent; padding: 8px 4px 10px; color: var(--muted); font-size: 11px; cursor: pointer; display: grid; gap: 2px; justify-items: center; }
nav.tabs button span { font-size: 21px; line-height: 1.1; }
nav.tabs button.on { color: var(--ink); font-weight: 700; box-shadow: inset 0 2px 0 var(--gold); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; box-shadow: var(--shadow); }
.stack { display: grid; gap: 10px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { padding: 12px 14px; } .kpi small { color: var(--muted); display: block; font-size: 12px; }
.kpi b { font-family: var(--serif); font-size: 21px; overflow-wrap: anywhere; }
.kpi.hero { background: var(--brand); color: var(--brand-ink); } .kpi.hero small { color: var(--brand-ink); opacity: .7; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--gold-soft); color: var(--gold); font-weight: 600; white-space: nowrap; }
.pill.low { background: #fbe9d0; color: var(--warn); } .pill.out { background: #f8dcd8; color: var(--bad); }
.seg { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.seg button { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 16px; cursor: pointer; min-height: 40px; }
.seg button.on { background: var(--brand); color: var(--brand-ink); border-color: transparent; font-weight: 600; }

/* mahsulotlar */
.prod { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); cursor: pointer; width: 100%; text-align: left; }
.prod b { display: block; } .prod .qty { font-family: var(--serif); font-size: 22px; text-align: right; }
.prod .qty small { display: block; font-family: inherit; font-size: 11px; color: var(--muted); }
.wrow { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; }
.wrow .n { color: var(--muted); text-align: center; }
.total { font-family: var(--serif); font-size: 30px; text-align: center; padding: 6px 0; }

.sheet { position: fixed; inset: 0; z-index: 20; background: rgba(20,10,5,.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet > div { background: var(--bg); width: 100%; max-width: 560px; max-height: 92dvh; overflow: auto; border-radius: 24px 24px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
#toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 50; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; } #toast.bad { background: var(--bad); color: #fff; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; }
.bars div { flex: 1; background: var(--gold); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars div.ads { background: var(--brand); opacity: .75; }
.bars-x { display: flex; gap: 4px; font-size: 10px; color: var(--muted); } .bars-x span { flex: 1; text-align: center; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 14px; } td, th { text-align: left; padding: 7px 4px; border-bottom: 1px solid var(--line); } th { color: var(--muted); font-weight: 500; font-size: 12px; } td.r, th.r { text-align: right; }
pre.rep { white-space: pre-wrap; font: inherit; margin: 0; }

#bars { max-width: 760px; margin: 0 auto; padding: 8px 16px 0; display: grid; gap: 8px; }
#bars:empty { display: none; }
.bar { border-radius: 14px; padding: 10px 14px; font-size: 14px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.bar.bad { background: var(--bad); color: #fff; }
.bar.gold { background: var(--gold-soft); color: var(--ink); border: 1px solid var(--gold); }
.bar.gold span { flex: 1; }
