/* Miya Mini App. Ranglar Telegram mavzusidan (--tg-theme-*); SDK boʻlmasa fallback qiymatlar.
   Hosila ranglar color-mix() bilan; eski WebView uchun oldin oddiy qiymat yoziladi. */

:root {
  color-scheme: light;
  --bg: var(--tg-theme-secondary-bg-color, #f5f4ef);
  --card: var(--tg-theme-section-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #1a1a17);
  --hint: var(--tg-theme-hint-color, #5e5d57);
  --accent: var(--tg-theme-button-color, #1e6b52);
  --accent-text: var(--tg-theme-button-text-color, #ffffff);
  --sep: var(--tg-theme-section-separator-color, #efede6);
  --danger: var(--tg-theme-destructive-text-color, #a33f17);
  --fill: #eceae3;
  --fill: color-mix(in srgb, var(--text) 8%, var(--bg));
  --border: #d6d4cb;
  --border: color-mix(in srgb, var(--hint) 40%, var(--card));
  --check: #a9a79e;
  --check: color-mix(in srgb, var(--hint) 75%, var(--card));
  --pill: rgba(26, 26, 23, 0.07);
  --ok: #1e6b52;
  --ok-bg: #e3efe9;
  --hero-text: #ffffff;
  --hero: #1a1a17;
  --hero: color-mix(in srgb, var(--text) 94%, var(--bg));
  --hero-box: #2a2a26;
  --hero-box: color-mix(in srgb, var(--hero-text) 12%, var(--hero));
  --hero-sub: #c9c7be;
  --hero-sub: color-mix(in srgb, var(--hero-text) 72%, var(--hero));
  --b0-bg: var(--ok-bg);
  --b0: var(--ok);
  --b1-bg: #e4eaf6;
  --b1: #24477f;
  --b2-bg: #fbf1dc;
  --b2: #7a4f00;
  --b3-bg: #f6e6e0;
  --b3: #8a3414;
  --top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
  --bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom, 0px));
}

:root[data-scheme="dark"] {
  color-scheme: dark;
  --bg: var(--tg-theme-secondary-bg-color, #141412);
  --card: var(--tg-theme-section-bg-color, #22221f);
  --text: var(--tg-theme-text-color, #f2f1ec);
  --hint: var(--tg-theme-hint-color, #a3a199);
  --accent: var(--tg-theme-button-color, #1e6b52);
  --sep: var(--tg-theme-section-separator-color, #2e2e2a);
  --danger: var(--tg-theme-destructive-text-color, #f08a62);
  --fill: #2e2e2a;
  --fill: color-mix(in srgb, var(--text) 10%, var(--bg));
  --border: #3a3a35;
  --border: color-mix(in srgb, var(--hint) 40%, var(--card));
  --check: #6e6c64;
  --check: color-mix(in srgb, var(--hint) 75%, var(--card));
  --pill: rgba(255, 255, 255, 0.1);
  --ok: #5cc29a;
  --ok-bg: #1f3a2f;
  --hero: #2a2a26;
  --hero: color-mix(in srgb, var(--text) 10%, var(--bg));
  --hero-box: #3a3a35;
  --hero-box: color-mix(in srgb, var(--hero-text) 10%, var(--hero));
  --hero-sub: #c9c7be;
  --hero-sub: color-mix(in srgb, var(--hero-text) 72%, var(--hero));
  --b1-bg: #1f2a40;
  --b1: #9db8f0;
  --b2-bg: #3a3018;
  --b2: #e5b85c;
  --b3-bg: #40261c;
  --b3: #f0a07f;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; color: inherit; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- qobiq ---- */
.app {
  position: relative;
  height: var(--tg-viewport-height, 100dvh);
  padding-top: var(--top);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}
.head { flex-shrink: 0; padding: 12px 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.head-sub { font-size: 13px; font-weight: 500; color: var(--hint); }
.head h1 { margin: 0; font-size: 28px; line-height: 34px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.miya-btn {
  flex-shrink: 0; height: 44px; padding: 0 14px 0 12px; border: none; border-radius: 22px;
  background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
}
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  padding: 4px 16px 20px; display: flex; flex-direction: column; gap: 16px;
}
.scroll::-webkit-scrollbar { display: none; }
/* a column that scrolls must not squeeze its children: they keep their own height */
.scroll > * { flex-shrink: 0; }
.scroll.gap10 { gap: 10px; }
.scroll.gap12 { gap: 12px; padding-top: 0; padding-bottom: 12px; }
.scroll.gap14 { gap: 14px; }
.scroll.tight { padding-bottom: 12px; }

.nav {
  flex-shrink: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--card); border-top: 1px solid var(--sep); padding: 6px 8px calc(6px + var(--bottom));
}
.nav button {
  height: 54px; border: none; background: transparent; color: var(--hint); font-size: 11px; font-weight: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 0;
}
.nav button[aria-current="page"] { color: var(--accent); font-weight: 600; }

.toast {
  position: absolute; left: 16px; right: 16px; bottom: calc(96px + var(--bottom)); z-index: 10;
  background: var(--text); color: var(--bg); border-radius: 12px; padding: 12px 14px; font-size: 14px; text-align: center;
}
.gate { height: var(--tg-viewport-height, 100dvh); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }
.gate h1 { margin: 0; font-size: 28px; }
.gate p { margin: 0; max-width: 28ch; color: var(--hint); font-size: 15px; line-height: 22px; }

/* ---- kartalar va qatorlar ---- */
.section { display: flex; flex-direction: column; gap: 8px; }
.section > h2 { margin: 0 4px; font-size: 13px; font-weight: 600; color: var(--hint); text-transform: uppercase; letter-spacing: 0.04em; }
.section > h2.danger { color: var(--danger); }
.group-title { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 4px 0; }
.group-title h2 { margin: 0; font-size: 15px; font-weight: 700; }
.group-title span { font-size: 12px; color: var(--hint); }
.card { background: var(--card); border-radius: 16px; display: flex; flex-direction: column; }
.panel { background: var(--card); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.panel h2 { margin: 0; font-size: 15px; font-weight: 700; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--sep); }
.row:first-child { border-top: none; }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.row-text { font-size: 15px; line-height: 20px; overflow-wrap: anywhere; }
.row-text.done { color: var(--hint); text-decoration: line-through; }
.row-meta { font-size: 12px; color: var(--hint); }
.row-meta.overdue { color: var(--danger); }
.empty-row { padding: 14px; font-size: 14px; color: var(--hint); }
.empty-card { background: var(--card); border-radius: 16px; padding: 20px; font-size: 14px; color: var(--hint); text-align: center; }

.check {
  width: 44px; height: 44px; margin: -10px -10px -10px -12px; border: none; background: transparent;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.check > span {
  width: 22px; height: 22px; border-radius: 7px; background: var(--card); border: 1.5px solid var(--check);
  display: flex; align-items: center; justify-content: center;
}
.check.on > span { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.icon-btn {
  width: 36px; height: 36px; border: none; border-radius: 10px; background: transparent; color: var(--hint);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ---- Bugun ---- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--card); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.stat b { font-size: 22px; font-weight: 700; }
.stat.money b { font-size: 15px; line-height: 27px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat small { font-size: 12px; color: var(--hint); }
.cta {
  height: 48px; border: none; border-radius: 14px; background: var(--hero); color: var(--hero-text);
  display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; font-weight: 600;
}

/* ---- segment, pill, forma ---- */
.seg-wrap { flex-shrink: 0; padding: 0 16px 10px; }
.seg { display: grid; gap: 4px; background: var(--fill); border-radius: 12px; padding: 4px; }
.seg.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg button {
  height: 36px; border: none; border-radius: 9px; padding: 0 2px; white-space: nowrap;
  background: transparent; color: var(--hint); font-size: 13px; font-weight: 500;
}
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
.seg.small { border-radius: 10px; padding: 3px; }
.seg.small button { height: 34px; border-radius: 8px; }
.pill {
  height: 32px; padding: 0 12px; border-radius: 16px; font-size: 13px; display: flex; align-items: center; gap: 6px;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
}
.pill.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.composer {
  flex-shrink: 0; padding: 10px 16px 12px; border-top: 1px solid var(--sep); background: var(--bg);
  display: flex; flex-direction: column; gap: 8px;
}
.line { display: flex; gap: 8px; }
.line.wrap { flex-wrap: wrap; gap: 6px; }
.input {
  flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 16px;
}
.input.small { height: 40px; border-radius: 10px; padding: 0 12px; }
/* an input that stands alone in a column keeps its height; flex: 1 is for inputs in a row */
.composer > .input, .form-card > .input { flex: none; }
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-icon {
  width: 44px; height: 44px; border: none; border-radius: 12px; background: var(--accent); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-icon.small { height: 40px; border-radius: 10px; }
.btn-wide { height: 46px; border: none; border-radius: 12px; background: var(--accent); color: var(--accent-text); font-size: 15px; font-weight: 600; }
.btn-outline { height: 44px; border-radius: 12px; border: 1px solid var(--border); background: transparent; color: var(--text); font-size: 14px; font-weight: 600; }
.btn-currency { height: 44px; min-width: 64px; border-radius: 12px; border: 1px solid var(--border); background: var(--bg); font-size: 14px; font-weight: 600; }
.form-card { background: var(--card); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.form-card h2 { margin: 0; font-size: 15px; font-weight: 700; }

/* ---- loyihalar ---- */
.proj {
  width: 100%; text-align: left; border: none; border-radius: 16px; padding: 14px; background: var(--card); color: var(--text);
  display: flex; flex-direction: column; gap: 10px;
}
.proj.done { flex-direction: row; align-items: center; gap: 12px; padding: 12px 14px; }
.proj-top { display: flex; align-items: center; gap: 12px; width: 100%; }
.proj-name { font-size: 16px; font-weight: 600; }
.proj-holat { font-size: 13px; line-height: 18px; color: var(--hint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.proj-bar { display: flex; align-items: center; gap: 10px; width: 100%; }
.proj-count { font-size: 12px; color: var(--hint); white-space: nowrap; }
.chev { color: var(--hint); flex-shrink: 0; }
.badge { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; flex-shrink: 0; }
.badge.b0 { background: var(--b0-bg); color: var(--b0); }
.badge.b1 { background: var(--b1-bg); color: var(--b1); }
.badge.b2 { background: var(--b2-bg); color: var(--b2); }
.badge.b3 { background: var(--b3-bg); color: var(--b3); }
.badge.muted { width: 36px; height: 36px; border-radius: 10px; background: var(--fill); color: var(--hint); }
.progress { flex: 1; height: 6px; border-radius: 3px; background: var(--fill); overflow: hidden; }
.progress > i { display: block; height: 6px; border-radius: 3px; background: var(--accent); }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.status {
  height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 600; display: flex; align-items: center;
  background: var(--ok-bg); color: var(--ok);
}
.status.off { background: var(--fill); color: var(--hint); }
.holat { font-size: 15px; line-height: 22px; white-space: pre-line; overflow-wrap: anywhere; }
.holat.empty { color: var(--hint); }
.fileinfo { font-size: 12px; color: var(--hint); }
.toggle-btn {
  align-self: flex-start; height: 32px; margin-left: -4px; padding: 0 8px; border: none; border-radius: 8px; background: transparent;
  display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--hint); text-transform: uppercase; letter-spacing: 0.04em;
}
.toggle-btn svg { transition: transform 0.15s; }
.toggle-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.add-line { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--sep); }
.add-line.top { border-top: none; border-bottom: 1px solid var(--sep); }
.add-line.top:last-child { border-bottom: none; }
.btn-icon.outline { border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.prog-icon { width: 40px; height: 40px; border-radius: 12px; background: var(--fill); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.prog-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.row > .pill { flex-shrink: 0; }
.note { display: flex; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--sep); }
.note:first-child { border-top: none; }
.note-date { width: 52px; flex-shrink: 0; font-size: 12px; line-height: 20px; color: var(--hint); }
.note-body { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 6px; font-size: 14px; line-height: 20px; overflow-wrap: anywhere; }
.note-body.file { color: var(--accent); font-weight: 500; }
.note-body svg { color: var(--accent); margin-top: 3px; flex-shrink: 0; }

/* ---- chat ---- */
.chat-list {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  padding: 8px 16px; display: flex; flex-direction: column-reverse; gap: 8px;
}
.chat-list::-webkit-scrollbar { display: none; }
.bubble { flex-shrink: 0; max-width: 82%; padding: 10px 14px; font-size: 15px; line-height: 21px; white-space: pre-line; overflow-wrap: anywhere; }
.bubble.me { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-radius: 18px 18px 6px 18px; }
.bubble.bot { align-self: flex-start; background: var(--card); color: var(--text); border-radius: 18px 18px 18px 6px; }
.bubble.typing { display: flex; align-items: center; gap: 10px; padding: 12px 16px; }
.bubble.typing small { color: var(--hint); font-size: 12px; line-height: 16px; overflow-wrap: anywhere; }
.dots { display: flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 4px; background: var(--hint); animation: dots 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.2s; }
.dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes dots { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dots i { animation: none; opacity: 0.6; } }
.chips { flex-shrink: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 6px 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); font-size: 13px; white-space: nowrap;
}
.chat-bar { flex-shrink: 0; display: flex; gap: 8px; align-items: center; padding: 8px 16px 12px; }
/* with the keyboard up the viewport is short: the bottom bar steps aside for the input */
.app:has(.chat-bar input:focus) .nav { display: none; }
.input.round { border-radius: 22px; padding: 0 16px; }
.btn-icon.round { border-radius: 22px; }
.btn-icon:disabled { opacity: 0.4; cursor: default; }

/* ---- gʻoyalar ---- */
.idea { background: var(--card); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.idea-top { display: flex; gap: 12px; align-items: flex-start; }
.idea-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--b2-bg); color: var(--b2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.idea-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.idea-title { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.idea-note { font-size: 14px; line-height: 20px; color: var(--hint); overflow-wrap: anywhere; }
.idea-date { font-size: 12px; color: var(--hint); }
.idea-actions { display: flex; gap: 8px; }
.btn-sm { height: 36px; padding: 0 12px; border: none; border-radius: 10px; font-size: 13px; font-weight: 600; background: var(--accent); color: var(--accent-text); }
.btn-sm.outline { border: 1px solid var(--border); background: var(--bg); color: var(--text); }
.btn-sm.ghost { background: transparent; color: var(--hint); font-weight: 500; }

/* ---- pul ---- */
.hero { background: var(--hero); color: var(--hero-text); border-radius: 20px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.hero-top { display: flex; flex-direction: column; gap: 4px; }
.hero-sub { font-size: 13px; color: var(--hero-sub); }
.hero-big { font-size: 30px; line-height: 36px; font-weight: 700; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.hero-usd { font-size: 14px; color: var(--hero-sub); }
.hero-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.hero-box { background: var(--hero-box); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.hero-box small { font-size: 12px; color: var(--hero-sub); }
.hero-box b { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.cat { display: flex; flex-direction: column; gap: 6px; }
.cat-top { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.cat-top b { font-weight: 600; white-space: nowrap; }
.bar { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; }
.bar > i { display: block; height: 8px; border-radius: 4px; background: var(--accent); }
.entry { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--sep); }
.entry:first-child { border-top: none; }
.sign { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; flex-shrink: 0; background: var(--fill); color: var(--text); }
.sign.in { background: var(--ok-bg); color: var(--ok); }
.entry-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.entry-title { font-size: 15px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-sub { font-size: 12px; color: var(--hint); }
.entry-amount { font-size: 15px; font-weight: 600; white-space: nowrap; }
.entry-amount.in { color: var(--ok); }
