:root {
  --bg: #0f1117;
  --bg-soft: #151824;
  --card: #181b28;
  --card-hi: #1e2231;
  --line: #262a3a;
  --line-hi: #343a4f;
  --text: #e9eaf2;
  --text-dim: #a7adc4;
  --muted: #6f7793;
  --accent: #7c6cf0;
  --accent-soft: rgba(124, 108, 240, .16);
  --ok: #2ecf8f;
  --err: #ff6b6b;
  --warn: #f5b23a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .18);
}

:root[data-theme="light"] {
  --bg: #f6f7fb;
  --bg-soft: #eef0f7;
  --card: #ffffff;
  --card-hi: #f5f6fb;
  --line: #e3e6f0;
  --line-hi: #cfd4e6;
  --text: #1a1d29;
  --text-dim: #4d5470;
  --muted: #858cab;
  --accent: #5b4bd6;
  --accent-soft: rgba(91, 75, 214, .1);
  --shadow: 0 1px 2px rgba(20, 24, 50, .06), 0 8px 24px rgba(20, 24, 50, .07);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.dim { color: var(--text-dim); }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }

/* ---------------- Karkas ---------------- */

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

aside {
  background: var(--bg-soft);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 0 6px; }
.mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #a89bff);
  color: #fff; font-weight: 800; font-size: 15px;
  box-shadow: 0 4px 14px rgba(124, 108, 240, .35);
}

nav { display: flex; flex-direction: column; gap: 2px; }
nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--text-dim);
  font-weight: 550;
}
nav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
nav a.on { background: var(--accent-soft); color: var(--text); }
nav a.on svg { color: var(--accent); }
nav svg { width: 17px; height: 17px; flex: none; }

aside .foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
aside .who { font-size: 12px; color: var(--muted); padding: 0 6px; }

main { min-width: 0; }

header.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
header.bar h1 { font-size: 16px; margin: 0; font-weight: 650; }

.content { padding: 22px 24px 60px; max-width: 1280px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; align-items: center; gap: 12px; }
  aside nav { flex-direction: row; overflow: auto; }
  aside .foot { margin: 0; flex-direction: row; }
  aside .who { display: none; }
  .content { padding: 16px; }
}

/* ---------------- Kartalar ---------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
}
.stat .k { color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .v { font-size: 25px; font-weight: 700; margin-top: 5px; letter-spacing: -.02em; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }

h2.sec { font-size: 13px; margin: 26px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 650; }

/* ---------------- Grafik ---------------- */

.chart { display: flex; align-items: stretch; gap: 3px; height: 96px; padding-top: 8px; }
.chart .bar { flex: 1 1 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-width: 0; }
.chart .seg { border-radius: 3px 3px 0 0; flex: none; transition: opacity .15s; }
.chart .seg.v { background: var(--accent); }
.chart .seg.t { background: color-mix(in srgb, var(--ok) 72%, transparent); }
.chart .bar:hover .seg { opacity: .68; }
/* Nomi `empty` bo'lmasin — jadvaldagi .empty da padding bor, bar cho'zilib ketadi */
.chart .nil { background: var(--line); height: 3px; border-radius: 2px; flex: none; padding: 0; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

/* ---------------- Jadval ---------------- */

.table-wrap {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; }
thead th {
  position: sticky; top: 0;
  background: var(--card-hi);
  color: var(--muted);
  font-size: 11.5px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  z-index: 1;
  white-space: nowrap;
}
tbody td { border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--card-hi); }
tbody tr.sel { background: var(--accent-soft); }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--card-hi);
  border: 1px solid var(--line);
  color: var(--text-dim);
  white-space: nowrap;
}
.badge.ok { background: rgba(46, 207, 143, .14); border-color: rgba(46, 207, 143, .35); color: #6fe3b6; }
.badge.tr { background: var(--accent-soft); border-color: rgba(124, 108, 240, .4); color: #b7adff; }
:root[data-theme="light"] .badge.ok { color: #12805a; }
:root[data-theme="light"] .badge.tr { color: #4a3bc0; }

/* ---------------- Boshqaruv ---------------- */

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }

input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 11px;
  transition: border-color .12s, background .12s;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; width: 100%; min-height: 36px; line-height: 1.45; }

button { cursor: pointer; font-weight: 600; }
button:hover:not(:disabled) { border-color: var(--line-hi); background: var(--card-hi); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover:not(:disabled) { background: #8d7ff5; border-color: #8d7ff5; }
button.danger { color: var(--err); border-color: rgba(255, 107, 107, .32); }
button.danger:hover:not(:disabled) { background: rgba(255, 107, 107, .12); border-color: rgba(255, 107, 107, .5); }
button:disabled { opacity: .45; cursor: default; }
button.sm { padding: 4px 10px; font-size: 12.5px; border-radius: 7px; }
button.icon { padding: 6px; line-height: 0; }
button.icon svg { width: 16px; height: 16px; }

.search { position: relative; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 32px; min-width: 250px; }

input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); padding: 0; }

/* ---------------- Kirish ---------------- */

.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login {
  width: 340px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login h1 { font-size: 19px; margin: 14px 0 4px; }
.login .lead { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login label { display: block; color: var(--text-dim); font-size: 12.5px; margin: 14px 0 6px; font-weight: 600; }
.login input { width: 100%; }
.login button { width: 100%; margin-top: 20px; padding: 10px; }

/* ---------------- Xabarlar ---------------- */

.msg { padding: 10px 13px; border-radius: 9px; font-size: 13px; margin-top: 14px; }
.msg.err { background: rgba(255, 107, 107, .12); border: 1px solid rgba(255, 107, 107, .3); color: #ff9d9d; }
:root[data-theme="light"] .msg.err { color: #b3231f; }

#toast {
  position: fixed; bottom: 22px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: var(--card);
  border: 1px solid var(--line-hi);
  border-radius: 10px;
  padding: 10px 18px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 100;
  font-weight: 550;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty { padding: 34px; text-align: center; color: var(--muted); }

/* Yuklanish skeleti */
.skel { background: linear-gradient(90deg, var(--card) 25%, var(--card-hi) 37%, var(--card) 63%); background-size: 400% 100%; animation: sh 1.3s ease infinite; border-radius: 8px; height: 14px; }
@keyframes sh { 0% { background-position: 100% 0 } 100% { background-position: 0 0 } }
.skel-card { height: 84px; border-radius: var(--radius); }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; }
.kv .k { color: var(--muted); font-size: 13px; }

.cue-t { width: 124px; text-align: center; }
textarea.cue { overflow: hidden; }
tr.gap td { box-shadow: inset 0 2px 0 rgba(245, 178, 58, .5); }

/* Solishtirish */
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.cmp > div { padding: 8px 12px; border-bottom: 1px solid var(--line); }
.cmp > div:nth-child(odd) { border-right: 1px solid var(--line); }
.cmp .hd { position: sticky; top: 0; background: var(--card-hi); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; z-index: 1; }
.cmp .ts { font-size: 11px; color: var(--muted); }
