:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1b2030; --mut: #6b7280; --line: #e4e7ec; --soft: #f8f9fb;
  --red: #c8102e; --red-d: #a10c24; --red-l: #fdecef;
  --ok: #0f7b45; --ok-l: #e7f6ee; --warn: #a35a00; --warn-l: #fff4e0; --bad: #c0262d; --bad-l: #fdeceb;
  --blue: #1d4ed8; --blue-l: #e9effd;
  --r: 12px; --sh: 0 1px 2px rgba(16,24,40,.05), 0 2px 10px rgba(16,24,40,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Microsoft YaHei", "PingFang SC", sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--blue); }
.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }

/* ---------- yon panel ---------- */
.side { background: #13161d; color: #cdd2dc; padding: 14px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 10px; z-index: 30; }
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 12px; border-bottom: 1px solid #252a35; text-decoration: none; color: inherit; }
.logo { width: 38px; height: 38px; flex: none; border-radius: 10px; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.brand b { color: #fff; display: block; font-size: 15px; }
.brand small { color: #8a93a5; font-size: 11.5px; }
nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 9px; color: #cdd2dc; text-decoration: none; margin: 1px 0; white-space: nowrap; }
nav a i { font-style: normal; width: 20px; text-align: center; }
nav a:hover { background: #1e232d; }
nav a.on { background: var(--red); color: #fff; }
nav em { margin-left: auto; font-style: normal; background: #2a303c; color: #dfe3ea; border-radius: 10px; padding: 0 7px; font-size: 11.5px; }
nav em:empty { display: none; }
nav a.on em { background: rgba(255,255,255,.22); }
.side-foot { margin-top: auto; font-size: 12px; color: #9aa3b4; border-top: 1px solid #252a35; padding: 10px 8px 0; }
.side-foot b { color: #e9ecf2; font-weight: 600; }
.side-foot .row { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }

/* ---------- asosiy ---------- */
main { padding: 22px 28px 70px; min-width: 0; }
.loading { padding: 40px; color: var(--mut); }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14.5px; margin: 0 0 8px; }
.sub { color: var(--mut); margin: 0 0 18px; max-width: 900px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.head .sub { margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--sh); }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.stat .k { color: var(--mut); font-size: 12.5px; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat .h { font-size: 12px; color: var(--mut); margin-top: 2px; }
.muted { color: var(--mut); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.mt { margin-top: 14px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }

/* ---------- tugmalar va maydonlar ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px; padding: 7px 12px; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--soft); border-color: #d0d5dd; }
.btn.pri { background: var(--red); border-color: var(--red); color: #fff; }
.btn.pri:hover { background: var(--red-d); }
.btn.sm { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--soft); }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .55; cursor: default; }
input, select, textarea { font: inherit; color: inherit; border: 1px solid #d0d5dd; border-radius: 9px; padding: 7px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid #f3b6c0; border-color: var(--red); }
textarea { width: 100%; resize: vertical; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--red); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12.5px; color: var(--mut); }
.field > input, .field > select, .field > textarea { width: 100%; }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--mut); }
.search-in { width: 100%; font-size: 15px; padding: 10px 12px; }
.check { display: inline-flex; gap: 8px; align-items: center; cursor: pointer; }

/* ---------- belgilar ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 20px; font-size: 12px; background: var(--soft); border: 1px solid var(--line); color: #344054; white-space: nowrap; }
.tag.red { background: var(--red-l); border-color: #f6c6cf; color: var(--red-d); }
.tag.ok { background: var(--ok-l); border-color: #bfe6d0; color: var(--ok); }
.tag.warn { background: var(--warn-l); border-color: #f5d9a8; color: var(--warn); }
.tag.bad { background: var(--bad-l); border-color: #f5c2c0; color: var(--bad); }
.tag.blue { background: var(--blue-l); border-color: #c9d7fb; color: var(--blue); }
button.tag { cursor: pointer; font: inherit; font-size: 12px; }
button.tag.on { background: var(--red); border-color: var(--red); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.zh { font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif; }
.pos { color: var(--ok); font-weight: 600; }
.neg { color: var(--bad); font-weight: 600; }
.warnq { color: var(--warn); font-weight: 600; }
.print-only { display: none; }
code { background: var(--soft); border: 1px solid var(--line); border-radius: 5px; padding: 0 4px; font-size: 12.5px; }

/* ---------- ogohlantirish ---------- */
.note { border-radius: 10px; padding: 10px 14px; background: var(--blue-l); border: 1px solid #c9d7fb; color: #1e3a8a; }
.note.warn { background: var(--warn-l); border-color: #f5d9a8; color: #7a4300; }
.note.bad { background: var(--bad-l); border-color: #f5c2c0; color: #8a1c1c; }
.note + .card, .note + .grid, .note + .note { margin-top: 12px; }
.card + .note, .grid + .note { margin-top: 12px; }

/* ---------- jadval ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: #fff; box-shadow: var(--sh); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 8px 10px; border-bottom: 1px solid #eef0f3; text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--mut); background: var(--soft); position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover td { background: #fbfbfd; }
tfoot td { font-weight: 700; background: var(--soft); }
td .nm { font-weight: 500; }
td .meta { font-size: 12px; color: var(--mut); }
.thumb { width: 42px; height: 42px; border-radius: 8px; object-fit: cover; background: var(--soft); border: 1px solid var(--line); display: block; }
.thumb.ph { display: grid; place-items: center; color: #b0b6c2; font-size: 18px; }
.acts { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.more { text-align: center; padding: 14px; }

/* ---------- bar ---------- */
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; gap: 10px; align-items: center; cursor: pointer; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { height: 10px; background: #eef0f3; border-radius: 6px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--red); border-radius: 6px; }
.bar .val { font-size: 12.5px; color: var(--mut); font-variant-numeric: tabular-nums; min-width: 90px; text-align: right; }
.bar:hover .lbl { color: var(--red); }

/* ---------- platforma kartalari ---------- */
.plats { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.plat { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; background: #fff; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.plat:hover { border-color: var(--red); transform: translateY(-1px); }
.plat b { font-size: 14.5px; }
.plat p { margin: 0; font-size: 12.5px; color: var(--mut); flex: 1; }
.plat .go { font-size: 12.5px; color: var(--red); font-weight: 600; }
.plat .q { font-size: 12px; color: #344054; background: var(--soft); border-radius: 6px; padding: 2px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- bozor kartalari ---------- */
.mkts { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.mkt { display: flex; flex-direction: column; gap: 8px; }
.mkt .t { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.mkt .zh { font-size: 15px; color: var(--red-d); }
.mkt p { margin: 0; }
.mkt .tip { font-size: 12.5px; background: var(--warn-l); border-radius: 8px; padding: 7px 10px; color: #6b3c00; }
.mkt .links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 4px; }
.rel { font-size: 12px; color: var(--ok); font-weight: 600; }

/* ---------- ta'minotchi kartalari ---------- */
.sups { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.sup { display: flex; flex-direction: column; gap: 6px; }
.sup .t { display: flex; justify-content: space-between; gap: 8px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--mut); }
.stars { color: #e0a100; letter-spacing: 1px; }

/* ---------- hisob-kitob ---------- */
.calc { background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.calc table td { padding: 3px 0; border: 0; }
.calc .tot td { border-top: 1px solid var(--line); padding-top: 6px; font-weight: 700; }
.big { font-size: 20px; font-weight: 700; }

/* ---------- avtoto'ldirish ---------- */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(16,24,40,.12); max-height: 300px; overflow: auto; z-index: 5; }
.ac-list button { display: flex; width: 100%; gap: 10px; align-items: center; text-align: left; border: 0; background: #fff; padding: 7px 10px; cursor: pointer; font: inherit; }
.ac-list button:hover { background: var(--soft); }
.ac-list:empty { display: none; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15,18,26,.5); display: grid; place-items: start center; padding: 40px 16px; overflow: auto; z-index: 100; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 16px; width: min(760px, 100%); padding: 22px 22px 18px; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-box.wide { width: min(980px, 100%); }
.modal-x { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--mut); }
.modal h2 { padding-right: 30px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.driver { text-align: center; padding: 26px 10px; }
.driver .zh { font-size: clamp(34px, 7vw, 64px); font-weight: 700; color: var(--ink); line-height: 1.2; }
.driver .city { font-size: 22px; margin-top: 10px; }

/* ---------- sinxron paneli va toast ---------- */
#syncBar { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; box-shadow: var(--sh); }
#syncBar .track { height: 6px; background: #eef0f3; border-radius: 4px; overflow: hidden; margin-top: 6px; }
#syncBar .fill { height: 100%; background: var(--red); transition: width .4s; }
#syncBar .fill.ind { animation: ind 1.4s ease-in-out infinite; }
@keyframes ind { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
body.locked .side { display: none; }
body.locked .app { grid-template-columns: 1fr; }
.login { min-height: 80vh; display: grid; place-items: center; }
.login form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 12px; text-align: center; padding: 28px 24px; }
.login .logo { width: 60px; height: 60px; font-size: 32px; margin: 0 auto; border-radius: 16px; }
.login h1 { margin: 0; }
.login p { margin: 0 0 6px; }
.login input { font-size: 16px; padding: 11px 12px; }
.login .btn { justify-content: center; padding: 11px; font-size: 15px; }
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
#toast div { background: #1b2030; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 90vw; }
#toast div.err { background: var(--bad); }
#toast div.warn { background: #8a5200; }
#toast div.ok { background: var(--ok); }

.hero { text-align: center; padding: 40px 20px; }
.hero .logo { width: 64px; height: 64px; font-size: 34px; margin: 0 auto 14px; border-radius: 16px; }
.steps { counter-reset: s; display: grid; gap: 10px; }
.steps > div { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; gap: 10px; align-items: start; }
.steps > div::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; background: var(--red-l); color: var(--red-d); font-weight: 700; display: grid; place-items: center; font-size: 13px; }
.cont-bar { height: 8px; background: #eef0f3; border-radius: 5px; overflow: hidden; margin-top: 4px; }
.cont-bar div { height: 100%; background: var(--ok); }
.cont-bar div.over { background: var(--bad); }
.msg { white-space: pre-wrap; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 13.5px; max-height: 320px; overflow: auto; }

@media (max-width: 1100px) { .g3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; padding: 8px; gap: 6px; overflow-x: auto; }
  .brand { border: 0; padding: 0 6px 0 2px; }
  .brand > span:last-child, .side-foot { display: none; }
  nav { display: flex; gap: 2px; }
  nav a { padding: 7px 9px; }
  nav a span { display: none; }
  nav a.on span { display: inline; }
  main { padding: 16px 12px 60px; }
  .g2, .g3, .form { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .v { font-size: 19px; }
  .modal { padding: 12px 8px; }
  .modal-box { padding: 18px 14px 14px; }
  .modal-box .grid { grid-template-columns: 1fr !important; }
  .bar { grid-template-columns: 110px 1fr auto; }
}
@media print {
  .side, #syncBar, .noprint, .btn { display: none !important; }
  .print-only { display: inline; }
  .app { display: block; }
  main { padding: 0; }
  .card, .tbl-wrap { box-shadow: none; }
  body { background: #fff; }
}
@media (max-width: 860px) {
  .hm { display: none; }
  input, select, textarea { font-size: 16px; }
  .thumb { width: 36px; height: 36px; }
  th, td { padding: 7px 8px; }
  .acts { flex-direction: column; align-items: stretch; }
  .head { align-items: flex-start; }
}
