:root {
  color-scheme: light;
  --bg: #f1f4f9;
  --panel: #ffffff;
  --panel-2: #f5f7fb;
  --line: #e2e8f0;
  --text: #0f1a2a;
  --muted: #5d6b80;
  --accent: #2a78d6;
  --accent-strong: #1f66bd;
  --accent-soft: #e6f0fc;
  --good: #087a4b;
  --good-ring: #14a866;
  --good-soft: #def5ea;
  --warn: #8a5a00;
  --warn-soft: #fdf0d2;
  --bad: #c0362c;
  --bad-soft: #fde8e6;
  --shadow: 0 1px 2px #0f1a2a0d, 0 8px 24px #0f1a2a0d;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b121b;
    --panel: #131b26;
    --panel-2: #1a2432;
    --line: #243042;
    --text: #e9eff7;
    --muted: #92a2b8;
    --accent: #3987e5;
    --accent-strong: #2a73cc;
    --accent-soft: #172b47;
    --good: #4ade9e;
    --good-ring: #22c57d;
    --good-soft: #10332a;
    --warn: #f5c04e;
    --warn-soft: #3a2e12;
    --bad: #f2786d;
    --bad-soft: #3d1c1c;
    --shadow: 0 1px 2px #0006, 0 12px 32px #0004;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Segoe UI Variable Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 24px; letter-spacing: -.02em; }
h2 { font-size: 17px; letter-spacing: -.01em; }
.muted { color: var(--muted); font-size: 13.5px; }
.error { color: var(--bad); min-height: 1.5em; }
svg.icon { width: 20px; height: 20px; flex: none; }

/* ---------- boshqaruv elementlari ---------- */
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  font-weight: 600;
  transition: filter .15s, transform .05s;
}
.btn:not(:disabled):hover { filter: brightness(1.08); }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn.primary { background: var(--accent-strong); border-color: transparent; color: #fff; }
.btn.danger { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.btn.block { width: 100%; }
.btn.large { padding: 15px; font-size: 16px; }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.link { display: inline-flex; align-items: center; gap: 6px; padding: 4px 0; border: 0; background: none; color: var(--muted); font-size: 13.5px; }
.link:not(:disabled):hover { color: var(--text); }
.icon-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
label { display: block; color: var(--muted); font-size: 13px; font-weight: 600; }
input:not([type=radio]) {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 500;
}
input:focus { border-color: var(--accent); outline: none; }
.big-input { font-size: 28px; font-weight: 700 !important; }
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 14px; border-radius: 9px; text-align: center; white-space: nowrap; cursor: pointer; }
.segmented input:checked + span { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px #0003; }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border: 0; border-radius: 99px; background: var(--panel-2); color: var(--muted); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.info { background: var(--accent-soft); color: var(--text); }
.chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.live::before { animation: blink 1.4s ease-in-out infinite; }
button.chip { cursor: pointer; border: 1px solid var(--line); padding: 6px 12px; }
button.chip[aria-pressed=true] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
@keyframes blink { 50% { opacity: .25; } }

/* ---------- kirish ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(700px 500px at 50% 15%, #2a78d633, transparent 70%);
}
.login-card { width: min(380px, 100%); padding: 32px; display: grid; gap: 12px; text-align: center; background: var(--panel); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); }
.login-card img { margin: 0 auto; filter: drop-shadow(0 10px 20px #2a78d666); }
.login-card input { text-align: center; margin-top: 8px; }

/* ---------- qobiq ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 22px 14px; background: var(--panel); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; font-size: 20px; font-weight: 800; }
nav { display: grid; gap: 4px; }
nav button, .sidebar .logout { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border: 0; border-radius: 12px; background: none; color: var(--muted); font-weight: 600; text-align: left; }
nav button:hover, .sidebar .logout:hover { background: var(--panel-2); color: var(--text); }
nav button.active { background: var(--accent-soft); color: var(--text); }
nav button.active svg { color: var(--accent); }
.sidebar .logout { margin-top: auto; }
.content { width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px 28px 48px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.topbar .logout { display: none; }
.banner { margin-bottom: 14px; padding: 12px 16px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.panel { padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }

/* ---------- ko'rsatkichlar ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.kpi { display: flex; gap: 14px; align-items: flex-start; padding: 16px; }
.kpi .badge-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--accent-soft); color: var(--accent); }
.kpi > div { min-width: 0; }
.kpi strong { display: block; font-size: 22px; line-height: 1.25; letter-spacing: -.02em; }
.kpi small { display: block; color: var(--muted); font-size: 12.5px; }
.kpi small.alert { color: var(--warn); font-weight: 700; }

/* ---------- stansiya ---------- */
.station + .station { margin-top: 28px; }
.station-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.station-head .muted { flex: 1; }
.connectors { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.connector { display: flex; flex-direction: column; gap: 16px; transition: border-color .3s; }
.connector.charging { border-color: var(--good-ring); background: linear-gradient(180deg, var(--good-soft), var(--panel) 150px); }
.connector-head { display: flex; align-items: center; gap: 12px; }
.connector-head h2 { flex: 1; }
.letter { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--accent-strong); color: #fff; font-size: 20px; font-weight: 800; }
.charging .letter { background: #0f8a55; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.amount { position: relative; }
.amount input { padding-right: 56px !important; font-size: 18px; }
.amount span { position: absolute; right: 14px; bottom: 13px; color: var(--muted); font-weight: 600; }
.last { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--panel-2); font-size: 13.5px; }
.last b { display: block; font-size: 15px; }
.last .change { padding: 6px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); text-align: right; font-weight: 700; white-space: nowrap; }
.last.pending { background: var(--accent-soft); }
.gauge { position: relative; width: 210px; margin: 0 auto; }
.gauge svg { display: block; width: 100%; transform: rotate(-90deg); }
.gauge circle { fill: none; stroke-width: 9; }
.gauge .track { stroke: var(--line); }
.gauge .value { stroke: var(--good-ring); stroke-linecap: round; transition: stroke-dasharray .8s ease; filter: drop-shadow(0 0 5px #22c57d80); }
.gauge.unknown svg { animation: spin 2.4s linear infinite; }
.gauge div { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gauge strong { font-size: 46px; line-height: 1; letter-spacing: -.04em; }
.gauge .kw { margin-top: 8px; color: var(--good); font-size: 17px; font-weight: 700; }
@keyframes spin { to { transform: rotate(270deg); } }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { padding: 11px 14px; border-radius: 12px; background: var(--panel-2); }
.stat small { display: block; color: var(--muted); font-size: 12px; }
.stat b { font-size: 17px; white-space: nowrap; }
.limit-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .8s ease; }
.connector-foot { display: flex; justify-content: space-between; }

/* ---------- hisobot ---------- */
.report-top { display: grid; grid-template-columns: minmax(280px, 2fr) 3fr; gap: 16px; margin-bottom: 24px; }
.hero { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1.2; margin-top: 14px; }
.breakdown { display: grid; gap: 12px; margin-top: 18px; }
.breakdown .limit-row { margin-bottom: 5px; }
.breakdown .meter { height: 6px; }
.topups { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.chart-panel { display: flex; flex-direction: column; min-width: 0; }
.chart { position: relative; flex: 1; min-height: 220px; margin: 30px 0 28px 54px; }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.gridline span { position: absolute; right: calc(100% + 8px); top: -10px; color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.bars { position: absolute; inset: 0; display: flex; }
.column { position: relative; flex: 1; height: 100%; padding: 0; border: 0; background: none; cursor: default; }
.column i { position: absolute; bottom: 0; left: 50%; width: min(34px, 62%); transform: translateX(-50%); border-radius: 4px 4px 0 0; background: var(--accent); transition: filter .15s; }
.column:hover i, .column:focus-visible i { filter: brightness(1.25); }
.column .day { position: absolute; top: calc(100% + 6px); left: 0; right: 0; color: var(--muted); font-size: 12px; }
.column .direct { position: absolute; left: 50%; transform: translateX(-50%); margin-bottom: 4px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.column .tip { position: absolute; left: 50%; z-index: 2; transform: translateX(-50%); margin-bottom: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2); box-shadow: var(--shadow); font-size: 12.5px; text-align: left; white-space: nowrap; pointer-events: none; visibility: hidden; }
.column:first-child .tip { transform: translateX(-20%); }
.column:last-child .tip { transform: translateX(-80%); }
.column:hover .tip, .column:focus-visible .tip { visibility: visible; }
.column:hover .direct, .column:focus-visible .direct { visibility: hidden; }
details summary { color: var(--muted); font-size: 13px; cursor: pointer; }
table { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
.list-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.list { padding: 4px 18px; }
.list + .btn { margin-top: 12px; }
.row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center; padding: 14px 0; }
.row + .row { border-top: 1px solid var(--line); }
.row .letter { width: 36px; height: 36px; border-radius: 11px; font-size: 16px; background: var(--panel-2); color: var(--text); }
.row .money { text-align: right; font-size: 16px; font-weight: 700; white-space: nowrap; }
.row .money small { display: block; color: var(--muted); font-size: 12px; font-weight: 500; }
.row .actions { display: flex; justify-content: flex-end; align-items: center; gap: 6px; min-width: 190px; }
.empty { padding: 28px 0; text-align: center; color: var(--muted); }

/* ---------- kartalar ---------- */
.split { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
#card-form { display: grid; gap: 14px; }
.panel-head { display: flex; gap: 14px; align-items: center; }
.nfc-pulse { display: grid; place-items: center; width: 48px; height: 48px; flex: none; border-radius: 50%; background: var(--accent-soft); color: var(--accent); animation: pulse 2s infinite; }
.nfc-pulse svg { width: 26px; height: 26px; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 #2a78d666; } 70% { box-shadow: 0 0 0 12px #2a78d600; } 100% { box-shadow: 0 0 0 0 #2a78d600; } }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; align-items: start; }
.card-item { display: grid; gap: 12px; padding: 14px; }
.nfc-card { display: flex; flex-direction: column; justify-content: space-between; aspect-ratio: 1.75; padding: 18px; border-radius: 14px; color: #fff; background: linear-gradient(135deg, #1b4f96, #2a78d6 60%, #2f9fc4); overflow: hidden; }
.nfc-card.postpaid { background: linear-gradient(135deg, #283447, #4a5a75); }
.nfc-card .line { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.nfc-card svg { width: 28px; height: 28px; }
.nfc-card small { opacity: .8; font-size: 12px; }
.nfc-card strong { display: block; font-size: 28px; letter-spacing: -.02em; line-height: 1.2; }
.nfc-card .number { font-family: ui-monospace, Consolas, monospace; letter-spacing: .08em; }
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.settings .panel { display: grid; gap: 14px; }
.copy { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); }
.copy div { min-width: 0; }
.copy code { display: block; font-size: 13px; word-break: break-all; }
pre { margin: 0 0 6px; white-space: pre-wrap; word-break: break-all; font-size: 12px; }

/* ---------- xabarlar ---------- */
#toast { position: fixed; z-index: 10; left: 50%; bottom: 28px; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 32px); padding: 13px 20px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 600; box-shadow: 0 12px 32px #0006; animation: rise .25s ease; }
#toast.bad { background: #b3261e; color: #fff; }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 10px); } }
dialog { width: min(400px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 20px; background: var(--panel); color: var(--text); box-shadow: 0 24px 64px #0008; }
dialog::backdrop { background: #050a12b3; }
dialog form { display: grid; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- planshet va telefon ---------- */
@media (max-width: 980px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .report-top, .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 5; top: auto; bottom: 0; left: 0; right: 0; height: auto; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border: 0; border-top: 1px solid var(--line); }
  .brand, .sidebar .logout { display: none; }
  nav { grid-template-columns: repeat(4, 1fr); }
  nav button { flex-direction: column; gap: 2px; padding: 7px 0; font-size: 11.5px; }
  .content { padding: 16px 16px 92px; }
  .topbar .logout { display: grid; }
  .topbar .muted { display: none; }
  .connectors, .settings { grid-template-columns: minmax(0, 1fr); }
  .kpis { gap: 10px; }
  .kpi { flex-direction: column; gap: 8px; padding: 14px; }
  .kpi strong { font-size: 18px; }
  .chart { margin: 30px 0 42px 46px; }
  .column .day { font-size: 11px; line-height: 1.3; }
  .column .direct { font-size: 10.5px; }
  .list { padding: 4px 14px; }
  .row { grid-template-columns: auto 1fr auto; gap: 10px; }
  .row .money { grid-column: 3; grid-row: 1; }
  .row .actions { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
  .row .actions:empty { display: none; }
  #toast { bottom: 86px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
