/* ===== Palitra (dataviz qo'llanmasi bo'yicha tasdiqlangan) ===== */
.viz-root {
  color-scheme: light;
  --surface-1: #fcfcfb;   /* kartochka yuzasi */
  --plane:     #f9f9f7;   /* sahifa foni */
  --ink-1:     #0b0b0b;
  --ink-2:     #52514e;
  --muted:     #898781;
  --grid:      #e1e0d9;
  --axis:      #c3c2b7;
  --ring:      rgba(11, 11, 11, 0.10);

  --kelgan:    #2a78d6;   /* slot 1 blue */
  --kelmagan:  #e34948;   /* red */
  --bekor:     #4a3aa7;   /* violet */
  --kirim:     #2a78d6;   /* diverging: blue */
  --chiqim:    #e34948;   /* diverging: red */

  --w1: #2a78d6; --w2: #008300; --w3: #e87ba4;
  --w4: #eda100; --w5: #1baf7a; --w6: #eb6834;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --plane:     #0d0d0d;
    --ink-1:     #ffffff;
    --ink-2:     #c3c2b7;
    --muted:     #898781;
    --grid:      #2c2c2a;
    --axis:      #383835;
    --ring:      rgba(255, 255, 255, 0.10);

    --kelgan:   #3987e5;
    --kelmagan: #e66767;
    --bekor:    #9085e9;
    --kirim:    #3987e5;
    --chiqim:   #e66767;

    --w1: #3987e5; --w2: #008300; --w3: #d55181;
    --w4: #c98500; --w5: #199e70; --w6: #d95926;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --surface-1: #1a1a19; --plane: #0d0d0d; --ink-1: #ffffff; --ink-2: #c3c2b7;
  --muted: #898781; --grid: #2c2c2a; --axis: #383835; --ring: rgba(255,255,255,0.10);
  --kelgan: #3987e5; --kelmagan: #e66767; --bekor: #9085e9;
  --kirim: #3987e5; --chiqim: #e66767;
  --w1: #3987e5; --w2: #008300; --w3: #d55181;
  --w4: #c98500; --w5: #199e70; --w6: #d95926;
}

* { box-sizing: border-box; }
/* `hidden` atributi display qoidalaridan ustun turishi kerak (masalan .custom{display:flex}) */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--plane, #f9f9f7);
}
.viz-root {
  background: var(--plane);
  color: var(--ink-1);
  min-height: 100vh;
  padding: 14px 14px 32px;
  max-width: 780px;
  margin: 0 auto;
}

/* ===== Sarlavha ===== */
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.head__title { font-size: 19px; font-weight: 700; margin: 0; letter-spacing: .2px; color: var(--kelgan); text-transform: uppercase; }
.head__sub { font-size: 13px; color: var(--ink-2); margin-top: 3px; }
.badge { background: var(--kelgan); color: #fff; font-size: 11px; font-weight: 700; padding: 6px 11px; border-radius: 8px; white-space: nowrap; text-transform: uppercase; }

/* ===== Tablar ===== */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tab {
  flex: 1; padding: 11px 10px; border: 1px solid var(--ring); background: var(--surface-1);
  color: var(--ink-2); border-radius: 12px; font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit;
}
.tab--on { background: var(--kelgan); color: #fff; border-color: transparent; }

/* ===== Filtrlar (bitta qator, diagrammalar ustida) ===== */
.filters { display: flex; gap: 7px; margin-bottom: 10px; flex-wrap: wrap; }
.chip {
  padding: 8px 13px; border-radius: 999px; border: 1px solid var(--ring);
  background: var(--surface-1); color: var(--ink-2); font-size: 13px; cursor: pointer; font-family: inherit;
}
.chip--on { background: var(--ink-1); color: var(--surface-1); border-color: transparent; font-weight: 600; }
.custom { display: flex; gap: 7px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.custom input {
  padding: 8px 10px; border-radius: 10px; border: 1px solid var(--ring);
  background: var(--surface-1); color: var(--ink-1); font-family: inherit; font-size: 13px;
}
.custom__dash { color: var(--muted); }

.btn {
  padding: 9px 15px; border-radius: 10px; border: none; background: var(--kelgan);
  color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; font-family: inherit;
}
.btn--wide { display: block; width: 100%; padding: 14px; font-size: 15px; margin: 4px 0 14px; }

.msg { background: var(--surface-1); border: 1px solid var(--ring); border-radius: 12px; padding: 16px; color: var(--ink-2); font-size: 14px; margin-bottom: 12px; }

/* ===== KPI kartochkalar ===== */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 12px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 14px;
  padding: 13px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.tile__label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
/* uzun qiymat ("280 ming") ikki qatorga tushmasin — ekran kengligiga moslashadi */
.tile__value {
  font-size: clamp(17px, 5.4vw, 25px);
  font-weight: 700; margin-top: 5px; line-height: 1.15; color: var(--ink-1);
  white-space: nowrap;
}
.tile__value--in { color: var(--ink-1); }
.tile__value--out { color: var(--ink-1); }
.tile__foot { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.key { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.key--kelgan { background: var(--kelgan); }
.key--kelmagan { background: var(--kelmagan); }
.key--bekor { background: var(--bekor); }

/* Hero raqam — bitta ko'rinishda bittadan ortiq emas */
.hero {
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 14px;
  padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.hero__label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.hero__value { font-size: 34px; font-weight: 700; margin-top: 4px; color: var(--ink-1); }

/* ===== Kartochka / diagramma ===== */
.card {
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 16px;
  padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card__title { font-size: 14px; font-weight: 700; margin: 0; color: var(--ink-1); }
.card__note { font-size: 12px; color: var(--muted); }
.chart { width: 100%; height: 210px; position: relative; }
.chart--sm { height: 150px; }
.chart svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* Legend — 2+ seriya uchun doim bor */
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.legend__item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.legend__line { width: 14px; height: 3px; border-radius: 2px; flex: none; }

/* ===== Donut ===== */
.donutWrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.donut { width: 178px; height: 178px; flex: none; position: relative; }
.donut svg { width: 100%; height: 100%; display: block; overflow: visible; }
.donut__seg { transition: stroke-dasharray 1s cubic-bezier(.22,.9,.28,1), opacity .2s; cursor: pointer; }
.donut__seg:hover { opacity: .85; }
/* aylanib chiqadigan kirish animatsiyasi (hajmli ko'rinish uchun) */
.donut__g { transform-box: view-box; transform-origin: 50px 50px; animation: donutIn .75s cubic-bezier(.22,.9,.28,1) both; }
@keyframes donutIn {
  from { transform: rotate(-24deg) scale(.90); opacity: 0; }
  to   { transform: rotate(0deg) scale(1); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .donut__g { animation: none; }
  .donut__seg { transition: none; }
}
.dlegend { flex: 1 1 165px; display: flex; flex-direction: column; gap: 8px; min-width: 150px; }
.dlegend__row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.dlegend__dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.dlegend__name { color: var(--ink-2); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dlegend__val { color: var(--ink-1); font-weight: 700; white-space: nowrap; }
.dlegend__pct { color: var(--muted); font-size: 11px; min-width: 34px; text-align: right; }

.empty { color: var(--muted); font-size: 13px; padding: 18px 4px; text-align: center; }

/* ===== Admin: doktor kartochkalari (jadval o'rniga — tor ekranda o'qiladi) ===== */
.docCard {
  background: var(--plane); border: 1px solid var(--ring); border-radius: 14px;
  margin-bottom: 10px; overflow: hidden;
}
.docCard__head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 13px; background: none; border: none; color: inherit;
  font-family: inherit; cursor: pointer; text-align: left;
}
.docCard__name { font-size: 15px; font-weight: 700; color: var(--ink-1); overflow-wrap: anywhere; line-height: 1.25; }
.docCard__headRight { display: flex; align-items: center; gap: 8px; flex: none; }
.docCard__chev { color: var(--muted); font-size: 13px; transition: transform .2s; }
.docCard.is-open .docCard__chev { transform: rotate(180deg); }
.docCard__body { display: none; }
.docCard.is-open .docCard__body { display: block; }
.docCard__inner { padding: 2px 13px 13px; }
.docCard__badge { font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 8px; white-space: nowrap; flex: none; }
.docCard__badge.is-on { background: rgba(42,120,214,.15); color: var(--kelgan); }
.docCard__badge.is-off { background: rgba(227,73,72,.15); color: var(--kelmagan); }
.docCard__sub { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; overflow-wrap: anywhere; }
.docCard__chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }
.docCard__chip {
  font-size: 12px; color: var(--ink-2); background: var(--surface-1);
  border: 1px solid var(--ring); border-radius: 8px; padding: 5px 9px; white-space: nowrap;
}
.docCard__till { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* Admin jadvallar: qisqa bo'lsa to'ldiradi, uzun bo'lsa gorizontal skroll (siqilmaydi) */
.adminScroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.adminScroll table { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12.5px; }
.adminScroll th, .adminScroll td { padding: 7px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; color: var(--ink-2); }
.adminScroll th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; }
.adminScroll input { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--ring); background: var(--plane); color: var(--ink-1); font-family: inherit; }

/* Admin sozlamalar — flex qatorlar (yorliq kesilmaydi) */
.cfgRow { display: flex; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid var(--grid); }
.cfgRow:last-child { border-bottom: none; }
.cfgRow__label { flex: 1; font-size: 13px; color: var(--ink-2); }
.cfgRow__input { width: 66px; flex: none; padding: 8px 9px; border-radius: 8px; border: 1px solid var(--ring); background: var(--plane); color: var(--ink-1); font-family: inherit; font-size: 14px; }
.cfgRow .btn { flex: none; padding: 8px 12px; }

/* "Kirim bo'yicha top" — flex qatorlar (ism qisqaradi, kirim doim ko'rinadi) */
.topList { display: flex; flex-direction: column; }
.topRow { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--grid); }
.topRow__rank { width: 20px; flex: none; text-align: center; color: var(--muted); font-weight: 700; }
.topRow__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: 13px; }
.topRow__val { flex: none; text-align: right; color: var(--ink-1); font-weight: 700; font-size: 13px; }
.topRow__sub { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }

/* ===== Hamyon kartochkalari (Click uslubi) ===== */
.wallets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wcard {
  position: relative; border-radius: 14px; padding: 13px 12px 12px; min-height: 96px;
  display: flex; flex-direction: column; justify-content: space-between;
  color: #fff; overflow: hidden; box-shadow: 0 3px 10px rgba(0,0,0,.18);
  text-shadow: 0 1px 2px rgba(0,0,0,.30);
}
.wcard::after { /* yengil yaltiroq */
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,0) 55%);
  pointer-events: none;
}
.wcard__top { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; }
.wcard__num { font-size: 11.5px; opacity: .9; letter-spacing: .6px; font-variant-numeric: tabular-nums; }
.wcard__bal { font-size: 15px; font-weight: 700; white-space: nowrap; }
.wcard--add {
  background: transparent; color: var(--ink-2); border: 1.5px dashed var(--axis);
  align-items: center; justify-content: center; gap: 6px; box-shadow: none; cursor: pointer;
}
.wcard--add::after { display: none; }
.wcard__plus { font-size: 26px; line-height: 1; font-weight: 300; color: var(--kelgan); }
.wcard--add span { font-size: 12px; }

/* ===== Pastdan chiquvchi oyna ===== */
.sheetBg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 60; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 61;
  background: var(--surface-1); color: var(--ink-1);
  border-radius: 18px 18px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 28px rgba(0,0,0,.25); max-width: 780px; margin: 0 auto;
  animation: sheetUp .26s cubic-bezier(.22,.9,.28,1) both;
  max-height: 88vh; overflow-y: auto;
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet__grip { width: 38px; height: 4px; border-radius: 3px; background: var(--axis); margin: 2px auto 12px; }
.sheet__title { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.field { display: block; margin-bottom: 13px; }
.field__label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }
.field__label em { font-style: normal; color: var(--muted); font-weight: 400; }
.field input {
  width: 100%; padding: 11px 12px; border-radius: 11px; border: 1px solid var(--ring);
  background: var(--plane); color: var(--ink-1); font-family: inherit; font-size: 15px;
}
.field input:focus { outline: 2px solid var(--kelgan); outline-offset: 1px; }
.field__hint { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.sheet__err { background: rgba(227,73,72,.12); color: var(--kelmagan); border-radius: 10px; padding: 9px 11px; font-size: 12.5px; margin-bottom: 10px; }
.sheet__row { display: flex; gap: 9px; }
.sheet__row .btn { flex: 1; padding: 13px; font-size: 14.5px; }
.btn--ghost { background: transparent; color: var(--ink-2); border: 1px solid var(--ring); }

/* ===== Tooltip ===== */
.tip {
  position: fixed; z-index: 50; pointer-events: none;
  background: #26272b; color: #fff; border-radius: 10px; padding: 8px 11px;
  font-size: 12px; line-height: 1.5; box-shadow: 0 6px 18px rgba(0,0,0,.25);
  transform: translate(-50%, -115%); white-space: nowrap;
}
.tip__x { color: #b9bac0; font-size: 11px; margin-bottom: 2px; }
.tip__row { display: flex; align-items: center; gap: 7px; }
.tip__line { width: 11px; height: 3px; border-radius: 2px; flex: none; }
.tip__v { font-weight: 700; }
.tip__n { color: #b9bac0; }

/* ===== Jadval ko'rinishi ===== */
.tableBox { background: var(--surface-1); border: 1px solid var(--ring); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; overflow-x: auto; }
.tableBox summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.tableBox table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 12.5px; font-variant-numeric: tabular-nums; table-layout: fixed; }
.tableBox th, .tableBox td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); color: var(--ink-2); word-break: break-word; overflow-wrap: break-word; }
.tableBox th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 10.5px; letter-spacing: .4px; }
.tableBox td:last-child, .tableBox th:last-child { text-align: right; }

/* Admin panel jadvallari va kartochkalaridagi uzun matnlarni to'g'ri ko'rsatish */
#adminConfig table, #adminDoctors table, #adminStats table { table-layout: fixed; width: 100%; }
#adminConfig td, #adminDoctors td, #adminStats td { word-break: break-word; overflow-wrap: break-word; }
#adminBackup p { word-break: break-word; overflow-wrap: break-word; }
#pane-admin .card { overflow-x: auto; }
#pane-admin input[type="number"] { max-width: 80px; }
#pane-admin table td:first-child { min-width: 100px; }

.loading { opacity: .45; transition: opacity .2s; }
