/* "Qorong'i dashboard" dizayni: feruza-yashil urg'u, tekis (flat) uslub.
   Ikki rejim: kunduzgi (yorug') va kechki (qorong'i) — menyudagi tugma bilan almashtiriladi. */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --border: #e2e7eb;
  --border-strong: #cdd5dc;
  --text: #16212a;
  --text-2: #586876;
  --text-3: #8795a2;
  --brand: #0f766e;
  --brand-2: #115e59;
  --brand-soft: #e4f3f1;
  --on-brand: #ffffff;
  --sidebar: #0d1f24;
  --sidebar-text: #b4c4c8;
  --sidebar-line: rgba(255, 255, 255, .08);
  --green: #16a34a; --green-soft: #dcfce7; --green-text: #166534;
  --yellow: #eab308; --yellow-soft: #fef9c3; --yellow-text: #854d0e;
  --red: #dc2626; --red-soft: #fee2e2; --red-text: #991b1b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .07);
  --shadow-lg: 0 20px 40px -12px rgba(16, 24, 40, .3);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d1317; --surface: #141c21; --surface-2: #19232a; --border: #25323a; --border-strong: #33434d;
  --text: #e5ecef; --text-2: #a1b1ba; --text-3: #71828c; --brand: #2dd4bf; --brand-2: #5eead4; --brand-soft: #113633;
  --on-brand: #04201d;
  --sidebar: #091013;
  --green-soft: #12301c; --green-text: #86efac; --yellow-soft: #352b0b; --yellow-text: #fde047; --red-soft: #3a1414; --red-text: #fca5a5;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--text-3); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--text-3); }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: #fff; font-weight: 700; font-size: 16px; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; background: #0f766e; display: grid; place-items: center; font-weight: 800; }
.brand small { display: block; font-weight: 400; font-size: 11px; color: var(--sidebar-text); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--sidebar-text); margin-bottom: 2px; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: rgba(45, 212, 191, .14); color: #fff; }
.nav a.active .icon { color: #2dd4bf; }
.nav a .label { flex: 1; }
.nav-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--sidebar-line); }
.theme-btn { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: none; background: none; color: var(--sidebar-text); border-radius: 9px; cursor: pointer; text-align: left; }
.theme-btn:hover { background: rgba(255,255,255,.07); color: #fff; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 10px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.content { padding: 24px 28px 56px; width: 100%; max-width: 1400px; }

/* ---------- holat chirog'i ---------- */
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--text-3); }
.dot.green { background: var(--green); box-shadow: 0 0 0 3px rgba(22, 163, 74, .2); }
.dot.yellow { background: var(--yellow); box-shadow: 0 0 0 3px rgba(234, 179, 8, .25); }
.dot.red { background: var(--red); box-shadow: 0 0 0 3px rgba(220, 38, 38, .25); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.status-pill { display: inline-flex; align-items: center; gap: 9px; padding: 7px 14px 7px 12px; border-radius: 999px; font-weight: 600; font-size: 13px; border: 1px solid transparent; cursor: pointer; background: none; }
.status-pill.green { background: var(--green-soft); color: var(--green-text); }
.status-pill.yellow { background: var(--yellow-soft); color: var(--yellow-text); }
.status-pill.red { background: var(--red-soft); color: var(--red-text); }

/* ---------- sahifa ---------- */
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; line-height: 1.25; }
.page-head .sub { color: var(--text-2); margin-top: 3px; }
.page-head .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .dot { width: 8px; height: 8px; box-shadow: none; }

.empty-state { padding: 48px 24px; text-align: center; }
.empty-state .big { width: 56px; height: 56px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 14px; }
.empty-state .big .icon { width: 28px; height: 28px; }
.empty-state h2 { margin: 0 0 6px; font-size: 18px; }
.empty-state p { margin: 0 auto; max-width: 520px; color: var(--text-2); }

/* ---------- vidjetlar ---------- */
.widgets { display: grid; grid-template-columns: repeat(12, 1fr); gap: 14px; }
.widget { grid-column: span 3; padding: 16px; min-height: 110px; display: flex; flex-direction: column; }
.widget.md { grid-column: span 6; }
.widget.lg { grid-column: span 12; }
.widget-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; color: var(--text-2); font-size: 13px; font-weight: 600; }
.widget-head .from { margin-left: auto; font-weight: 400; color: var(--text-3); font-size: 12px; }
.widget .stat-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.widget .stat-hint { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.widget.error { border-color: var(--red); }
.widget .err { color: var(--red-text); background: var(--red-soft); padding: 8px 10px; border-radius: 8px; font-size: 13px; }
.widget ul { list-style: none; margin: 0; padding: 0; }
.widget li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.widget li:last-child { border-bottom: none; }
.widget li .v { margin-left: auto; font-weight: 600; }

table.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.table th { font-size: 12px; color: var(--text-2); background: var(--surface-2); font-weight: 600; }
.table-wrap { overflow-x: auto; }

/* ---------- tizim holati ---------- */
.status-list { display: flex; flex-direction: column; }
.status-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.status-row:last-child { border-bottom: none; }
.status-row .dot { margin-top: 6px; }
.status-row .t { font-weight: 600; }
.status-row .r { color: var(--text-2); font-size: 13px; }
.section-title { font-size: 15px; margin: 26px 0 10px; }

/* ---------- forma, tugma, modal ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border-strong); background: var(--surface); padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-2); }
.btn-ghost { border-color: transparent; background: transparent; }
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); outline: none; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.field .help { font-size: 12px; color: var(--text-3); margin-top: 3px; }

.modal-back { position: fixed; inset: 0; background: rgba(10, 20, 25, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; flex: 1; }
.modal-body { padding: 8px 4px; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #16212a; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; }
.toast.error { background: #991b1b; }
.toast.ok { background: #166534; }

.error-card { padding: 28px; text-align: center; }
.error-card h2 { margin: 0 0 6px; color: var(--red-text); }
.skeleton { height: 110px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }

@media (max-width: 1100px) { .widget { grid-column: span 6; } }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .layout.nav-open .sidebar { transform: none; }
  .layout.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 30; }
  .topbar { display: flex; }
  .content { padding: 16px 16px 40px; }
  .widget, .widget.md { grid-column: span 12; }
}

/* ---------- guruhlar va bo'limcha kartochkalari ---------- */
.crumbs { font-size: 13px; color: var(--text-3); margin-bottom: 4px; }
.crumbs a { color: var(--text-2); }
.sub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.sub-card { padding: 14px 16px; color: var(--text); display: flex; flex-direction: column; gap: 8px; transition: border-color .15s; }
.sub-card:hover { border-color: var(--brand); text-decoration: none; }
.sub-card .t { font-weight: 600; line-height: 1.35; }
.sub-card-top { display: flex; align-items: center; gap: 8px; }
.tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.plan-list { text-align: left; max-width: 560px; margin: 14px auto 0; color: var(--text-2); padding-left: 20px; }
.plan-list li { margin: 4px 0; }

/* ---------- bilim bazasi, agentlar, tasdiqlash ---------- */
.modal.wide { max-width: 880px; }
.pad { padding: 14px 16px; }
textarea.input { resize: vertical; min-height: 90px; font-family: inherit; line-height: 1.5; }
textarea.input.tall { min-height: 320px; }
textarea.input.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
select.input { width: auto; min-width: 160px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
.kb-layout { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
.kb-cats a { display: flex; justify-content: space-between; gap: 8px; padding: 9px 14px; color: var(--text); border-bottom: 1px solid var(--border); }
.kb-cats a:last-child { border-bottom: none; }
.kb-cats a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.kb-cats .n { color: var(--text-3); font-size: 12px; }
.list-row { display: flex; gap: 12px; align-items: center; padding: 11px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--surface-2); }
.list-row .t { font-weight: 600; }
.list-row .s { color: var(--text-3); font-size: 12px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green-text); }
.badge.yellow { background: var(--yellow-soft); color: var(--yellow-text); }
.badge.red { background: var(--red-soft); color: var(--red-text); }
.badge.gray { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; color: var(--text-2); font-size: 13px; }
.approved-box { white-space: pre-wrap; max-height: 200px; overflow: auto; }
.agent-card { padding: 16px; margin-bottom: 14px; }
.agent-card h3 { margin: 0; font-size: 16px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 14px 0; }
.kv label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 4px; }
.tools-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.transcript > div { padding: 10px 0; border-bottom: 1px solid var(--border); }
.transcript pre, pre.json { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 8px 10px; border-radius: 6px; font-size: 12px; margin: 6px 0 0; max-height: 260px; overflow: auto; }
.nav .count { background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
@media (max-width: 900px) { .kb-layout { grid-template-columns: 1fr; } }

.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
