:root {
  --bg: #07090f;
  --glass: rgba(18, 24, 38, 0.52);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  --text: #f4f7fb;
  --muted: #9aa6bd;
  --ink: #081018;
  --in: #6ee7b7;
  --out: #fda4af;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
html { font-size: 16px; }
html, body, .sheet, .modal-card, .sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(11, 15, 26, 0.55);
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(11, 15, 26, 0.55); }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border: 2px solid rgba(11, 15, 26, 0.55);
  border-radius: 8px;
}
::-webkit-scrollbar-corner { background: transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Myanmar Text", "Pyidaungsu", "Noto Sans Myanmar", sans-serif;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; touch-action: manipulation; }
button { cursor: pointer; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #b7adf8; outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.orb {
  position: absolute;
  width: 540px;
  height: 540px;
  border-radius: 50%;
  pointer-events: none;
}
.orb-indigo {
  top: -180px;
  left: -140px;
  opacity: 0.18;
  background: radial-gradient(circle, #4338ca 0%, rgba(67, 56, 202, 0) 68%);
}
.orb-teal {
  top: 16%;
  right: -200px;
  opacity: 0.15;
  background: radial-gradient(circle, #06b6d4 0%, rgba(6, 182, 212, 0) 68%);
}
.orb-emerald {
  bottom: -180px;
  left: 24%;
  opacity: 0.12;
  background: radial-gradient(circle, #34d399 0%, rgba(52, 211, 153, 0) 68%);
}

.shell { position: relative; z-index: 1; min-height: 100dvh; }
.sidebar, #sidebar {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 22px 14px;
  border-right: 1px solid var(--glass-border);
  overflow: auto;
  background: rgba(18, 24, 38, 0.42);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.brand { padding: 6px 12px 16px; }
.brand strong { display: block; font-size: 18px; letter-spacing: -0.02em; }
.brand span { color: var(--muted); font-size: 12px; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0 12px;
}
.nav-btn.active {
  background: linear-gradient(135deg, #7c6bff 0%, #3ddec0 100%);
  color: var(--ink);
  font-weight: 700;
}
.nav-btn svg { flex: none; }
.nav-btn span { line-height: 1.2; }

.content {
  min-width: 0;
  padding: 0 16px calc(84px + env(safe-area-inset-bottom));
}
.page {
  width: min(1160px, 100%);
  margin: 0 auto;
}
.topbar, #topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  margin: 0 0 12px;
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
  background: rgba(18, 24, 38, 0.62);
  border-bottom: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.month-switch { display: flex; align-items: center; gap: 2px; min-width: 0; }
.month-label {
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 4px;
}
.top-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.icon-btn, .fx-badge {
  min-width: 42px;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}
.icon-btn { width: 42px; padding: 0; }
.fx-badge {
  padding: 0 10px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.stream-grid { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
.card {
  min-width: 0;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--glass-highlight);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.hero { position: relative; }
.hero::before {
  content: "";
  position: absolute;
  top: 0;
  left: 18px;
  right: 18px;
  height: 2px;
  border-radius: 2px;
  background: rgba(167, 196, 255, 0.72);
  pointer-events: none;
}
.kpi-label { color: var(--muted); font-size: 13px; }
.kpi-value { margin: 6px 0 0; font-size: 28px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; }
.hero .kpi-value { font-size: 40px; }
.sub { display: flex; flex-wrap: wrap; gap: 8px 14px; margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.sub b { color: var(--text); font-weight: 600; }
.split { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.split-row, .bar-row { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; min-width: 0; }
.split-row {
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  padding: 8px 10px;
}
.split-row span, .bar-name { min-width: 0; overflow-wrap: anywhere; }
.net {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.net strong { font-size: 20px; }
.pos { color: var(--in); }
.neg { color: var(--out); }
.amt-in { color: var(--in); }
.amt-out { color: var(--out); }
.fx-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 0 6px;
  min-height: 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 11px;
  vertical-align: 1px;
}
.bar-track { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; margin-top: 6px; }
.bar-fill { height: 100%; border-radius: 99px; }
.banner {
  border-color: rgba(245, 158, 11, 0.38);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 220, 160, 0.28);
  margin-bottom: 12px;
}
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  color: #ffd98a;
  font-size: 11px;
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  padding: 10px;
  margin-top: 8px;
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  min-width: 0;
}
.row-main { flex: 1; min-width: 140px; }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-meta { color: var(--muted); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; margin-left: auto; max-width: 100%; }
.row-amt { font-size: 14px; text-align: right; overflow-wrap: anywhere; }
.row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  font-size: 11px;
  margin-right: 4px;
}
.pill-income { color: var(--in); }
.pill-expense { color: var(--out); }
.pill-pending { color: #ffe3a3; }
.pill-paid { color: var(--muted); }
.pill-auto { color: #c4b5fd; border-color: rgba(167, 139, 250, 0.45); }
.pill-sync { color: #7dd3fc; border-color: rgba(125, 211, 252, 0.45); }
.filters { display: flex; gap: 8px; overflow: auto; padding-bottom: 8px; margin-bottom: 4px; }
.filters .chip { flex: none; }
.ledger-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.ledger-tools input, .ledger-tools select {
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  padding: 0 12px;
  font-size: 16px;
}
.ledger-tools input { flex: 1; min-width: 0; }
.ledger-tools select { max-width: 46%; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 14px;
  min-height: 42px;
}
.check-row input { width: 20px; height: 20px; margin-top: 2px; flex: none; }
.presets { display: flex; gap: 8px; overflow: auto; padding-bottom: 2px; }
.presets .chip { flex: none; }

.btn, .chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  color: inherit;
  text-decoration: none;
  font-size: 14px;
}
.btn-primary, .fab {
  border: 0;
  background: linear-gradient(135deg, #7c6bff 0%, #3ddec0 100%);
  color: var(--ink);
  font-weight: 700;
}
.btn.top-add { display: inline-flex; min-width: 48px; min-height: 42px; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--out); border-color: rgba(253, 164, 175, 0.4); }
.btn-ok { color: var(--in); border-color: rgba(110, 231, 183, 0.4); }
.btn[disabled] { opacity: 0.45; }
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.sheet .actions, .modal-card .actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  margin-top: 16px;
  padding: 12px 0 calc(8px + env(safe-area-inset-bottom));
  background: rgba(11, 15, 26, 0.94);
  border-top: 1px solid rgba(255, 255, 255, 0.10);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.actions .btn { flex: 0 0 auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2, .section-title { margin: 0; font-size: 16px; }
.section-head .btn { flex: none; }
.help { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.empty { padding: 12px 0; color: var(--muted); display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.boot { color: var(--muted); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border-radius: 999px; padding: 0 12px; }
.chip.on { background: #f4f6fb; color: #12141c; border-color: #f4f6fb; }
.chip.hide { display: none; }
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
}
.seg button {
  min-height: 42px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
}
.seg button.on { background: #f4f6fb; color: #12141c; font-weight: 700; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 12px;
  font-size: 16px;
}
.amount-field input { font-size: 32px; font-weight: 650; letter-spacing: -0.03em; }
textarea { min-height: 72px; resize: vertical; }
.preview { min-height: 1.4em; font-size: 18px; margin: 8px 0 0; }
.secret, pre {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.03);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12px;
}
.copy-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.project-dot { width: 8px; height: 8px; border-radius: 99px; display: inline-block; margin-right: 6px; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet, .modal-card {
  width: min(480px, 100%);
  max-height: min(92dvh, 860px);
  overflow: auto;
  background: rgba(18, 24, 38, 0.72);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-highlight);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-radius: 22px 22px 0 0;
  padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
}
.grabber { width: 40px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.16); margin: 2px auto 12px; }
h2 { margin: 0; font-size: 18px; }

.tabbar, #tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  height: calc(64px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(7, 9, 15, 0.72);
  border-top: 1px solid var(--glass-border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}
.tab {
  min-height: 48px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  font-size: 10px;
  line-height: 1.15;
  text-align: center;
}
.tab span { max-width: 100%; white-space: normal; }
.tab.active {
  color: var(--ink);
  font-weight: 700;
  background: linear-gradient(135deg, #7c6bff 0%, #3ddec0 100%);
  border-radius: 12px;
  margin: 6px 3px;
  min-height: 44px;
}

.lock {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#lock { position: relative; z-index: 80; }
.lock-card { width: min(360px, 100%); text-align: center; }
.dots { letter-spacing: 0.4em; font-size: 22px; min-height: 32px; margin: 12px 0; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pad button { min-height: 52px; border-radius: 14px; border: 1px solid var(--glass-border); background: rgba(255, 255, 255, 0.03); font-size: 20px; }
body.locked #shell, body.locked #tabbar { display: none; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(12px);
  max-width: calc(100% - 28px);
  padding: 10px 14px;
  border-radius: 12px;
  background: #f4f6fb;
  color: #12141c;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 70;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 768px) {
  html, body { overflow-x: hidden; }
  .shell, .content, .page, .tabbar, #tabbar { max-width: 100%; }
  .tabbar, #tabbar { display: grid; width: 100%; left: 0; right: 0; }
}

@media (min-width: 769px) {
  .shell {
    display: block;
    margin-left: 232px;
    width: calc(100% - 232px);
  }
  .sidebar, #sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 232px;
    z-index: 40;
  }
  .content { padding: 0; }
  .page {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0 28px 40px;
  }
  .tabbar, #tabbar { display: none; }
  .bento, .stream-grid { grid-template-columns: 1fr 1fr; gap: 14px; }
  .hero, .span-2 { grid-column: 1 / -1; }
  .backdrop { align-items: center; padding: 24px; }
  .sheet, .modal-card { border-radius: 22px; }
  #toast { bottom: 28px; }
}

@media (max-width: 380px) {
  .hero .kpi-value { font-size: 32px; }
  .fx-badge { font-size: 11px; padding: 0 8px; }
  .month-label { font-size: 14px; }
}
