:root {
  --brand: #F26B21;
  --brand-2: #1E9A4B;
  --bg: #F4F5F7;
  --card: #FFFFFF;
  --text: #1F2328;
  --muted: #6B7280;
  --line: #E5E7EB;
  --bad: #D93025;
  --good: #1E9A4B;
  --bar: #F26B21;
  --bar-2: #F7A26F;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111315; --card: #1B1E21; --text: #ECEDEE; --muted: #9BA1A6; --line: #2A2E33;
    --bar-2: #8A4A26; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
button { font: inherit; color: inherit; }

/* kirish */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border-radius: 18px; padding: 28px 22px; box-shadow: var(--shadow); text-align: center; }
.login-logo { width: 72px; height: 72px; }
.login-card h1 { margin: 10px 0 2px; font-size: 22px; }
.login-card form { margin-top: 20px; text-align: left; display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
input, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: -1px; }
.btn-primary { background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 12px; font-weight: 600; cursor: pointer; }
.btn-primary:disabled { opacity: .6; }
.btn { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; }
.error { color: var(--bad); font-size: 13px; margin: 0; }

/* sarlavha */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { flex: 1; display: grid; }
.brand-name { font-weight: 800; letter-spacing: .5px; font-size: 18px; color: var(--brand); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--good); box-shadow: 0 0 0 3px rgba(30,154,75,.18); }
.dot.off { background: var(--bad); }
.icon-btn { background: none; border: 0; padding: 8px; border-radius: 50%; cursor: pointer; color: var(--text); display: grid; }
.icon-btn:active { background: var(--line); }
.icon-btn.spin svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { margin: 10px 16px 0; padding: 10px 12px; border-radius: 10px; font-size: 13px; background: #FFF4E5; color: #8A4B00; }
@media (prefers-color-scheme: dark) { .banner { background: #3A2A12; color: #F5C27A; } }
.banner.bad { background: #FDECEA; color: #A1271C; }
@media (prefers-color-scheme: dark) { .banner.bad { background: #3A1715; color: #F2A39C; } }

main { padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
h2 { font-size: 15px; margin: 18px 2px 8px; color: var(--muted); font-weight: 600; }
.card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); }
.card + .card { margin-top: 10px; }

/* KPI */
.hero { background: linear-gradient(135deg, var(--brand), #E2541A); color: #fff; border-radius: 16px; padding: 16px; }
.hero .label { opacity: .9; font-size: 13px; }
.hero .value { font-size: 30px; font-weight: 800; margin-top: 2px; }
.hero .sub { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; opacity: .95; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-top: 10px; }
.kpi { background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 19px; font-weight: 700; margin-top: 2px; }
.kpi .value.good { color: var(--good); }
.kpi .value.bad { color: var(--bad); }

/* ro'yxatlar */
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .right { text-align: right; white-space: nowrap; }
.rank { width: 22px; height: 22px; border-radius: 50%; background: var(--bg); color: var(--muted); display: grid; place-items: center; font-size: 12px; flex: none; }
.meter { height: 6px; background: var(--bg); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--bar); border-radius: 3px; }

/* grafik */
.chart { width: 100%; height: 170px; display: block; }
.chart text { fill: var(--muted); font-size: 10px; }

.seg { display: flex; background: var(--card); border-radius: 10px; padding: 3px; gap: 3px; box-shadow: var(--shadow); }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.seg button.active { background: var(--brand); color: #fff; }
.search { margin: 10px 0; position: relative; }
.search input { padding-right: 52px; }
.scan-btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 42px; height: 38px; border: 0; border-radius: 8px;
  background: var(--brand); color: #fff; display: grid; place-items: center; cursor: pointer; }
.scan-back { position: fixed; inset: 0; z-index: 30; background: #000; display: grid; place-items: center; }
.scan-back video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: relative; width: min(80vw, 360px); height: 150px; border: 3px solid var(--brand); border-radius: 14px;
  box-shadow: 0 0 0 100vmax rgba(0,0,0,.45); }
.scan-hint { position: absolute; top: calc(20px + env(safe-area-inset-top)); left: 0; right: 0; text-align: center; color: #fff; font-weight: 600; }
.scan-close { position: absolute; bottom: calc(24px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); min-width: 140px; }

.kassa-head { display: flex; justify-content: space-between; align-items: baseline; }
.kassa-head b { font-size: 18px; }
.stock-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

/* sana tanlash */
.datebar { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.datebar .icon-btn { background: var(--card); box-shadow: var(--shadow); border-radius: 10px; width: 40px; height: 40px; place-items: center; }
.datebar .icon-btn:disabled { opacity: .35; }
.datebar .pick { flex: 1; min-width: 0; background: var(--card); box-shadow: var(--shadow); border: 0; border-radius: 10px; height: 40px;
  display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 600; cursor: pointer; padding: 0 8px;
  white-space: nowrap; overflow: hidden; }
.datebar .pick svg { color: var(--brand); flex: none; }
.datebar .pick .pick-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.datebar .pick .small { flex: none; }

/* davr tanlash oynasi */
.sheet-back { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 520px; background: var(--card); border-radius: 18px 18px 0 0; padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  display: grid; gap: 14px; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.presets { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.presets button { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 11px 8px; cursor: pointer; font-weight: 500; }
.presets button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.datebar .today { background: var(--card); border: 0; box-shadow: var(--shadow); border-radius: 10px; height: 40px; padding: 0 12px; color: var(--brand); font-weight: 600; cursor: pointer; }

.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

/* pastki menyu */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
.tabs button { flex: 1; border: 0; background: none; display: grid; justify-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; cursor: pointer; }
.tabs svg { width: 24px; height: 24px; }
.tabs button.active { color: var(--brand); }
