/* ==========================================================================
   Ovoz berish paneli — dizayn tizimi
   Tashqi bog'liqliksiz: CDN yo'q, shrift yuklanmaydi, VPS'da internetsiz ishlaydi.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Tokenlar
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light;

  /* Yuzalar */
  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --surface-2:   #f3f3f0;
  --sidebar:     #ffffff;

  /* Matn */
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --ink-muted:   #898781;

  /* Chiziqlar */
  --line:        #e1e0d9;
  --line-strong: #c3c2b7;
  --ring:        rgba(11, 11, 11, .10);

  /* Asosiy rang (diagramma seriyasi ham shu) */
  --accent:      #2a78d6;
  --accent-ink:  #ffffff;
  --accent-soft: #eaf2fd;
  --accent-2:    #184f95;

  /* Holat ranglari — hech qachon seriya sifatida ishlatilmaydi */
  --good:        #0ca30c;
  --warning:     #fab219;
  --serious:     #ec835a;
  --critical:    #d03b3b;
  --good-soft:   #e8f7e8;
  --warn-soft:   #fdf5e3;
  --crit-soft:   #fbeaea;
  --info-soft:   #eef1fb;
  --info-ink:    #3b3f8f;

  /* Diagramma */
  --grid:        #e1e0d9;
  --baseline:    #c3c2b7;

  /* O'lchamlar */
  --r-sm: 7px;
  --r:    11px;
  --r-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow:    0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 28px -8px rgba(16, 24, 40, .16);
  --sidebar-w: 244px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page:        #0d0d0d;
    --surface:     #1a1a19;
    --surface-2:   #232322;
    --sidebar:     #151514;
    --ink:         #ffffff;
    --ink-2:       #c3c2b7;
    --ink-muted:   #898781;
    --line:        #2c2c2a;
    --line-strong: #383835;
    --ring:        rgba(255, 255, 255, .10);
    --accent:      #3987e5;
    --accent-ink:  #ffffff;
    --accent-soft: #17253a;
    --accent-2:    #86b6ef;
    --good-soft:   #102a10;
    --warn-soft:   #2e2611;
    --crit-soft:   #2e1414;
    --info-soft:   #1a1d33;
    --info-ink:    #a8b0f0;
    --grid:        #2c2c2a;
    --baseline:    #383835;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow:    0 1px 3px rgba(0, 0, 0, .45);
    --shadow-lg: 0 12px 28px -8px rgba(0, 0, 0, .6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page:        #0d0d0d;
  --surface:     #1a1a19;
  --surface-2:   #232322;
  --sidebar:     #151514;
  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --ink-muted:   #898781;
  --line:        #2c2c2a;
  --line-strong: #383835;
  --ring:        rgba(255, 255, 255, .10);
  --accent:      #3987e5;
  --accent-ink:  #ffffff;
  --accent-soft: #17253a;
  --accent-2:    #86b6ef;
  --good-soft:   #102a10;
  --warn-soft:   #2e2611;
  --crit-soft:   #2e1414;
  --info-soft:   #1a1d33;
  --info-ink:    #a8b0f0;
  --grid:        #2c2c2a;
  --baseline:    #383835;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow:    0 1px 3px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 28px -8px rgba(0, 0, 0, .6);
}

/* --------------------------------------------------------------------------
   2. Asos
   -------------------------------------------------------------------------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

h1 { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 2px; letter-spacing: -.01em; }

.hint { color: var(--ink-muted); font-size: 13px; margin: 4px 0 14px; }
.mono, code {
  font-family: "Cascadia Mono", Consolas, ui-monospace, monospace;
  font-size: 12.5px;
  background: var(--surface-2);
  padding: 2px 6px;
  border-radius: 6px;
  color: var(--ink-2);
}

/* --------------------------------------------------------------------------
   3. Karkas: yon panel + kontent
   -------------------------------------------------------------------------- */
.shell { display: flex; min-height: 100%; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 16px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -.01em;
  color: var(--ink);
}
.brand .logo {
  width: 30px; height: 30px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-size: 15px;
  flex: none;
}

.nav { padding: 4px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  font-weight: 500;
  font-size: 14px;
  line-height: 1.2;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a svg { width: 17px; height: 17px; flex: none; }

.side-foot {
  padding: 12px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 9px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--surface-2); color: var(--ink-2);
  display: grid; place-items: center;
  font-weight: 650; font-size: 12px;
  flex: none;
}
.side-foot .who { flex: 1; min-width: 0; font-size: 13px; font-weight: 550; }
.side-foot .who small { display: block; color: var(--ink-muted); font-weight: 400; font-size: 11.5px; }

.icon-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  cursor: pointer;
  display: grid; place-items: center;
  flex: none;
  padding: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn svg { width: 15px; height: 15px; }

.main { flex: 1; min-width: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 28px 60px; }
.wrap.narrow { max-width: 760px; }

/* --------------------------------------------------------------------------
   4. Kartalar va sarlavhalar
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; }

.page-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 22px; flex-wrap: wrap;
}
.page-head .sub { color: var(--ink-muted); font-size: 13.5px; margin-top: 3px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* Qolgan joyni egallab, keyingi elementlarni o'ng chekkaga suradi */
.spacer { flex: 1; }

/* --------------------------------------------------------------------------
   5. Statistika kartalari  (dataviz: stat tile)
   -------------------------------------------------------------------------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 16px 18px;
}
.tile .l {
  color: var(--ink-muted);
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: 8px;
}
/* Katta raqamlar proportsional figuralarda — tabular-nums ularni bo'shashtiradi */
.tile .n { font-size: 30px; font-weight: 700; line-height: 1.05; letter-spacing: -.025em; }
.tile .d { font-size: 12.5px; color: var(--ink-muted); margin-top: 6px; }
.tile .d b { color: var(--ink-2); font-weight: 600; }

/* Eski `.stats` uslubi — moslik uchun */
.stats { display: flex; gap: 28px; flex-wrap: wrap; }
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--ink-muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }

/* --------------------------------------------------------------------------
   6. Diagramma  (dataviz: bar mark 24px, 4px yumaloq uchi, 2px oraliq)
   -------------------------------------------------------------------------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--baseline); stroke-width: 1; }
.chart .tick { fill: var(--ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--accent); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar,
.chart .bar.on { fill: var(--accent-2); }

.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--ink);
  color: var(--page);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 550;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .12s;
  box-shadow: var(--shadow-lg);
  z-index: 5;
}
.chart-tip.on { opacity: 1; }
.chart-wrap { position: relative; }

/* --------------------------------------------------------------------------
   7. Jadval
   -------------------------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); }
th {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-muted); font-weight: 650;
  background: var(--surface-2);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
/* Ustundagi raqamlar vertikal tekislanishi uchun tabular */
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   8. Tugmalar
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font: inherit; font-size: 14px; font-weight: 550;
  line-height: 1.3;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--critical); border-color: var(--line); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* --------------------------------------------------------------------------
   9. Formalar
   -------------------------------------------------------------------------- */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=password], input[type=datetime-local],
input[type=file], input[type=search], textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font: inherit;
  background: var(--surface);
  color: var(--ink);
}
input:focus, textarea:focus, select:focus, .editor:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
  outline-offset: 0;
  border-color: var(--accent);
}
textarea { min-height: 84px; resize: vertical; }
.field { margin-bottom: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

.check { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 11px; }
.check input { margin-top: 3px; width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.check label { margin: 0; font-weight: 550; }
.check .sub { color: var(--ink-muted); font-size: 12.5px; font-weight: 400; display: block; margin-top: 1px; }

/* --------------------------------------------------------------------------
   10. Nishonlar  (holat ranglari + matn — hech qachon faqat rang emas)
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.draft     { background: var(--surface-2); color: var(--ink-2); }
.badge.active    { background: var(--good-soft); color: var(--good); }
.badge.finished  { background: var(--info-soft); color: var(--info-ink); }
.badge.cancelled { background: var(--crit-soft); color: var(--critical); }
.badge.off       { background: var(--surface-2); color: var(--ink-muted); }

/* --------------------------------------------------------------------------
   11. Flash xabarlar
   -------------------------------------------------------------------------- */
.flash {
  padding: 11px 15px; border-radius: var(--r-sm);
  margin-bottom: 12px; font-size: 14px;
  border: 1px solid; display: flex; gap: 9px; align-items: flex-start;
}
.flash.ok    { background: var(--good-soft); color: var(--good); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.flash.warn  { background: var(--warn-soft); color: #8a6100; border-color: color-mix(in srgb, var(--warning) 40%, transparent); }
.flash.error { background: var(--crit-soft); color: var(--critical); border-color: color-mix(in srgb, var(--critical) 25%, transparent); }

/* --------------------------------------------------------------------------
   12. Progress / meter  (to'ldirilmagan qism — o'sha rampaning och pog'onasi)
   -------------------------------------------------------------------------- */
.bar-row { margin-bottom: 15px; }
.bar-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 14px; }
.bar-head .name { font-weight: 600; }
.bar-head .val { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.bar-track { height: 9px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .45s ease; }

/* --------------------------------------------------------------------------
   13. Tavsif muharriri
   -------------------------------------------------------------------------- */
.editor-toolbar {
  display: flex; align-items: center; gap: 3px;
  padding: 6px 8px;
  border: 1px solid var(--line); border-bottom: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--surface-2);
  flex-wrap: wrap;
}
.tb {
  min-width: 30px; height: 28px; padding: 0 8px;
  border: 1px solid transparent; border-radius: 6px;
  background: transparent; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--ink-2); line-height: 1;
}
.tb:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.tb-hint { color: var(--ink-muted); font-size: 12px; margin-left: auto; }

.editor {
  min-height: 170px; max-height: 440px; overflow-y: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit; line-height: 1.6;
  white-space: pre-wrap; word-wrap: break-word;
}
.editor.is-empty::before { content: attr(data-placeholder); color: var(--ink-muted); pointer-events: none; }
.editor a { color: var(--accent); }
.editor blockquote { margin: 6px 0; padding-left: 11px; border-left: 3px solid var(--line-strong); color: var(--ink-2); }
.editor code { background: var(--surface-2); }

/* --------------------------------------------------------------------------
   14. Bo'sh holat, login, mayda-chuyda
   -------------------------------------------------------------------------- */
.empty { color: var(--ink-muted); text-align: center; padding: 40px 16px; font-size: 14px; }
.empty a { font-weight: 600; }

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-box { width: 100%; max-width: 380px; }
.login-box .brand { justify-content: center; padding: 0 0 22px; font-size: 17px; }
.login-box .card { padding: 24px; box-shadow: var(--shadow-lg); }

hr.sep { border: none; border-top: 1px solid var(--line); margin: 16px 0 13px; }

/* --------------------------------------------------------------------------
   15. Moslashuvchanlik
   -------------------------------------------------------------------------- */
@media (max-width: 940px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 20;
    border-right: none; border-bottom: 1px solid var(--line);
    flex-direction: row; align-items: center; gap: 6px;
    padding-right: 10px;
  }
  .brand { padding: 12px 14px; }
  .brand span:not(.logo) { display: none; }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px 0; flex: 1; }
  .nav a { white-space: nowrap; }
  .side-foot { border-top: none; padding: 8px 0; }
  .side-foot .who { display: none; }
  .wrap { padding: 18px 14px 40px; }
  .grid2 { grid-template-columns: 1fr; }
  .table-scroll { overflow-x: auto; }
}
