/* =============================================================
   Monitoring platformasi — umumiy uslublar
   ============================================================= */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #1d4ed8;
  --primary-soft: #e0e9ff;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 8px rgba(15, 23, 42, .04);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- tugmalar va formalar ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #1e40af; }
.btn-danger { color: var(--bad); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; color: var(--primary); font: inherit; cursor: pointer; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; height: 36px; padding: 0 10px; min-width: 0;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary-soft); outline-offset: 0; }
input.invalid { border-color: var(--bad); background: var(--bad-soft); }
.form-error { color: var(--bad); background: var(--bad-soft); padding: 8px 10px; border-radius: 8px; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; align-items: end; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- kirish sahifasi ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, #dbe6ff 0, transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 28px; display: grid; gap: 20px; }
.login-card form { display: grid; gap: 14px; }
.login-foot { display: grid; gap: 6px; font-size: 12px; color: var(--muted); text-align: center; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-title { font-weight: 700; font-size: 15px; line-height: 1.25; }
.brand-sub { font-size: 12px; color: var(--muted); }

/* ---------- asosiy tartib ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 16px;
  padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .brand-title { font-size: 14px; }
.topbar .spacer { flex: 1; }
.user-chip { text-align: right; line-height: 1.2; }
.user-chip b { display: block; font-size: 13px; }
.user-chip span { font-size: 12px; color: var(--muted); }
.menu-btn { display: none; }
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidenav { background: var(--surface); border-right: 1px solid var(--border); padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }
.sidenav a { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; color: var(--text); font-weight: 500; }
.sidenav a:hover { background: var(--surface-2); text-decoration: none; }
.sidenav a.active { background: var(--primary-soft); color: var(--primary); }
.sidenav .badge { margin-left: auto; }
main#view { padding: 20px 24px 48px; max-width: 1400px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }

/* ---------- kartalar ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > h2 { padding: 14px 16px 0; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .k-value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi.bad .k-value { color: var(--bad); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.filters select, .filters input { height: 34px; }

/* ---------- jadvallar ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; }
tbody tr:hover { background: #f9fbff; }
tr.clickable { cursor: pointer; }
tfoot td { font-weight: 700; background: var(--surface-2); }
.sticky-col { position: sticky; left: 0; background: var(--surface); z-index: 1; }
th.sticky-col, tfoot .sticky-col { background: var(--surface-2); z-index: 2; }
.nowrap { white-space: nowrap; }
.wide { min-width: 220px; }
.sidenav-inner { position: sticky; top: 68px; display: flex; flex-direction: column; gap: 2px; }
tr.edit-row > td { background: #f6f9ff; }
.empty { padding: 32px; text-align: center; color: var(--muted); }

/* foiz chizig'i */
.bar { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar i { display: block; width: 64px; height: 6px; border-radius: 3px; background: var(--border); position: relative; overflow: hidden; }
.bar i b { position: absolute; inset: 0 auto 0 0; background: var(--primary); border-radius: 3px; }
.bar.low i b { background: var(--bad); }
.bar.mid i b { background: #d97706; }
.bar.full i b { background: var(--ok); }

/* holat belgilari */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-remind { background: var(--warn-soft); color: var(--warn); }
.badge-overdue, .badge-never { background: var(--bad-soft); color: var(--bad); }
.badge-muted { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-count { background: var(--bad); color: #fff; min-width: 20px; justify-content: center; }

.banner { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 500; }
.banner-ok { background: var(--ok-soft); color: #14532d; }
.banner-remind { background: var(--warn-soft); color: #78350f; }
.banner-overdue, .banner-never { background: var(--bad-soft); color: #7f1d1d; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-color: var(--primary); }

/* modal oyna */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; max-width: 720px; width: 100%; max-height: 90vh; overflow: auto; padding: 20px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); border: 1px dashed var(--border); padding: 2px 8px; border-radius: 6px; user-select: all; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { padding: 10px 14px; border-radius: 8px; color: #fff; background: var(--ok); box-shadow: var(--shadow); max-width: 360px; }
.toast-err { background: var(--bad); }

/* ---------- mobil ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .menu-btn { display: inline-flex; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidenav { position: fixed; top: 56px; left: 0; bottom: 0; width: 240px; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidenav.open { transform: none; }
  main#view { padding: 16px; }
  .user-chip { display: none; }
  .topbar .brand-sub { display: none; }
}
@media print {
  .topbar, .sidenav, .filters, .btn { display: none !important; }
  .layout { display: block; }
}

/* ---------- modul yorliqlari va formalar ---------- */
.tabs a { display: block; padding: 10px 14px; border-bottom: 2px solid transparent; font-weight: 600; color: var(--muted); white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }
.mod-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.prog-list { position: sticky; top: 68px; max-height: calc(100vh - 84px); overflow: auto; }
.prog-list a { display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.prog-list a:hover { background: var(--surface-2); text-decoration: none; }
.prog-list a.active { background: var(--primary-soft); }
.prog-list a > span:first-child { display: grid; gap: 2px; font-size: 13px; }
.prog-list .muted { font-size: 12px; }
.mod-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
fieldset.card { min-width: 0; }
fieldset legend { font-weight: 700; font-size: 15px; padding: 0 6px; margin-left: -6px; }
.form-grid .full { grid-column: 1 / -1; }
.field-label { font-size: 13px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
table.matrix { width: auto; min-width: 50%; }
table.matrix th[scope=row] { text-align: left; color: var(--text); font-weight: 500; background: var(--surface); position: static; }
table.matrix td { padding: 4px 6px; }
table.matrix input[type=number] { width: 96px; text-align: right; }
table.matrix select { min-width: 150px; }
.wide-input { min-width: 200px; width: 100%; }
.kpis-sm .kpi { padding: 10px 14px; }
.kpis-sm .k-value { font-size: 20px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0; border-top: 1px solid var(--border); z-index: 5; }
.reply { padding: 10px 0; border-bottom: 1px solid var(--border); display: grid; gap: 4px; }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--text); opacity: 1; }
@media (max-width: 900px) {
  .mod-layout { grid-template-columns: minmax(0, 1fr); }
  .prog-list { position: static; max-height: 280px; }
}

/* ---------- diagrammalar (toifali palitra — qat'iy tartib) ---------- */
:root {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948; --s-other: #a8a29e;
}
.chart { position: relative; }
.chart-tip { position: absolute; z-index: 10; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 6px 20px rgba(15,23,42,.12); padding: 8px 10px; font-size: 12px; min-width: 140px; max-width: 280px; }
.chart-tip i, .chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.chart-legend.vertical { flex-direction: column; gap: 6px; }
.chart-legend b { color: var(--text); font-weight: 600; }
.hbar { display: grid; gap: 6px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 32%) 1fr 64px; gap: 8px; align-items: center; font-size: 12px; border-radius: 6px; }
.hbar-row:hover { background: var(--surface-2); }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-bars { display: grid; gap: 2px; }
.hbar-track { display: flex; gap: 2px; height: 12px; overflow: hidden; }
.hbar-track b { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 0; }
.hbar-track b:not(:last-child) { border-radius: 0; }
.hbar-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.chart svg .grid { stroke: var(--border); stroke-width: 1; }
.chart svg .axis { fill: var(--muted); font-size: 11px; }
.chart svg .crosshair { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .clickable, .chart path.clickable { cursor: pointer; }
.donut { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.donut-total { font-size: 20px; font-weight: 700; fill: var(--text); }
.chart-card h2 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.chart-card h2 small { font-weight: 400; color: var(--muted); font-size: 12px; }
.pivot-controls { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.measure-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.measure-picks label { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); cursor: pointer; font-weight: 400; }
.measure-picks input { height: auto; }
.measure-picks label:has(input:checked) { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.report-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.report-list a { display: block; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.report-list a:hover { border-color: var(--primary); text-decoration: none; }
.report-list small { display: block; color: var(--muted); font-weight: 400; margin-top: 4px; }
.grid-res { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid-res { grid-template-columns: minmax(0, 1fr); } }
