/* HisobotAI — dizayn tizimi (v2).
   Rollar orqali yozilgan: ranglar faqat tokenlardan olinadi, qora/oq mavzu
   alohida tanlangan qiymatlar (avtomatik "invert" emas).
   Diagramma palitrasi validate_palette.js bilan tekshirilgan (ikkala mavzu). */

:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0f1e;
  --bg-2: #0e1428;
  --surface: #121a31;
  --surface-2: #172040;
  --surface-3: #1d2850;
  --hover: rgba(148, 163, 214, 0.07);
  --line: rgba(148, 163, 214, 0.13);
  --line-strong: rgba(148, 163, 214, 0.24);
  --text: #eef1fb;
  --text-2: #b4bcd8;
  --text-3: #7d87aa;
  --brand: #6d72f6;
  --brand-2: #22b8d6;
  --brand-soft: rgba(109, 114, 246, 0.16);
  --grad: linear-gradient(135deg, #6d72f6 0%, #22b8d6 100%);

  /* Diagramma: kategorik slotlar (qorong'i sirt uchun qadamlar) */
  --s1: #3987e5;  --s2: #d95926;  --s3: #199e70;  --s4: #c98500;
  --s5: #d55181;  --s6: #008300;  --s7: #9085e9;  --s8: #e66767;
  --s-neutral: #8a93b4;
  /* Ketma-ket (issiqlik xaritasi): sirtga yaqindan yorqinga */
  --q0: rgba(148, 163, 214, 0.09);
  --q1: #184f95;  --q2: #256abf;  --q3: #3987e5;  --q4: #6da7ec;

  /* Holat (status) — faqat ma'no bo'lganda */
  --good: #34d399;  --good-bg: rgba(52, 211, 153, 0.13);
  --warn: #fbbf24;  --warn-bg: rgba(251, 191, 36, 0.13);
  --bad: #f87171;   --bad-bg: rgba(248, 113, 113, 0.13);
  --info: #60a5fa;  --info-bg: rgba(96, 165, 250, 0.13);

  --shadow: 0 24px 60px rgba(2, 6, 23, 0.55);
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 24px rgba(2, 6, 23, 0.28);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar: 248px;
  --pad: 18px;
  --gap: 16px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fa;
  --bg-2: #eceff7;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef1f8;
  --hover: rgba(30, 45, 100, 0.045);
  --line: rgba(30, 45, 100, 0.1);
  --line-strong: rgba(30, 45, 100, 0.2);
  --text: #121933;
  --text-2: #475273;
  --text-3: #76809e;
  --brand: #5157e8;
  --brand-2: #0e9ab8;
  --brand-soft: rgba(81, 87, 232, 0.1);
  --grad: linear-gradient(135deg, #5a60f0 0%, #13a6c4 100%);

  --s1: #2a78d6;  --s2: #eb6834;  --s3: #1baf7a;  --s4: #eda100;
  --s5: #e87ba4;  --s6: #008300;  --s7: #4a3aa7;  --s8: #e34948;
  --s-neutral: #9aa1b8;
  --q0: rgba(30, 45, 100, 0.07);
  --q1: #86b6ef;  --q2: #5598e7;  --q3: #256abf;  --q4: #104281;

  --good: #059669;  --good-bg: rgba(5, 150, 105, 0.1);
  --warn: #b45309;  --warn-bg: rgba(217, 119, 6, 0.11);
  --bad: #dc2626;   --bad-bg: rgba(220, 38, 38, 0.09);
  --info: #2563eb;  --info-bg: rgba(37, 99, 235, 0.09);

  --shadow: 0 24px 60px rgba(20, 32, 80, 0.16);
  --shadow-sm: 0 1px 2px rgba(20, 32, 80, 0.05), 0 6px 18px rgba(20, 32, 80, 0.05);
}

body.compact { --pad: 13px; --gap: 11px; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Inter", "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss01";
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(900px 460px at 8% -12%, color-mix(in srgb, var(--brand) 20%, transparent), transparent 70%),
    radial-gradient(700px 380px at 100% 0%, color-mix(in srgb, var(--brand-2) 13%, transparent), transparent 70%);
}
body.no-anim *, body.no-anim *::before, body.no-anim *::after { animation: none !important; transition: none !important; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code, kbd {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface-3);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: 6px;
}
kbd { font-size: 11px; color: var(--text-3); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.015em; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--brand-soft); }

/* ================================================================== kirish */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  position: relative; z-index: 1; width: 100%; max-width: 430px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 24px;
  padding: 40px 34px; box-shadow: var(--shadow); text-align: center;
}
.login-logo {
  width: 58px; height: 58px; margin: 0 auto 18px; border-radius: 17px;
  background: var(--grad); display: grid; place-items: center;
  color: #fff; font-size: 27px; font-weight: 800;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--brand) 45%, transparent);
}
.login-card h1 { font-size: 25px; margin-bottom: 6px; }
.login-steps { display: grid; gap: 9px; margin: 26px 0 18px; text-align: left; }
.login-steps .step {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-2);
}
.login-steps .step span {
  flex: none; width: 24px; height: 24px; border-radius: 8px;
  background: var(--grad); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
.warn {
  background: var(--bad-bg); color: var(--bad);
  border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent);
  padding: 10px 14px; border-radius: var(--radius-sm); margin: 14px 0;
}

/* ================================================================= karkas */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar); flex: none;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 20px 14px 16px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 2px 8px 20px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; background: var(--grad);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 18px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--brand) 40%, transparent);
}
.brand strong { display: block; font-size: 15px; letter-spacing: -0.02em; }
.brand span { display: block; font-size: 11.5px; color: var(--text-3); }

.nav { display: grid; gap: 2px; }
.nav-label {
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-3); padding: 14px 10px 6px;
}
.nav button {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 9px 11px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2);
  font: inherit; font-size: 13.5px; text-align: left; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.nav button:hover { background: var(--hover); color: var(--text); }
.nav button.active {
  background: var(--brand-soft); color: var(--text);
  box-shadow: inset 2px 0 0 var(--brand);
}
.nav .ico { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav button.active .ico { color: var(--brand); opacity: 1; }
.nav .badge {
  margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 999px;
  background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; text-align: center;
}

.side-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 14px; }
.palette-hint {
  display: flex; align-items: center; gap: 8px; padding: 8px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text-3); font-size: 12.5px; cursor: pointer;
}
.palette-hint:hover { color: var(--text-2); border-color: var(--line-strong); }
.palette-hint kbd { margin-left: auto; }
.who {
  display: flex; align-items: center; gap: 10px; padding: 9px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2);
}
.avatar {
  flex: none; width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12.5px;
  background: linear-gradient(135deg, #f59e0b, #ec4899);
}
.avatar.sm { width: 28px; height: 28px; border-radius: 9px; font-size: 11px; }
.avatar.lg { width: 56px; height: 56px; border-radius: 17px; font-size: 19px; }
.who-text { min-width: 0; flex: 1; }
.who-text strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text span { font-size: 11px; color: var(--text-3); }

.main { flex: 1; min-width: 0; padding: 20px 26px 60px; }

/* ================================================================= topbar */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: -20px -26px 20px; padding: 14px 26px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; }
.topbar .sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.seg {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
}
.seg button {
  border: 0; background: transparent; color: var(--text-2);
  padding: 6px 11px; border-radius: 8px; font: inherit; font-size: 12.5px;
  cursor: pointer; white-space: nowrap; transition: all 0.15s;
}
.seg button:hover { color: var(--text); background: var(--hover); }
.seg button.active { background: var(--surface-3); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); }

select, input[type="text"], input[type="search"], input[type="number"],
input[type="time"], input[type="url"], textarea {
  font: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 11px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select:hover, input:hover, textarea:hover { border-color: var(--line-strong); }
select:focus, input:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
}
input.invalid, select.invalid { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }
textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--brand); border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--brand) 35%, transparent);
}
.btn-primary:hover { background: color-mix(in srgb, var(--brand) 88%, #000); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); color: var(--text); }
.btn-danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); background: transparent; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-good { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); background: transparent; }
.btn-good:hover { background: var(--good-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center; flex: none;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text-2); cursor: pointer; transition: all 0.15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-3); }
.icon-btn svg, .btn svg { width: 16px; height: 16px; }
.spin svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================================================================ kartochka */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: var(--pad) calc(var(--pad) + 2px);
  box-shadow: var(--shadow-sm); min-width: 0;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; min-height: 28px; }
.card-head h3 { font-size: 14px; font-weight: 650; }
.card-head .hint { font-size: 12px; color: var(--text-3); }
.card-head .right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.grid { display: grid; gap: var(--gap); margin-bottom: var(--gap); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.g-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.span-all { grid-column: 1 / -1; }

/* ================================================================ salomlashish */
.hero { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: var(--gap); }
.hero h2 { font-size: 24px; letter-spacing: -0.025em; }
.hero p { margin: 4px 0 0; color: var(--text-2); }
.hero .right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ================================================================ xulosalar */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-bottom: var(--gap); }
.insight {
  display: flex; gap: 11px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--surface);
}
.insight .i-ico {
  flex: none; width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; font-size: 13px; font-weight: 800;
  background: var(--info-bg); color: var(--info);
}
.insight.up .i-ico { background: var(--good-bg); color: var(--good); }
.insight.down .i-ico { background: var(--bad-bg); color: var(--bad); }
.insight.warn .i-ico { background: var(--warn-bg); color: var(--warn); }
.insight strong { display: block; font-size: 13px; line-height: 1.35; }
.insight span { font-size: 12px; color: var(--text-3); }

/* ===================================================================== KPI */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px 13px; box-shadow: var(--shadow-sm);
  transition: border-color 0.18s, transform 0.18s;
}
.kpi:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.kpi-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.kpi-label .dot { width: 8px; height: 8px; border-radius: 3px; }
.kpi-row { display: flex; align-items: baseline; gap: 8px; margin-top: 8px; }
.kpi-value { font-size: 28px; font-weight: 720; letter-spacing: -0.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-unit { font-size: 13px; color: var(--text-3); }
.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11.5px; font-weight: 650; padding: 2px 7px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-3);
}
.delta.up { background: var(--good-bg); color: var(--good); }
.delta.down { background: var(--bad-bg); color: var(--bad); }
.kpi-foot { margin-top: 8px; font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spark { position: absolute; right: 12px; top: 14px; width: 84px; height: 30px; opacity: 0.9; }

/* ============================================================== diagramma */
.chart { position: relative; width: 100%; }
.h-200 { height: 200px; } .h-240 { height: 240px; } .h-280 { height: 280px; } .h-320 { height: 320px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.line { height: 2px; width: 14px; border-radius: 2px; }

/* Ulush (meter) — 2 qismli tarkib uchun donut o'rniga */
.meter { display: grid; gap: 9px; }
.meter-bar { display: flex; gap: 2px; height: 10px; border-radius: 6px; overflow: hidden; background: var(--surface-3); }
.meter-bar span { height: 100%; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.meter-bar span:first-child { border-radius: 6px 0 0 6px; }
.meter-bar span:last-child { border-radius: 0 6px 6px 0; }
.meter-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.meter-stat .lbl { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.meter-stat .val { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.meter-stat .val small { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: 4px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* Reyting */
.ranks { display: grid; gap: 12px; }
.rank { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.rank-no { font-size: 12px; font-weight: 700; color: var(--text-3); text-align: center; font-variant-numeric: tabular-nums; }
.rank-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 5px; }
.track { display: flex; gap: 2px; height: 6px; border-radius: 4px; overflow: hidden; }
.track span { height: 100%; border-radius: 4px; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.rank-val { font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.rank-val small { font-size: 11px; color: var(--text-3); font-weight: 500; }

/* Reja bajarilishi */
.goal-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.ring { position: relative; width: 84px; height: 84px; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .ring-val { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 750; font-size: 18px; font-variant-numeric: tabular-nums; }
.goal-rows { display: grid; gap: 11px; }
.goal-row .top { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; margin-bottom: 5px; }
.goal-row .top span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.goal-track { position: relative; height: 7px; border-radius: 4px; background: var(--surface-3); overflow: visible; }
.goal-track .fill { height: 100%; border-radius: 4px; background: var(--s1); transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
.goal-track .fill.done { background: var(--good); }
.goal-track .pace { position: absolute; top: -3px; width: 2px; height: 13px; border-radius: 2px; background: var(--text-3); }

/* Issiqlik xaritasi */
.heat-wrap { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.heat-days { display: grid; grid-template-rows: repeat(7, 13px); gap: 3px; font-size: 10px; color: var(--text-3); padding-top: 18px; }
.heat-days span { line-height: 13px; }
.heat-cols { display: flex; flex-direction: column; gap: 5px; }
.heat-months { display: flex; font-size: 10.5px; color: var(--text-3); height: 13px; position: relative; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 13px); grid-auto-columns: 13px; gap: 3px; }
.heat i { width: 13px; height: 13px; border-radius: 3px; background: var(--q0); display: block; }
.heat i[data-l="1"] { background: var(--q1); }
.heat i[data-l="2"] { background: var(--q2); }
.heat i[data-l="3"] { background: var(--q3); }
.heat i[data-l="4"] { background: var(--q4); }
.heat i.pad { visibility: hidden; }
.heat-scale { display: flex; align-items: center; gap: 4px; margin-top: 12px; font-size: 11px; color: var(--text-3); }
.heat-scale i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* =================================================================== jadval */
.table-wrap { overflow-x: auto; margin: 0 calc(-1 * (var(--pad) + 2px)); padding: 0 calc(var(--pad) + 2px); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  padding: 9px 10px; text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-3); border-bottom: 1px solid var(--line);
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text-2); }
tbody td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
th.r, td.r { text-align: right; font-variant-numeric: tabular-nums; }
.clip { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wide { max-width: 440px; }
.person { display: flex; align-items: center; gap: 10px; }
.person .nm { font-weight: 550; }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.tag.plain::before { display: none; }
.tag.reja { color: var(--s1); background: color-mix(in srgb, var(--s1) 14%, transparent); }
.tag.kundalik { color: var(--s2); background: color-mix(in srgb, var(--s2) 14%, transparent); }
.tag.active, .tag.good { color: var(--good); background: var(--good-bg); }
.tag.pending, .tag.warnt { color: var(--warn); background: var(--warn-bg); }
.tag.blocked, .tag.badt { color: var(--bad); background: var(--bad-bg); }
.tag.owner { color: var(--brand); background: var(--brand-soft); }
.tag.admin { color: var(--info); background: var(--info-bg); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: 0.55; transition: opacity 0.15s; }
tbody tr:hover .row-actions { opacity: 1; }
.row-btn {
  width: 28px; height: 28px; display: grid; place-items: center;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  color: var(--text-3); cursor: pointer;
}
.row-btn svg { width: 15px; height: 15px; }
.row-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.row-btn.danger:hover { color: var(--bad); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type="search"] { min-width: 240px; flex: 1; max-width: 360px; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 14px; font-size: 12.5px; color: var(--text-3); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button {
  border: 0; background: transparent; color: var(--text-2);
  padding: 9px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--brand); font-weight: 600; }
.tabs .count { margin-left: 6px; font-size: 11px; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); color: var(--text-3); }

/* ================================================================== holatlar */
.empty { text-align: center; padding: 36px 16px; color: var(--text-3); }
.empty .e-ico {
  width: 46px; height: 46px; margin: 0 auto 12px; border-radius: 14px;
  display: grid; place-items: center; background: var(--surface-3); color: var(--text-3);
}
.empty .e-ico svg { width: 22px; height: 22px; }
.empty strong { display: block; color: var(--text-2); margin-bottom: 4px; }
.skel {
  border-radius: 10px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.3s ease infinite;
}
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.view { animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.notice {
  display: flex; gap: 10px; padding: 11px 14px; border-radius: 12px; font-size: 13px;
  background: var(--info-bg); color: var(--text-2);
  border: 1px solid color-mix(in srgb, var(--info) 25%, transparent);
}
.notice.warnn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.notice b { color: var(--text); }

/* ================================================================== toast */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 90; display: grid; gap: 8px; max-width: 360px; }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: 12px; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line-strong); box-shadow: var(--shadow);
  animation: slide 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast::before { content: ""; flex: none; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--info); }
.toast.ok::before { background: var(--good); }
.toast.err::before { background: var(--bad); }
@keyframes slide { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* =================================================================== modal */
.overlay {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px;
  background: rgba(3, 7, 18, 0.6); backdrop-filter: blur(4px); animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 20px;
  padding: 20px 22px; box-shadow: var(--shadow); animation: pop 0.2s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal.sm { max-width: 420px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-foot { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.modal-foot .grow { flex: 1; }

/* Buyruqlar palitrasi */
.cmdk { max-width: 580px; padding: 0; overflow: hidden; align-self: start; margin-top: 12vh; }
.cmdk input { width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 16px 18px; font-size: 15px; background: transparent; box-shadow: none !important; }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 6px; }
.cmdk-group { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); padding: 10px 12px 4px; font-weight: 650; }
.cmdk-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 13.5px; color: var(--text-2); }
.cmdk-item.sel { background: var(--brand-soft); color: var(--text); }
.cmdk-item .k { margin-left: auto; font-size: 11.5px; color: var(--text-3); }
.cmdk-foot { display: flex; gap: 14px; padding: 9px 14px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--text-3); }

/* ================================================================== forma */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field { display: grid; gap: 6px; align-content: start; }
.field > label, .field .lbl { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--text-3); line-height: 1.45; }
.field .err { font-size: 12px; color: var(--bad); }
.field input, .field select, .field textarea { width: 100%; }

.switch { position: relative; display: inline-flex; flex: none; width: 38px; height: 22px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong); transition: 0.18s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: 0.18s; }
.switch input:checked + span { background: var(--brand); border-color: transparent; }
.switch input:checked + span::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.switch input:disabled + span { opacity: 0.5; cursor: not-allowed; }

/* Sozlamalar */
.settings { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.set-nav { position: sticky; top: 84px; display: grid; gap: 2px; }
.set-nav .nav-label { padding-top: 12px; }
.set-nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 11px;
  border: 0; border-radius: 9px; background: transparent; color: var(--text-2);
  font: inherit; font-size: 13px; text-align: left; cursor: pointer;
}
.set-nav button:hover { background: var(--hover); color: var(--text); }
.set-nav button.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.set-nav svg { width: 16px; height: 16px; opacity: 0.8; flex: none; }
.set-panel { display: grid; gap: var(--gap); }
.set-title h2 { font-size: 19px; }
.set-title p { margin: 4px 0 0; color: var(--text-3); font-size: 13px; }
.set-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 300px); gap: 20px; align-items: center;
  padding: 15px 0; border-bottom: 1px solid var(--line);
}
.set-row:first-child { padding-top: 2px; }
.set-row:last-child { border-bottom: 0; padding-bottom: 2px; }
.set-row .t { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.set-row .d { font-size: 12.5px; color: var(--text-3); margin-top: 3px; line-height: 1.45; }
.set-row .ctl { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.set-row .ctl input, .set-row .ctl select { width: 100%; }
.set-row .ctl .err { position: static; }
.src { font-size: 10.5px; font-weight: 650; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; }
.src.panel { background: var(--brand-soft); color: var(--brand); }
.lock { font-size: 11px; color: var(--text-3); }
.savebar {
  position: sticky; bottom: 16px; z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 11px 14px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 14px;
  box-shadow: var(--shadow); animation: rise 0.2s ease;
}
.savebar .grow { flex: 1; font-size: 13px; color: var(--text-2); }
.choice-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.choice {
  display: grid; gap: 8px; padding: 12px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface-2); text-align: left;
  font: inherit; color: var(--text-2);
}
.choice:hover { border-color: var(--line-strong); }
.choice.active { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); color: var(--text); }
.choice .pv { height: 52px; border-radius: 8px; border: 1px solid var(--line); }
.pv.dark { background: linear-gradient(135deg, #0a0f1e 50%, #172040 50%); }
.pv.light { background: linear-gradient(135deg, #f3f5fa 50%, #ffffff 50%); }
.pv.system { background: linear-gradient(135deg, #0a0f1e 50%, #f3f5fa 50%); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.stat { padding: 14px; border-radius: 13px; border: 1px solid var(--line); background: var(--surface-2); }
.stat .lbl { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 7px; }
.stat .val { font-size: 19px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 var(--good); animation: pulse 2s infinite; }
.pulse.off { background: var(--bad); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--gap); }
.report-card { display: flex; flex-direction: column; gap: 12px; }
.report-card .r-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; }
.report-card .r-ico svg { width: 21px; height: 21px; }
.r-xlsx { background: color-mix(in srgb, var(--s3) 15%, transparent); color: var(--s3); }
.r-docx { background: color-mix(in srgb, var(--s1) 15%, transparent); color: var(--s1); }
.report-card h4 { font-size: 14px; }
.report-card p { margin: 0; font-size: 12.5px; color: var(--text-3); flex: 1; }

/* ================================================================== mobil */
.menu-toggle { display: none; }
@media (max-width: 1180px) {
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-21, .g-12 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow); background: var(--surface); }
  .sidebar.open { transform: none; }
  .menu-toggle { display: grid; }
  .main { padding: 16px 14px 50px; }
  .topbar { margin: -16px -14px 16px; padding: 12px 14px; }
  .g-2, .g-3 { grid-template-columns: minmax(0, 1fr); }
  .settings { grid-template-columns: minmax(0, 1fr); }
  .set-nav { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .set-nav .nav-label { display: none; }
  .set-nav button { white-space: nowrap; width: auto; }
  .set-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .set-row .ctl { justify-content: flex-start; }
  .form-grid, .choice-cards { grid-template-columns: minmax(0, 1fr); }
  .hero h2 { font-size: 20px; }
}
@media print {
  .sidebar, .topbar, .toasts, .row-actions { display: none !important; }
  .main { padding: 0; }
  .card { break-inside: avoid; box-shadow: none; }
}
