: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; }
.minus-alert { display: block; width: 100%; text-align: left; border: 0; cursor: pointer; margin: 0 0 10px; padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 14px; background: #FDECEA; color: #A1271C; }
.minus-tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 6px; background: #FDECEA; color: #A1271C; vertical-align: middle; }
.neg { color: var(--bad); }
.more-btn { display: block; width: 100%; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: none; color: var(--brand); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.more-btn .muted { font-weight: 400; }
.more-btn:active { background: var(--line); }
@media (prefers-color-scheme: dark) { .minus-alert, .minus-tag { background: #3A1715; color: #F2A39C; } }
.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); }

/* ---------- tovar kartochkasi va signallar (2026-11-15) ---------- */
.row-btn { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; cursor: pointer; font: inherit; color: inherit; }
.row-btn:last-child { border-bottom: 0; }
.row-btn:active { background: var(--bg); }
.chev { color: var(--muted); flex: none; opacity: .6; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 0 0 10px; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.chip b { margin-left: 2px; }
.chip:disabled { opacity: .45; cursor: default; }
.chip.warn b { color: #B45309; } .chip.bad b { color: var(--bad); } .chip.info b { color: #2563EB; }
.chip.active { color: #fff; border-color: transparent; }
.chip.active b { color: #fff; }
.chip.warn.active { background: #D97706; } .chip.bad.active { background: var(--bad); } .chip.info.active { background: #2563EB; }
.filter-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 0 0 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
.link { background: none; border: 0; color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; padding: 4px 0; }
.seg button:disabled { opacity: .45; }
.seg-sm { box-shadow: none; background: var(--bg); margin-bottom: 8px; }
.seg-sm button { padding: 6px; font-size: 13px; }

.noscroll { overflow: hidden; }
.page { position: fixed; inset: 0; z-index: 15; background: var(--bg); overflow-y: auto; -webkit-overflow-scrolling: touch; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }
.page-top { gap: 4px; padding-left: 6px; padding-right: 6px; }
.page-top .brand { min-width: 0; }
.page-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-body { padding: 12px 16px calc(28px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.item-head .item-name { font-size: 18px; font-weight: 700; line-height: 1.3; }
.bcs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.bc { font: 12px/1 ui-monospace, Menlo, Consolas, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; cursor: pointer; color: var(--text); }
.bc.copied { background: var(--good); color: #fff; border-color: var(--good); }
.item-hero { margin-top: 10px; }
.stores { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.3); font-size: 13px; }
.signals { display: grid; gap: 6px; margin-top: 10px; }
.sig { padding: 9px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 500; }
.sig.bad { background: #FDECEA; color: #A1271C; }
.sig.warn { background: #FFF4E5; color: #8A4B00; }
.sig.info { background: #EAF1FE; color: #1E4FBF; }
.sig.good { background: #E7F6EC; color: #17703A; }
@media (prefers-color-scheme: dark) {
  .sig.bad { background: #3A1715; color: #F2A39C; } .sig.warn { background: #3A2A12; color: #F5C27A; }
  .sig.info { background: #14243F; color: #9DBBF5; } .sig.good { background: #12301F; color: #8FD9A8; }
  .chip.warn b { color: #F5C27A; } .chip.info b { color: #9DBBF5; }
}
.kpi .value.warn { color: #B45309; }
@media (prefers-color-scheme: dark) { .kpi .value.warn { color: #F5C27A; } }
.kpis-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .kpis-4 { grid-template-columns: repeat(4, 1fr); } }
.kpis-4 .value { font-size: 17px; }
.pos { color: var(--good); }
.chg { font-size: 11px; font-weight: 600; margin-left: 4px; }
.chg.up { color: var(--bad); } .chg.down { color: var(--good); }
.order { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.order .big { font-size: 20px; color: var(--brand); }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: pulse 1s ease-in-out infinite; vertical-align: middle; }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- qaytarishlar sahifasi (v13) ---------- */
.kpi-link { text-align: left; border: 0; font: inherit; color: inherit; cursor: pointer; }
.kpi-link:active { background: var(--bg); }
.kpi-link .chev { float: right; font-size: 16px; line-height: 1; }
.ret-hero { background: linear-gradient(135deg, #C2410C, #A1271C); }
.ret + .ret { border-top: 1px solid var(--line); }
.ret > .row-btn { border-bottom: 0; align-items: flex-start; }
.ret.open > .row-btn { background: var(--bg); border-radius: 10px; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.tag.bad { background: #FDECEA; color: #A1271C; }
.tag.warn { background: #FFF4E5; color: #8A4B00; }
.tag.info { background: #EAF1FE; color: #1E4FBF; }
.ret-body { padding: 4px 0 12px; }
.ret-body .signals { margin: 6px 0 10px; }
.kv { display: grid; gap: 6px; font-size: 13.5px; }
.kv > div { display: flex; justify-content: space-between; gap: 12px; }
.kv span { color: var(--muted); flex: none; }
.kv b { text-align: right; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.sale-box { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--bg); display: grid; gap: 6px; }
.ret-items { margin-top: 8px; }
.ret-items .row-btn { padding: 8px 0; }

/* Asl sotuv cheki - chek ko'rinishida (1.9.2) */
.receipt { margin-top: 12px; padding: 12px 14px; border-radius: 6px; background: #fffdf6; color: #222;
  border: 1px dashed #cfc6ad; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13px; }
.receipt .rc-head { text-align: center; padding-bottom: 8px; margin-bottom: 6px; border-bottom: 1px dashed #cfc6ad; }
.receipt .rc-head div { color: #777; font-size: 12px; margin-top: 2px; }
.receipt .rc-line { padding: 5px 0; opacity: .3; }
.receipt .rc-line.back { opacity: 1; background: #fdecea; margin: 2px -8px; padding: 6px 8px; border-radius: 4px; }
.receipt .rc-name { font-weight: 600; }
.receipt .rc-row { display: flex; justify-content: space-between; gap: 8px; }
.receipt .rc-back { color: #c62828; font-weight: 700; font-size: 12px; margin-top: 2px; }
.receipt .rc-sep { border-top: 1px dashed #cfc6ad; margin: 8px 0; }
.receipt .rc-total { font-size: 14px; }
.receipt .rc-ret { color: #c62828; }
