/* ============================ Kirim-Chiqim ============================ */
:root {
  --primary: #0d9488;
  --primary-600: #0f766e;
  --primary-soft: #ccfbf1;
  --on-primary: #fff;
  --income: #16a34a;
  --income-soft: #dcfce7;
  --expense: #e11d48;
  --expense-soft: #ffe4e6;
  --transfer: #2563eb;
  --transfer-soft: #dbeafe;
  --lend: #d97706;
  --lend-soft: #fef3c7;
  --borrow: #7c3aed;
  --borrow-soft: #ede9fe;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 2px rgb(15 23 42 / .05), 0 4px 16px rgb(15 23 42 / .06);
  --shadow-lg: 0 10px 40px rgb(15 23 42 / .18);
  --radius: 16px;
  --radius-sm: 12px;
  --topbar-h: 56px;
  --tabbar-h: 64px;
  --rail-w: 248px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --tb-h: 0px; /* window-controls-overlay sarlavha balandligi */
  color-scheme: light;
}

:root[data-theme="dark"] {
  --primary: #2dd4bf;
  --primary-600: #14b8a6;
  --primary-soft: #134e4a;
  --on-primary: #042f2e;
  --income: #4ade80;
  --income-soft: #14532d66;
  --expense: #fb7185;
  --expense-soft: #88133766;
  --transfer: #60a5fa;
  --transfer-soft: #1e3a8a66;
  --lend: #fbbf24;
  --lend-soft: #78350f66;
  --borrow: #a78bfa;
  --borrow-soft: #4c1d9566;
  --bg: #0b1120;
  --surface: #131c2e;
  --surface-2: #1a2539;
  --surface-3: #25324a;
  --text: #e6ebf2;
  --text-2: #cbd5e1;
  --muted: #8b9ab1;
  --border: #233049;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
  --shadow-lg: 0 10px 40px rgb(0 0 0 / .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Ubuntu, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--primary); text-decoration: none; }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 18px; height: 18px; }
.num, .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.standalone body, .standalone .nosel { -webkit-user-select: none; user-select: none; }
.standalone input, .standalone textarea { -webkit-user-select: text; user-select: text; }

/* ------------------------------ Splash (aysapps) ------------------------------ */
.aysplash {
  position: fixed; inset: 0; z-index: 100; overflow: hidden; background: #030303;
  display: grid; place-items: center; transition: opacity .45s ease; cursor: pointer;
}
/* Gorizontal video: ekranni to'ldiradi, telefonda esa logotip kesilmasligi uchun kenglik cheklanadi */
.aysplash video {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(max(100vw, 177.78vh), 170vw); height: auto; pointer-events: none;
}
.aysplash-logo { width: min(260px, 60vw); height: auto; animation: splashLogo .6s ease-out; }
@keyframes splashLogo { from { opacity: 0; transform: scale(.94); } }
.aysplash.hide { opacity: 0; pointer-events: none; }

/* aysapps.uz mualliflik belgisi */
.made-by { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.made-by img { width: 18px; height: 18px; border-radius: 5px; }
.made-by:hover { color: var(--text); }
.brand-lockup { display: inline-flex; align-items: flex-end; gap: 2px; color: var(--text); font-weight: 900; font-size: 15px; line-height: 1; }
.brand-lockup img { height: 30px; width: auto; }

/* ------------------------------ Shell ------------------------------ */
.topbar {
  position: fixed; z-index: 20; top: var(--tb-h); left: 0; right: 0;
  height: calc(var(--topbar-h) + var(--sat));
  padding: var(--sat) calc(8px + var(--sar)) 0 calc(8px + var(--sal));
  display: flex; align-items: center; gap: 4px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  transition: box-shadow .2s, border-color .2s;
  border-bottom: 1px solid transparent;
}
.scrolled .topbar { border-bottom-color: var(--border); }
.topbar h1 {
  flex: 1; margin: 0 0 0 8px; font-size: 20px; font-weight: 700; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .back + h1 { margin-left: 0; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center;
  color: var(--text-2); transition: background .15s; position: relative; flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { background: var(--surface-3); }
.sync-dot { position: absolute; top: 10px; right: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); border: 2px solid var(--bg); }
.sync-dot.ok { background: var(--income); }
.sync-dot.error { background: var(--expense); }
.sync-dot.syncing { background: var(--lend); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .35; } }

main#view {
  padding: calc(var(--topbar-h) + var(--sat) + var(--tb-h)) calc(16px + var(--sar)) calc(var(--tabbar-h) + var(--sab) + 96px) calc(16px + var(--sal));
  max-width: 1180px; margin: 0 auto;
}
.page-enter { animation: pageIn .22s ease-out; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--sab));
  padding: 0 var(--sar) var(--sab) var(--sal);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 600; color: var(--muted); position: relative;
}
.tabbar a .pill { width: 56px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: background .2s; }
.tabbar a.active { color: var(--text); }
.tabbar a.active .pill { background: var(--primary-soft); color: var(--primary-600); }
:root[data-theme="dark"] .tabbar a.active .pill { color: var(--primary); }

.fab {
  position: fixed; z-index: 21; right: calc(16px + var(--sar)); bottom: calc(var(--tabbar-h) + var(--sab) + 16px);
  width: 60px; height: 60px; border-radius: 20px; display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); box-shadow: 0 6px 20px color-mix(in srgb, var(--primary) 45%, transparent);
  transition: transform .15s;
}
.fab:active { transform: scale(.93); }
.fab svg.i { width: 28px; height: 28px; stroke-width: 2.4; }

.rail { display: none; }

/* Pull-to-refresh */
.ptr {
  position: fixed; z-index: 19; left: 50%; top: calc(var(--topbar-h) + var(--sat) + var(--tb-h));
  width: 40px; height: 40px; margin-left: -20px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); box-shadow: var(--shadow); color: var(--primary);
  transform: translateY(-60px); opacity: 0;
}
.ptr.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Window Controls Overlay (desktop PWA) */
.wco-bar { display: none; }
@media (display-mode: window-controls-overlay) {
  :root { --tb-h: env(titlebar-area-height, 0px); }
  .wco-bar {
    display: flex; align-items: center; gap: 8px; position: fixed; z-index: 30;
    left: env(titlebar-area-x, 0); top: env(titlebar-area-y, 0);
    width: env(titlebar-area-width, 100%); height: env(titlebar-area-height, 32px);
    padding: 0 12px; font-size: 13px; font-weight: 600; color: var(--muted);
    background: var(--surface); border-bottom: 1px solid var(--border);
    -webkit-app-region: drag; app-region: drag;
  }
  .wco-bar img { width: 18px; height: 18px; border-radius: 5px; }
  .wco-bar button { -webkit-app-region: no-drag; app-region: no-drag; }
}

/* ------------------------------ Desktop ------------------------------ */
@media (min-width: 900px) {
  .rail {
    display: flex; flex-direction: column; gap: 4px; position: fixed; z-index: 22;
    top: var(--tb-h); bottom: 0; left: 0; width: var(--rail-w); padding: 18px 14px;
    background: var(--surface); border-right: 1px solid var(--border);
  }
  .rail .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 800; font-size: 18px; }
  .rail .brand img { width: 34px; height: 34px; border-radius: 10px; }
  .rail .new-btn { margin: 0 4px 14px; justify-content: center; }
  .rail a {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px;
    color: var(--text-2); font-weight: 600;
  }
  .rail a:hover { background: var(--surface-2); }
  .rail a.active { background: var(--primary-soft); color: var(--primary-600); }
  :root[data-theme="dark"] .rail a.active { color: var(--primary); }
  .rail .spacer { flex: 1; }
  .rail .kbd-hint { font-size: 12px; color: var(--muted); padding: 8px 14px; }
  .topbar { left: var(--rail-w); padding-left: 16px; }
  main#view { margin-left: var(--rail-w); padding-left: 32px; padding-right: 32px; padding-bottom: 48px; max-width: calc(1180px + var(--rail-w)); }
  .tabbar, .fab { display: none; }
  .ptr { display: none; }
  body { font-size: 14.5px; }
}

/* ------------------------------ Building blocks ------------------------------ */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card, .section + .section, .card + .section, .section + .card { margin-top: 14px; }
.grid-2 > *, .stat-grid > *, .quick > * { margin-top: 0 !important; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 22px 4px 10px; }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.section-head a, .link-btn { font-size: 14px; font-weight: 600; color: var(--primary-600); }
:root[data-theme="dark"] .section-head a, :root[data-theme="dark"] .link-btn { color: var(--primary); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.dash { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 24px; }
@media (min-width: 1100px) {
  .dash { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); align-items: start; }
}

.hero {
  position: relative; overflow: hidden; border-radius: 22px; padding: 20px; color: #fff;
  background: linear-gradient(135deg, #0f766e 0%, #0d9488 45%, #0891b2 100%);
  box-shadow: 0 10px 30px rgb(13 148 136 / .3);
}
:root[data-theme="dark"] .hero { background: linear-gradient(135deg, #115e59 0%, #0f766e 50%, #155e75 100%); box-shadow: none; }
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 200px; height: 200px; border-radius: 50%;
  background: radial-gradient(circle, rgb(255 255 255 / .18), transparent 70%);
}
.hero .label { font-size: 13px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.hero .big { font-size: 32px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 16px; }
.hero .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hero .mini { background: rgb(255 255 255 / .14); border-radius: 14px; padding: 10px 12px; }
.hero .mini small { display: flex; align-items: center; gap: 4px; opacity: .85; font-size: 12px; }
.hero .mini b { font-size: 16px; }
.hero .eye { color: #fff; width: 32px; height: 32px; }
.hero .eye:hover { background: rgb(255 255 255 / .15); }

.hscroll { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 6px; margin: 0 -2px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.acc-card {
  scroll-snap-align: start; flex: 0 0 auto; min-width: 150px; padding: 12px 14px; border-radius: 14px;
  background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; text-align: left; color: var(--text);
}
.acc-card .t { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.sw { width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center; color: #fff; flex: none; }
.sw svg.i { width: 15px; height: 15px; }
.acc-card b { font-size: 16px; }
.acc-card.add { align-items: center; justify-content: center; color: var(--muted); border: 1.5px dashed var(--border); box-shadow: none; background: transparent; min-width: 110px; }

.debt-card { display: flex; flex-direction: column; gap: 4px; text-align: left; color: var(--text); }
.debt-card small { color: var(--muted); font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.debt-card b { font-size: 18px; }
@media (max-width: 420px) { .debt-card b { font-size: 16px; } }
.debt-card .sub { font-size: 12px; color: var(--muted); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick button { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); padding: 8px 0; border-radius: 14px; }
.quick button:active { background: var(--surface-2); }
.quick .qi { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; }

.k-income { color: var(--income); } .bg-income { background: var(--income-soft); color: var(--income); }
.k-expense { color: var(--expense); } .bg-expense { background: var(--expense-soft); color: var(--expense); }
.k-transfer { color: var(--transfer); } .bg-transfer { background: var(--transfer-soft); color: var(--transfer); }
.k-lend { color: var(--lend); } .bg-lend { background: var(--lend-soft); color: var(--lend); }
.k-borrow { color: var(--borrow); } .bg-borrow { background: var(--borrow-soft); color: var(--borrow); }
.pos { color: var(--income); } .neg { color: var(--expense); } .muted { color: var(--muted); }

/* Lists */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; width: 100%; text-align: left;
  position: relative; min-height: 60px; color: var(--text);
}
.item + .item::before { content: ""; position: absolute; top: 0; left: 66px; right: 0; border-top: 1px solid var(--border); }
button.item:hover, a.item:hover { background: var(--surface-2); }
button.item:active, a.item:active { background: var(--surface-3); }
.item .ic {
  width: 42px; height: 42px; border-radius: 14px; flex: none; display: grid; place-items: center; font-size: 20px;
}
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.item .sub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .end { text-align: right; flex: none; }
.item .end .amount { font-weight: 700; }
.item .end small { display: block; font-size: 11.5px; color: var(--muted); }
.item .chev { color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.tag.warn { background: var(--lend-soft); color: var(--lend); }
.tag.danger { background: var(--expense-soft); color: var(--expense); }
.tag.ok { background: var(--income-soft); color: var(--income); }

.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 6px 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.day-head:first-child { margin-top: 4px; }

.avatar {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  font-weight: 700; font-size: 15px; color: #fff;
}
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }

/* Bars */
.bar-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; }
.bar-row .e { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-size: 17px; background: var(--surface-2); }
.bar-row .n { font-size: 13.5px; font-weight: 600; display: flex; justify-content: space-between; gap: 8px; }
.bar-row .n span:last-child { color: var(--muted); font-weight: 500; }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; }
.bar-row .v { font-weight: 700; font-size: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px;
  padding: 0 18px; border-radius: 14px; font-weight: 650; background: var(--surface-2); color: var(--text);
  transition: transform .1s, background .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-600); }
.btn.danger { background: var(--expense-soft); color: var(--expense); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; border-radius: 16px; }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; }
.btn-row > * { flex: 1; }

/* Segmented & chips */
.seg { display: flex; background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 2px; }
.seg button { flex: 1; min-height: 36px; border-radius: 10px; font-size: 13.5px; font-weight: 650; color: var(--muted); padding: 0 6px; white-space: nowrap; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .1); }
:root[data-theme="dark"] .seg button.on { background: var(--surface-3); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border-radius: 999px; border: 1.5px solid var(--border); font-size: 13.5px; font-weight: 600; color: var(--text-2);
  background: var(--surface);
}
.chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-600); }
:root[data-theme="dark"] .chip.on { color: var(--primary); }
.chip .sw { width: 10px; height: 10px; border-radius: 50%; }

/* Forms */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 0 4px 6px; text-transform: uppercase; letter-spacing: .03em; }
.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 14px; border: 1.5px solid var(--border);
  background: var(--surface); outline: none; transition: border-color .15s; font-size: 16px;
}
.input:focus { border-color: var(--primary); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
.input-wrap { position: relative; }
.input-wrap .icon-btn { position: absolute; right: 2px; top: 2px; }
.amount-input { display: flex; align-items: baseline; gap: 8px; padding: 6px 4px 14px; border-bottom: 2px solid var(--border); margin-bottom: 18px; }
.amount-input:focus-within { border-color: var(--primary); }
.amount-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 38px; font-weight: 800; letter-spacing: -.02em; padding: 0; font-variant-numeric: tabular-nums; }
.amount-input .cur { font-size: 18px; font-weight: 700; color: var(--muted); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; border-radius: 15px; background: var(--surface-3); transition: background .2s; }
.switch i::after { content: ""; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .2s; }
.switch input:checked + i { background: var(--primary); }
.switch input:checked + i::after { transform: translateX(20px); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.cat-grid button {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 14px;
  font-size: 11.5px; font-weight: 600; color: var(--text-2); border: 1.5px solid transparent; background: var(--surface-2);
  line-height: 1.2; text-align: center; min-height: 74px;
}
.cat-grid button .e { font-size: 24px; }
.cat-grid button.on { border-color: var(--primary); background: var(--primary-soft); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.emoji-grid button { height: 44px; border-radius: 12px; font-size: 22px; background: var(--surface-2); border: 1.5px solid transparent; }
.emoji-grid button.on { border-color: var(--primary); background: var(--primary-soft); }
.color-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.color-grid button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1.5px var(--border); }
.color-grid button.on { box-shadow: 0 0 0 2.5px var(--text); }

/* Qarz yo'nalishi: Berdim / Oldim */
.dir { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.dir button {
  display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 16px; text-align: left;
  background: var(--surface-2); border: 1.5px solid transparent;
}
.dir button .qi { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.dir button b { display: block; font-size: 15px; }
.dir button small { display: block; font-size: 12px; color: var(--muted); }
.dir button.on { border-color: var(--primary); background: var(--primary-soft); }
.hint { font-size: 13px; color: var(--muted); margin: 0 4px 14px; }
.opening-row .input { width: 132px; min-height: 42px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }
.sign-btn { width: 42px; height: 42px; border-radius: 12px; background: var(--surface-2); font-size: 20px; font-weight: 800; flex: none; }
.sign-btn.pos { color: var(--income); } .sign-btn.neg { color: var(--expense); }
@media (max-width: 380px) { .opening-row .input { width: 110px; } }

/* ------------------------------ Sheets / dialogs ------------------------------ */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgb(2 6 23 / .45);
  animation: fadeIn .2s ease-out;
}
.backdrop.closing { animation: fadeOut .2s ease-in forwards; }
.sheet {
  position: fixed; z-index: 51; left: 0; right: 0; bottom: 0; max-height: calc(100dvh - var(--sat) - 24px);
  display: flex; flex-direction: column; background: var(--surface); border-radius: 24px 24px 0 0;
  box-shadow: var(--shadow-lg); animation: sheetUp .28s cubic-bezier(.2, .9, .3, 1);
  padding-bottom: var(--sab);
}
.sheet.closing { animation: sheetDown .2s ease-in forwards; }
.sheet .grab { padding: 8px 0 2px; display: grid; place-items: center; touch-action: none; cursor: grab; }
.sheet .grab::before { content: ""; width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); }
.sheet header { display: flex; align-items: center; gap: 4px; padding: 0 8px 4px; touch-action: none; }
.sheet header h3 { flex: 1; margin: 0 0 0 8px; font-size: 18px; font-weight: 750; }
.sheet .body { overflow-y: auto; padding: 8px 18px 18px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet footer { padding: 10px 18px 14px; border-top: 1px solid var(--border); display: flex; gap: 10px; }
.sheet footer > * { flex: 1; }
.dialog .body { padding-top: 4px; }
.dialog p { margin: 0 0 6px; color: var(--text-2); }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translate(-50%, -48%) scale(.96); } }
@keyframes popOut { to { opacity: 0; transform: translate(-50%, -48%) scale(.96); } }

@media (min-width: 700px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%; width: min(540px, calc(100vw - 48px));
    max-height: min(86vh, 820px); transform: translate(-50%, -50%); border-radius: 22px; padding-bottom: 0;
    animation: popIn .2s ease-out;
  }
  .sheet.dialog { width: min(420px, calc(100vw - 48px)); }
  .sheet.closing { animation: popOut .15s ease-in forwards; }
  .sheet .grab { display: none; }
  .sheet header { padding-top: 10px; }
}

/* Menu sheet list */
.menu { display: flex; flex-direction: column; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 14px; padding: 14px 8px; border-radius: 12px; font-weight: 600; text-align: left; color: var(--text);
}
.menu button:hover, .menu a:hover { background: var(--surface-2); }
.menu .danger { color: var(--expense); }

/* Settings list */
.settings .item { min-height: 56px; }
.settings .item .ic { width: 38px; height: 38px; border-radius: 12px; font-size: 18px; }
.settings .item + .item::before { left: 64px; }
.group-title { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 22px 8px 8px; }

/* Toasts */
#toasts {
  position: fixed; z-index: 90; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--sab) + 90px); display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
@media (min-width: 900px) { #toasts { bottom: 28px; left: calc(50% + var(--rail-w) / 2); } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 14px;
  background: #1e293b; color: #f8fafc; box-shadow: var(--shadow-lg); font-weight: 550; font-size: 14px;
  animation: toastIn .25s ease-out; max-width: 100%;
}
:root[data-theme="dark"] .toast { background: #e2e8f0; color: #0f172a; }
.toast.error { background: #be123c; color: #fff; }
.toast button { color: #5eead4; font-weight: 700; margin-left: auto; }
:root[data-theme="dark"] .toast button { color: var(--primary-600); }
.toast.out { animation: fadeOut .2s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }

/* Misc */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .e { font-size: 44px; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.skel { border-radius: 12px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.month-nav b { font-size: 16px; }
.sum-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.sum-row small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.sum-row b { font-size: 14px; }
.sum-row .amount { white-space: normal; }
.search-bar { margin-bottom: 12px; }
.banner { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius); background: var(--primary-soft); color: var(--text); margin-bottom: 14px; }
.banner .t { flex: 1; font-size: 14px; }
.banner b { display: block; }
.contact-head { text-align: center; padding: 22px 16px; }
.contact-head .avatar { margin: 0 auto 10px; }
.contact-head h2 { margin: 0; font-size: 20px; }
.contact-head .bal { font-size: 30px; font-weight: 800; margin: 10px 0 2px; letter-spacing: -.02em; }
.action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 16px; }
.action-grid .btn { min-height: 52px; font-size: 15px; padding: 0 10px; white-space: nowrap; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { padding: 14px; }
.stat small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.stat b { font-size: 20px; }
.stat .amount { white-space: normal; }
@media (max-width: 420px) { .stat b { font-size: 16px; } .stat { padding: 12px; } }
.stat .sub { font-size: 12px; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.donut-wrap { display: grid; grid-template-columns: 170px 1fr; gap: 16px; align-items: center; }
@media (max-width: 420px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.blur-amounts .amount, .blur-amounts .hero .big { filter: blur(8px); }
.kbd { font: 600 11px ui-monospace, monospace; padding: 1px 5px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); }
.auth {
  min-height: 100dvh; display: grid; place-items: center; padding: calc(24px + var(--sat)) 20px calc(24px + var(--sab));
  background: radial-gradient(1000px 500px at 10% -10%, color-mix(in srgb, var(--primary) 22%, transparent), transparent), var(--bg);
}
.auth .box { width: 100%; max-width: 400px; }
.auth .logo { width: 76px; height: 76px; border-radius: 22px; box-shadow: var(--shadow-lg); display: block; margin: 0 auto 16px; }
.auth h1 { text-align: center; margin: 0 0 4px; font-size: 26px; }
.auth p.lead { text-align: center; color: var(--muted); margin: 0 0 22px; }
.auth .card { padding: 20px; }
.auth .skip { display: block; width: 100%; text-align: center; margin-top: 18px; font-size: 14px; font-weight: 600; color: var(--muted); }
.err { color: var(--expense); font-size: 13.5px; font-weight: 600; min-height: 20px; margin: -4px 4px 10px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-2); }
.only-desktop { display: none; }
@media (min-width: 900px) { .only-desktop { display: revert; } .only-mobile { display: none !important; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-weight: 600; }

/* Kirish sahifasi: qobiqsiz */
.no-shell .topbar, .no-shell .tabbar, .no-shell .fab, .no-shell .rail, .no-shell .ptr { display: none !important; }
.no-shell main#view { padding: 0; margin: 0; max-width: none; }
