/* ==========================================================================
   apicloud.uz - ilova yuzalari: kirish sahifasi va boshqaruv paneli.
   style.css dagi tokenlar ustiga quriladi (rang, radius, shrift bir xil).
   Landing: VISUAL_DENSITY 4. Panel zichroq: 7 - kartalar kamroq, chiziqlar koʻproq.
   ========================================================================== */

/* Grafik va status ranglari. Status faqat raqamli kod bilan birga ishlatiladi,
   yaʼni maʼno hech qachon yolgʻiz rangga tayanmaydi.
   Juftlik dataviz validatori bilan tekshirilgan (CVD ΔE 9.7 qorongʻu, 11.7 yorugʻ). */
:root {
  --chart-line: #cdf24a;
  --chart-fill: rgba(205, 242, 74, .09);
  --chart-grid: rgba(255, 255, 255, .09);
  --st-warn: #c4872b;
  --st-crit: #d4445f;
  --st-warn-bg: rgba(196, 135, 43, .14);
  --st-crit-bg: rgba(212, 68, 95, .14);
  --st-warn-text: #dba956;
  --st-crit-text: #e8798a;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --chart-line: #6b8a0c;
    --chart-fill: rgba(107, 138, 12, .12);
    --chart-grid: rgba(19, 24, 10, .10);
    --st-warn: #b5780a;
    --st-crit: #b3271a;
    --st-warn-bg: rgba(181, 120, 10, .12);
    --st-crit-bg: rgba(179, 39, 26, .10);
    --st-warn-text: #835703;
    --st-crit-text: #a3231a;
  }
}
:root[data-theme="light"] {
  --chart-line: #6b8a0c;
  --chart-fill: rgba(107, 138, 12, .12);
  --chart-grid: rgba(19, 24, 10, .10);
  --st-warn: #b5780a;
  --st-crit: #b3271a;
  --st-warn-bg: rgba(181, 120, 10, .12);
  --st-crit-bg: rgba(179, 39, 26, .10);
  --st-warn-text: #835703;
  --st-crit-text: #a3231a;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ================= KIRISH SAHIFASI ================= */
.auth {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}
.auth-form-side {
  display: flex; flex-direction: column;
  padding: 32px clamp(24px, 5vw, 72px) 40px;
}
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.auth-box { margin: auto; width: 100%; max-width: 400px; padding-block: 48px; }
.auth-box h1 { font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.25rem); margin-bottom: 10px; }
.auth-box > p { color: var(--text-dim); font-size: .95rem; }
.auth-form { margin-top: 32px; display: grid; gap: 18px; }

.f { display: grid; gap: 7px; }
.f label { font-size: .86rem; font-weight: 560; }
.f-input {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--surface); padding-right: 6px;
  transition: border-color .18s var(--ease);
}
.f-input:focus-within { border-color: var(--accent-text); box-shadow: 0 0 0 3px var(--accent-soft); }
.f-input input {
  flex: 1; min-width: 0; padding: 13px 14px; font: inherit; font-size: .95rem;
  background: none; border: 0; color: var(--text);
}
.f-input input:focus { outline: none; }
.f-input input::placeholder { color: var(--text-faint); }
.f-input button { padding: 8px; border-radius: 8px; color: var(--text-faint); display: grid; place-items: center; }
.f-input button:hover { color: var(--text); }
.f-input button svg { width: 18px; height: 18px; }
.f .hint { font-size: .8rem; color: var(--text-dim); }
.f .err { font-size: .82rem; color: var(--st-crit-text); display: none; }
.f[data-invalid="true"] .f-input { border-color: var(--st-crit); }
.f[data-invalid="true"] .err { display: block; }

.f-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 9px; font-size: .9rem; color: var(--text-dim); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.auth-form .btn { width: 100%; }
.auth-alt { margin-top: 28px; font-size: .92rem; color: var(--text-dim); text-align: center; }
.auth-alt a { color: var(--accent-text); font-weight: 560; }
.auth-foot { font-size: .84rem; color: var(--text-faint); }

/* Xatolik bildirishnomasi */
.alert {
  display: none; gap: 10px; align-items: flex-start;
  border: 1px solid var(--st-crit); background: var(--st-crit-bg);
  border-radius: var(--r-sm); padding: 13px 15px; font-size: .9rem;
}
.alert[data-show="true"] { display: flex; }
.alert svg { width: 18px; height: 18px; color: var(--st-crit); flex: none; margin-top: 2px; }

/* Brend paneli */
.auth-brand-side {
  position: relative; overflow: hidden;
  background: var(--surface-2);
  border-left: 1px solid var(--line);
  padding: clamp(40px, 5vw, 72px);
  display: flex; flex-direction: column; justify-content: center; gap: clamp(40px, 6vh, 80px);
}
.auth-brand-side::before {
  content: ""; position: absolute; inset: -20% -30% 40% 20%;
  background: radial-gradient(45% 45% at 50% 50%, var(--accent-soft), transparent 70%);
}
.auth-brand-side > * { position: relative; }
.auth-quote { font-size: clamp(1.4rem, 1.1rem + 1.3vw, 2.1rem); letter-spacing: -.03em; line-height: 1.2; max-width: 16ch; }
.auth-quote b { color: var(--accent-text); font-weight: inherit; }
.consent a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
.auth-snippet {
  font-family: "Geist Mono", ui-monospace, monospace; font-size: .8rem; line-height: 1.8;
  color: var(--text-dim); background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 18px 20px; overflow-x: auto;
}
.auth-snippet .tok-s { color: var(--accent-text); }

@media (max-width: 900px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand-side { display: none; }
}
@media (max-width: 380px) {
  .auth-form-side { padding-inline: 16px; min-width: 0; }
}

/* ================= BOSHQARUV PANELI ================= */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }

.side {
  border-right: 1px solid var(--line); background: var(--surface);
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px 14px; position: sticky; top: 0; height: 100dvh;
}
.side .brand { padding: 6px 10px 18px; }
.side-label {
  font-size: .68rem; text-transform: uppercase; letter-spacing: .14em;
  color: var(--text-faint); padding: 14px 10px 6px;
}
.side a.nav-item, .side button.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 10px 11px; border-radius: var(--r-sm); font-size: .93rem;
  color: var(--text-dim); transition: background-color .16s var(--ease), color .16s var(--ease);
}
.nav-item svg { width: 19px; height: 19px; flex: none; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 560; }
.nav-item .count {
  margin-left: auto; font-family: "Geist Mono", monospace; font-size: .74rem; color: var(--text-faint);
}
.side-bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 999px; flex: none;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: .82rem; font-weight: 600;
}
.side-user div { min-width: 0; }
.side-user b { display: block; font-size: .88rem; font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user > div span { font-size: .78rem; color: var(--text-dim); }

.scrim {
  position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .5);
  opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
}
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  padding: 0 clamp(18px, 2.5vw, 32px); height: 64px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
.topbar h1 { font-size: 1.1rem; letter-spacing: -.02em; }
.topbar .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.demo-badge {
  font-family: "Geist Mono", monospace; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
  border: 1px solid var(--line-strong); color: var(--text-dim);
  border-radius: 999px; padding: 4px 10px;
}
.app-body { padding: clamp(20px, 2.6vw, 32px); display: grid; gap: 22px; }
.app-body > *, .cols > * { min-width: 0; }

/* Filtrlar: bitta qator, kontentdan yuqorida */
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.seg { display: flex; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.seg button {
  padding: 8px 14px; font-size: .86rem; color: var(--text-dim);
  border-right: 1px solid var(--line); transition: background-color .16s var(--ease), color .16s var(--ease);
}
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 560; }
.seg button:hover { color: var(--text); }
.filters-note {
  display: flex; align-items: center; gap: 7px;
  font-size: .82rem; color: var(--text-dim); line-height: 1.4;
}
.filters-note svg { flex: none; width: 15px; height: 15px; color: var(--text-faint); }
select.control, input.control {
  padding: 8px 12px; font: inherit; font-size: .86rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
}
input.control::placeholder { color: var(--text-faint); }
input.control:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Koʻrsatkichlar: quti emas, chiziq ajratadi */
.figures {
  display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden;
}
.fig { background: var(--surface); padding: 22px 24px; }
.fig .label { font-size: .84rem; color: var(--text-dim); }
.fig .value {
  font-size: 1.9rem; font-weight: 560; letter-spacing: -.035em; margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.fig.hero .value { font-size: clamp(3rem, 2.4rem + 1.4vw, 3.4rem); line-height: 1.05; }
/* Backend javobi kelmaguncha raqam oʻrnida chiziqcha turadi - soʻnik, chunki bu qiymat emas */
.fig .value[data-empty="true"] { color: var(--text-faint); }
.fig .delta { display: inline-flex; align-items: center; gap: 5px; font-size: .84rem; margin-top: 8px; color: var(--text-dim); }
.fig .delta svg { width: 14px; height: 14px; }
.fig .delta[data-dir="down"] svg { transform: scaleY(-1); }
.fig .delta[data-good="true"] { color: var(--accent-text); }
.fig .delta[data-good="false"] { color: var(--st-warn-text); }

/* Panel bloklari */
.panel { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); min-width: 0; }
.panel-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 18px 22px; border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 1rem; letter-spacing: -.015em; }
.panel-head p { font-size: .84rem; color: var(--text-dim); margin-top: 3px; }
.panel-head .right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 22px; }
.panel-note {
  padding: 14px 22px; border-top: 1px solid var(--line);
  font-size: .82rem; color: var(--text-dim); line-height: 1.5;
}

/* Grafik */
.chart-wrap { position: relative; }
.chart-wrap[data-loading="true"] { opacity: .45; transition: opacity .2s var(--ease); }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .axis-text { fill: var(--text-faint); font-size: 11px; font-family: "Geist Mono", monospace; }
.chart .series-line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .series-area { fill: var(--chart-fill); }
.chart .end-dot { fill: var(--chart-line); stroke: var(--surface); stroke-width: 2; }
.chart .end-label { fill: var(--text); font-size: 12px; font-weight: 560; font-variant-numeric: tabular-nums; }
.chart .cross { stroke: var(--line-strong); stroke-width: 1; opacity: 0; }
.chart .cross-dot { fill: var(--chart-line); stroke: var(--surface); stroke-width: 2; opacity: 0; }
.chart[data-hover="true"] .cross, .chart[data-hover="true"] .cross-dot { opacity: 1; }
.tip {
  position: absolute; pointer-events: none; opacity: 0; transform: translate(-50%, -100%);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 9px 12px; box-shadow: var(--shadow-md); white-space: nowrap; transition: opacity .12s var(--ease);
}
.tip[data-show="true"] { opacity: 1; }
.tip b { display: block; font-size: 1rem; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.tip .k { display: flex; align-items: center; gap: 7px; font-size: .78rem; color: var(--text-dim); margin-top: 3px; }
.tip .k i { width: 12px; height: 2px; border-radius: 2px; background: var(--chart-line); display: block; }

/* Jadval koʻrinishi (grafikka muqobil, klaviatura bilan ham ochiladi) */
.table-view { display: none; margin-top: 18px; max-height: 260px; overflow-y: auto; }
.table-view[data-show="true"] { display: block; }

.table-scroll { overflow-x: auto; min-width: 0; }
table.t { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.t th {
  text-align: left; font-weight: 500; font-size: .74rem; text-transform: uppercase;
  letter-spacing: .1em; color: var(--text-faint); padding: 0 16px 12px; white-space: nowrap;
}
table.t td { padding: 13px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
table.t tbody tr:hover { background: var(--surface-2); }
table.t .num { font-family: "Geist Mono", monospace; font-variant-numeric: tabular-nums; }
.key-cell { display: flex; align-items: center; gap: 10px; }
.key-cell code { font-family: "Geist Mono", monospace; font-size: .82rem; color: var(--text-dim); }
.mini-btn {
  padding: 6px; border-radius: 7px; color: var(--text-faint);
  border: 1px solid transparent; transition: color .16s var(--ease), border-color .16s var(--ease);
}
.mini-btn:hover { color: var(--text); border-color: var(--line); }
.mini-btn svg { width: 16px; height: 16px; }

/* Status: rang + matn + belgi, hech qachon yolgʻiz rang emas */
.st { display: inline-flex; align-items: center; gap: 6px; font-family: "Geist Mono", monospace; font-size: .8rem; }
.st i { width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex: none; }
.st-ok { color: var(--text-dim); }
.st-warn { color: var(--st-warn-text); }
.st-crit { color: var(--st-crit-text); }
.pill {
  font-family: "Geist Mono", monospace; font-size: .72rem; border-radius: 999px;
  padding: 3px 9px; border: 1px solid var(--line); color: var(--text-dim);
}
.pill-live { border-color: var(--accent); color: var(--accent-text); }

/* Ikki ustunli qism */
.cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 22px; align-items: start; }

/* Boʻsh holat */
.empty { text-align: center; padding: 44px 24px; }
.empty .ico {
  width: 46px; height: 46px; border-radius: var(--r-sm); margin: 0 auto 16px;
  display: grid; place-items: center; background: var(--surface-2); color: var(--text-faint);
}
.empty .ico svg { width: 23px; height: 23px; }
.empty h3 { font-size: 1rem; margin-bottom: 6px; }
.empty p { font-size: .88rem; color: var(--text-dim); margin: 0 auto 20px; max-width: 34ch; }

/* Skelet yuklagich: yakuniy tuzilishni takrorlaydi */
.sk { background: var(--surface-2); border-radius: 6px; height: 13px; }
.sk-row { display: flex; align-items: center; gap: 16px; padding: 13px 16px; border-top: 1px solid var(--line); }
@media (prefers-reduced-motion: no-preference) {
  .sk { animation: sk 1.4s var(--ease) infinite; }
  @keyframes sk { 0%, 100% { opacity: .55 } 50% { opacity: 1 } }
}

/* Mobil */
.side-toggle { display: none; }
@media (max-width: 1200px) {
  .figures { grid-template-columns: 1fr 1fr; }
  .cols { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 50;
    transform: translateX(-100%); transition: transform .25s var(--ease);
  }
  .side[data-open="true"] { transform: none; box-shadow: var(--shadow-md); }
  .side-toggle { display: grid; }
  .scrim[data-show="true"] { opacity: 1; pointer-events: auto; }
  /* Faqat jurnal jadvali gorizontal siljiydi, kalitlar jadvali ekranga sigʻadi */
  table.t-log { min-width: 520px; }
}
@media (max-width: 560px) {
  .figures { grid-template-columns: 1fr; }
  table.t td, table.t th { padding-inline: 14px; }
  .topbar h1 { font-size: 1rem; }
  .demo-badge { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .side { transition: none; }
}

/* ---------- Boʻsh holat matni ---------- */
.t td.muted { color: var(--text-dim); font-size: .86rem; padding-top: 22px; padding-bottom: 22px; }
.muted { color: var(--text-dim); }

/* ---------- Jonli sinov ---------- */
.f-lite { display: grid; gap: 6px; }
.f-lite > span { font-size: .82rem; color: var(--text-dim); }
.f-lite > span i { font-style: normal; color: var(--text-faint); }
.f-lite input.control { width: 100%; }

.try { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.try .f-lite { flex: 1 1 160px; }
.try button { flex: none; }
.try-url { margin-top: 12px; font-size: .78rem; color: var(--text-dim); word-break: break-all; }
.try-url code { font-size: .78rem; }
.try-out {
  margin-top: 10px; padding: 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  font-family: "Geist Mono", monospace; font-size: .78rem; line-height: 1.55;
  color: var(--text-dim);
  max-height: 260px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.try-out:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.try-out[data-state="ok"] { border-color: var(--accent); color: var(--text); }
.try-out[data-state="err"] { border-color: var(--st-crit-text); color: var(--text); }
.try-out[data-state="loading"] { opacity: .6; }
