/* Qarzchi — umumiy stil (oq-ko'k, minimalist, Poppins)
   Shrift <link rel="preconnect/stylesheet"> orqali HTML <head>'da yuklanadi.
   Bu yerda @import ISHLATILMAYDI — u renderni bloklaydi va HTML'dagi link bilan takrorlanadi. */

:root {
  --bg: #F5F8FE;
  --surface: #FFFFFF;
  --primary: #26295E;
  --primary-dark: #161845;
  --primary-tint: #E4E7F9;
  --text: #10192E;
  --text-muted: #62719A;
  --border: #E1E8F7;
  --success: #17945F;
  --success-tint: #E7F7EF;
  --warning: #C97A16;
  --warning-tint: #FCF0DF;
  --danger: #D33A2C;
  --danger-tint: #FCE9E7;
  --teal: #1E93A5;

  /* Radius shkalasi — oldingiga qaraganda ancha kichik (burchaklar keskinroq) */
  --r-xs: 3px;    /* progress/bar to'ldirmalari */
  --r-sm: 5px;    /* tugma, input, select, badge, icon-btn */
  --r: 8px;       /* karta, panel, ro'yxat (eski --radius o'rniga) */
  --r-lg: 10px;   /* modal, login kartasi */
  --r-pill: 999px;/* faqat haqiqiy dumaloq elementlar: toggle, splash */
  --radius: var(--r); /* orqaga moslik: .side-box, .summary-box, .report-card ... */

  --shadow: 0 1px 3px rgba(38, 41, 94, .07), 0 1px 2px rgba(38, 41, 94, .04);
  --shadow-lg: 0 6px 20px rgba(16, 25, 46, .12);

  /* z-index shkalasi */
  --z-sticky: 10;
  --z-mnav: 40;
  --z-overlay: 50;
  --z-drawer: 60;
  --z-toast: 80;
  --z-blocked: 200;
  --z-splash: 500;

  color-scheme: light;
}

/* ---------- Dark mode (data-theme="dark" qo'yilganda ishlaydi) ---------- */
[data-theme="dark"] {
  --bg: #0B1022;
  --surface: #141A33;
  --primary: #8B90F5;
  --primary-dark: #B9BEFF;
  --primary-tint: #232A55;
  --text: #E9EEF9;
  --text-muted: #9CAAC8;
  --border: #263154;
  --success: #34C38F;
  --success-tint: #123B2C;
  --warning: #F0A22E;
  --warning-tint: #3D2C10;
  --danger: #FF6B61;
  --danger-tint: #3D1B18;
  --shadow: 0 1px 3px rgba(0, 0, 0, .45);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
[data-theme="dark"] .toast { background: #E9EEF9; color: #0B1428; }
[data-theme="dark"] .avatar { background: var(--primary-tint); color: #C9DAFF; }
[data-theme="dark"] .brand-mark { background: var(--surface); }
[data-theme="dark"] .login-card { box-shadow: var(--shadow); }
[data-theme="dark"] .over-alert { background: var(--danger-tint); border-color: var(--danger); color: var(--danger); }
[data-theme="dark"] .sms-box { background: var(--primary-tint); }
[data-theme="dark"] img { filter: brightness(.92); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  font-size: 15.5px;
  line-height: 1.5;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Gorizontal scroll bo'lmasligi kafolati.
   `clip` ishlatiladi, `hidden` emas — `hidden` body'ni scroll konteynerga aylantirib
   sidebar'ning position:sticky'sini buzadi. */
body { overflow-x: clip; }

/* 400 vazn yuklanmaydi — forma elementlari ham 500'dan boshlanadi */
button, input, select, textarea {
  font-family: 'Poppins', 'Segoe UI', system-ui, Arial, sans-serif;
  font-weight: 500;
  color: var(--text);
}
input, select, textarea { font-size: 14px; }

a { color: inherit; text-decoration: none; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

img, svg { max-width: 100%; }

/* ---------- O'tishlar: faqat interaktiv elementlarda ---------- */
.btn, .icon-btn, .nav-item, .logout-btn, .row-clickable, .m-item, .m-add,
.eye-btn, .drawer-close, .link-btn, .toggle, .toggle::after,
input, select, textarea, .search-box {
  transition: background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}
/* Rejim almashinuvi uchun sirtlar (data-theme o'zgarganda) */
html, body, .sidebar, .stat-card, .list, .modal, .drawer, .login-card,
.card-sm, .report-card, .summary-box, .side-box, .mobile-footer {
  transition: background-color .3s ease, color .3s ease, border-color .3s ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Klaviatura fokusi (a11y) ---------- */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.btn:focus-visible, .icon-btn:focus-visible, .m-item:focus-visible, .m-add:focus-visible {
  outline-offset: 3px;
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible,
.search-box input:focus-visible, .filter-select:focus-visible {
  outline-offset: 0;
}
button, a { -webkit-tap-highlight-color: transparent; }

/* ---------- Login sahifasidagi kirish animatsiyalari ---------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.login-ok {
  background: var(--success-tint);
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 16px;
  display: none;
}
.login-ok.show { display: block; }

.login-switch { text-align: center; margin-top: 14px; }
.form-btns { display: flex; gap: 10px; margin-top: 6px; }
.form-btns .btn { flex: 1; justify-content: center; }
.link-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  padding: 8px;
  border-radius: var(--r-sm);
}

/* Rejim almashinuvi pardasi (JS yaratsa ishlaydi) */
.theme-wipe {
  position: fixed; border-radius: 50%; pointer-events: none; z-index: 300;
  transform: translate(-50%, -50%) scale(0); opacity: .35;
}

/* ---------- Layout shell ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  /* Desktop'da yopishib turadi va o'zi scroll bo'ladi */
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  z-index: var(--z-sticky);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: #fff;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
}
.brand-mark img { width: 22px; height: 22px; }

.brand-logout-popover {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 132px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
  padding: 4px;
  z-index: var(--z-overlay);
}
.brand-logout-popover.open { display: block; }
.brand-logout-popover .logout-btn { padding: 9px 10px; }

.brand-name {
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: -2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Ma'lumot/Sozlamalar: mobilda tepadagi .brand qatorida (o'ng chetda,
   Ma'lumot Sozlamalardan chapda), PC'da esa pastki sidebar-footer'da
   (Chiqish tugmasi ustida) ko'rinadi — .sidebar-tools shu yerda
   .sidebar-footer'ning o'zi bilan birga mobilda avtomatik yashiriladi. */
.brand-tools {
  display: none;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.sidebar-tools {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

/* ---------- Oylik obuna holati ---------- */

.sub-status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  text-align: left;
  cursor: pointer;
}
.sub-status-bar.active { background: var(--success-tint); border-color: transparent; color: var(--success); }
.sub-status-bar.warning { background: var(--warning-tint); border-color: transparent; color: var(--warning); }
.sub-status-bar.danger { background: var(--danger-tint); border-color: transparent; color: var(--danger); }

.sub-status-icon { width: 17px; height: 17px; flex-shrink: 0; display: flex; }
.sub-status-icon svg { width: 100%; height: 100%; }
.sub-status-text { flex: 1 1 auto; min-width: 0; font-size: 12.5px; font-weight: 700; overflow-wrap: anywhere; }
.sub-status-chevron { width: 14px; height: 14px; flex-shrink: 0; opacity: .6; }

/* Obuna holati qatori + uning chap tomonidagi "Ma'lumot" tugmasi (faqat mobilda
   ko'rinadi — PC'da bu tugma sidebar-footer'dagi #infoBtnDesktop sifatida bor,
   shuning uchun bu yerda standart holatda yashirin). */
.sub-status-row { display: flex; align-items: center; gap: 8px; }
.sub-status-info-btn { display: none; }

.sub-detail {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border-radius: var(--r-sm);
  background: var(--bg);
}
.sub-detail.active { background: var(--success-tint); color: var(--success); }
.sub-detail.warning { background: var(--warning-tint); color: var(--warning); }
.sub-detail.danger { background: var(--danger-tint); color: var(--danger); }
.sub-detail .sub-status-icon { width: 20px; height: 20px; margin-top: 1px; }
.sub-detail-label { font-weight: 800; font-size: 14px; color: var(--text); }

@media (max-width: 860px) {
  .sub-status-bar { flex: 1 1 auto; min-width: 0; }
  .sub-status-row { flex: 1 1 100%; }
  .sub-status-info-btn { display: flex; }
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-size: 14.5px;
  font-weight: 700;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active {
  background: var(--primary-tint);
  color: var(--primary-dark);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 10px;
  width: 100%;
  border-radius: var(--r-sm);
  line-height: 1;
}
.logout-btn:hover { background: var(--danger-tint); color: var(--danger); }
.logout-btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 40px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-sub {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 14.5px;
  font-weight: 700;
  white-space: nowrap;
  border: none;
}
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(38, 41, 94, .22); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn-text {
  background: none;
  color: var(--primary);
  padding: 6px 4px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--r-sm);
}

.btn-danger-text {
  background: none;
  color: var(--danger);
  padding: 6px 4px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--r-sm);
}

.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Stat cards ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 26px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.stat-label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.stat-value {
  font-size: 25px;
  font-weight: 800;
  margin-top: 6px;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}

.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success .stat-value { color: var(--success); }

/* Eski 5 ta statistika kartasi #statGridNew bilan almashtirildi — DOM'da
   qoladi (app.js shu elementlarga yozishda davom etadi), lekin ko'rinmaydi. */
#statGridOld { display: none; }

/* ---------- Toolbar / search ---------- */

.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
  align-items: stretch;
}

.search-box {
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  font-weight: 600;
}
.search-box svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  border: none;
  outline: none;
  width: 100%;
  min-width: 0;
  background: none;
  font-weight: 600;
  font-size: 13.5px;
  -webkit-appearance: none;
  appearance: none;
}
.search-box:focus-within { border-color: var(--primary); }

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  color: var(--text);
  font-weight: 700;
  min-width: 0;
  max-width: 100%;
}
/* .filter-select sinfidagi date/month inputlari iOS'da to'g'ri ko'rinishi uchun */
input.filter-select {
  -webkit-appearance: none;
  appearance: none;
  min-height: 38px;
}
/* Oy filtri (select) — native o'q/strelka belgisini olib tashlaymiz (tegilsa
   native variantlar ro'yxati hamon ochiladi, faqat o'ng tomondagi belgi yo'qoladi) */
select.filter-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
select.filter-select::-ms-expand { display: none; }

/* Hisobot: Oy filtri tepada, Sana filtri pastda — ikkalasi ham alohida to'liq qatorda
   (mobilda esa pastdagi @media (max-width: 860px) qoidasi ikkalasini yonma-yon qiladi) */
#monthInput, #dayInput { flex: 1 1 100%; }

/* Sana filtri oddiy date-input bo'lib qoladi (kalendar belgisi ko'rinadi —
   aks holda maydon sana tanlagichga o'xshamay qoladi), faqat o'ng tomondagi
   spin/scroll strelkalari (qiymatni yuqori-past oshirish tugmalari) yashiriladi */
#dayInput::-webkit-inner-spin-button,
#dayInput::-webkit-clear-button {
  display: none;
  -webkit-appearance: none;
  margin: 0;
}

/* ---------- List / rows ---------- */

.list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.row:last-child { border-bottom: none; }

.row-main { flex: 1 1 auto; min-width: 0; }

.row-name {
  font-weight: 800;
  font-size: 15.5px;
  overflow-wrap: anywhere;
}

.row-detail {
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 600;
  margin-top: 3px;
  display: flex;
  gap: 4px 10px;
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}

.row-amount {
  font-weight: 800;
  font-size: 16px;
  min-width: 110px;
  text-align: right;
  flex-shrink: 0;
  overflow-wrap: anywhere;
}

.row-clickable { cursor: pointer; }
.row-clickable:hover { background: var(--bg); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--r-sm);
  font-size: 12.5px;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-success { background: var(--success-tint); color: var(--success); }
.badge-warning { background: var(--warning-tint); color: var(--warning); }
.badge-danger { background: var(--danger-tint); color: var(--danger); }
.badge-muted { background: var(--bg); color: var(--text-muted); }

.row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  align-items: center;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--bg);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--primary-tint); color: var(--primary); }
.icon-btn svg { width: 16px; height: 16px; }

/* ---------- Mijoz guruhi (1 mijoz — bir nechta mahsulot/qarz) ----------
   <details class="debtor-group"><summary class="row ... group-header">...</summary>
   <div class="group-body">...</div></details> — audit.html'dagi .acc-item bilan bir xil
   native <details>/<summary> mexanizmi: ochiq/yopiq holat [open] atributi orqali, JS
   faqat shu atributni va ro'yxatdagi state'ni sinxronlab turadi. */

.debtor-group { border-bottom: 1px solid var(--border); }
.debtor-group:last-child { border-bottom: none; }

.group-header {
  border-bottom: none;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.group-header::-webkit-details-marker,
.group-header::marker { display: none; content: ''; }

.group-chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform .2s ease;
}
.debtor-group[open] .group-chevron { transform: rotate(180deg); }

.group-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .22s ease;
  background: var(--bg);
}
.debtor-group[open] .group-body { grid-template-rows: 1fr; border-top: 1px solid var(--border); }
.group-body-inner { overflow: hidden; }
.group-body-inner .row {
  padding-left: 30px;
  background: var(--bg);
}
.group-body-inner .row .avatar { width: 28px; height: 28px; font-size: 11px; }
.group-body-inner .row:last-child { border-bottom: none; }

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-muted);
}
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: 0.5; }
.empty-state p { font-size: 14px; margin: 0; }

/* ---------- Avatar / progress ---------- */

.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--primary-tint);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.progress-track {
  height: 5px;
  border-radius: var(--r-xs);
  background: var(--border);
  overflow: hidden;
  margin-top: 6px;
  width: 140px;
  max-width: 100%;
}
.progress-fill {
  height: 100%;
  background: var(--success);
  border-radius: var(--r-xs);
}

/* ---------- Audit: mijozlar bo'yicha qarz ro'yxati (accordion) ---------- */

.acc-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }

.acc-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.acc-item > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  -webkit-tap-highlight-color: transparent;
}
.acc-item > summary::-webkit-details-marker,
.acc-item > summary::marker { display: none; content: ''; }
.acc-item > summary:hover { background: var(--bg); }
.acc-item[open] > summary { border-bottom: 1px solid var(--border); }

.acc-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--primary-tint);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12.5px;
  flex-shrink: 0;
}

.acc-main { flex: 1 1 auto; min-width: 0; }
.acc-name { font-weight: 800; font-size: 13.5px; overflow-wrap: anywhere; }
.acc-sub { font-size: 11.5px; color: var(--text-muted); font-weight: 600; margin-top: 2px; }

.acc-sum {
  font-weight: 800;
  font-size: 13.5px;
  color: var(--danger);
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
  overflow-wrap: anywhere;
}

.acc-chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform .18s ease;
}
.acc-item[open] .acc-chevron { transform: rotate(180deg); }

.acc-body { padding: 2px 14px 8px; }

.acc-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
}
.acc-row:last-child { border-bottom: none; }

.acc-row-main { min-width: 0; flex: 1 1 auto; }
.acc-row-product { font-weight: 700; font-size: 12px; overflow-wrap: anywhere; }
.acc-row-date { color: var(--text-muted); font-size: 11px; font-weight: 600; margin-top: 1px; }

.acc-row-amt {
  text-align: right;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}
.acc-row-amt .paid-tag {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--success);
  white-space: normal;
}

.debtor-search-box { margin-bottom: 10px; }

/* ---------- Modal ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 25, 46, 0.45);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 20px;
  z-index: var(--z-overlay);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
}

.field { margin-bottom: 12px; }

.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  outline: none;
  background: var(--bg);
  font-weight: 600;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}
/* iOS'da date/number inputlari o'z o'lchamini buzmasligi uchun */
.field input[type="date"], .field input[type="number"], .field input[type="tel"] {
  -webkit-appearance: none;
  appearance: none;
}

.field-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.field-row .field { flex: 1 1 0; min-width: 0; }

/* .field-row'ning umumiy mobil qoidasi (flex-direction:column) ustunlanadi —
   shu sinf qo'yilgan qatorlar mobilda ham 2 tadan yonma-yon turadi. */
.field-row.field-row-force { flex-direction: row; gap: 10px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* ---------- Mobil: Yangi mijoz / Mavjud mijozga qo'shish tanlovi ---------- */

.choice-grid {
  display: flex;
  gap: 10px;
}

.choice-btn {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  text-align: center;
  min-height: 96px;
  justify-content: center;
}
.choice-btn:hover, .choice-btn:focus-visible { border-color: var(--primary); background: var(--primary-tint); }
.choice-btn:active { transform: scale(.98); }

.choice-btn-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: var(--primary-tint);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.choice-btn-icon svg { width: 18px; height: 18px; }

.choice-btn-label { font-size: 13px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }

.choice-back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 12px;
}
.choice-back-btn svg { width: 15px; height: 15px; }

/* "Yangi mijoz" varag'idagi Ism/Nomer maydonlari — kichikroq matn */
#ncName, #ncPhone, #ncProduct, #ncAmount { font-size: 13px; }

/* Bu varaqdagi "Bekor qilish"/"Davom etish" tugmalari mobilda ham yonma-yon
   tursin — .modal-actions'ning umumiy mobil qoidasi (column-reverse, 100% kenglik)
   ni shu ikki sinfli selektor orqali ustunlab o'tamiz, boshqa modal'larga tegmaydi. */
.modal-actions.modal-actions-row { flex-direction: row; }
.modal-actions.modal-actions-row .btn { width: auto; flex: 1 1 0; min-width: 0; }

.ec-list {
  margin-top: 10px;
  max-height: 46vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.ec-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.ec-row:last-child { border-bottom: none; }
.ec-row:hover, .ec-row:focus-visible { background: var(--bg); }
.ec-row .acc-avatar { width: 30px; height: 30px; font-size: 11.5px; }
.ec-row-main { flex: 1 1 auto; min-width: 0; }
.ec-row-name { font-weight: 700; font-size: 13px; overflow-wrap: anywhere; }
.ec-row-phone { font-size: 11.5px; color: var(--text-muted); font-weight: 600; margin-top: 1px; }

/* ---------- Fayl tanlash (pasport yuklash) ---------- */

.file-pick {
  display: block;
  cursor: pointer;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  padding: 12px;
}
.file-pick:hover, .file-pick:focus-within { border-color: var(--primary); background: var(--primary-tint); }

.file-pick-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.file-pick-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-pick-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--r-sm);
  background: var(--primary-tint);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.file-pick-icon svg { width: 17px; height: 17px; }
.file-pick-icon-ok { background: var(--success-tint); color: var(--success); }

.file-pick-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-pick-title { font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-pick-hint { font-size: 11px; color: var(--text-muted); font-weight: 600; }

.file-pick-remove {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.file-pick-remove:hover { background: var(--danger-tint); color: var(--danger); }
.file-pick-remove svg { width: 14px; height: 14px; }

.toggle {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: var(--r-pill);
  background: var(--border);
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s ease;
}
.toggle.on { background: var(--success); }
.toggle.on::after { transform: translateX(18px); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100vw - 32px);
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: var(--z-toast);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ---------- Drawer (qarzdor tafsiloti) ---------- */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 25, 46, 0.45);
  display: none;
  justify-content: flex-end;
  z-index: var(--z-drawer);
}
.drawer-overlay.open { display: flex; }

.drawer {
  background: var(--surface);
  width: 100%;
  max-width: 420px;
  height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 24px;
  box-shadow: var(--shadow-lg);
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.drawer-close {
  background: var(--bg);
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}
.drawer-close:hover { color: var(--text); background: var(--border); }

.drawer-name { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.drawer-meta { color: var(--text-muted); font-size: 13px; margin-top: 4px; overflow-wrap: anywhere; }

.summary-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.summary-item { text-align: left; min-width: 0; }
.summary-item .label { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.summary-item .value { font-size: 16px; font-weight: 700; margin-top: 3px; overflow-wrap: anywhere; }
.summary-item .value.danger { color: var(--danger); }
.summary-item .value.success { color: var(--success); }

.section-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: none;
  margin: 18px 0 10px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.history-item:last-child { border-bottom: none; }
.history-item .h-date { color: var(--text-muted); }
.history-item .h-amount { font-weight: 700; color: var(--success); white-space: nowrap; }

.drawer-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.drawer-actions .btn { flex: 1 1 auto; justify-content: center; }

/* ---------- Login page ---------- */

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.login-title { font-size: 19px; font-weight: 700; margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: 13.5px; margin-bottom: 22px; }

.login-error {
  background: var(--danger-tint);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

.pass-wrap { position: relative; }
.pass-wrap input { width: 100%; padding-right: 44px; }
.eye-btn {
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: var(--r-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.eye-btn:hover { color: var(--primary); background: var(--primary-tint); }

.login-page .btn-primary { width: 100%; justify-content: center; padding: 12px; margin-top: 6px; }

/* ---------- Login animatsiyasi ---------- */
@keyframes logoPop {
  0% { opacity: 0; transform: scale(.3) rotate(-120deg); }
  60% { opacity: 1; transform: scale(1.12) rotate(8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes cardUp { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fieldIn { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: translateX(0); } }
.login-card { animation: cardUp .45s ease both; }
.login-brand .brand-mark { animation: logoPop .7s cubic-bezier(.34, 1.56, .64, 1) both; }
.login-brand .brand-mark img { animation: logoPop .7s cubic-bezier(.34, 1.56, .64, 1) both; }
.login-title, .login-sub { animation: fadeUp .4s ease both; }
.login-sub { animation-delay: .08s; }
#loginForm .field:nth-child(1) { animation: fieldIn .35s ease .12s both; }
#loginForm .field:nth-child(2) { animation: fieldIn .35s ease .2s both; }
#loginForm .btn-primary { animation: fadeUp .4s ease .28s both; }

/* ---------- Splash (ochilish animatsiyasi) ---------- */
.splash {
  position: fixed; inset: 0; z-index: var(--z-splash);
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; padding: 20px;
  transition: opacity .5s ease, visibility .5s;
}
.splash.hide { opacity: 0; visibility: hidden; }
.splash-ring {
  width: 120px; height: 120px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; position: relative;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.splash-ring::before {
  content: ''; position: absolute; inset: -7px; border-radius: 50%;
  border: 4px solid transparent; border-top-color: var(--teal); border-right-color: var(--teal);
  animation: splashSpin 1s linear infinite;
}
.splash-ring img { width: 68px; height: 68px; animation: splashPop 1s ease infinite alternate; }
.splash-name { font-weight: 800; font-size: 22px; letter-spacing: -.02em; animation: fadeUp .5s ease .15s both; }
.splash-bar { width: 150px; height: 6px; border-radius: var(--r-pill); background: var(--border); overflow: hidden; }
.splash-bar::after {
  content: ''; display: block; width: 40%; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--teal), var(--primary));
  animation: splashSlide 1.1s ease-in-out infinite alternate;
}
@keyframes splashSpin { to { transform: rotate(360deg); } }
@keyframes splashPop { from { transform: scale(.92); } to { transform: scale(1.05); } }
@keyframes splashSlide { from { margin-left: -40%; } to { margin-left: 100%; } }

/* ---------- Report page (chart) ---------- */

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.report-card h3 { font-size: 14.5px; font-weight: 700; margin: 0 0 16px; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.bar-label { width: 110px; flex-shrink: 0; color: var(--text-muted); font-weight: 600; }
.bar-track {
  flex: 1 1 auto;
  min-width: 0;
  height: 18px;
  background: var(--bg);
  border-radius: var(--r-xs);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-xs);
}
.bar-value { width: 110px; text-align: right; font-weight: 700; flex-shrink: 0; }

.top-debtor-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.top-debtor-row:last-child { border-bottom: none; }
.top-debtor-row > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.top-debtor-row > span:last-child { white-space: nowrap; font-weight: 700; }

.report-empty {
  text-align: center;
  padding: 28px 10px;
  color: var(--text-muted);
}
.report-empty svg { width: 32px; height: 32px; margin-bottom: 10px; opacity: 0.5; }
.report-empty p { font-size: 13.5px; margin: 0 0 14px; }

/* ---------- Ogohlantirish / kichik bloklar ---------- */

.over-alert {
  background: #FFF1F0;
  border: 1px solid #FFC9C5;
  color: #8f1d1d;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.over-alert svg { flex-shrink: 0; }

.muted-sm { color: var(--text-muted); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }

/* app.js "Tanlandi: ..." matnini dinamik display:block bilan ko'rsatadi —
   shuning uchun oddiy hide emas, !important bilan ustunlab yashiramiz. */
#oldClientHint { display: none !important; }

.card-sm {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.sms-box {
  background: #EFF4FF;
  border: 1px dashed var(--primary);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

/* ---------- Admin: sidebar'dagi to'lagan/to'lamagan box'lar ---------- */

.side-box {
  background: var(--surface);
  border: 1px solid var(--danger);
  border-radius: var(--r);
  padding: 12px;
  box-shadow: var(--shadow);
  margin-top: 4px;
  min-width: 0;
}
.side-box.paid-box { border-color: var(--success); }
.side-box .over-actions .btn { padding: 7px 8px; font-size: 12.5px; }
#paidList, #overdueList { max-height: 300px; overflow-y: auto; overscroll-behavior: contain; }
.admin-main { min-width: 0; }

.overdue-title {
  font-size: 14.5px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.side-box .overdue-title {
  background: var(--primary-tint);
  border-radius: var(--r-sm);
  padding: 8px 10px;
  color: var(--primary-dark);
}
.overdue-title .count {
  background: var(--danger); color: #fff;
  font-size: 12px; font-weight: 800;
  min-width: 24px; height: 24px;
  border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 7px;
  flex-shrink: 0;
}
.overdue-title .count-ok { background: var(--success); }

.over-item {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  margin-bottom: 8px;
  min-width: 0;
}
.over-item:last-child { margin-bottom: 0; }
.over-main { min-width: 0; }
.over-name { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.over-meta { color: var(--text-muted); font-size: 12px; margin-top: 3px; line-height: 1.5; overflow-wrap: anywhere; }
.over-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.over-actions .btn { flex: 1 1 auto; justify-content: center; }

/* ================================================================
   RESPONSIVE
   ================================================================ */

.mobile-footer { display: none; }

/* ---- Planshet / kichik laptop: sidebar va padding siqiladi ---- */
@media (max-width: 1200px) {
  .sidebar { width: 200px; padding: 20px 12px; gap: 20px; }
  .nav-item { font-size: 14px; padding: 10px; }
  .main { padding: 24px 24px; }
  .page-title { font-size: 22px; }
}

/* ---- Mobil va planshet-portret (<= 860px): pastki menyu layout ---- */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }

  /* Sidebar -> yuqoridagi yopishqoq sarlavha */
  .sidebar {
    position: sticky;
    top: 0;
    width: auto;
    height: auto;
    max-height: none;
    align-self: stretch;
    overflow: visible;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: var(--z-sticky);
  }
  .sidebar .nav, .sidebar .sidebar-footer { display: none; }
  .brand { flex: 1 1 100%; padding: 0; }
  .brand-tools { display: flex; }

  /* Admin sahifasi: ikkita box yonma-yon -> vertikal joy tejaladi */
  .side-box { flex: 1 1 calc(50% - 5px); margin: 0; }
  #paidList, #overdueList { max-height: 190px; }

  .main { padding: 14px 12px 20px; }
  /* Pastki menyu bor sahifalarda joy qoldiriladi */
  body.has-mnav .main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  .page-header { margin-bottom: 12px; align-items: flex-start; }
  .page-header > div:last-child { flex-wrap: wrap; row-gap: 8px; }
  .page-title { font-size: 19px; }
  .page-sub { font-size: 13px; }
  /* Bosh sahifada mobilda sarlavha ham, "Yangi qarz qo'shish" tugmasi ham
     pastdagi "+" bilan almashadi — ikkalasi bo'sh qolgandan ko'ra butun
     blokni olib tashlaymiz, aks holda yuqorida foydasiz bo'sh joy qoladi. */
  #pageHeaderMain { display: none; }
  #debtorList [data-action="delete"] { display: none; }

  /* Statistika: 2 ustun, toq qolgan oxirgi karta to'liq kenglikda — ixcham */
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin-bottom: 12px; }
  .stat-card { padding: 10px 12px; }
  .stat-label { font-size: 10.5px; }
  .stat-value { font-size: 18px; margin-top: 2px; }
  .stat-grid > .stat-card:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Toolbar: qidiruv to'liq qator, selectlar 2 ustun, tugmalar teng bo'linadi */
  .toolbar { gap: 8px; }
  /* Qidiruv maydoni to'liq 44px teginish nishoni bo'lishi uchun input qutini to'ldiradi */
  .search-box { flex: 1 1 100%; padding: 0 12px; min-height: 46px; }
  .search-box input { align-self: stretch; min-height: 44px; }
  /* `input.filter-select` bazaviy qoidasi spetsifikligi yuqori — shu sababli u ham yoziladi */
  .filter-select, input.filter-select { flex: 1 1 calc(50% - 4px); min-height: 44px; font-size: 14px; }
  /* Hisobot: mobil ekranda Oy va Sana filtri bitta qatorda yonma-yon (yuqoridagi
     bazaviy #monthInput/#dayInput qoidasini shu o'lchamda qayta ustidan bosib) */
  #monthInput, #dayInput { flex: 1 1 calc(50% - 4px); }
  /* Toolbarda bitta tugma qolsa (masalan Hisobot/Admin: "Tozalash"/"Excel"),
     uni 33% kenglikda yolg'iz qoldirmay to'liq qatorga yoyamiz */
  .toolbar > .btn { flex: 1 1 calc(33.333% - 6px); justify-content: center; padding: 9px 6px; font-size: 12px; gap: 5px; }
  .toolbar > .btn:only-of-type { flex: 1 1 100%; }
  .toolbar > .btn svg { width: 15px; height: 15px; }

  /* Ro'yxat qatori: avatar + ism + summa bir qatorda, badge'lar keyingi qatorda,
     tugmalar esa alohida pastdagi qatorda (barmoq uchun keng) */
  .row { flex-wrap: wrap; gap: 8px 10px; padding: 12px 14px; }
  .row > .avatar { order: 1; }
  .row > .row-main { order: 2; flex: 1 1 auto; }
  .row > .row-amount { order: 3; min-width: 0; text-align: right; margin-left: auto; font-size: 15.5px; }
  .row > .badge { order: 4; }
  .row > .group-chevron { order: 5; align-self: center; }
  .group-body-inner .row { padding-left: 18px; }
  .row > .row-actions {
    order: 5;
    flex: 1 0 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
  }
  .progress-track { width: 100%; max-width: 200px; }

  /* Barmoq uchun minimal 44px */
  .icon-btn { width: 44px; height: 44px; }
  .icon-btn svg { width: 18px; height: 18px; }
  .btn, .btn-sm { min-height: 44px; }
  .btn-text, .btn-danger-text { min-height: 44px; }
  /* iOS zoom bo'lmasligi uchun 16px */
  input, select, textarea { font-size: 16px; }
  .field input, .field select, .field textarea { font-size: 16px; min-height: 46px; }

  /* Modal — pastdan chiqadigan oyna (bottom sheet) */
  .overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
    max-height: 92vh;
    max-height: 92dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .field-row { flex-direction: column; gap: 0; }
  .modal-actions { flex-direction: column-reverse; gap: 8px; }
  .modal-actions .btn { width: 100%; justify-content: center; }

  /* Drawer — to'liq ekran */
  .drawer {
    max-width: 100%;
    padding: 20px 16px calc(96px + env(safe-area-inset-bottom));
  }
  .drawer-actions { flex-direction: column; }
  .drawer-actions .btn { width: 100%; min-height: 48px; }

  /* Hisobot diagrammasi: yorliq + qiymat tepada, chiziq to'liq kenglikda */
  .report-card { padding: 16px 14px; }
  .bar-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    margin-bottom: 14px;
  }
  .bar-label { width: auto; }
  .bar-value { width: auto; }
  .bar-track { grid-column: 1 / -1; height: 14px; }

  /* Pastki menyu */
  .mobile-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    position: fixed;
    left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom));
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 8px 4px;
    z-index: var(--z-mnav);
    box-shadow: var(--shadow-lg);
  }
  .m-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: 0; color: var(--text-muted);
    font-size: 10.5px; font-weight: 600; padding: 6px 2px;
    min-height: 50px; justify-content: center;
    border-radius: var(--r-sm);
  }
  .m-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .m-item svg { width: 21px; height: 21px; flex-shrink: 0; }
  .m-item.active { color: var(--primary-dark); }
  .m-add {
    width: 54px; height: 54px; border-radius: 50%;
    background: var(--primary); color: #fff; border: 0;
    display: flex; align-items: center; justify-content: center;
    margin: -28px 4px 0; flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(38, 41, 94, .35);
  }
  .m-add svg { width: 25px; height: 25px; }
  .m-add:active { transform: scale(.96); }
}

/* ---- Telefon (<= 560px) ---- */
@media (max-width: 560px) {
  .main { padding: 12px 10px 20px; }
  body.has-mnav .main { padding-bottom: calc(94px + env(safe-area-inset-bottom)); }
  .page-header > div:last-child { width: 100%; }
  .page-header > div:last-child .btn-primary { flex: 1 1 100%; justify-content: center; }

  /* Admin: boxlar ustma-ust */
  .side-box { flex: 1 1 100%; }

  /* Summary — yorliq chapda, qiymat o'ngda (o'qish oson) */
  .summary-box { grid-template-columns: 1fr; gap: 0; padding: 12px 14px; }
  .summary-item {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }
  .summary-item:first-child { padding-top: 0; }
  .summary-item:last-child { border-bottom: none; padding-bottom: 0; }
  .summary-item .value { margin-top: 0; text-align: right; }

  .over-alert { font-size: 13px; padding: 10px 12px; }
  .over-alert .btn { width: 100%; justify-content: center; }
  .drawer-meta, .row-detail { font-size: 13px; }
}

/* ---- Juda kichik telefonlar (<= 380px) ---- */
@media (max-width: 380px) {
  /* 2 ustun sig'maydi, lekin 5 ta baland karta ham juda ko'p joy oladi:
     shuning uchun karta ixcham qatorga aylanadi — yorliq chapda, qiymat o'ngda. */
  .stat-grid { grid-template-columns: 1fr; gap: 6px; }
  .stat-grid > .stat-card:last-child:nth-child(odd) { grid-column: auto; }
  .stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
  }
  .stat-label { font-size: 10.5px; }
  .stat-value { font-size: 17px; margin-top: 0; text-align: right; }
  .filter-select { flex: 1 1 100%; }
  .toolbar > .btn { flex: 1 1 calc(50% - 4px); }
  .row > .row-amount { margin-left: 0; flex: 1 0 100%; text-align: left; }
  .acc-item > summary { flex-wrap: wrap; }
  .acc-sum { flex: 1 0 100%; text-align: left; margin-left: 42px; }
  .m-item { font-size: 10px; }
  .m-item svg { width: 20px; height: 20px; }
  .m-add { width: 50px; height: 50px; margin-top: -26px; }
  .login-card { padding: 24px 18px; }
}

/* ---- Yotiq (landscape) past ekran: splash va login siqilmasin ---- */
@media (max-height: 460px) and (orientation: landscape) {
  .splash-ring { width: 84px; height: 84px; }
  .splash-ring img { width: 46px; height: 46px; }
  .splash-name { font-size: 18px; }
  .login-page { align-items: flex-start; padding: 16px; }
  .login-card { padding: 20px 18px; }
  .login-brand { margin-bottom: 14px; }
}

/* ---------- Print (Chek / kvitansiya) ----------
   MUHIM: #printArea'da inline style="display:none" bor.
   Faqat visibility bilan uni ko'rsatib bo'lmaydi — shuning uchun display:block !important. */
@media print {
  .app-shell, .mobile-footer, .overlay, .drawer-overlay, .toast, .splash, #blockedOverlay {
    display: none !important;
  }
  html, body {
    background: #fff !important;
    color: #000 !important;
    font-size: 12pt;
  }
  #printArea {
    display: block !important;
    position: static !important;
    width: 100%;
    padding: 0;
  }
  #printArea h2 { margin: 0 0 4px; font-size: 18pt; }
  #printArea p { margin: 3px 0; }
  #printArea hr { border: none; border-top: 1px solid #000; margin: 8px 0; }
  @page { margin: 12mm; }
}
