:root {
  --bg: #f3f4ff;
  --card: #ffffff;
  --ink: #1b1d4b;
  --muted: #5a5d8a;
  --line: #e6e8ff;
  --track: #eef0ff;
  --blue: #2f5bff;
  --violet: #5b3df5;
  --pink: #e5197a;
  --orange: #ff7a00;
  --yellow: #ffb800;
  --green: #00a86b;
  --teal: #0a7ea4;
  --shadow: 0 10px 30px -14px rgba(47, 42, 140, .25);
  --heat: 91, 61, 245;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1030;
    --card: #181b4a;
    --ink: #f1f2ff;
    --muted: #a9acd9;
    --line: #2b2f6b;
    --track: #23276a;
    --shadow: none;
    --heat: 140, 120, 255;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 16px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; }
button, input, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }
.wrap { max-width: 1360px; margin: 0 auto; padding: 0 32px; }

/* ===== sarlavha ===== */
.hero { background: linear-gradient(120deg, #2f2a8c 0%, #5b3df5 55%, #e5197a 125%); color: #fff; padding-top: 28px; }
.hero-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.eyebrow { font-size: 13px; font-weight: 700; color: #e3deff; letter-spacing: .08em; }
.hero h1 { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.status { display: inline-flex; align-items: center; gap: 8px; background: #fff; color: #006e5a; font-weight: 700; font-size: 14px; padding: 8px 16px; border-radius: 999px; }
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: #00a86b; }
.status.bad { color: #a8123f; } .status.bad::before { background: #e5197a; }
.status.idle { color: #4a4d7a; } .status.idle::before { background: #9a9dc8; }
.glass { background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 12px; padding: 9px 18px; font-weight: 700; cursor: pointer; }
.range { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 22px; }
.range button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 999px; padding: 9px 18px; font-weight: 700; font-size: 14px; cursor: pointer; }
.range button.active { background: var(--yellow); color: #1b1d4b; font-weight: 800; }
.range label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #e3deff; }
.range input { background: rgba(255,255,255,.95); color: #1b1d4b; border: 0; border-radius: 10px; padding: 6px 10px; font-weight: 600; }
.csv { margin-left: auto; font-weight: 700; font-size: 14px; text-decoration: underline; }
.nav { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 18px; }
.nav a { padding: 12px 18px; border-radius: 14px 14px 0 0; font-weight: 700; font-size: 14px; color: #e3deff; }
.nav a:hover, .nav a.active { background: #2f2a8c; color: #fff; }

/* ===== joylashuv ===== */
main.wrap { padding-top: 28px; padding-bottom: 64px; display: flex; flex-direction: column; gap: 22px; }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }

.card { background: var(--card); border-radius: 28px; padding: 26px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 20px; font-weight: 800; }
.card .hint { margin: 4px 0 16px; font-size: 13px; font-weight: 600; color: var(--muted); }
.card h2 + .chart { margin-top: 16px; }
.chart { position: relative; height: 250px; }
.chart.short { height: 200px; }
.pill { display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 99px; margin-left: 6px; background: #ffe0ec; color: #b3125f; font-weight: 800; }
.tone-green { color: #00875a; } .tone-orange { color: #c2410c; } .tone-pink { color: #b5179e; } .tone-teal { color: #0b5e8c; }
@media (prefers-color-scheme: dark) { .tone-green { color: #3be3a6; } .tone-orange { color: #ff9d57; } .tone-pink { color: #ff7ac0; } .tone-teal { color: #5cc8ee; } }

/* KPI kartalar */
.kpi { position: relative; overflow: hidden; border-radius: 24px; padding: 22px; color: #fff; }
.kpi::before, .kpi::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.14); }
.kpi::before { width: 110px; height: 110px; right: -30px; top: -30px; }
.kpi::after { width: 80px; height: 80px; right: 20px; bottom: -40px; background: rgba(255,255,255,.09); }
.kpi > * { position: relative; }
.kpi .label { font-size: 14px; font-weight: 700; }
.kpi .value { font-size: 36px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; line-height: 1.1; }
.kpi .value small { font-size: 15px; font-weight: 700; margin-left: 5px; }
.kpi .sub { font-size: 13px; font-weight: 600; }
.k-blue { background: linear-gradient(135deg, #2f5bff, #5b3df5); box-shadow: 0 12px 28px -12px rgba(47,91,255,.7); }
.k-green { background: linear-gradient(135deg, #008a5e, #006e5a); box-shadow: 0 12px 28px -12px rgba(0,138,94,.7); }
.k-pink { background: linear-gradient(135deg, #e5197a, #b5179e); box-shadow: 0 12px 28px -12px rgba(229,25,122,.7); }
.k-orange { background: linear-gradient(135deg, #ea5a0c, #c2410c); box-shadow: 0 12px 28px -12px rgba(234,90,12,.7); }
.k-violet { background: linear-gradient(135deg, #7b3fe4, #5a2fc2); box-shadow: 0 12px 28px -12px rgba(123,63,228,.7); }
.k-teal { background: linear-gradient(135deg, #0a7ea4, #0b5e8c); box-shadow: 0 12px 28px -12px rgba(10,126,164,.7); }
.progress { height: 8px; background: rgba(255,255,255,.3); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: #fff; border-radius: 99px; }

/* gorizontal chiziqlar (chastota, markalar) */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 96px 1fr 44px; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.bar-row .track { height: 14px; background: var(--track); border-radius: 99px; overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 99px; }
.bar-row .n { text-align: right; font-weight: 800; }

/* yangi/qaytgan doira */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { position: relative; width: 150px; height: 150px; border-radius: 50%; flex: none; }
.donut > div { position: absolute; inset: 26px; border-radius: 50%; background: var(--card); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut b { font-size: 26px; font-weight: 800; }
.donut span { font-size: 11px; font-weight: 700; color: var(--muted); }
.legend { display: flex; flex-direction: column; gap: 10px; font-size: 14px; font-weight: 700; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 5px; margin-right: 8px; vertical-align: -2px; }
.legend .muted { color: var(--muted); font-weight: 600; }

/* rang chiplari, kuzov plitkalari */
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { display: flex; align-items: center; gap: 8px; border-radius: 999px; padding: 7px 14px 7px 7px; background: var(--bg); font-size: 14px; font-weight: 700; }
.chip .dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 2px #c9ccff; }
.chip em { font-style: normal; color: var(--muted); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { border-radius: 20px; padding: 16px; color: #fff; }
.tile b { display: block; font-size: 30px; font-weight: 800; line-height: 1.1; }
.tile span { font-size: 14px; font-weight: 700; }

/* issiqlik xaritasi */
.heat-wrap { overflow-x: auto; }
.heat { display: grid; grid-template-columns: 30px repeat(24, minmax(0, 1fr)); gap: 3px; min-width: 620px; font-size: 11px; }
.heat div { text-align: center; padding: 7px 0; border-radius: 6px; font-weight: 700; }
.heat .h { color: var(--muted); padding: 2px 0; font-weight: 600; }
.heat .c { color: var(--ink); background: rgba(var(--heat), var(--a, 0)); }
.heat .c.hot { color: #fff; }

/* jadvallar */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 360px; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 700; padding: 8px 6px; }
td { padding: 10px 6px; border-top: 1px solid var(--line); font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-weight: 800; }
.plate { font-family: ui-monospace, Consolas, monospace; font-weight: 700; background: #ebe3ff; color: #3b1fa3; padding: 3px 9px; border-radius: 8px; }
.plate.risk { background: #ffe0ec; color: #8a0e4a; }
@media (prefers-color-scheme: dark) { .plate { background: #33307e; color: #d9d0ff; } .plate.risk { background: #5a1d45; color: #ffc7e2; } }
.rank { color: var(--violet); font-weight: 800; }
.since { color: #c2185b; font-weight: 800; }

/* prognoz */
.forecast { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.fc { border-radius: 18px; padding: 12px; text-align: center; color: #fff; }
.fc small { display: block; font-size: 12px; font-weight: 700; }
.fc b { font-size: 26px; font-weight: 800; }

/* tushum kartasi */
.card.sun { background: linear-gradient(145deg, #ffb800, #ff7a00); box-shadow: 0 14px 30px -14px rgba(234,90,12,.6); color: #2b1400; }
.card.sun .hint { color: #4a2300; }
.entry { display: flex; flex-wrap: wrap; align-items: center; gap: 18px 32px; }
.entry-text { flex: 1 1 260px; }
.entry-text .hint { margin-bottom: 0; }
.form.entry-form { flex: 2 1 520px; flex-direction: row; flex-wrap: wrap; align-items: end; }
.entry-form label { flex: 1 1 150px; }
.entry-form button { flex: 0 0 auto; padding: 12px 28px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 700; }
.form input, .form textarea { border: 0; border-radius: 14px; padding: 12px 14px; font-weight: 600; background: #fff; color: #1b1d4b; max-width: 100%; }
.form textarea { min-height: 84px; resize: vertical; }
.form.plain input, .form.plain textarea { background: var(--bg); border: 1px solid var(--line); color: var(--ink); }
.form button, .btn { border: 0; border-radius: 14px; padding: 14px; min-height: 48px; font-weight: 800; font-size: 16px; background: #1b1d4b; color: #fff; cursor: pointer; }
.form.plain button { background: var(--violet); }
.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.form-row label { flex: 1 1 140px; }
.form-row button { flex: 0 0 auto; padding: 12px 22px; }
.mini-table td, .mini-table th { padding: 8px 6px; }
.danger { background: none; border: 0; color: #c2185b; font-weight: 700; cursor: pointer; padding: 4px 8px; }
.camp { border-radius: 20px; padding: 14px 16px; background: #eafbf3; color: #1b1d4b; display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
@media (prefers-color-scheme: dark) { .camp { background: #12385a; color: var(--ink); } }
.camp b { font-size: 16px; font-weight: 800; }
.camp .meta { font-size: 13px; font-weight: 600; color: var(--muted); }
.tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.tag { color: #fff; font-weight: 800; font-size: 14px; padding: 5px 12px; border-radius: 99px; background: #6b7280; }
.tag.up { background: #00875a; } .tag.down { background: #c2185b; }
.rev-list { max-height: 360px; overflow: auto; }
.empty { color: var(--muted); padding: 16px 0; font-weight: 600; }
.note { font-size: 13px; font-weight: 600; color: var(--muted); margin: 12px 0 0; }
.error { color: #c2185b; min-height: 1.2em; margin: 0; font-weight: 700; }

/* kirish */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(120deg, #2f2a8c, #5b3df5 60%, #e5197a); }
.login-card { width: min(380px, 100%); display: grid; gap: 12px; background: var(--card); border-radius: 28px; padding: 32px; box-shadow: 0 30px 60px -20px rgba(0,0,0,.45); }
.login-badge { width: 56px; height: 56px; border-radius: 18px; background: linear-gradient(135deg, #ffb800, #ff7a00); color: #2b1400; font-weight: 800; font-size: 20px; display: grid; place-items: center; }
.login-card h1 { font-size: 24px; font-weight: 800; }
.login-card p { margin: 0; color: var(--muted); font-weight: 600; }
.login-card input { border: 2px solid var(--line); border-radius: 14px; padding: 13px 14px; background: var(--bg); color: var(--ink); font-weight: 600; }
.login-card button { border: 0; border-radius: 14px; padding: 14px; min-height: 48px; font-weight: 800; font-size: 16px; color: #fff; background: linear-gradient(135deg, #5b3df5, #e5197a); cursor: pointer; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); opacity: 0; background: #1b1d4b; color: #fff; font-weight: 700; padding: 12px 20px; border-radius: 12px; transition: .25s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #c2185b; }

@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .hero h1 { font-size: 26px; }
  .kpi .value { font-size: 30px; }
  .card { padding: 20px; border-radius: 22px; }
  .csv { margin-left: 0; }
  .nav { flex-wrap: nowrap; overflow-x: auto; }
  .nav a { white-space: nowrap; }
}
