/* Shriftlar o'z serverimizda — tashqi so'rov yo'q, kuzatuv yo'q.
   Sarlavhalar Fraunces: yumshoq, biroz "qiyshiq" serif — mashina emas, odam
   yozgandek ko'rinadi (SOFT va WONK o'qlari aynan shuning uchun).
   Matn Karla: iliq grotesk, uzun o'zbekcha jumlalarda charchatmaydi. */
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/fraunces-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Fraunces"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/fraunces-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
                 U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF,
                 U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Karla"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/karla-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Karla"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("/static/fonts/karla-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
                 U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF,
                 U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Izchil — shaxsiy rivojlanish paneli.
   Mobil birinchi: foydalanuvchilarning ko'pchiligi telefonda ochadi.

   Tuzilishi:
     1. Belgilar (token)   — rang, o'lcham, oraliq. Faqat shu yerda o'zgartiriladi.
     2. Asos               — reset, tipografiya
     3. Karkas             — sarlavha, navigatsiya, sahifa
     4. Bo'laklar          — karta, plitka, tugma, ro'yxat, jadval, forma
     5. Grafiklar          — charts.py chiqaradigan SVG/HTML uchun
     6. Sahifalar          — kirish (landing), xatolik
     7. Yordamchi klasslar — shablonda inline style yozmaslik uchun
     8. Telefon            — 720px va 420px

   Qoida: shablonda `style="..."` yozilmaydi. Kerak bo'lsa shu yerda klass
   ochiladi — aks holda rang/oraliq bir joydan boshqarilmay qoladi. */

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

  /* yuza — sarg'ish qog'oz. Sof oq ekranda charchatadi va "shablon" ko'rinadi */
  --surface-0: #f6f2e9;      /* sahifa foni */
  --surface-1: #fffdf7;      /* karta */
  --surface-2: #ece6d9;      /* ichki blok, hover */
  --surface-3: #e0d8c7;      /* bosilgan holat */
  --border:        #e5ddcc;
  --border-strong: #c6bca5;

  --text-primary:   #1f1c15;
  --text-secondary: #5a5449;
  --text-muted:     #8a8272;

  /* interaktiv — chuqur qarag'ay rangi. Sovuq ko'k emas, qog'oz bilan yarashadi */
  --accent:       #1f5f57;
  --accent-hover: #164a44;
  --accent-soft:  #e2ece9;   /* juda yengil fon (belgilangan holat) */
  --on-accent:    #fffdf7;

  /* holat */
  --good: #2e7d4f;
  --warn: #b07d16;
  --bad:  #c04a3e;

  /* grafik qatorlari: pul yashil/g'ishtrang, "siz" esa qarag'ay rangida */
  --series-1: #2e7d4f;       /* kirim */
  --series-2: #c0603a;       /* chiqim */
  --seq:      #1f5f57;
  --grid:     #ece5d6;
  --heat-0:   #e7e0d0;       /* belgilanmagan */
  --heat-1:   #edc6ae;       /* bajarilmadi */
  --heat-2:   #1f5f57;       /* bajarildi */

  --paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.05'/%3E%3C/svg%3E");
  --squiggle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 18' preserveAspectRatio='none'%3E%3Cpath d='M3 12c34-6 58 3 92-1 30-3 54 5 102 2' fill='none' stroke='%231f5f57' stroke-width='4' stroke-linecap='round' opacity='.5'/%3E%3C/svg%3E");
  --shadow:      0 1px 2px rgba(60,45,20,.06);
  --shadow-lift: 0 1px 2px rgba(60,45,20,.07), 0 10px 26px rgba(60,45,20,.08);
  --shadow-pop:  0 2px 6px rgba(60,45,20,.09), 0 18px 40px rgba(60,45,20,.14);

  /* o'lcham */
  --font-ui:      "Karla", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;

  --t-xs:   11.5px;
  --t-sm:   12.5px;
  --t-md:   13.5px;
  --t-base: 15px;
  --t-lg:   17px;
  --t-xl:   21px;
  --t-2xl:  27px;

  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 28px; --s7: 40px; --s8: 56px;

  --r-sm: 9px; --r-md: 12px; --r-lg: 16px; --r-full: 999px;
  --r: var(--r-lg);          /* eski nom — mos kelishi uchun */

  --tap: 36px;               /* tugma minimal o'lchovi (telefonda 42px) */
  --ease: cubic-bezier(.32,.72,.28,1);
}

/* qorong'i — ikki joyda takrorlanadi: tizim tanlovi va qo'lda tanlangan rejim */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #14120e; --surface-1: #1c1a15; --surface-2: #26231c; --surface-3: #322e25;
    --border: #322e26; --border-strong: #4c463a;
    --text-primary: #f6f1e4; --text-secondary: #bdb5a3; --text-muted: #8d8574;
    --accent: #7fcbbc; --accent-hover: #9adbcd; --accent-soft: #1b2f2c; --on-accent: #10201d;
    --good: #46b077; --warn: #d2a23a; --bad: #e8746a;
    --series-1: #46b077; --series-2: #dd7f52; --seq: #7fcbbc;
    --grid: #272318; --heat-0: #262219; --heat-1: #6b3f2a; --heat-2: #7fcbbc;
    --paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.045' fill='%23fff'/%3E%3C/svg%3E");
    --squiggle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 18' preserveAspectRatio='none'%3E%3Cpath d='M3 12c34-6 58 3 92-1 30-3 54 5 102 2' fill='none' stroke='%237fcbbc' stroke-width='4' stroke-linecap='round' opacity='.5'/%3E%3C/svg%3E");
    --shadow: 0 1px 2px rgba(0,0,0,.4);
    --shadow-lift: 0 2px 6px rgba(0,0,0,.45), 0 14px 32px rgba(0,0,0,.35);
    --shadow-pop: 0 4px 10px rgba(0,0,0,.5), 0 22px 48px rgba(0,0,0,.45);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #14120e; --surface-1: #1c1a15; --surface-2: #26231c; --surface-3: #322e25;
  --border: #322e26; --border-strong: #4c463a;
  --text-primary: #f6f1e4; --text-secondary: #bdb5a3; --text-muted: #8d8574;
  --accent: #7fcbbc; --accent-hover: #9adbcd; --accent-soft: #1b2f2c; --on-accent: #10201d;
  --good: #46b077; --warn: #d2a23a; --bad: #e8746a;
  --series-1: #46b077; --series-2: #dd7f52; --seq: #7fcbbc;
  --grid: #272318; --heat-0: #262219; --heat-1: #6b3f2a; --heat-2: #7fcbbc;
  --paper: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.045' fill='%23fff'/%3E%3C/svg%3E");
  --squiggle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 18' preserveAspectRatio='none'%3E%3Cpath d='M3 12c34-6 58 3 92-1 30-3 54 5 102 2' fill='none' stroke='%237fcbbc' stroke-width='4' stroke-linecap='round' opacity='.5'/%3E%3C/svg%3E");
  --shadow: 0 1px 2px rgba(0,0,0,.4);
  --shadow-lift: 0 2px 6px rgba(0,0,0,.45), 0 14px 32px rgba(0,0,0,.35);
  --shadow-pop: 0 4px 10px rgba(0,0,0,.5), 0 22px 48px rgba(0,0,0,.45);
}

/* ================================ 2. Asos ================================ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
body {
  margin: 0;
  /* Qog'oz donadorligi: fon "yalang'och ekran" bo'lib qolmasin.
     Rasm fayli emas — 300 baytlik SVG shovqini, qo'shimcha so'rov yo'q. */
  background: var(--surface-0) var(--paper);
  color: var(--text-primary);
  font: var(--t-base)/1.6 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Sarlavhalar — serif. Bitta shu qaror sahifani "shablon"dan chiqaradi.
   WONK 1: g va y harflarining o'ynoqi shakli; SOFT: burchaklar yumshaydi. */
h1, h2, h3, .display {
  font-family: var(--font-display);
  font-variation-settings: "SOFT" 45, "WONK" 1;
  letter-spacing: -.012em; font-weight: 600;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.ic { flex: 0 0 auto; display: block; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* =============================== 3. Karkas =============================== */
.brand {
  display: flex; align-items: center; gap: var(--s2);
  font-family: var(--font-display); font-variation-settings: "SOFT" 45, "WONK" 1;
  font-weight: 600; font-size: 19px; letter-spacing: -.01em;
}
.brand .mark { width: 22px; height: 22px; flex: 0 0 auto; color: var(--accent); }
.brand small { color: var(--text-muted); font-weight: 400; font-size: var(--t-md); }

header.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s4);
  padding: 10px var(--s5);
  background: color-mix(in srgb, var(--surface-1) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.spacer { flex: 1; }

nav.tabs { display: flex; gap: 2px; }
nav.tabs a {
  padding: 7px 13px; border-radius: var(--r-full); color: var(--text-secondary);
  font-weight: 500; font-size: var(--t-md); white-space: nowrap;
  transition: background .14s var(--ease), color .14s var(--ease);
}
nav.tabs a:hover { background: var(--surface-2); color: var(--text-primary); text-decoration: none; }
nav.tabs a.on { background: var(--accent); color: var(--on-accent); }
nav.tabs a.on:hover { background: var(--accent-hover); }

main { max-width: 1140px; margin: 0 auto; padding: var(--s5) var(--s5) var(--s8); }

nav.bottom { display: none; }        /* faqat telefonda */

/* foydalanuvchi menyusi */
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex: 0 0 auto;
  object-fit: cover; background: var(--surface-2); display: block;
}
.avatar.lg { width: 40px; height: 40px; }
.who {
  color: var(--text-primary); font-size: var(--t-md); font-weight: 500;
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.usermenu { position: relative; display: flex; align-items: center; }
.usermenu-trigger {
  display: flex; align-items: center; gap: var(--s2); cursor: pointer;
  padding: 3px 8px 3px 3px; border-radius: var(--r-full);
  background: transparent; border: 1px solid transparent; color: inherit;
  font-weight: 500; line-height: 1;
}
.usermenu-trigger:hover,
.usermenu-trigger[aria-expanded="true"] { background: var(--surface-2); }
.usermenu .chev { color: var(--text-muted); transition: transform .16s var(--ease); }
.usermenu-trigger[aria-expanded="true"] .chev { transform: rotate(180deg); }
.usermenu-panel[hidden] { display: none; }
.usermenu-panel {
  position: absolute; right: 0; top: calc(100% + var(--s2)); z-index: 50;
  min-width: 236px; padding: 6px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-md); box-shadow: var(--shadow-pop);
}
.usermenu-head {
  display: flex; align-items: center; gap: 10px;
  padding: var(--s2) 10px var(--s3); border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.usermenu-id { min-width: 0; }
.usermenu-id b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usermenu-id span { display: block; font-size: var(--t-sm); color: var(--text-muted); }
.usermenu-panel a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  color: var(--text-primary); font-size: 14px;
}
.usermenu-panel a:hover { background: var(--surface-2); text-decoration: none; }
.usermenu-panel a .ic { color: var(--text-muted); }
.usermenu-panel a.danger { color: var(--bad); }
.usermenu-panel a.danger .ic { color: var(--bad); }
.usermenu-panel a.danger:hover { background: color-mix(in srgb, var(--bad) 12%, transparent); }

/* bo'lim sarlavhasi — uzun sahifani bo'laklarga ajratadi */
.section { margin: var(--s6) 0 var(--s3); display: flex; align-items: baseline; gap: 10px; }
.section:first-child { margin-top: 0; }
.section h2 { margin: 0; font-size: 19px; font-weight: 600; }
.section .note { font-size: var(--t-md); color: var(--text-muted); }
.section .spacer { flex: 1; }
.section .link { font-size: var(--t-md); color: var(--accent); white-space: nowrap; }

/* bo'limlarga sakrash — uzun boshqaruv sahifasi uchun, faqat telefonda */
.jump { display: none; }

/* ============================= 4. Bo'laklar ============================== */
.grid { display: grid; gap: var(--s3); }
/* grid/flex bolasi standart holatda mazmunidan kichrayolmaydi — 720px li
   grafik butun sahifani kengaytirib yuboradi. min-width:0 buni to'xtatadi. */
.grid > * { min-width: 0; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); }

.card {
  min-width: 0; overflow-wrap: break-word;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow);
}
/* asosiy karta — ko'z birinchi shu yerga tushsin */
.card.hero {
  box-shadow: var(--shadow-lift);
  border-color: color-mix(in srgb, var(--accent) 26%, var(--border));
}
.card > h2 {
  margin: 0 0 var(--s3); font-size: 15.5px; font-weight: 600;
  color: var(--text-primary); letter-spacing: -.008em;
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.card > h2 .sub {
  font-family: var(--font-ui); font-variation-settings: normal;
  font-size: var(--t-md); font-weight: 400; color: var(--text-muted);
}
.card > h2 + .card-sep { margin-top: calc(var(--s3) * -1); }

/* salomlashish — sahifadagi birinchi gap odamga aytiladi */
.hello { margin-bottom: var(--s4); }
.hello .when {
  font-size: var(--t-sm); color: var(--text-muted);
  text-transform: lowercase; letter-spacing: .01em;
}
.hello h1 {
  margin: 2px 0 4px; font-size: 27px; font-weight: 600; line-height: 1.15;
}
.hello .note { margin: 0; color: var(--text-secondary); font-size: 14.5px; max-width: 56ch; }

/* pastki qator — sayt "tugadi" degan tuyg'u bersin */
.foot {
  max-width: 1140px; margin: var(--s7) auto 0; padding: var(--s5) var(--s5) var(--s6);
  border-top: 1px solid var(--border);
  display: flex; gap: var(--s3); justify-content: space-between; flex-wrap: wrap;
  font-size: var(--t-md); color: var(--text-muted);
}
.foot .brand-line { display: flex; align-items: center; gap: 7px; }
.foot .mark { width: 15px; height: 15px; color: var(--text-muted); }
.foot em { font-style: italic; }

/* plitka — bitta raqam */
.tile { padding: var(--s4); box-shadow: none; }
.tile .label { font-size: var(--t-sm); color: var(--text-secondary); line-height: 1.3; }
.tile .value {
  font-family: var(--font-display); font-variation-settings: "SOFT" 45;
  font-size: 26px; font-weight: 600; letter-spacing: -.028em; margin-top: 5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile .value .of { font-size: var(--t-base); font-weight: 500; color: var(--text-muted); }
.tile .hint { font-size: var(--t-xs); color: var(--text-muted); margin-top: 3px; }
.tile .hint.warn { color: var(--warn); }
.value.pos { color: var(--good); }
.value.neg { color: var(--bad); }
.value.out { color: var(--series-2); }
.tile .title { font-weight: 600; font-size: 14.5px; overflow-wrap: anywhere; }
.tile.row { display: flex; align-items: center; gap: var(--s3); }
.tile.row > div { min-width: 0; }

/* tugmalar */
input, select, textarea, button {
  font: inherit; color: inherit;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 9px 12px;
}
input::placeholder { color: var(--text-muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
label { font-size: var(--t-md); color: var(--text-secondary); }

button, .btn {
  cursor: pointer; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--tap);
  background: var(--accent); color: var(--on-accent); border-color: transparent;
  transition: background .14s var(--ease), transform .06s var(--ease);
}
button:hover, .btn:hover { background: var(--accent-hover); text-decoration: none; }
button:active, .btn:active { transform: translateY(1px); }
button.ghost, .btn.ghost {
  background: var(--surface-2); color: var(--text-primary); border-color: var(--border);
}
button.ghost:hover, .btn.ghost:hover { background: var(--surface-3); }
button.mini, .btn.mini { padding: 6px 11px; font-size: var(--t-md); min-height: 32px; }
button:disabled { opacity: .5; cursor: default; }
form.inline { display: inline-flex; }

/* ikonka-tugma — emoji o'rniga. Barmoq uchun yetarli, ko'z uchun tinch */
.iconbtn {
  width: var(--tap); height: var(--tap); min-height: var(--tap); padding: 0;
  border-radius: var(--r-sm); flex: 0 0 auto;
  background: var(--surface-2); border: 1px solid transparent; color: var(--text-secondary);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.iconbtn:hover { background: var(--surface-3); color: var(--text-primary); }
.iconbtn.primary { background: var(--accent); color: var(--on-accent); }
.iconbtn.primary:hover { background: var(--accent-hover); }
.iconbtn.quiet { background: transparent; color: var(--text-muted); }
.iconbtn.quiet:hover { background: var(--surface-2); color: var(--text-primary); }
.iconbtn.danger { background: transparent; color: var(--text-muted); }
.iconbtn.danger:hover { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.actions { display: flex; gap: var(--s1); align-items: center; }
td.act-cell { text-align: right; }
.amt-in  { font-weight: 600; color: var(--good); }
.amt-out { font-weight: 600; color: var(--text-primary); }

/* qator forma */
.row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.row.grow > input[type="text"] { flex: 1 1 220px; min-width: 0; }
.row.tight { gap: var(--s1); }
.field { display: flex; flex-direction: column; gap: 3px; font-size: var(--t-md); }

/* tanlov chiplari (davr, filtr) */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  padding: 7px 13px; border-radius: var(--r-full); font-size: var(--t-md); font-weight: 500;
  background: var(--surface-2); color: var(--text-secondary);
  border: 1px solid transparent; white-space: nowrap; min-height: 34px;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip-btn:hover { background: var(--surface-3); color: var(--text-primary); text-decoration: none; }
.chip-btn.on { background: var(--accent); color: var(--on-accent); }
.chip-btn.on:hover { background: var(--accent-hover); }

/* belgi-chip (holat) */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: var(--r-full); font-size: var(--t-sm);
  background: var(--surface-2); color: var(--text-secondary);
}
.chip.late { background: color-mix(in srgb, var(--bad) 15%, transparent); color: var(--bad); }
.chip.ok   { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.chip.hot  { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

/* ro'yxat qatori */
.item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.item:last-of-type { border-bottom: 0; }
.item .body { flex: 1; min-width: 0; }
.item .title { font-weight: 500; overflow-wrap: anywhere; }
.meta {
  font-size: var(--t-sm); color: var(--text-muted);
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.item .meta { margin-top: 2px; }
.item.done .title { text-decoration: line-through; color: var(--text-muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 9px; flex: 0 0 auto; }
.p1 { background: var(--bad); } .p2 { background: var(--warn); } .p3 { background: var(--border-strong); }

/* bo'sh holat — panel deyarli har doim shundan boshlanadi, shuning uchun
   u «hech narsa yo'q» emas, «birinchi qadam» bo'lishi kerak */
.empty { color: var(--text-muted); margin: var(--s2) 0; font-size: 14px; }
.blank {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; padding: var(--s5) var(--s4);
  color: var(--text-secondary);
}
.blank .ic { color: var(--text-muted); margin-bottom: 2px; }
.blank b { font-size: 15px; color: var(--text-primary); font-weight: 600; }
.blank p { margin: 0; font-size: var(--t-md); color: var(--text-muted); max-width: 42ch; line-height: 1.5; }
.blank .btn, .blank .chip-btn { margin-top: var(--s2); }

/* jadval */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-size: var(--t-sm); font-weight: 600; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table select { padding: 5px 8px; font-size: var(--t-md); }

/* yig'iladigan blok */
details > summary {
  cursor: pointer; color: var(--text-muted); font-size: var(--t-md);
  list-style: none; display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 0; user-select: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: ""; width: 5px; height: 5px; flex: 0 0 auto;
  border-right: 1.6px solid currentColor; border-bottom: 1.6px solid currentColor;
  transform: rotate(-45deg); transition: transform .16s var(--ease); margin-right: 2px;
}
details[open] > summary::before { transform: rotate(45deg); }
details > summary:hover { color: var(--text-primary); }

/* ============================= 5. Grafiklar ============================== */
.scroll-x {
  min-width: 0; max-width: 100%;
  overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
}
.scroll-x::-webkit-scrollbar { height: 6px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
svg.chart { display: block; max-width: none; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; }
svg.chart .axis-line { stroke: var(--border-strong); stroke-width: 1; }
svg.chart text.axis { fill: var(--text-muted); font-size: 11px; }
svg.chart .bar.s1 { fill: var(--series-1); }
svg.chart .bar.s2 { fill: var(--series-2); }
svg.chart .bar:hover { opacity: .82; }
svg.chart .hm { stroke: var(--surface-1); stroke-width: 2; }
svg.chart .hm-none { fill: var(--heat-0); }
svg.chart .hm-miss { fill: var(--heat-1); }
svg.chart .hm-done { fill: var(--heat-2); }

/* kategoriya ro'yxati — HTML, matn hech qachon kichraymaydi */
.catlist { display: flex; flex-direction: column; gap: var(--s2); }
.catrow {
  display: grid; grid-template-columns: minmax(84px, 116px) minmax(0, 1fr) auto;
  gap: 10px; align-items: center;
}
.catname {
  font-size: var(--t-md); color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cattrack { height: 9px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.catbar { display: block; height: 100%; background: var(--seq); border-radius: 5px; }
.catval { font-size: var(--t-md); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.catval em { font-style: normal; color: var(--text-muted); font-weight: 400; margin-left: 6px; }

svg.ring { width: 84px; height: 84px; flex: 0 0 auto; }
svg.ring .ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 9; }
svg.ring .ring-fg { fill: none; stroke: var(--seq); stroke-width: 9; stroke-linecap: round; }
svg.ring .ring-text {
  fill: var(--text-primary); font-size: 20px; font-weight: 600;
  font-family: "Fraunces", Georgia, serif;
}

.legend {
  display: flex; gap: var(--s4); flex-wrap: wrap; margin-top: 10px;
  font-size: var(--t-sm); color: var(--text-secondary);
}
.legend i {
  width: 10px; height: 10px; border-radius: 3px;
  display: inline-block; margin-right: 6px; vertical-align: -1px;
}
.legend .k1 { background: var(--series-1); }
.legend .k2 { background: var(--series-2); }
.legend .k0 { background: var(--heat-0); }
.legend .km { background: var(--heat-1); }

/* progress chizig'i (byudjet, maqsad qadamlari) */
.bar-line {
  height: 8px; border-radius: 4px; background: var(--surface-2);
  overflow: hidden; margin-top: 6px;
}
.bar-line > span { display: block; height: 100%; background: var(--seq); border-radius: 4px; }
.bar-line.over > span { background: var(--bad); }
.bar-line.near > span { background: var(--warn); }

/* byudjet qatori */
.budget { margin-top: var(--s3); }
.budget-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 6px; font-size: 14px;
}
.budget-head .amt { font-size: var(--t-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* maslahatlar */
.tips { margin: 0; padding-left: 18px; }
.tips li { margin-bottom: var(--s2); color: var(--text-secondary); }
.tips li:last-child { margin-bottom: 0; }

/* maqsad bloki */
.goalrow { display: flex; gap: var(--s4); align-items: flex-start; flex-wrap: nowrap; }
.goal-title { font-size: var(--t-lg); overflow-wrap: anywhere; }
/* qadamlar — chap chiziq ularning maqsadga tegishliligini ko'rsatadi */
.goal-steps {
  margin-top: var(--s2); padding-left: var(--s3);
  border-left: 2px solid var(--border);
}
.goal-steps .item:first-of-type { padding-top: 6px; }

/* odat bloki */
.habit { padding: var(--s3) 0; border-bottom: 1px solid var(--border); }
.habit:first-of-type { padding-top: 0; }
.habit:last-of-type { border-bottom: 0; padding-bottom: 0; }
.habit-head {
  display: flex; justify-content: space-between; align-items: center;
  gap: var(--s2); margin-bottom: var(--s2);
}
.habit-head b { font-size: 14.5px; }

/* ============================== 6. Sahifalar ============================= */
/* kirish — saytning yagona ochiq sahifasi, shuning uchun tanishtiruv ham shu yerda */
.land { max-width: 1000px; margin: 0 auto; padding: var(--s5) var(--s5) var(--s8); }
.land-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s3); padding: var(--s2) 0 var(--s7);
}
.land-hero { display: grid; grid-template-columns: 1.05fr .95fr; gap: var(--s7); align-items: start; }
.land-hero h1 {
  font-size: clamp(30px, 5.2vw, 44px); line-height: 1.12; margin: 0 0 var(--s3);
  letter-spacing: -.03em;
}
.land-hero .lead {
  font-size: var(--t-lg); color: var(--text-secondary); margin: 0 0 var(--s5);
  line-height: 1.5; max-width: 46ch;
}
/* qo'lda tortilgandek chizgi — sahifada bitta joyda, ko'zga tashlanadi */
.underline {
  white-space: nowrap;
  background: var(--squiggle) no-repeat 0 100%;
  background-size: 100% .26em;
  padding-bottom: .08em;
}
.land-trust {
  margin: var(--s5) 0 0; padding-top: var(--s4);
  border-top: 1px solid var(--border);
  font-size: var(--t-md); color: var(--text-muted); line-height: 1.6; max-width: 52ch;
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 6px; margin-bottom: var(--s4);
  padding: 5px 12px; border-radius: var(--r-full);
  background: var(--accent-soft); color: var(--accent);
  font-size: var(--t-md); font-weight: 600;
}
.land-cta {
  position: sticky; top: var(--s5);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-lift);
  text-align: center;
}
.land-cta .mark { display: block; width: 40px; height: 40px; color: var(--accent); margin: 0 auto var(--s3); }
.land-cta h2 { margin: 0 0 6px; font-size: var(--t-xl); }
.land-cta p { margin: 0 0 var(--s4); color: var(--text-secondary); font-size: var(--t-md); line-height: 1.5; }
.land-cta .tg { display: flex; justify-content: center; min-height: 46px; }
.land-note {
  margin-top: var(--s4); padding-top: var(--s4); border-top: 1px solid var(--border);
  font-size: var(--t-sm); color: var(--text-muted); line-height: 1.5; text-align: left;
}

.feat { display: flex; gap: var(--s3); align-items: flex-start; }
.feat .ic { color: var(--accent); margin-top: 2px; }
.feat b { display: block; font-size: 14.5px; margin-bottom: 2px; }
.feat p { margin: 0; font-size: var(--t-md); color: var(--text-secondary); line-height: 1.5; }

.steps { counter-reset: step; display: grid; gap: var(--s4); }
.steps li { list-style: none; display: flex; gap: var(--s3); align-items: flex-start; }
.steps li::before {
  counter-increment: step; content: counter(step);
  width: 26px; height: 26px; flex: 0 0 auto; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: var(--t-md); font-weight: 700;
}
.steps b { display: block; font-size: 14.5px; }
.steps span { font-size: var(--t-md); color: var(--text-secondary); }
ul.steps { padding: 0; margin: 0; }

/* markazlashgan kichik sahifa (xatolik) */
.mid-wrap { min-height: 100dvh; display: grid; place-items: center; padding: var(--s5); }
.mid-card {
  max-width: 420px; width: 100%; text-align: center;
  padding: var(--s6) var(--s5); box-shadow: var(--shadow-lift);
}
.mid-card h1 { font-size: 23px; margin: var(--s3) 0 6px; }
.mid-card .lead { color: var(--text-secondary); margin: 0 0 var(--s5); }
.mid-card .ic { margin: 0 auto; color: var(--warn); }

/* ========================== 7. Yordamchi klasslar ======================== */
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); flex-wrap: wrap; }
.grow-1 { flex: 1; min-width: 0; }
.muted { color: var(--text-muted); }
.small { font-size: var(--t-md); }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); } .mt-5 { margin-top: var(--s5); }
.mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: var(--s3); } .mb-4 { margin-bottom: var(--s4); }
.full { width: 100%; }

/* ============================== 8. Telefon =============================== */
@media (max-width: 720px) {
  :root { --tap: 42px; }

  header.top { padding: 9px var(--s3); gap: var(--s2); }
  header.top nav.tabs { display: none; }          /* pastdagi panelga ko'chdi */
  .who { max-width: 92px; font-size: var(--t-sm); }
  .usermenu-panel { min-width: 214px; }

  main { padding: var(--s3) var(--s3) 88px; }
  .card { padding: var(--s4) var(--s3); border-radius: var(--r-md); }
  .grid { gap: var(--s3); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .g4 { grid-template-columns: 1fr 1fr; }         /* 2x2 */
  .tile { padding: var(--s3); }
  .tile .value { font-size: var(--t-xl); }
  .tile.row { gap: 10px; }
  svg.ring { width: 60px; height: 60px; }
  .goalrow { gap: var(--s3); }
  .goal-title { font-size: 15.5px; }
  .section { margin: var(--s5) 0 var(--s2); }
  .section h2 { font-size: 17px; }
  .hello h1 { font-size: 23px; }
  .foot { margin-top: var(--s5); padding: var(--s4) var(--s3) var(--s5); flex-direction: column; gap: 6px; }

  .catrow { grid-template-columns: minmax(66px, 88px) minmax(0, 1fr) auto; gap: var(--s2); }
  .catval em { display: block; margin: 0; font-size: var(--t-xs); }

  /* bo'limlarga sakrash — boshqaruv sahifasi telefonda uzun */
  .jump {
    display: flex; gap: 6px; overflow-x: auto; margin: 0 0 var(--s3);
    padding-bottom: 2px; -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .jump::-webkit-scrollbar { display: none; }

  /* forma elementlari telefonda to'liq kenglikda — yonma-yon siqilmasin */
  .row.grow > input[type="text"] { flex: 1 1 100%; }
  .row.stack-sm { flex-direction: column; align-items: stretch; }
  .row.stack-sm > select,
  .row.stack-sm > button,
  .row.stack-sm > .btn { width: 100%; }
  select, input, textarea { font-size: 16px; }   /* iOS zoom qilmasin */

  nav.bottom {
    display: flex; position: fixed; z-index: 40; left: 0; right: 0; bottom: 0;
    background: color-mix(in srgb, var(--surface-1) 93%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    border-top: 1px solid var(--border);
    padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
  }
  nav.bottom a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 6px 2px; font-size: var(--t-xs); color: var(--text-muted); font-weight: 500;
  }
  nav.bottom a:hover { text-decoration: none; }
  nav.bottom a.on { color: var(--accent); }
  nav.bottom .ic { width: 21px; height: 21px; }

  /* jadval -> kartalar */
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr {
    border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 10px var(--s3); margin-bottom: var(--s2); background: var(--surface-1);
  }
  table.cards tr:hover { background: var(--surface-1); }
  table.cards td { border: 0; padding: 3px 0; text-align: left; }
  table.cards td::before {
    content: attr(data-label); display: inline-block; min-width: 84px;
    color: var(--text-muted); font-size: var(--t-sm);
  }
  table.cards td.num { text-align: left; }
  table.cards td.act-cell { text-align: right; padding-top: 6px; }
  table.cards td.act-cell::before { content: none; }
  .table-wrap { overflow: visible; }

  /* kirish sahifasi — bitta ustun, CTA tepada bo'lmasin */
  .land { padding: var(--s4) var(--s3) var(--s7); }
  .land-top { padding: 0 0 var(--s5); }
  .land-hero { grid-template-columns: 1fr; gap: var(--s5); }
  .land-cta { position: static; padding: var(--s4); }
}

@media (max-width: 420px) {
  .who, .usermenu .chev { display: none; }        /* faqat avatar qoladi */
  .usermenu-trigger { padding: 3px; }
  .brand { font-size: 16px; }
  .g4 { gap: var(--s2); }
}
