/* ============================================================
   RohApp — Sovereign Financial Intelligence
   Theme: Emerald (#064E3B) & Gold (#D97706) | RTL Arabic
   ============================================================ */

:root {
  --emerald-950: #03251c;
  --emerald-900: #052e22;
  --emerald: #064e3b;
  --emerald-600: #0b6b52;
  --emerald-500: #12876a;
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.14);
  --gold-line: rgba(217, 119, 6, 0.35);
  --sand: #f6f4ef;
  --paper: #ffffff;
  --ink: #12211c;
  --muted: #5a6b63;
  --line: rgba(6, 78, 59, 0.12);
  --line-strong: rgba(6, 78, 59, 0.22);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.1);
  --ok: #047857;
  --ok-soft: rgba(4, 120, 87, 0.1);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(3, 37, 28, 0.05), 0 8px 24px rgba(3, 37, 28, 0.06);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}

/* Dark theme overrides */
[data-theme="dark"] {
  --emerald-950: #0a1f18;
  --emerald-900: #0f2a20;
  --emerald: #12876a;
  --emerald-600: #0b6b52;
  --emerald-500: #10b981;
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.16);
  --gold-line: rgba(245, 158, 11, 0.4);
  --sand: #0a1f18;
  --paper: #0f2a20;
  --ink: #e8f0ec;
  --muted: #8fa89d;
  --line: rgba(246, 244, 239, 0.12);
  --line-strong: rgba(246, 244, 239, 0.22);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --shadow: 0 1px 2px rgba(0,0,0,0.3), 0 8px 24px rgba(0,0,0,0.4);
  color-scheme: dark;
}
/* Ocean Blue theme (light base, ocean blue & signature gold) */
[data-accent="ocean"][data-theme="light"] {
  --emerald-950: #0c2a4a;
  --emerald-900: #123a63;
  --emerald: #1d6fa5;
  --emerald-600: #0b8cc9;
  --emerald-500: #38bdf8;
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.14);
  --gold-line: rgba(217, 119, 6, 0.38);
  --sand: #f0f7fc;
  --paper: #ffffff;
  --ink: #0f2740;
  --muted: #5b7a99;
  --line: rgba(29, 111, 165, 0.12);
  --line-strong: rgba(29, 111, 165, 0.22);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.1);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.1);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(12, 42, 74, 0.06), 0 8px 24px rgba(12, 42, 74, 0.08);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: light;
}
/* Burgundy theme (light base, burgundy & signature gold) */
[data-accent="burgundy"][data-theme="light"] {
  --emerald-950: #3b0a0a;
  --emerald-900: #5a1212;
  --emerald: #7f1d1d;
  --emerald-600: #9f2424;
  --emerald-500: #c24141;
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.14);
  --gold-line: rgba(217, 119, 6, 0.38);
  --sand: #fbf2f2;
  --paper: #ffffff;
  --ink: #2a0f0f;
  --muted: #7a5b5b;
  --line: rgba(127, 29, 29, 0.12);
  --line-strong: rgba(127, 29, 29, 0.22);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.1);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.1);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(59, 10, 10, 0.06), 0 8px 24px rgba(59, 10, 10, 0.08);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: light;
}
/* Royal Purple theme (light base, royal purple & signature gold) */
[data-accent="purple"][data-theme="light"] {
  --emerald-950: #2e1065;
  --emerald-900: #3b1578;
  --emerald: #6d28d9;
  --emerald-600: #7c3aed;
  --emerald-500: #8b5cf6;
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.14);
  --gold-line: rgba(217, 119, 6, 0.38);
  --sand: #f5f0fc;
  --paper: #ffffff;
  --ink: #1f1033;
  --muted: #6b5b7a;
  --line: rgba(109, 40, 217, 0.12);
  --line-strong: rgba(109, 40, 217, 0.22);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.1);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.1);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(46, 16, 101, 0.06), 0 8px 24px rgba(46, 16, 101, 0.08);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: light;
}
/* Ocean Blue dark variant (midnight ocean & signature gold) */
[data-accent="ocean"][data-theme="dark"] {
  --emerald-950: #07192b;
  --emerald-900: #0c253d;
  --emerald: #0284c7;
  --emerald-600: #0369a1;
  --emerald-500: #38bdf8;
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.16);
  --gold-line: rgba(245, 158, 11, 0.42);
  --sand: #07192b;
  --paper: #0c253d;
  --ink: #e2f1fc;
  --muted: #88a8c4;
  --line: rgba(226, 241, 252, 0.12);
  --line-strong: rgba(226, 241, 252, 0.24);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.45);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: dark;
}
/* Burgundy dark variant (deep wine & signature gold) */
[data-accent="burgundy"][data-theme="dark"] {
  --emerald-950: #22080d;
  --emerald-900: #320e16;
  --emerald: #9f1239;
  --emerald-600: #881337;
  --emerald-500: #f43f5e;
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.16);
  --gold-line: rgba(245, 158, 11, 0.42);
  --sand: #22080d;
  --paper: #320e16;
  --ink: #fce7eb;
  --muted: #c49ba3;
  --line: rgba(252, 231, 235, 0.12);
  --line-strong: rgba(252, 231, 235, 0.24);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.45);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: dark;
}
/* Royal Purple dark variant (deep royal violet & signature gold) */
[data-accent="purple"][data-theme="dark"] {
  --emerald-950: #150a2a;
  --emerald-900: #21113f;
  --emerald: #6d28d9;
  --emerald-600: #5b21b6;
  --emerald-500: #a78bfa;
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.16);
  --gold-line: rgba(245, 158, 11, 0.42);
  --sand: #150a2a;
  --paper: #21113f;
  --ink: #efe9fe;
  --muted: #a898c9;
  --line: rgba(239, 233, 254, 0.12);
  --line-strong: rgba(239, 233, 254, 0.24);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.45);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: dark;
}

/* Teal theme (light base, teal & signature gold) */
[data-accent="teal"][data-theme="light"] {
  --emerald-950: #042f2e;
  --emerald-900: #0a3d3a;
  --emerald: #0d9488;
  --emerald-600: #0f766e;
  --emerald-500: #14b8a6;
  --gold: #d97706;
  --gold-soft: rgba(217, 119, 6, 0.14);
  --gold-line: rgba(217, 119, 6, 0.38);
  --sand: #f0fdfa;
  --paper: #ffffff;
  --ink: #042f2e;
  --muted: #4a7c78;
  --line: rgba(13, 148, 136, 0.12);
  --line-strong: rgba(13, 148, 136, 0.22);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.1);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.1);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(4, 47, 46, 0.06), 0 8px 24px rgba(4, 47, 46, 0.08);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: light;
}
/* Amber theme (light base, amber & signature gold) */
[data-accent="amber"][data-theme="light"] {
  --emerald-950: #451a03;
  --emerald-900: #78350f;
  --emerald: #d97706;
  --emerald-600: #b45309;
  --emerald-500: #f59e0b;
  --gold: #92400e;
  --gold-soft: rgba(146, 64, 14, 0.14);
  --gold-line: rgba(146, 64, 14, 0.38);
  --sand: #fffbeb;
  --paper: #ffffff;
  --ink: #451a03;
  --muted: #78350f;
  --line: rgba(180, 83, 9, 0.12);
  --line-strong: rgba(180, 83, 9, 0.22);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.1);
  --ok: #059669;
  --ok-soft: rgba(5, 150, 105, 0.1);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(69, 26, 3, 0.06), 0 8px 24px rgba(69, 26, 3, 0.08);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: light;
}
/* Teal dark variant */
[data-accent="teal"][data-theme="dark"] {
  --emerald-950: #021a19;
  --emerald-900: #042f2e;
  --emerald: #2dd4bf;
  --emerald-600: #14b8a6;
  --emerald-500: #5eead4;
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.16);
  --gold-line: rgba(245, 158, 11, 0.42);
  --sand: #021a19;
  --paper: #042f2e;
  --ink: #e6fffa;
  --muted: #7ab8b3;
  --line: rgba(230, 255, 250, 0.12);
  --line-strong: rgba(230, 255, 250, 0.24);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.45);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: dark;
}
/* Amber dark variant */
[data-accent="amber"][data-theme="dark"] {
  --emerald-950: #1c0a00;
  --emerald-900: #291200;
  --emerald: #f59e0b;
  --emerald-600: #d97706;
  --emerald-500: #fbbf24;
  --gold: #fcd34d;
  --gold-soft: rgba(252, 211, 77, 0.16);
  --gold-line: rgba(252, 211, 77, 0.42);
  --sand: #1c0a00;
  --paper: #291200;
  --ink: #fef3c7;
  --muted: #d4a017;
  --line: rgba(254, 243, 199, 0.12);
  --line-strong: rgba(254, 243, 199, 0.24);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.12);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.45);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: dark;
}
/* Voice amplitude visualizer bars inside #actionBtn.listening */
.voice-bars {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2.5px;
  height: 18px;
}
.voice-bars i {
  display: block;
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: currentColor;
  animation: voiceWave 0.75s ease-in-out infinite alternate;
}
.voice-bars i:nth-child(2) { animation-delay: 0.15s; height: 14px; }
.voice-bars i:nth-child(3) { animation-delay: 0.3s; height: 10px; }
.voice-bars i:nth-child(4) { animation-delay: 0.45s; height: 16px; }
@keyframes voiceWave {
  0% { transform: scaleY(0.45); opacity: 0.75; }
  100% { transform: scaleY(1.25); opacity: 1; }
}
/* Rank 3 Pro CFO: Royal Gold dark variant */
[data-accent="royal-gold"][data-theme="dark"] {
  --emerald-950: #0c0902;
  --emerald-900: #1a1305;
  --emerald: #d4af37;
  --emerald-600: #b8860b;
  --emerald-500: #f3e5ab;
  --gold: #ffd700;
  --gold-soft: rgba(212, 175, 55, 0.18);
  --gold-line: rgba(212, 175, 55, 0.48);
  --sand: #0c0902;
  --paper: #171104;
  --ink: #fdf6e2;
  --muted: #c5a059;
  --line: rgba(212, 175, 55, 0.16);
  --line-strong: rgba(212, 175, 55, 0.32);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, 0.14);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,0.5), 0 8px 24px rgba(0,0,0,0.6);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: dark;
}
/* Rank 3 Pro CFO: Cyberpunk dark variant */
[data-accent="cyberpunk"][data-theme="dark"] {
  --emerald-950: #070514;
  --emerald-900: #110b29;
  --emerald: #00f5d4;
  --emerald-600: #00bbf9;
  --emerald-500: #72efdd;
  --gold: #ff2a85;
  --gold-soft: rgba(255, 42, 133, 0.18);
  --gold-line: rgba(255, 42, 133, 0.48);
  --sand: #070514;
  --paper: #110b29;
  --ink: #eef9ff;
  --muted: #9b87f5;
  --line: rgba(0, 245, 212, 0.16);
  --line-strong: rgba(0, 245, 212, 0.32);
  --danger: #ff4d6d;
  --danger-soft: rgba(255, 77, 109, 0.14);
  --ok: #00f5d4;
  --ok-soft: rgba(0, 245, 212, 0.14);
  --radius: 18px;
  --shadow: 0 1px 2px rgba(0,0,0,0.5), 0 8px 24px rgba(0,0,0,0.65);
  --tabbar-h: 62px;
  --font: "MoneyRiyal", "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
  color-scheme: dark;
}
/* Dark-mode overrides for hardcoded accent colors */
[data-theme="dark"] .draft-title,
[data-theme="dark"] .draft-badge,
[data-theme="dark"] .badge.soon,
[data-theme="dark"] .alert.gold,
[data-theme="dark"] .modal-title,
[data-theme="dark"] .kpi .k-value { color: var(--gold); }
[data-theme="dark"] .alert.ok { color: var(--ok); }
[data-theme="dark"] .msg.sys .bubble,
[data-theme="dark"] .ai-badge { color: var(--gold); }
[data-theme="dark"] .ai-hint { color: var(--gold); }
[data-theme="dark"] .alert.danger,
[data-theme="dark"] .fraud-high { color: #fca5a5; }
[data-theme="dark"] body {
  background: var(--sand);
  color: var(--ink);
}
[data-theme="dark"] .modal input,
[data-theme="dark"] .modal select,
[data-theme="dark"] .modal textarea {
  background: var(--sand);
  color: var(--ink);
  border-color: var(--line-strong);
}
/* Ensure the more specific text-input rule (monospace LTR fields) also
   adapts to dark mode — it overrides the generic rule above by specificity. */
[data-theme="dark"] .modal input[type="text"] {
  background: var(--sand);
  color: var(--ink);
  border-color: var(--line-strong);
}
[data-theme="dark"] .tabbar {
  background: linear-gradient(180deg, var(--emerald-900) 0%, var(--emerald-950) 100%);
  border-top: 1px solid var(--gold-line);
  box-shadow: 0 -6px 22px rgba(0, 0, 0, 0.35);
}
@media all and (display-mode: standalone) {
  .topbar {
    padding-top: max(10px, env(safe-area-inset-top, 0px));
  }
  .tabbar {
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(58px + env(safe-area-inset-bottom, 0px));
  }
}
[data-theme="dark"] .tab { color: var(--muted); }
[data-theme="dark"] .tab.active { color: var(--gold); background: var(--gold-soft); }
[data-theme="dark"] .tab.active::after { background: var(--gold); }
[data-theme="dark"] .toast { background: var(--paper); color: var(--ink); }

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--sand);
  color: var(--ink);
  font-size: calc(15px * var(--font-scale, 1));
  line-height: 1.55;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}

button:active {
  transform: scale(0.98);
}

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

/* ------------------------------------------------------------
   Top bar
   ------------------------------------------------------------ */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: linear-gradient(135deg, var(--emerald-950) 0%, var(--emerald) 70%, var(--emerald-600) 100%);
  color: #fff;
  box-shadow: 0 2px 14px rgba(3, 37, 28, 0.25);
  position: relative;
  z-index: 20;
}

.topbar::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  opacity: 0.85;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark svg { display: block; width: 28px; height: 28px; }
.brand-mark {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--gold-line);
  color: var(--gold);
  font-size: calc(16px * var(--font-scale, 1));
  line-height: 1;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  font-weight: 800;
  font-size: calc(17px * var(--font-scale, 1));
  line-height: 1.15;
  white-space: nowrap;
  margin: 0;
}

.brand-text small {
  overflow: hidden;
  font-weight: 500;
  font-size: calc(11px * var(--font-scale, 1));
  color: rgba(255, 255, 255, 0.85);
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 6px;
}

.ask-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.ask-btn:hover, .ask-btn:focus-visible { background: rgba(255, 255, 255, 0.18); }
.ask-btn .ui-icon { width: calc(18px * var(--font-scale, 1)); height: calc(18px * var(--font-scale, 1)); }

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: calc(17px * var(--font-scale, 1));
  color: inherit;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.15s ease;
}

.icon-btn[aria-pressed="true"] {
  background: var(--gold-soft);
  border-color: var(--gold-line);
  color: var(--gold);
}

/* ------------------------------------------------------------
   Views
   ------------------------------------------------------------ */
#views {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
}

.view {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  flex-direction: column;
}

.view.active {
  display: flex;
}

.scroll-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px calc(var(--tabbar-h) + 24px);
}

/* ------------------------------------------------------------
   Chat
   ------------------------------------------------------------ */
.chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  animation: rise 0.22s ease both;
  margin-bottom: 6px;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg.user {
  align-items: flex-end;
  max-width: 85%;
  margin-inline-start: auto;
}

.msg.bot,
.msg.sys {
  align-items: stretch;
}

.bubble {
  max-width: 92%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: calc(14px * var(--font-scale, 1));
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.user .bubble {
  background: linear-gradient(135deg, var(--emerald) 0%, var(--emerald-600) 100%);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 14px rgba(6, 78, 59, 0.2);
  max-width: 80%;
  padding: 8px 12px;
  font-size: calc(13.5px * var(--font-scale, 1));
}

.msg.bot .bubble {
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
  box-shadow: var(--shadow);
}

.msg.sys .bubble {
  background: var(--gold-soft);
  border: 1px dashed var(--gold-line);
  color: #7c4a04;
  font-size: calc(13px * var(--font-scale, 1));
  max-width: 100%;
}

.msg-time {
  font-size: calc(11px * var(--font-scale, 1));
  color: var(--muted);
  text-align: left;
  margin-top: 3px;
  padding: 0 4px;
  opacity: 0.85;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.msg.user .msg-time {
  text-align: right;
}
.sent-check {
  align-self: center;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(17px * var(--font-scale, 1));
  height: calc(17px * var(--font-scale, 1));
  border-radius: 50%;
  background: var(--emerald);
  color: #fff;
  font-size: calc(11px * var(--font-scale, 1));
  font-weight: 800;
  line-height: 1;
}
button.sent-check { border: 0; padding: 0; cursor: pointer; font-family: inherit; }
#composerChips.collapsed > .chip:not(.suggest-btn) { display: none; }
.chips.chips-tight.icon-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; gap: 4px; }
.chips.chips-tight.icon-chips .chip { flex: none; min-height: 26px; padding: 2px 8px; font-size: calc(11px * var(--font-scale, 1)); white-space: nowrap; }
.debt-icon { display: inline-flex; width: calc(20px * var(--font-scale, 1)); height: calc(20px * var(--font-scale, 1)); flex: none; }
.debt-icon .ui-icon { width: 100%; height: 100%; }
.modal-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt-grid .btn { min-width: 0; font-size: calc(12.5px * var(--font-scale, 1)); }
.modal-actions .btn > .ui-icon { flex: none; width: calc(16px * var(--font-scale, 1)); height: calc(16px * var(--font-scale, 1)); }
.radar-section-title { font-size: calc(12px * var(--font-scale, 1)); font-weight: 800; color: var(--muted); margin: 14px 2px 6px; }
.radar-toolbar { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; margin: 0 0 8px; }
.choice-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.choice-list li { font-size: calc(12.5px * var(--font-scale, 1)); padding: 4px 10px; border-radius: 8px; color: var(--muted); }
.choice-list li.picked { color: var(--ink); font-weight: 700; background: var(--gold-soft); }
.choice-list li.skipped { opacity: 0.6; }
.sent-check.waiting { background: #d97706; }
.sent-check.cancelled { background: #dc2626; }
.sent-check.form { background: #facc15; color: #422006; }

/* Local AI answer */
.msg.bot .bubble.ai-bubble {
  background: linear-gradient(160deg, var(--gold-soft) 0%, var(--paper) 45%);
  border: 1px solid var(--gold-line);
  border-inline-start: 3px solid var(--gold);
  max-width: 94%;
  box-shadow: 0 8px 22px rgba(217, 119, 6, 0.1);
}

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.ai-badge {
  font-size: calc(10.5px * var(--font-scale, 1));
  font-weight: 800;
  letter-spacing: 0.3px;
  color: #7c4a04;
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  border-radius: 999px;
  padding: 2px 8px;
}

.ai-model {
  font-size: calc(10px * var(--font-scale, 1));
  color: var(--muted);
  direction: ltr;
}

.ai-text {
  font-size: calc(14px * var(--font-scale, 1));
  line-height: 1.75;
}

.tts-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-inline-start: 4px;
  vertical-align: middle;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--emerald);
  cursor: pointer;
}

/* Shows only while the app is reading aloud, so the owner can stop it from
   anywhere in the chat without hunting for the message that started it. */
.tts-stop {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 13px;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 999px;
  background: var(--paper);
  color: var(--danger);
  font-family: inherit;
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 800;
  line-height: 1.6;
  cursor: pointer;
  box-shadow: var(--shadow);
  animation: ttsStopIn 0.16s ease-out;
}
.tts-stop[hidden] { display: none; }
.tts-stop::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
  animation: ttsStopPulse 1.1s ease-in-out infinite;
}
.tts-stop:active { transform: scale(0.97); }
@keyframes ttsStopIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}
@keyframes ttsStopPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
@media (prefers-reduced-motion: reduce) {
  .tts-stop, .tts-stop::before { animation: none; }
}
.tts-btn:hover, .tts-btn:focus-visible { background: var(--sand); }
.tts-btn .ui-icon { width: calc(18px * var(--font-scale, 1)); height: calc(18px * var(--font-scale, 1)); }

.ai-foot {
  margin-top: 6px;
  font-size: calc(10px * var(--font-scale, 1));
  color: var(--muted);
  direction: ltr;
  text-align: left;
}

.ai-hint {
  margin-top: 6px;
  font-size: calc(11px * var(--font-scale, 1));
  color: #8a3b12;
}

.msg.bot .bubble.ai-error {
  border-inline-start-color: #b45309;
  background: #fff8f1;
  box-shadow: none;
}

.ai-pending {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: calc(12.5px * var(--font-scale, 1));
  color: var(--muted);
}

.ai-pending span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: aiDot 1.1s infinite ease-in-out;
}

.ai-pending span:nth-child(2) {
  animation-delay: 0.18s;
}

.ai-pending span:nth-child(3) {
  animation-delay: 0.36s;
}

@keyframes aiDot {
  0%, 80%, 100% {
    opacity: 0.25;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}


/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.chips.chips-bar {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px 8px;
  margin-top: 0;
  border-top: 1px solid var(--line);
  background: var(--sand);
  scrollbar-width: none;
}
.chips.chips-bar[hidden] { display: none; }
.chips.chips-bar::-webkit-scrollbar { display: none; }

.more-chips { margin: 0 0 12px; }
.more-chips .chip { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.chips.chips-bar .chip.suggested {
  background: var(--gold-soft);
  border-color: var(--gold-line);
}
.chips.chips-bar .chip {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 3px 8px;
  font-size: calc(10.5px * var(--font-scale, 1));
  border-radius: 999px;
}

.chip {
  padding: 6px 10px;
  min-height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--sand);
  color: var(--emerald);
  font-size: calc(11px * var(--font-scale, 1));
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

/* Suggestions: compact and still easy to tap. */
.chips.chips-bar { gap: 6px; padding: 4px 8px; }
.chips.chips-bar .chip { min-height: 36px; padding: 3px 12px; border-color: var(--gold-line); background: var(--paper); color: var(--ink); font-size: calc(12px * var(--font-scale, 1)); font-weight: 600; }
.chips.chips-bar .chip.suggested { border-color: var(--gold); background: var(--gold-soft); color: var(--ink); }
.chips.chips-bar .chip:not(.more):active { background: var(--gold-soft); }
.chips.chips-bar .chip.more { font-weight: 700; color: var(--emerald); }
[data-theme="dark"] .chips.chips-bar .chip.more { color: var(--gold); }
.chips.chips-bar .chip.suggest-btn { display: inline-flex; align-items: center; justify-content: center; padding: 4px 10px; border-color: var(--emerald); background: var(--emerald); color: #fff; }
.chips.chips-bar .chip.suggest-btn .ui-icon { width: calc(15px * var(--font-scale, 1)); height: calc(15px * var(--font-scale, 1)); stroke-width: 4; }
.chips.chips-bar .chip.suggest-btn:active { background: var(--emerald-2, var(--emerald)); opacity: 0.85; }
[data-theme="dark"] .chips.chips-bar .chip.suggest-btn { color: #fff; }
/* Actions under a message: lighter than the message and the suggestions. */
.msg .chips { gap: 4px; }
.msg .chips .chip { min-height: 36px; padding: 3px 12px; border-color: var(--line-strong); background: var(--sand); color: var(--emerald); font-size: calc(12px * var(--font-scale, 1)); font-weight: 700; }
.msg .chips .chip:active { background: var(--gold-soft); }
[data-theme="dark"] .msg .chips .chip { border-color: var(--gold-line); background: var(--gold-soft); color: var(--gold); }
[data-theme="dark"] .msg .chips .chip:active { background: var(--gold-line); }
.chip:hover,
.chip:active {
  background: var(--gold-soft);
  border-color: var(--gold-line);
}

/* Draft confirmation card */
.draft-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 3px solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-top: 2px;
  width: 100%;
  box-sizing: border-box;
}

.draft-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.draft-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: calc(15px * var(--font-scale, 1));
  color: var(--emerald);
  letter-spacing: 0.2px;
}
.draft-title .glyph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--gold-soft); color: var(--gold);
  font-size: calc(16px * var(--font-scale, 1));
}

.draft-badge {
  font-size: calc(10.5px * var(--font-scale, 1));
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #8a4b04;
  border: 1px solid var(--gold-line);
}

.draft-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  margin-bottom: 6px;
  font-size: calc(11.5px * var(--font-scale, 1));
}
.draft-meta div {
  padding: 2px 0;
}
.draft-meta b {
  font-size: calc(12px * var(--font-scale, 1));
}

.draft-meta div {
  background: var(--sand);
  border-radius: 10px;
  padding: 6px 9px;
  color: var(--muted);
}

.draft-meta b {
  color: var(--ink);
  font-weight: 600;
}

.draft-lines {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 12px;
}

.draft-line {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  font-size: calc(12.5px * var(--font-scale, 1));
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.draft-line:first-child {
  border-top: 0;
}

.draft-rate,
.entry-rate {
  justify-content: center;
  color: var(--muted);
  background: var(--sand);
  font-size: calc(11px * var(--font-scale, 1));
  gap: 8px;
}
.draft-rate .rate-edit-btn {
  padding: 2px 6px;
  font-size: calc(11px * var(--font-scale, 1));
  border-radius: 4px;
}

.edit-equiv {
  margin: -4px 0 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--sand);
  color: var(--muted);
  font-size: calc(11.5px * var(--font-scale, 1));
  line-height: 1.7;
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.draft-actions .btn {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 8px;
  font-size: calc(11.5px * var(--font-scale, 1));
}
  font-size: calc(10px * var(--font-scale, 1));
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  flex: 0 0 auto;
}

.side.debit {
  background: var(--ok-soft);
  color: var(--ok);
}

.side.credit {
  background: var(--danger-soft);
  color: var(--danger);
}

.details {
  cursor: text;
  min-width: 20px;
  outline: none;
  border-bottom: 1px dashed var(--line);
  padding: 0 2px;
  text-align: center;
}
/* A draft line's note: its own full-width row under the line (side, account, amount on top),
   a soft field holding the text, a mic to say it and × to clear it. */
.draft-line.draft-line-note { grid-template-columns: auto 1fr auto; row-gap: 7px; }
.draft-line-note > .side { grid-column: 1; grid-row: 1; }
.draft-line-note > .accounts { grid-column: 2; grid-row: 1; min-width: 0; }
.draft-line-note > .amount { grid-column: 3; grid-row: 1; }
.draft-line-note > .note-field { grid-column: 1 / -1; grid-row: 2; }
.note-field {
  display: flex;
  align-items: center;
  gap: 2px;
  min-width: 0;
  min-height: calc(34px * var(--font-scale, 1));
  padding: 2px 4px;
  padding-inline-start: 11px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--sand);
  transition: border-color .15s, background-color .15s;
}
.note-field:focus-within { border-color: var(--emerald); background: var(--paper); }
[data-theme="dark"] .note-field:focus-within { border-color: var(--gold); }
[data-theme="dark"] .note-btn:hover, [data-theme="dark"] .note-btn:focus-visible { color: var(--gold); }
.note-field .details {
  flex: 1 1 auto;
  min-width: 0;
  border-bottom: 0;
  padding: 4px 0;
  text-align: start;
  color: var(--ink, inherit);
  font-size: calc(12.5px * var(--font-scale, 1));
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.note-field .details:empty::before { content: attr(data-placeholder); color: var(--muted); }
.note-field .details:empty { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.note-field .details:empty ~ .note-clear { display: none; }
.note-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(30px * var(--font-scale, 1));
  height: calc(30px * var(--font-scale, 1));
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.note-btn:hover, .note-btn:focus-visible { background: var(--line); color: var(--emerald); outline: none; }
.note-btn .ui-icon { width: calc(16px * var(--font-scale, 1)); height: calc(16px * var(--font-scale, 1)); }
.rate-inline:focus {
  border-color: var(--emerald);
  outline: none;
  box-shadow: 0 0 0 2px rgba(6, 78, 59, .15);
}
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1 1 0;
  padding: 11px 14px;
  min-height: 44px;
  border-radius: 12px;
  font-size: calc(14px * var(--font-scale, 1));
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  border: none;
  transition: filter 0.15s ease, background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }
.password-field {
  position: relative;
  display: flex;
  align-items: center;
}
.password-field input {
  flex: 1 1 0;
  padding-inline-end: 36px;
}
.password-toggle {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  color: var(--muted);
}

.btn.primary {
  background: linear-gradient(135deg, var(--emerald) 0%, var(--emerald-600) 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(6, 78, 59, 0.22);
}

.btn.gold {
  background: linear-gradient(135deg, var(--gold) 0%, #b45309 100%);
  color: #fff;
  box-shadow: 0 6px 16px rgba(217, 119, 6, 0.25);
}

.btn.ghost {
  background: var(--sand);
  color: var(--emerald);
  border: 1px solid var(--line-strong);
}

.btn.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(185, 28, 28, 0.25);
}

.group-total { margin-right: auto; margin-left: 12px; color: var(--emerald); font-size: calc(13px * var(--font-scale, 1)); font-weight: 800; }
.acc-glyph { display: inline-block; width: 1.4em; text-align: center; margin-inline-end: 4px; }
.account-row .r-value.zero { color: var(--muted); font-weight: 600; }
.group-add { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 50%; color: var(--emerald); }
.group-add:hover, .group-add:focus-visible { background: var(--gold-soft); }
.setting.stacked { flex-wrap: wrap; gap: 8px; }
.setting.stacked .s-main { flex: 1 0 100%; }
.theme-groups { display: flex; flex-direction: column; gap: 8px; }
.theme-group { display: flex; flex-direction: column; gap: 4px; }
.theme-group-label { font-size: calc(11px * var(--font-scale, 1)); color: var(--muted); font-weight: 700; padding-inline-start: 4px; }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; width: 100%; padding: 3px; border: 1px solid var(--line); border-radius: 13px; background: var(--sand); }
.segmented button { display: flex; align-items: center; justify-content: center; gap: 5px; min-width: 0; min-height: 40px; padding: 4px 6px; border-radius: 10px; color: var(--ink); font-size: calc(12.5px * var(--font-scale, 1)); font-weight: 600; }
@media (hover: hover) { .segmented button:not([aria-pressed="true"]):hover { background: var(--line); } }
.segmented button:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.segmented button[aria-pressed="true"] { background: var(--emerald); color: #fff; box-shadow: 0 1px 3px rgba(3, 37, 28, 0.2); }
.segmented .ui-icon { flex: none; width: calc(16px * var(--font-scale, 1)); height: calc(16px * var(--font-scale, 1)); }
.icon-chips .chip { display: inline-flex; align-items: center; gap: 5px; }
.icon-chips .ui-icon { flex: none; width: calc(15px * var(--font-scale, 1)); height: calc(15px * var(--font-scale, 1)); }
.app-lock { position: fixed; inset: 0; z-index: 9000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; background: var(--emerald-950); color: #fff; font-size: calc(16px * var(--font-scale, 1)); }
.app-lock[hidden] { display: none; }
.owner-gate-input { width: 100%; max-width: 280px; min-height: 44px; padding: 8px 12px; border: 1px solid rgba(255, 255, 255, 0.3); border-radius: 12px; background: rgba(255, 255, 255, 0.1); color: #fff; text-align: center; font-size: calc(15px * var(--font-scale, 1)); font-family: inherit; }
.owner-gate-input::placeholder { color: rgba(255, 255, 255, 0.65); }
.owner-gate-note { min-height: 1.5em; margin: 0; color: #fecaca; text-align: center; font-size: calc(13px * var(--font-scale, 1)); }
.app-lock .ui-icon { width: 56px; height: 56px; }
.app-lock .btn { flex: none; min-width: 160px; }
.btn-icon { gap: 6px; }
.btn-icon .ui-icon { flex: none; width: calc(17px * var(--font-scale, 1)); height: calc(17px * var(--font-scale, 1)); }

.btn.small {
  flex: 0 0 auto;
  padding: 8px 12px;
  min-height: 44px;
  font-size: calc(12.5px * var(--font-scale, 1));
  border-radius: 10px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Composer */
.account-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--sand);
  border-top: 1px solid var(--line);
  overflow-x: auto;
  white-space: nowrap;
}
.account-chips .ac-label {
  font-size: calc(11px * var(--font-scale, 1));
  color: var(--muted);
  font-weight: 700;
}
.acc-chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: calc(11.5px * var(--font-scale, 1));
  font-weight: 600;
  cursor: pointer;
  flex: 0 0 auto;
}
.acc-chip.active {
  background: var(--emerald);
  color: #fff;
  border-color: var(--emerald);
}

.date-chip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 6px;
  background: var(--sand);
  border-top: 1px solid var(--line);
}
.date-chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: calc(11.5px * var(--font-scale, 1));
  font-weight: 600;
  cursor: pointer;
}
.date-chip.clear {
  padding: 4px 8px;
  color: var(--danger);
}
.date-picker-hidden {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0;
  height: 0;
}

.composer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px 8px 6px;
  background: var(--sand);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 16px rgba(3, 37, 28, 0.06);
}
.input-wrap textarea {
  width: 100%;
  resize: none;
  min-height: 40px;
  padding: 10px 12px;
  font-size: calc(14px * var(--font-scale, 1));
  line-height: 1.4;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: inset 0 1px 2px rgba(3, 37, 28, 0.04);
  transition: height 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  overflow: hidden;
}
.input-wrap textarea:focus {
  border-color: var(--gold-line);
  box-shadow: inset 0 1px 2px rgba(3, 37, 28, 0.04), 0 0 0 3px var(--gold-soft);
}
.action-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--emerald);
  color: #fff;
  font-size: calc(16px * var(--font-scale, 1));
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 0;
  box-shadow: 0 4px 12px rgba(6, 78, 59, 0.25);
}
.composer-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-wrap {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
/* The placeholder only shows on an empty box, so this also follows text set by code. */
.clear-btn { position: absolute; top: 4px; inset-inline-end: 76px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); font-size: calc(13px * var(--font-scale, 1)); }
.clear-btn:hover { background: var(--sand); color: var(--ink); }
.input-wrap textarea:placeholder-shown ~ .clear-btn { display: none; }
.composer .input-wrap textarea { padding-inline-end: 78px; }
.composer .input-wrap textarea:not(:placeholder-shown) { padding-inline-end: 114px; }
.form-btn { position: absolute; top: 4px; inset-inline-end: 40px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--emerald); }
.form-btn:hover { background: var(--sand); }
.attach-btn { position: absolute; top: 4px; inset-inline-end: 4px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; font-size: calc(15px * var(--font-scale, 1)); }
.attach-btn:hover { background: var(--sand); }
.attach-chip { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; padding: 2px 4px 2px 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper); font-size: calc(12px * var(--font-scale, 1)); }
.attach-chip[hidden] { display: none; }
.attach-chip span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.attach-chip button { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); }
.attach-link { display: inline-flex; align-items: center; gap: 4px; min-height: 36px; margin-top: 4px; padding: 2px 10px; border-radius: 10px; background: rgba(127, 127, 127, 0.18); color: inherit; font-size: calc(12px * var(--font-scale, 1)); }
.entry-attach { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; font-size: calc(14px * var(--font-scale, 1)); }
.memo-field { position: relative; }
.memo-field input { width: 100%; padding-inline-end: 42px; box-sizing: border-box; }
.memo-attach { position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; min-height: 0; padding: 0; display: grid; place-items: center; border: 0; border-radius: 10px; background: transparent; color: inherit; font-size: calc(15px * var(--font-scale, 1)); cursor: pointer; opacity: 0.7; }
.memo-attach.has-file { opacity: 1; background: rgba(127, 127, 127, 0.18); }
.attachment-photo { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; background: #000; }
.input-hint {
  font-size: calc(10.5px * var(--font-scale, 1));
  color: var(--muted);
  padding: 2px 12px 0;
  min-height: 14px;
  text-align: right;
}
.input-hint.warn { color: var(--gold); }
.input-hint.ok { color: var(--ok); }
.autocomplete {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  margin-bottom: 6px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 50;
  padding: 4px;
}
.autocomplete[hidden] { display: none; }
.ac-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  min-height: 44px;
  border-radius: 10px;
  cursor: pointer;
  font-size: calc(13px * var(--font-scale, 1));
}
.ac-item:hover, .ac-item.active {
  background: var(--gold-soft);
}
.ac-text { color: var(--ink); font-weight: 600; }
.ac-hint {
  font-size: calc(10.5px * var(--font-scale, 1));
  color: var(--muted);
  background: var(--sand);
  padding: 2px 6px;
  border-radius: 999px;
}

.composer .icon-btn {
  flex: 0 0 auto;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--emerald);
  width: 44px;
  height: 44px;
  border-radius: 14px;
}

.composer textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  font-size: calc(14px * var(--font-scale, 1));
  line-height: 1.45;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.action-btn:active { transform: scale(0.96); }

.send-btn {
  flex: 0 0 auto;
  min-height: 44px;
  height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--emerald) 0%, var(--emerald-600) 100%);
  color: #fff;
  font-weight: 700;
  font-size: calc(13.5px * var(--font-scale, 1));
  box-shadow: 0 4px 12px rgba(6, 78, 59, 0.22);
}

/* ------------------------------------------------------------
   Cards & generic UI
   ------------------------------------------------------------ */
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 10px;
  font-size: calc(13px * var(--font-scale, 1));
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.2px;
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}

.hero {
  background: linear-gradient(135deg, var(--emerald-950) 0%, var(--emerald) 65%, var(--emerald-600) 100%);
  color: #fff;
  border: 0;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  border: 1px solid var(--gold-line);
  inset-inline-end: -70px;
  top: -80px;
  pointer-events: none;
}

.hero-label {
  font-size: calc(11.5px * var(--font-scale, 1));
  color: rgba(255, 255, 255, 0.66);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hero-value {
  font-size: calc(30px * var(--font-scale, 1));
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 2px 0 0;
  line-height: 1.2;
}

.amount {
  direction: ltr;
  unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  display: inline-block;
}

.hero-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.pill {
  font-size: calc(11.5px * var(--font-scale, 1));
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.9);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.pill.gold {
  background: var(--gold-soft);
  border-color: var(--gold-line);
  color: var(--gold);
}

.pill .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--gold);
  display: inline-block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  box-shadow: 0 1px 2px rgba(3, 37, 28, 0.03);
}

.kpi .k-label {
  font-size: calc(11px * var(--font-scale, 1));
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kpi .k-value {
  font-size: calc(18px * var(--font-scale, 1));
  font-weight: 800;
  margin-top: 2px;
  color: var(--emerald);
}

.kpi.warn .k-value {
  color: var(--danger);
}

.kpi.good .k-value {
  color: var(--ok);
}

/* progress */
.meter {
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-top: 8px;
}

.meter > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), #b45309);
  transition: width 0.4s ease;
}

.meter.good > i {
  background: linear-gradient(90deg, var(--emerald-500), var(--emerald));
}

.meter.bad > i {
  background: linear-gradient(90deg, #f59e0b, var(--danger));
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: calc(13.5px * var(--font-scale, 1));
}

.row:first-of-type {
  border-top: 0;
}

.row .r-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.row .r-title {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
}

.row .r-sub {
  font-size: calc(11px * var(--font-scale, 1));
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.row .r-value {
  font-weight: 700;
  white-space: nowrap;
}

.pos {
  color: var(--ok);
}
.pos::before {
  content: "▲\00a0";
  font-size: 0.8em;
  opacity: 0.85;
}
.neg {
  color: var(--danger);
}
.neg::before {
  content: "▼\00a0";
  font-size: 0.8em;
  opacity: 0.85;
}

.muted {
  color: var(--muted);
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 26px 14px;
  font-size: calc(13px * var(--font-scale, 1));
  line-height: 1.7;
}

.empty .glyph {
  display: block;
  font-size: calc(30px * var(--font-scale, 1));
  margin-bottom: 8px;
  color: var(--gold);
  opacity: 0.85;
}

.divider {
  height: 1px;
  background: var(--line);
  margin: 12px 0;
}

.badge {
  font-size: calc(10px * var(--font-scale, 1));
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--sand);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.badge.overdue {
  background: var(--danger-soft);
  border-color: rgba(185, 28, 28, 0.25);
  color: var(--danger);
}

.badge.soon {
  background: var(--gold-soft);
  border-color: var(--gold-line);
  color: #8a4b04;
}

.badge.ok {
  background: var(--ok-soft);
  border-color: rgba(4, 120, 87, 0.25);
  color: var(--ok);
}

/* alerts */
.alert {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: calc(12.5px * var(--font-scale, 1));
  border: 1px solid var(--line);
  background: var(--sand);
  margin-bottom: 8px;
}

.alert .a-glyph {
  flex: 0 0 auto;
  font-size: calc(14px * var(--font-scale, 1));
  line-height: 1.3;
}

.alert.danger {
  background: var(--danger-soft);
  border-color: rgba(185, 28, 28, 0.22);
  color: #7f1d1d;
}

.alert.gold {
  background: var(--gold-soft);
  border-color: var(--gold-line);
  color: #7c4a04;
}

.alert.ok {
  background: var(--ok-soft);
  border-color: rgba(4, 120, 87, 0.22);
  color: #065f46;
}

/* sparkline */
.spark {
  width: 100%;
  height: 74px;
  display: block;
  margin-top: 6px;
}

.spark-empty {
  font-size: calc(11.5px * var(--font-scale, 1));
  color: var(--muted);
  margin-top: 6px;
}

/* ------------------------------------------------------------
   Ledger
   ------------------------------------------------------------ */
 .filters {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 10px;
  padding-bottom: 2px;
  scrollbar-width: none;
  position: relative;
  padding-inline-end: 18px;
  -webkit-mask-image: linear-gradient(to right, transparent 0, #000 18px);
  mask-image: linear-gradient(to right, transparent 0, #000 18px);
}
.filters::-webkit-scrollbar { display: none; }
.filters .filter {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 5px 10px;
  font-size: calc(11.5px * var(--font-scale, 1));
}

.filter {
  padding: 6px 11px;
  min-height: 44px;
  border-radius: 999px;
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 600;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  color: var(--muted);
}

.filter.active {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #fff;
}

.search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  outline: none;
  font-size: calc(13px * var(--font-scale, 1));
}

.search input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.entry {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  margin-bottom: 9px;
  box-shadow: 0 1px 2px rgba(3, 37, 28, 0.03);
}

.entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.r-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.entry-head .r-main {
  gap: 1px;
}

.entry-title {
  font-weight: 700;
  font-size: calc(13.5px * var(--font-scale, 1));
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.entry-date {
  font-size: calc(10.5px * var(--font-scale, 1));
  color: var(--muted);
  white-space: nowrap;
}

.entry-amount {
  font-weight: 800;
  font-size: calc(15px * var(--font-scale, 1));
  color: var(--emerald);
  white-space: nowrap;
}

.entry-lines {
  margin-top: 8px;
  border-top: 1px dashed var(--line);
  padding-top: 7px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.entry-line {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: calc(11.5px * var(--font-scale, 1));
  color: var(--muted);
}

.entry-line b {
  color: var(--ink);
  font-weight: 600;
}

.entry-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}
.entry.compact {
  padding: 8px 12px;
}
.entry.compact .entry-head { margin: 0; }
.entry.compact .entry-date { font-size: calc(10px * var(--font-scale, 1)); }
.entry.compact .entry-amount { font-size: calc(13px * var(--font-scale, 1)); }

.link-btn {
  font-size: calc(11.5px * var(--font-scale, 1));
  color: var(--danger);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
}

.chat-date {
  position: sticky;
  top: 6px;
  z-index: 3;
  align-self: center;
  flex: 0 0 auto;
  padding: 4px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(3, 37, 28, 0.14);
  transition: opacity 0.2s ease;
}
.chat-date.stuck { opacity: 0; pointer-events: none; }
.chat.scrolling .chat-date.stuck { opacity: 1; }

.account-row {
  gap: 8px;
  padding: 10px 12px;
}
.account-row .r-main { flex: 1 1 0; }
.account-row .r-value { font-size: calc(15px * var(--font-scale, 1)); font-weight: 800; }
.row-menu-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  font-size: calc(20px * var(--font-scale, 1));
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
}
.topbar .row-menu-btn { width: 44px; height: 44px; color: #fff; }
.topbar .row-menu-btn:hover,
.topbar .row-menu-btn[aria-expanded="true"] { background: rgba(255, 255, 255, 0.18); }
.topbar .row-menu-btn[aria-pressed="true"] { background: var(--gold-soft); border-color: var(--gold-line); color: var(--gold); }
.global-search {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  padding: 10px 16px 0;
  background: rgba(246, 244, 239, 0.15);
  background: color-mix(in srgb, var(--sand) 15%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.global-search[hidden] { display: none; }
.global-search-box {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
}
.global-search-box:focus-within { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.global-search-box input { flex: 1 1 auto; min-width: 0; padding: 9px 8px; border: 0; outline: none; background: transparent; color: var(--ink); font-size: calc(14px * var(--font-scale, 1)); }
.global-search-box input:placeholder-shown { text-overflow: ellipsis; }
.global-search-box input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.global-search-btn { flex: 0 0 auto; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); font-size: calc(15px * var(--font-scale, 1)); }
.global-search-btn:hover,
.global-search-btn:focus-visible { background: var(--sand); color: var(--ink); }
.global-search-box { position: relative; }
.global-search-box input.global-search-date { position: absolute; inset-inline-end: 80px; bottom: 0; flex: none; width: 1px; height: 1px; padding: 0; opacity: 0; pointer-events: none; }
.global-search-day { flex: 0 0 auto; align-self: flex-start; margin: 8px 0 0; font-weight: 700; }
.global-search-results { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 10px 0; }
.search-group { margin-bottom: 12px; }
.search-group-title { margin: 4px 2px 6px; font-size: calc(12px * var(--font-scale, 1)); font-weight: 800; color: var(--muted); }
/* The panel behind them is see-through, so these stay solid to remain readable. */
.global-search-results .search-group-title { display: inline-block; margin: 4px 0 6px; padding: 2px 10px; border-radius: 999px; background: var(--paper); color: var(--ink); }
.global-search-results .search-result { margin-bottom: 4px; border: 1px solid var(--line); background: var(--paper); }
.global-search-results .search-result:hover,
.global-search-results .search-result:focus-visible { background: var(--sand); }
.global-search-results .modal-note { background: var(--paper); }
.search-result {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 7px 10px;
  border-radius: 10px;
  color: var(--ink);
  text-align: start;
}
.search-result:hover,
.search-result:focus-visible { background: var(--sand); }
.search-result.more { min-height: 44px; font-size: calc(12.5px * var(--font-scale, 1)); font-weight: 700; color: var(--emerald); }
.search-result-title { display: block; font-size: calc(13.5px * var(--font-scale, 1)); font-weight: 600; overflow-wrap: anywhere; }
.search-result-sub { display: block; margin-top: 1px; font-size: calc(11px * var(--font-scale, 1)); color: var(--muted); }
.masked-amount { cursor: pointer; padding: 2px 4px; margin: -2px -4px; border-radius: 6px; }
.masked-amount .eye-off { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -0.2em; }
.masked-amount.revealed { background: var(--gold-soft); }
.search-hit { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 10px; }
.row-menu-btn:hover,
.row-menu-btn[aria-expanded="true"] { background: var(--sand); }
.row-menu {
  position: fixed;
  z-index: 40;
  min-width: 150px;
  max-height: calc(100dvh - 80px);
  overflow-y: auto;
  padding: 6px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(3, 37, 28, 0.22);
}
.row-menu-item {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: calc(13.5px * var(--font-scale, 1));
  font-weight: 600;
  color: var(--ink);
  text-align: start;
}
.ui-icon { display: block; width: calc(20px * var(--font-scale, 1)); height: calc(20px * var(--font-scale, 1)); stroke-width: 3.8; }
.action-btn .ui-icon { width: calc(22px * var(--font-scale, 1)); height: calc(22px * var(--font-scale, 1)); stroke-width: 4; }
.attach-chip span .ui-icon, .attach-link .ui-icon { display: inline-block; width: 1.2em; height: 1.2em; vertical-align: -0.25em; }
.attach-btn { color: var(--muted); }
.menu-icon { display: inline-block; width: calc(20px * var(--font-scale, 1)); height: calc(20px * var(--font-scale, 1)); margin-inline-end: 10px; vertical-align: -0.35em; color: var(--emerald); }
[data-theme="dark"] .menu-icon { color: var(--gold); }
.row-menu-item:hover,
.row-menu-item:focus-visible { background: var(--sand); }
.row-menu-item.danger {
  margin-top: 6px;
  color: var(--danger);
  box-shadow: 0 -7px 0 -6px var(--line-strong);
}
.row-menu-item.danger:hover,
.row-menu-item.danger:focus-visible { background: var(--danger-soft); }

.link-btn:hover {
  background: var(--danger-soft);
}

/* ------------------------------------------------------------
   Settings — Sovereign Flagship Layout
   ------------------------------------------------------------ */
.settings-hero {
  background: linear-gradient(135deg, var(--emerald-950) 0%, var(--emerald) 60%, var(--emerald-600) 100%);
  color: #fff;
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--gold-line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.18);
}
[data-theme="dark"] .settings-hero {
  background: linear-gradient(135deg, var(--emerald-950) 0%, var(--emerald-900) 45%, var(--emerald) 100%);
  border: 1px solid var(--gold-line);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.settings-hero-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.settings-hero .profile-avatar {
  width: 52px;
  height: 52px;
  font-size: calc(20px * var(--font-scale, 1));
  border: 2px solid var(--gold-line);
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}
.settings-hero-info {
  flex: 1 1 0;
  min-width: 0;
}
.settings-hero-name {
  font-size: calc(15.5px * var(--font-scale, 1));
  font-weight: 800;
  color: #fff;
  line-height: 1.3;
}
.settings-hero-meta {
  font-size: calc(11.5px * var(--font-scale, 1));
  color: rgba(255, 255, 255, 0.85);
  margin-top: 2px;
}
.settings-hero-edit {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 700;
  cursor: pointer;
}
.settings-hero-license {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.settings-hero-plan {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 180px;
}
.settings-hero-plan-title {
  font-size: calc(12.5px * var(--font-scale, 1));
  font-weight: 800;
  color: var(--gold);
}
.settings-hero-plan-sub {
  font-size: calc(11px * var(--font-scale, 1));
  color: rgba(255, 255, 255, 0.88);
}
.settings-hero-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 3px;
}
.settings-hero-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 999px;
}
.settings-hero-cta {
  background: var(--gold);
  color: #111827;
  border: none;
  border-radius: 10px;
  padding: 7px 14px;
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 800;
  cursor: pointer;
}
.settings-quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.settings-quick-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 6px;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.settings-quick-tile:active,
.settings-quick-tile:hover {
  border-color: var(--emerald);
  transform: translateY(-1px);
}
.settings-quick-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--sand);
  color: var(--emerald);
}
[data-theme="dark"] .settings-quick-icon {
  background: var(--gold-soft);
  color: var(--gold);
}
.settings-quick-icon .ui-icon {
  width: calc(19px * var(--font-scale, 1));
  height: calc(19px * var(--font-scale, 1));
  stroke-width: 4;
}
.settings-hero-plan-title .ui-icon {
  width: calc(15px * var(--font-scale, 1));
  height: calc(15px * var(--font-scale, 1));
  vertical-align: -0.18em;
  margin-inline-end: 4px;
  stroke-width: 4.2;
}
.settings-quick-label {
  font-size: calc(11px * var(--font-scale, 1));
  font-weight: 700;
  text-align: center;
  line-height: 1.2;
}
.settings-toolbar {
  position: sticky;
  top: -10px;
  z-index: 6;
  background: var(--sand);
  margin: 0 -14px 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(3, 37, 28, 0.05);
}
.settings-search-box {
  position: relative;
  margin-bottom: 8px;
}
.settings-search-box input {
  width: 100%;
  height: 38px;
  padding: 6px 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: calc(12.5px * var(--font-scale, 1));
}
.settings-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.settings-chips::-webkit-scrollbar { display: none; }
.settings-chips .chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: calc(11.5px * var(--font-scale, 1));
  font-weight: 700;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--ink);
}
.settings-chips .chip .ui-icon {
  width: calc(13.5px * var(--font-scale, 1));
  height: calc(13.5px * var(--font-scale, 1));
  stroke-width: 4;
}
.settings-chips .chip:hover,
.settings-chips .chip.active {
  background: var(--emerald);
  color: #fff;
  border-color: var(--emerald);
}

.group-title {
  font-size: calc(13px * var(--font-scale, 1));
  font-weight: 800;
  letter-spacing: 0.2px;
  color: var(--emerald);
  margin: 16px 2px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  padding: 6px 8px;
  border-radius: 10px;
  background: transparent;
  transition: background 0.15s ease;
}
[data-theme="dark"] .group-title {
  color: var(--gold);
}
.group-title:hover {
  background: var(--gold-soft);
}
.gt-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--emerald);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
[data-theme="dark"] .gt-icon {
  color: var(--gold);
}
.gt-icon .ui-icon {
  width: calc(17px * var(--font-scale, 1));
  height: calc(17px * var(--font-scale, 1));
  stroke-width: 4;
}
.group-title::after {
  content: '▾';
  margin-inline-start: auto;
  font-size: calc(13px * var(--font-scale, 1));
  color: var(--muted);
  transition: transform 0.2s ease;
}
.group-title.collapsed::after {
  transform: rotate(90deg);
}
.group-title.collapsed + .card { display: none; }

.group-title:first-child {
  margin-top: 0;
}

#settingsBody .card {
  border-radius: 15px;
  border: 1px solid var(--line);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  overflow: hidden;
  margin-bottom: 10px;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  border-top: 1px solid var(--line);
  transition: background 0.15s ease;
}
.setting:hover { background: var(--sand); }

.setting:first-of-type {
  border-top: 0;
}

.setting .s-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 0;
  min-width: 0;
}

.setting .s-title {
  font-size: calc(13.5px * var(--font-scale, 1));
  font-weight: 700;
  color: var(--ink);
}

.setting .s-sub {
  font-size: calc(11.5px * var(--font-scale, 1));
  color: var(--muted);
  line-height: 1.4;
}

.settings-control {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: calc(12.5px * var(--font-scale, 1));
  font-weight: 600;
  min-height: 36px;
}

.switch {
  position: relative;
  width: 46px;
  height: 27px;
  border-radius: 999px;
  background: var(--line-strong);
  border: 0;
  flex: 0 0 auto;
  transition: background 0.18s ease;
  cursor: pointer;
}
.switch::before {
  content: '';
  position: absolute;
  inset: -8px;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  inset-inline-start: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}

.switch[aria-checked="true"] {
  background: var(--emerald);
}

.switch[aria-checked="true"]::after {
  transform: translateX(-19px);
}

[dir="rtl"] .switch[aria-checked="true"]::after {
  transform: translateX(-19px);
}

[dir="ltr"] .switch[aria-checked="true"]::after {
  transform: translateX(19px);
}

/* ------------------------------------------------------------
   Tab bar
   ------------------------------------------------------------ */
.tabbar {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 4px;
  background: linear-gradient(180deg, var(--paper) 0%, var(--sand) 100%);
  border-top: 1px solid var(--gold-line);
  padding: 5px 8px;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.08);
  position: relative;
  z-index: 5;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar::-webkit-scrollbar { display: none; }
/* Hide the bottom tab bar while the soft keyboard is open. */
body.keyboard-open .tabbar { display: none; }
.tab {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
}
.tab .tab-badge {
  position: absolute;
  top: 2px;
  inset-inline-end: calc(50% + 10px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--emerald);
  color: #fff !important;
  font-size: calc(9.5px * var(--font-scale, 1)) !important;
  font-weight: 800;
  line-height: 14px !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1.5px solid var(--paper, #fff);
  box-shadow: 0 2px 4px rgba(0,0,0,0.18);
  pointer-events: none;
  z-index: 2;
}
.tab .tab-badge[hidden] { display: none !important; }
.tab #botBadge {
  background: var(--emerald, #047857);
}
.tab #radarBadge {
  background: var(--danger, #dc2626);
}
.tab #radarBadge.warn {
  background: var(--gold, #d97706);
}

.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: calc(54px * var(--font-scale, 1));
  min-height: 44px;
  border-radius: 14px;
  font-size: calc(10.5px * var(--font-scale, 1));
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s ease, background 0.15s ease;
  position: relative;
}

.tab span {
  font-size: calc(19px * var(--font-scale, 1));
  line-height: 1;
}

.tab.active {
  color: var(--emerald);
  background: var(--gold-soft);
  font-weight: 800;
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: var(--gold);
}

.tab span svg { display: block; width: calc(22px * var(--font-scale, 1)); height: calc(22px * var(--font-scale, 1)); stroke-width: 3.6; }
.tab.active span svg { stroke-width: 4.4; }
.tab.active span {
  color: var(--gold);
}

/* ------------------------------------------------------------
   Toast
   ------------------------------------------------------------ */
.toast {
  position: fixed;
  z-index: 300;
  inset-inline: 16px;
  bottom: calc(var(--tabbar-h) + 16px);
  background: var(--emerald-950);
  color: #fff;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: calc(13px * var(--font-scale, 1));
  text-align: center;
  box-shadow: 0 10px 30px rgba(3, 37, 28, 0.35);
  border: 1px solid var(--gold-line);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 420px;
  margin-inline: auto;
  /* Icon, text, ×2 and the time bar along the bottom. */
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: start;
  line-height: 1.6;
  overflow: hidden;
  cursor: pointer;
}

/* Shown, it can be tapped to close. */
.toast.show {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.toast.error {
  background: #7f1d1d;
  border-color: rgba(255, 255, 255, 0.2);
}

.toast-icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(24px * var(--font-scale, 1));
  height: calc(24px * var(--font-scale, 1));
  border-radius: 50%;
  background: var(--gold);
  color: var(--emerald-950);
}
.toast-icon svg { width: 62%; height: 62%; }
.toast.error .toast-icon { background: #fff; color: #7f1d1d; }
.toast-text { flex: 1 1 auto; min-width: 0; white-space: pre-line; overflow-wrap: anywhere; }
.toast-count {
  flex: none;
  font-size: calc(11px * var(--font-scale, 1));
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
}
.toast-count:empty { display: none; }
.toast-bar {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  height: 3px;
  background: var(--gold);
  opacity: 0.7;
  transform-origin: right;
  transform: scaleX(0);
}
[dir="ltr"] .toast-bar { transform-origin: left; }
.toast.error .toast-bar { background: #fecaca; }
.toast.show .toast-bar { animation: toast-time var(--toast-dur, 3000ms) linear forwards; }
@keyframes toast-time { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.2s ease; transform: none; }
  .toast.show .toast-bar { animation: none; transform: scaleX(0); }
}

/* ------------------------------------------------------------
   Modal
   ------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: flex-end;
  justify-content: center;
  background: rgba(3, 37, 28, 0.55);
  backdrop-filter: blur(4px);
  padding: 0;
}
@media (max-width: 360px) {
  .kpi-grid { grid-template-columns: 1fr; }
}
@media (min-width: 640px) {
  .modal { align-items: center; padding: 16px; }
}

.modal.see-through { background: rgba(3, 37, 28, 0.15); -webkit-backdrop-filter: none; backdrop-filter: none; }
.modal.see-through .modal-card { background: color-mix(in srgb, var(--sand) 100%, transparent); }
.modal.open {
  display: flex;
}

.modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--sand);
  border-radius: 22px 22px 0 0;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: sheet 0.22s ease both;
}
@media (min-width: 640px) {
  .modal-card { border-radius: 22px; }
}

@keyframes sheet {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-title {
  font-weight: 800;
  font-size: calc(15px * var(--font-scale, 1));
  color: var(--emerald);
}

.modal textarea {
  width: 100%;
  min-height: 150px;
  max-height: 40vh;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  padding: 10px 12px;
  font-size: calc(12px * var(--font-scale, 1));
  line-height: 1.5;
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.modal textarea.short {
  min-height: 78px;
  max-height: 22vh;
}
/* A description in words (Arabic first), not data: the app's font, read right to left. */
.modal textarea.owner-memo { min-height: 64px; direction: rtl; text-align: start; font-family: inherit; font-size: calc(13px * var(--font-scale, 1)); }

.modal input[type="text"] {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  padding: 10px 12px;
  font-size: calc(13px * var(--font-scale, 1));
  direction: rtl;
  text-align: right;
  font-family: inherit;
}
.modal input[type="text"][dir="ltr"],
.modal input[type="tel"],
.modal #edit-amount,
.modal #settle-amount,
.modal #newacc2-phone {
  direction: ltr;
  text-align: left;
  font-size: calc(12.5px * var(--font-scale, 1));
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="light"] { color-scheme: light; }
.modal select:disabled { opacity: 0.6; }
.modal .btn:disabled { opacity: 0.45; cursor: not-allowed; }
.modal .check-row { align-self: end; }
.modal .check-row[hidden] { display: none; }
.modal .form-row.check-row label { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; font-size: calc(12px * var(--font-scale, 1)); line-height: 1.3; }
.modal .form-row.check-row input[type="checkbox"] { flex: 0 0 auto; width: 20px; height: 20px; margin: 0; padding: 0; background: none; accent-color: var(--emerald); }

.modal .form-row {
  margin: 8px 0;
}
.modal .form-row label {
  display: block;
  font-size: calc(11px * var(--font-scale, 1));
  font-weight: 700;
  color: var(--muted);
  margin: 0 2px 3px;
}
.modal input,
.modal select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  padding: 8px 10px;
  font-size: calc(12.5px * var(--font-scale, 1));
  direction: rtl;
  text-align: right;
  font-family: inherit;
}
.modal input[type="date"]::-webkit-datetime-edit,
.modal input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  direction: ltr;
  unicode-bidi: bidi-override;
}
.modal input[type="number"],
.modal input[type="date"] {
  direction: ltr;
  text-align: left;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.modal input:focus,
.modal select:focus {
  outline: 2px solid rgba(217, 119, 6, 0.28);
  border-color: var(--gold-line);
}

.modal input[type="text"]:focus,
.modal textarea:focus {
  outline: 2px solid rgba(217, 119, 6, 0.28);
  border-color: var(--gold-line);
}

.modal .field-label {
  display: block;
  font-size: calc(11.5px * var(--font-scale, 1));
  font-weight: 700;
  color: var(--muted);
  margin: 12px 2px 5px;
}

.numpad-display {
  text-align: center;
  font-size: calc(24px * var(--font-scale, 1));
  font-weight: 800;
  color: var(--emerald);
  padding: 12px;
  background: var(--sand);
  border-radius: 12px;
  margin-bottom: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  direction: ltr;
}
.numpad-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.numpad-key {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: calc(18px * var(--font-scale, 1));
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.numpad-key:active { background: var(--gold-soft); }
.numpad-key.op {
  background: var(--gold-soft);
  color: #8a4b04;
  border-color: var(--gold-line);
}
.numpad-key.wide {
  grid-column: span 2;
}
.amount-currency-row {
  display: flex;
  gap: 8px;
}
.amount-currency-row input { flex: 1 1 auto; }
.amount-currency-row select { flex: 0 0 90px; }
.amount-input { cursor: pointer; }
.amount-input::placeholder { font-family: inherit; letter-spacing: 0; color: var(--muted); opacity: .75; }

.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.form-pair.narrow-first { grid-template-columns: 1fr 2fr; }
.form-pair.wide-first { grid-template-columns: 2fr 1fr; }
.form-pair.wide-first.with-rate { grid-template-columns: 1.4fr 1.2fr 1fr; }
.form-pair.with-swap { grid-template-columns: 1fr auto 1fr; align-items: end; }
.swap-btn { width: 30px; height: 30px; margin-bottom: 9px; padding: 0; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--paper); color: var(--emerald); font-size: calc(15px * var(--font-scale, 1)); line-height: 1; cursor: pointer; }
.swap-btn:hover, .swap-btn:focus-visible { background: var(--sand); }
.modal .form-label { display: block; margin: 0 2px 5px; color: var(--muted); font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 700; }
.modal .currency-checks { display: flex; flex-wrap: wrap; gap: 4px; }
.modal .form-label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 2px 4px; }
.modal .form-label-row .form-label { margin: 0; }
.modal .liquid-inline { display: inline-flex; align-items: center; gap: 5px; margin: 0; color: var(--ink); font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 600; white-space: nowrap; cursor: pointer; }
.modal .liquid-inline[hidden] { display: none; }
.modal .liquid-inline input[type="checkbox"] { flex: 0 0 auto; width: 16px; height: 16px; margin: 0; padding: 0; background: none; accent-color: var(--emerald); }
.modal .currency-checks label { display: inline-flex; align-items: center; gap: 4px; margin: 0; padding: 3px 8px; min-height: 30px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--paper); color: var(--ink); font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 600; cursor: pointer; }
.modal .currency-checks label:has(input:checked) { border-color: var(--emerald); background: var(--ok-soft); }
.modal .currency-checks input[type="checkbox"] { flex: 0 0 auto; width: 15px; height: 15px; margin: 0; padding: 0; background: none; accent-color: var(--emerald); }
.form-fill { display: flex; gap: 8px; }
.modal .form-fill .form-row { flex: 1 1 0; min-width: 0; margin: 6px 0; }
.select-with-add { display: flex; gap: 4px; }
.select-with-add select { flex: 1 1 auto; width: auto; min-width: 0; }
.select-with-add .btn { flex: 0 0 auto; min-width: 36px; padding: 0 8px; }
.form-pair select { min-width: 0; }
.modal .form-pair .form-row { min-width: 0; margin: 6px 0; }
.form-pair input { width: 100%; min-width: 0; }
.activation-sheet .modal-note { margin: 0 0 8px; padding: 6px 10px; }
.store-title { margin: 0 2px 6px; color: var(--emerald); font-size: calc(13px * var(--font-scale, 1)); font-weight: 800; }
.store-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
.store-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-width: 0; min-height: 48px; padding: 4px 2px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper); color: var(--emerald); }
.store-btn:hover, .store-btn:focus-visible { background: var(--sand); }
.store-btn .ui-icon { width: calc(19px * var(--font-scale, 1)); height: calc(19px * var(--font-scale, 1)); }
.store-btn span { max-width: 100%; color: var(--ink); font-size: calc(9.5px * var(--font-scale, 1)); font-weight: 700; line-height: 1.15; text-align: center; overflow-wrap: anywhere; }
.device-code { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 2px 10px 2px 4px; border: 1px dashed var(--line-strong); border-radius: 12px; font-size: calc(14px * var(--font-scale, 1)); font-weight: 700; }
.device-code span[dir="ltr"] { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 1px; }
.device-code-label { margin-inline-end: auto; color: var(--muted); font-size: calc(12px * var(--font-scale, 1)); font-weight: 600; }
.activation-phones { display: flex; flex-wrap: wrap; justify-content: space-around; gap: 2px 12px; margin-top: 2px; color: var(--ink); font-weight: 700; user-select: text; }
.btn.activation-request { width: 100%; min-height: 40px; margin-bottom: 8px; }
.activation-entry { display: flex; gap: 6px; }
/* The code is set in a fixed-width font; the Arabic hint keeps the app's own. */
.modal .activation-entry input::placeholder { font-family: inherit; }
/* Under the code field: letters so far, what's wrong, or ready. */
.activation-status { min-height: 1.4em; margin: 6px 2px 0; font-size: calc(12px * var(--font-scale, 1)); color: var(--muted); font-variant-numeric: tabular-nums; }
.activation-status.ok { color: var(--emerald); font-weight: 700; }
[data-theme="dark"] .activation-status.ok { color: var(--gold); }
.activation-status.bad { color: var(--danger); }
.modal .activation-entry input { flex: 1 1 auto; min-width: 0; padding-inline: 8px; font-size: calc(11px * var(--font-scale, 1)); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.activation-promise { margin: 6px 2px 0; color: var(--muted); font-size: calc(11px * var(--font-scale, 1)); text-align: center; }
.modal .owner-device { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: calc(12px * var(--font-scale, 1)); }
.modal-card:has(.account-form) .modal-head { margin-bottom: 4px; }
.modal .account-form .form-row, .modal .account-form .form-pair .form-row { margin: 0 0 6px; }
.account-form .form-pair { gap: 8px; }
.account-form label { display: block; margin-bottom: 3px; color: var(--muted); font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 700; }
.account-form .check-row label { display: flex; align-items: center; gap: 6px; min-height: 38px; margin: 0; color: var(--ink); font-weight: 600; }
.form-optional { font-weight: 400; opacity: 0.8; }
.account-form label .ui-icon { display: inline-block; width: calc(11px * var(--font-scale, 1)); height: calc(11px * var(--font-scale, 1)); margin-inline-start: 4px; vertical-align: -0.1em; stroke-width: 5; }
.modal .account-form input:not([type="checkbox"]), .modal .account-form select { height: 38px; min-height: 38px; padding: 6px 10px; border-radius: 10px; font-size: calc(13px * var(--font-scale, 1)); }
.modal .account-form select:disabled { opacity: 1; appearance: none; -webkit-appearance: none; background-image: none; background-color: var(--sand); color: var(--muted); }
.modal .account-form .modal-note { margin: 0 0 8px; padding: 5px 8px; font-size: calc(11px * var(--font-scale, 1)); line-height: 1.35; }
.account-form .modal-actions { gap: 8px; margin-top: 4px; }
.account-form .modal-actions .btn { min-height: 42px; }
.account-form .modal-actions .btn.primary { flex: 2 1 0; }
.account-form .modal-actions .btn.ghost { flex: 1 1 0; }
.name-with-contact { display: flex; align-items: center; gap: 6px; }
.name-with-contact input { flex: 1 1 auto; min-width: 0; }
.name-contact-btn { display: grid; place-items: center; flex: none; width: 44px; height: 40px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper); color: var(--emerald); cursor: pointer; }
.name-contact-btn .ui-icon { width: calc(20px * var(--font-scale, 1)); height: calc(20px * var(--font-scale, 1)); }
[data-theme="dark"] .name-contact-btn { background: var(--sand); color: var(--gold); }
.row-menu-title { margin-top: 4px; padding: 6px 12px 2px; border-top: 1px solid var(--line); color: var(--muted); font-size: calc(11px * var(--font-scale, 1)); font-weight: 700; }
.icon-filters { margin-bottom: 6px; padding-block: 4px; padding-inline-end: 0; padding-left: 0; gap: 3px; }
.icon-filters .filter { display: inline-flex; align-items: center; gap: 3px; min-height: 34px; padding: 3px 7px; font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 600; }
/* The list scrolls in a padded box, so the row is pulled up over that padding. */
.icon-filters { position: sticky; top: -16px; z-index: 3; background: var(--sand); }
.icon-filters .ui-icon { flex: none; width: calc(13px * var(--font-scale, 1)); height: calc(13px * var(--font-scale, 1)); stroke-width: 4.5; }
.filter-count { font-size: calc(10.5px * var(--font-scale, 1)); font-weight: 700; opacity: 0.7; }
#accountsList .account-row { cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
#accountsList .account-row:active { background: var(--gold-soft); }
#accountsList .account-row { gap: 8px; min-height: 46px; padding: 2px 0 2px 2px; padding-inline-start: 12px; }
#accountsList .account-row .r-title { font-size: calc(13px * var(--font-scale, 1)); font-weight: 700; }
#accountsList .account-row .r-sub { font-size: calc(10.5px * var(--font-scale, 1)); line-height: 1.25; }
#accountsList .account-row .r-value { font-size: calc(13px * var(--font-scale, 1)); }
#accountsList .account-row .row-menu-btn { width: 34px; height: 44px; }
.account-row-icon { flex: none; color: var(--muted); }
.account-row-icon .ui-icon { width: calc(18px * var(--font-scale, 1)); height: calc(18px * var(--font-scale, 1)); }
.account-row-nick { font-size: calc(10.5px * var(--font-scale, 1)); font-weight: 500; }
.account-row-liquid { display: inline-block; margin-inline-start: 4px; color: var(--emerald); vertical-align: -0.1em; }
.account-row-liquid .ui-icon { display: inline-block; width: calc(14px * var(--font-scale, 1)); height: calc(14px * var(--font-scale, 1)); stroke-width: 4.5; }
[data-theme="dark"] .account-row-liquid { color: var(--gold); }
/* Accounts tab: cash held in each currency, and each account's balance in its own currency. */
.account-currency-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 10px; }
.account-currency-label { font-size: calc(11.5px * var(--font-scale, 1)); color: var(--muted); font-weight: 600; margin-inline-end: 2px; }
.account-cur-chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 44px; padding: 5px 11px; border-radius: 12px; background: var(--paper); border: 1px solid var(--line-strong); color: var(--ink, inherit); text-align: start; }
.account-cur-chip.active { background: var(--emerald); border-color: var(--emerald); color: #fff; }
.account-cur-chip.active .account-cur-equiv, .account-cur-chip.active .neg { color: #fff; }
.account-cur-code { font-size: calc(10.5px * var(--font-scale, 1)); font-weight: 700; letter-spacing: 0.04em; opacity: 0.8; }
.account-cur-amount { font-size: calc(13px * var(--font-scale, 1)); font-weight: 800; }
.account-cur-equiv { font-size: calc(10.5px * var(--font-scale, 1)); color: var(--muted); }
.account-row .r-value .account-row-equiv { display: block; font-size: calc(10.5px * var(--font-scale, 1)); font-weight: 500; color: var(--muted); text-align: end; }
.account-row-currencies { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 3px; }
.account-row-currency { font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 700; }
.account-row-currency .account-row-equiv { font-weight: 500; color: var(--muted); font-size: calc(10.5px * var(--font-scale, 1)); }
.account-row-favorite { display: inline-block; margin-inline-start: 4px; color: var(--gold); vertical-align: -0.1em; }
.account-row-favorite .ui-icon { display: inline-block; width: calc(13px * var(--font-scale, 1)); height: calc(13px * var(--font-scale, 1)); fill: currentColor; }
/* Ledger rows join into one list. */
#ledgerList .entry { margin: 0; padding: 3px 0 3px 2px; padding-inline-start: 10px; border-bottom-width: 0; border-radius: 0; box-shadow: none; }
#ledgerList .entry:first-child { border-radius: 14px 14px 0 0; }
#ledgerList .entry:last-child { border-bottom-width: 1px; border-radius: 0 0 14px 14px; }
#ledgerList .entry:only-child { border-radius: 14px; }
#ledgerList .entry-head { gap: 8px; min-height: 42px; }
#ledgerList .entry .r-main { flex: 1 1 0; min-width: 0; }
#ledgerList .entry-title { font-size: calc(13px * var(--font-scale, 1)); line-height: 1.3; }
#ledgerList .entry.compact .entry-title { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#ledgerList .entry-date { display: block; overflow: hidden; line-height: 1.25; text-overflow: ellipsis; }
#ledgerList .entry-amount { flex: none; font-size: calc(13px * var(--font-scale, 1)); }
#ledgerList .entry-amount.out { color: var(--ink); }
#ledgerList .row-menu-btn { width: 34px; height: 44px; }
#ledgerList .entry-lines { margin: 2px 0 6px; margin-inline-end: 12px; padding-top: 6px; }
.entry-icon { display: grid; place-items: center; flex: none; width: calc(28px * var(--font-scale, 1)); height: calc(28px * var(--font-scale, 1)); border-radius: 8px; background: var(--sand); color: var(--muted); }
.entry-icon.in { background: var(--gold-soft); color: var(--emerald); }
.entry-icon .ui-icon { width: calc(16px * var(--font-scale, 1)); height: calc(16px * var(--font-scale, 1)); }
[data-theme="dark"] .entry-icon.in { color: var(--gold); }
.account-general-row { display: flex; align-items: stretch; background: var(--sand); border-bottom: 1px solid var(--line); }
.account-general-row:last-child { border-bottom: 0; }
.account-general-add { display: grid; place-items: center; flex: none; width: 40px; min-height: 44px; border: 0; background: transparent; color: var(--emerald); cursor: pointer; }
.account-general-add .ui-icon { width: calc(17px * var(--font-scale, 1)); height: calc(17px * var(--font-scale, 1)); }
.account-general-add:hover, .account-general-add:focus-visible { background: var(--gold-soft); }
[data-theme="dark"] .account-general-add { color: var(--gold); }
.account-general { display: flex; align-items: center; gap: 8px; flex: 1 1 auto; min-width: 0; min-height: 44px; padding: 4px 10px; padding-inline-end: 2px; background: transparent; border: 0; color: var(--emerald); font-family: inherit; text-align: start; cursor: pointer; }
.account-general-icon { display: grid; place-items: center; flex: none; width: calc(28px * var(--font-scale, 1)); height: calc(28px * var(--font-scale, 1)); border-radius: 8px; background: var(--gold-soft); color: var(--emerald); }
.account-general-icon .ui-icon { width: calc(17px * var(--font-scale, 1)); height: calc(17px * var(--font-scale, 1)); }
.account-general-name { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; flex: 1; min-width: 0; font-size: calc(13.5px * var(--font-scale, 1)); font-weight: 800; line-height: 1.3; overflow-wrap: anywhere; }
.account-general-count { color: var(--muted); font-size: calc(11px * var(--font-scale, 1)); font-weight: 600; }
.account-general-total { flex: none; font-size: calc(13px * var(--font-scale, 1)); font-weight: 800; }
.account-general-chevron { flex: none; width: calc(14px * var(--font-scale, 1)); height: calc(14px * var(--font-scale, 1)); color: var(--muted); }
.account-general[aria-expanded="true"] .account-general-chevron { transform: rotate(-90deg); }
[data-theme="dark"] .account-general, [data-theme="dark"] .account-general-icon { color: var(--gold); }
.owner-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: calc(11px * var(--font-scale, 1)); line-height: 1.5; overflow-wrap: anywhere; }
.owner-result { justify-content: center; margin-top: 8px; padding: 10px 6px; text-align: center; font-size: calc(12.5px * var(--font-scale, 1)); overflow-wrap: anywhere; }
.currency-search { position: relative; }
.modal .currency-search input { padding-inline-end: 44px; }
.currency-clear { position: absolute; top: 50%; inset-inline-end: 4px; transform: translateY(-50%); width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); font-size: calc(13px * var(--font-scale, 1)); }
.currency-clear[hidden] { display: none; }
.currency-list { margin-top: 4px; max-height: 220px; overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--paper); }
.currency-list[hidden] { display: none; }
.currency-option { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 12px; border-bottom: 1px solid var(--line); color: var(--ink); font-size: calc(13px * var(--font-scale, 1)); text-align: start; }
.currency-option:hover, .currency-option:focus-visible { background: var(--sand); }
.currency-option:last-child { border-bottom: 0; }
.currency-option.manual { color: var(--emerald); font-weight: 700; }
.currency-code { color: var(--muted); font-size: calc(12px * var(--font-scale, 1)); }
.rate-calc { margin: 0 0 10px; }
.rate-calc summary { min-height: 32px; padding: 6px 2px; font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 700; color: var(--muted); cursor: pointer; }
.rate-calc input { min-width: 0; }

.fix-option { margin: 10px 0; }
.fix-option > .btn { width: 100%; }
.fix-option .modal-note { margin: 6px 2px 0; }
.fix-option > .btn, .fix-transfer .btn { min-height: 42px; height: auto; padding: 8px 14px; line-height: 1.3; }
.fix-transfer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fix-transfer label { flex: 0 0 auto; white-space: nowrap; }
.fix-transfer select { flex: 1 1 140px; min-width: 0; height: 42px; }
.fix-transfer .btn { flex: 0 0 auto; white-space: nowrap; }

.copyright-note { margin: 10px 4px 0; color: var(--muted); font-size: calc(11px * var(--font-scale, 1)); text-align: center; }

.trainer-review { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: calc(12.5px * var(--font-scale, 1)); }
.modal .trainer-review input[type="checkbox"] { flex: 0 0 auto; width: 20px; height: 20px; margin: 0; padding: 0; background: none; accent-color: var(--emerald); }
.trainer-review small { display: block; margin-top: 2px; color: var(--muted); font-size: calc(11px * var(--font-scale, 1)); }
.trainer-review small.changed { color: var(--danger, #b91c1c); font-weight: 700; }
.modal .group-share { width: 96px; min-height: 40px; flex: none; margin-inline-start: auto; padding: 6px 8px; }
.modal #groupSheet label.trainer-review { display: flex; align-items: center; margin: 0; color: var(--ink); }
.group-net { white-space: nowrap; }
#groupSheet .trainer-row .btn { flex: none; width: auto; min-width: 64px; }
#groupSheet .trainer-row button:not(.btn) { display: grid; place-items: center; width: 44px; height: 44px; flex: none; color: var(--muted); }
#groupPayRow[hidden] { display: none; }
.trainer-understood { min-height: 40px; padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--ink); font-size: calc(13px * var(--font-scale, 1)); }
.trainer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--line); font-size: calc(12.5px * var(--font-scale, 1)); }
.trainer-row button { flex: 0 0 auto; width: 36px; height: 36px; display: grid; place-items: center; color: var(--muted); }

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.modal-actions .btn {
  flex: 1 1 0;
  min-height: 40px;
  padding: 8px 12px;
  font-size: calc(12.5px * var(--font-scale, 1));
}

.print-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.55);
  display: flex;
  flex-direction: column;
}
.print-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--emerald);
  color: #fff;
}
.report-tool { display: flex; flex: none; flex-direction: column; align-items: center; justify-content: center; gap: 2px; width: 54px; min-height: 48px; padding: 4px 2px; border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 11px; background: rgba(255, 255, 255, 0.1); color: #fff; font-size: calc(10px * var(--font-scale, 1)); font-weight: 700; line-height: 1.15; white-space: nowrap; }
.report-tool:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.report-tool .ui-icon { width: calc(19px * var(--font-scale, 1)); height: calc(19px * var(--font-scale, 1)); }
.report-tool.active, .report-tool[aria-expanded="true"] { background: var(--gold); border-color: var(--gold); }
@media (hover: hover) { .report-tool:hover { background: rgba(255, 255, 255, 0.2); } .report-tool.active:hover { background: var(--gold); } }
.report-search { display: flex; flex-direction: column; gap: 6px; padding: 6px 10px; border-bottom: 1px solid var(--line-strong); background: var(--sand); color: var(--ink); font-size: calc(12px * var(--font-scale, 1)); font-weight: 600; }
.report-search[hidden] { display: none; }
.report-search-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.report-search-row.amounts { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; }
.report-search label { display: flex; align-items: center; gap: 5px; min-width: 0; }
.report-search input { display: block; flex: 1 1 auto; width: 100%; min-width: 0; min-height: 40px; padding: 4px 8px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper); color: var(--ink); font-size: calc(12.5px * var(--font-scale, 1)); font-family: inherit; }
.report-words { position: relative; }
.report-words input { padding-inline-end: 38px; }
.report-words input::-webkit-search-cancel-button { display: none; }
.report-words button { position: absolute; top: 50%; inset-inline-end: 2px; transform: translateY(-50%); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; color: var(--muted); }
.report-words button[hidden] { display: none; }
.report-words .ui-icon { width: calc(15px * var(--font-scale, 1)); height: calc(15px * var(--font-scale, 1)); }
.report-search .btn.small { min-height: 40px; padding: 4px 10px; }
.print-title { flex: 1; min-width: 0; overflow: hidden; font-weight: 700; font-size: calc(13px * var(--font-scale, 1)); line-height: 1.25; }
.print-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.modal-note {
  font-size: calc(12px * var(--font-scale, 1));
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-line;
  padding: 8px 10px;
  margin-top: 6px;
  border-radius: 8px;
  background: var(--sand);
  border: 1px solid var(--line);
}

.modal-note.plan-reason {
  background: var(--gold-soft);
  border: 1px solid var(--gold-line);
  border-radius: 10px;
  color: var(--ink);
  font-size: calc(13px * var(--font-scale, 1));
  padding: 10px 12px;
}

.plan-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 10px 0;
  padding: 12px 14px;
}

.plan-card.current {
  border-color: var(--gold);
}

.plan-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.plan-name {
  color: var(--ink);
  font-size: calc(15px * var(--font-scale, 1));
  font-weight: 700;
}

.plan-features {
  color: var(--muted);
  font-size: calc(12.5px * var(--font-scale, 1));
  line-height: 1.8;
  margin: 0 0 8px;
  padding-inline-start: 18px;
}

.usage-progress-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 10px;
  padding: 10px 12px;
}
.usage-progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.usage-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.usage-progress-fill {
  height: 100%;
  background: var(--emerald);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.usage-progress-fill.warn {
  background: var(--gold);
}
.usage-progress-fill.full {
  background: var(--danger);
}
.offer-banner {
  background: var(--gold-soft);
  border: 1px solid var(--gold);
  border-radius: 10px;
  color: var(--ink);
  font-size: calc(12px * var(--font-scale, 1));
  font-weight: 700;
  margin-bottom: 8px;
  padding: 7px 10px;
  text-align: center;
}
.license-tier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.tier-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px;
  border: 1.5px solid var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  text-align: right;
  cursor: pointer;
}
.tier-card.selected {
  border-color: var(--emerald);
  background: var(--sand);
  box-shadow: 0 0 0 1px var(--emerald);
}
[data-theme="dark"] .tier-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold);
}
.tier-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 4px;
}
.tier-title {
  font-size: calc(13px * var(--font-scale, 1));
  font-weight: 800;
  color: var(--ink);
}
.tier-price-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}
.tier-price {
  font-size: calc(15px * var(--font-scale, 1));
  font-weight: 800;
  color: var(--emerald);
}
[data-theme="dark"] .tier-price {
  color: var(--gold);
}
.tier-old-price {
  font-size: calc(11.5px * var(--font-scale, 1));
  color: var(--muted);
  text-decoration: line-through;
}
.tier-desc {
  font-size: calc(11px * var(--font-scale, 1));
  color: var(--muted);
  line-height: 1.35;
}
.promo-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.promo-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding-inline: 10px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--paper);
  color: var(--ink);
  font-size: calc(12px * var(--font-scale, 1));
}
.license-self-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-strong);
}
.license-self-actions .btn {
  flex: 1 1 auto;
  font-size: calc(11.5px * var(--font-scale, 1));
}

/* ------------------------------------------------------------
   Utilities
   ------------------------------------------------------------ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.sr-only-focusable:focus {
  position: static;
  width: auto;
  height: auto;
  padding: 8px 12px;
  margin: 0;
  overflow: visible;
  clip: auto;
  white-space: normal;
}
.skip-link {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1000;
  background: var(--emerald);
  color: #fff;
  padding: 8px 14px;
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-120%);
  transition: transform 0.15s ease;
}
.skip-link:focus {
  transform: translateY(0);
}

.hidden {
  display: none !important;
}

@media (min-width: 720px) {
  .chat,
  .scroll-body {
    max-width: 680px;
    margin-inline: auto;
    width: 100%;
  }

  .composer {
    max-width: 680px;
    margin-inline: auto;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Storage problems: unsaved changes and damaged books */
.save-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(245, 158, 11, 0.16);
  color: var(--ink);
  font-size: calc(13px * var(--font-scale, 1));
}
.save-banner[hidden] { display: none; }
.save-banner.critical { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.save-banner p { margin: 0; flex: 1 1 220px; }
.save-banner-detail { flex: 1 1 100%; font-size: calc(11px * var(--font-scale, 1)); overflow-wrap: anywhere; opacity: 0.85; }
.save-banner-actions { display: flex; gap: 6px; }

.storage-fault {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--sand);
  overflow-y: auto;
}
.storage-fault[hidden] { display: none; }
.storage-fault-card { width: 100%; max-width: 440px; color: var(--ink); }
.storage-fault-card h1 { margin: 0 0 10px; font-size: calc(22px * var(--font-scale, 1)); color: var(--danger); }
.storage-fault-card p { margin: 0 0 18px; line-height: 1.7; }
.storage-fault-actions { display: flex; flex-direction: column; gap: 10px; }

/* Boot loading overlay */
.boot-loading { position: fixed; inset: 0; z-index: 9999; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--sand, #f7f5f0); color: var(--ink, #1f2937); font-family: inherit; }
[data-theme="dark"] .boot-loading { background: var(--sand, #0a1f18); color: var(--ink, #e8f0ec); }
.boot-loading.hidden { display: none; }
.boot-spinner { width: 36px; height: 36px; border: 3px solid var(--line-strong, rgba(0,0,0,0.18)); border-top-color: var(--emerald, #064e3b); border-radius: 50%; animation: boot-spin 0.8s linear infinite; }
@keyframes boot-spin { to { transform: rotate(360deg); } }
.boot-text { font-size: calc(15px * var(--font-scale, 1)); color: var(--muted, #5a6b63); }
@media (prefers-reduced-motion: reduce) { .boot-spinner { animation: none; } }

/* Compact composer: the suggestion row and text box take less height. */
.composer { gap: 3px; padding: 3px 8px 4px; }
.chips.chips-bar { padding: 2px 4px; }
.chips.chips-bar .chip { min-height: 30px; padding: 2px 10px; }
.chips.chips-bar .chip.suggest-btn { padding: 3px 8px; }
.composer textarea { min-height: 38px; padding: 8px 12px; border-radius: 12px; }
.action-btn { width: 40px; height: 40px; border-radius: 12px; }
.action-btn .ui-icon { width: calc(20px * var(--font-scale, 1)); height: calc(20px * var(--font-scale, 1)); }
.clear-btn, .form-btn, .attach-btn { top: 3px; width: 32px; height: 32px; }
.attach-btn { inset-inline-end: 3px; }
.form-btn { inset-inline-end: 35px; }
.clear-btn { inset-inline-end: 67px; }
.composer .input-wrap textarea { padding-inline-end: 70px; }
.composer .input-wrap textarea:not(:placeholder-shown) { padding-inline-end: 102px; }

/* The suggestion row floats over the chat's last lines, the chat showing through at 20%. */
.composer { position: relative; }
.composer > .chips-bar { position: absolute; bottom: 100%; left: 0; right: 0; z-index: 2; background: color-mix(in srgb, var(--sand) 80%, transparent); border-top: 1px solid var(--line); }
.composer > .chips-bar[hidden] { display: none; }
.chat { padding-bottom: 46px; }

/* Compact everywhere: the shared cards, rows, alerts and numbers take less room on every tab. */
.scroll-body { padding: 10px 10px calc(var(--tabbar-h) + 16px); }
.card { padding: 10px 12px; margin-bottom: 8px; }
.section-title { margin: 0 2px 6px; }
.hero-value { font-size: calc(26px * var(--font-scale, 1)); }
.hero-sub { gap: 6px; margin-top: 8px; }
.pill { padding: 3px 8px; font-size: calc(11px * var(--font-scale, 1)); }
.alert { align-items: center; gap: 7px; padding: 6px 10px; margin-bottom: 6px; font-size: calc(12px * var(--font-scale, 1)); }
.alert .btn.small { min-height: 32px; padding: 4px 10px; }
.kpi-grid { gap: 8px; margin-bottom: 8px; }
.kpi { padding: 8px 10px; }
.kpi .k-value { font-size: calc(16px * var(--font-scale, 1)); margin-top: 1px; }
.row { padding: 7px 0; }
.meter { margin-top: 6px; }
.btn.small { min-height: 36px; padding: 6px 10px; }
.entry { padding: 8px 10px; margin-bottom: 6px; }
.chat { gap: 8px; padding-top: 10px; }

/* Welcome: five steps on a new install. */
.onboard { position: fixed; inset: 0; z-index: 90; display: flex; flex-direction: column; padding: max(14px, env(safe-area-inset-top)) 16px max(14px, env(safe-area-inset-bottom)); background: radial-gradient(120% 70% at 85% 0%, var(--emerald-600, #0f766e) 0%, var(--emerald, #064e3b) 45%, var(--emerald-950, #022c22) 100%); color: #fff; overflow: hidden; }
.onboard[hidden] { display: none; }
.ob-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ob-step-count { font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 700; color: rgba(255, 255, 255, 0.75); background: rgba(255, 255, 255, 0.1); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.ob-progress { flex: 1 1 auto; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.2); overflow: hidden; }
.ob-progress-bar { height: 100%; border-radius: 999px; background: var(--gold, #d97706); transition: width 0.3s ease; }
.ob-skip { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.85); font-size: calc(12px * var(--font-scale, 1)); font-weight: 600; }
.ob-stage { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 2px; }
.ob-step-in { animation: obIn 0.45s cubic-bezier(.2, .8, .2, 1) both; }
.ob-art { width: min(100%, 300px); height: auto; align-self: center; margin: 4px 0 2px; overflow: visible; }
.ob-body h1 { margin: 4px 0 4px; font-size: calc(22px * var(--font-scale, 1)); font-weight: 800; line-height: 1.3; }
.ob-lead { margin: 0 0 12px; color: rgba(255, 255, 255, 0.82); font-size: calc(13.5px * var(--font-scale, 1)); line-height: 1.6; }
.ob-note { margin: 2px 2px 0; color: rgba(255, 255, 255, 0.65); font-size: calc(11.5px * var(--font-scale, 1)); }
.ob-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ob-points li { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.12); animation: obIn 0.5s ease both; }
.ob-points li:nth-child(2) { animation-delay: 0.12s; }
.ob-points li:nth-child(3) { animation-delay: 0.24s; }
.ob-points b { font-size: calc(13.5px * var(--font-scale, 1)); }
.ob-points span { color: rgba(255, 255, 255, 0.78); font-size: calc(12px * var(--font-scale, 1)); line-height: 1.5; }
.ob-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.ob-field span { color: rgba(255, 255, 255, 0.75); font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 700; }
.ob-field input { width: 100%; min-width: 0; height: 42px; padding: 8px 12px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.95); color: #12211c; font-size: calc(14px * var(--font-scale, 1)); }
.ob-field input:focus { outline: none; border-color: var(--gold, #d97706); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.3); }
.ob-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ob-currencies { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.ob-cur { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px; border-radius: 14px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16); color: #fff; transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease; }
.ob-cur b { font-size: calc(12.5px * var(--font-scale, 1)); }
.ob-cur span { font-size: calc(11px * var(--font-scale, 1)); color: rgba(255, 255, 255, 0.7); }
.ob-cur .ob-cur-sym { font-size: calc(20px * var(--font-scale, 1)); color: #fff; font-weight: 800; }
.ob-cur.on { background: var(--gold, #d97706); border-color: var(--gold, #d97706); transform: translateY(-2px); }
.ob-cur:disabled:not(.on) { opacity: 0.4; }
.ob-theme-groups { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.ob-theme-groups .ob-theme { margin-bottom: 0; }
.ob-theme { display: flex; gap: 6px; margin-bottom: 10px; }
.ob-theme button { flex: 1 1 0; padding: 9px 6px; border-radius: 12px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16); color: #fff; font-weight: 700; font-size: calc(12.5px * var(--font-scale, 1)); }
.ob-theme button[aria-pressed="true"] { background: var(--gold, #d97706); border-color: var(--gold, #d97706); }
.ob-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 12px; margin-bottom: 6px; border-radius: 14px; background: rgba(255, 255, 255, 0.08); }
.ob-switch-row div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ob-switch-row b { font-size: calc(13px * var(--font-scale, 1)); }
.ob-switch-row span { color: rgba(255, 255, 255, 0.7); font-size: calc(11.5px * var(--font-scale, 1)); }
.ob-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; }
.ob-back { padding: 12px 18px; border-radius: 14px; background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 700; }
.ob-next { flex: 0 1 60%; padding: 13px 18px; border-radius: 14px; background: #fff; color: var(--emerald, #064e3b); font-weight: 800; font-size: calc(15px * var(--font-scale, 1)); box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25); }
.ob-next:active, .ob-back:active { transform: scale(0.97); }

/* Pictures */
.ob-art .ob-bubble { fill: #fff; }
.ob-art .ob-txt { fill: #064e3b; font: 700 12px Tahoma, sans-serif; }
.ob-art .ob-card { fill: rgba(255, 255, 255, 0.95); }
.ob-art .ob-tag { fill: #d97706; }
.ob-art .ob-line, .ob-art .ob-line-f { stroke: #cbd5d1; stroke-width: 2; fill: #cbd5d1; }
.ob-art .ob-small { fill: #064e3b; font: 700 11px Tahoma, sans-serif; }
.ob-art .ob-num { fill: #064e3b; font: 800 18px Tahoma, sans-serif; }
.ob-art .ob-draw { fill: none; stroke: #fbbf24; stroke-width: 3; stroke-linecap: round; stroke-dasharray: 80; stroke-dashoffset: 80; animation: obDraw 1s 0.4s ease forwards, obDash 3.6s 1.4s ease-in-out infinite; }
.ob-art .ob-coin { fill: #fbbf24; stroke: #b45309; stroke-width: 2; }
.ob-art .ob-avatar { fill: #d1fae5; }
.ob-art .ob-face { fill: #064e3b; }
.ob-art .ob-face-line { fill: none; stroke: #064e3b; stroke-width: 4; stroke-linecap: round; }
.ob-art .ob-bigcoin { fill: #fbbf24; stroke: #b45309; stroke-width: 3; }
.ob-art .ob-bigcoin-in { fill: none; stroke: #b45309; stroke-width: 2; stroke-dasharray: 4 4; }
.ob-art .ob-sym { fill: #78350f; font: 800 38px Tahoma, sans-serif; }
.ob-art .ob-shield { fill: rgba(255, 255, 255, 0.95); }
.ob-art .ob-lock { fill: #064e3b; }
.ob-art .ob-lock-arc { fill: none; stroke: #064e3b; stroke-width: 5; stroke-linecap: round; animation: obShackle 2.4s 0.6s ease-in-out infinite; transform-origin: 130px 70px; }
.ob-float { animation: obFloat 3s ease-in-out infinite; }
.ob-pop { transform-box: fill-box; transform-origin: center; animation: obPop 0.6s 0.2s cubic-bezier(.2, 1.4, .4, 1) both; }
.ob-c1 { animation: obBob 2.6s ease-in-out infinite; }
.ob-c2 { animation: obBob 3.2s 0.4s ease-in-out infinite; }
.ob-c3 { animation: obBob 2.2s 0.8s ease-in-out infinite; }
.ob-spin { transform-box: fill-box; transform-origin: center; animation: obFlip 3.4s ease-in-out infinite; }
.ob-grow { transform-box: fill-box; transform-origin: right center; animation: obGrow 0.8s 0.5s ease both; }
.ob-grow2 { transform-box: fill-box; transform-origin: right center; animation: obGrow 0.8s 0.75s ease both; }
.ob-stack1, .ob-stack2, .ob-stack3 { animation: obSlide 0.6s cubic-bezier(.2, .8, .2, 1) both; }
.ob-stack2 { animation-delay: 0.15s; }
.ob-stack3 { animation-delay: 0.3s; }

@keyframes obIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes obPop { from { opacity: 0; transform: scale(0.6); } to { opacity: 1; transform: scale(1); } }
@keyframes obFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes obBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes obDraw { to { stroke-dashoffset: 0; } }
@keyframes obDash { 0%, 100% { stroke-dashoffset: 0; } 50% { stroke-dashoffset: 16; } }
@keyframes obFlip { 0%, 70%, 100% { transform: scaleX(1); } 80% { transform: scaleX(0.1); } 90% { transform: scaleX(1); } }
@keyframes obGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes obSlide { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
@keyframes obShackle { 0%, 60%, 100% { transform: translateY(0); } 70% { transform: translateY(-6px); } 80% { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .onboard *, .onboard *::before { animation: none !important; transition: none !important; }
  .ob-art .ob-draw { stroke-dashoffset: 0; }
}
.onboard .switch { background: rgba(255, 255, 255, 0.28); border-color: rgba(255, 255, 255, 0.35); }
.onboard .switch[aria-checked="true"] { background: var(--gold, #d97706); border-color: var(--gold, #d97706); }

/* The welcome's examples: small chips that sit two to a line. */
.chips.chips-tight { gap: 5px; margin-top: 8px; }
#chat .chips .chip { min-height: 26px; padding: 2px 8px; font-size: calc(11.5px * var(--font-scale, 1)); }
.chips.chips-tight .chip { min-height: 26px; padding: 2px 8px; font-size: calc(11.5px * var(--font-scale, 1)); }

.modal.see-through.see-85 .modal-card { background: color-mix(in srgb, var(--sand) 85%, transparent); }
/* Compact modal: tighter spacing for dense forms (entry editor). */
.modal.compact .modal-card { padding: 10px; gap: 4px; max-height: 94vh; }
.modal.compact .modal-head { margin-bottom: 0; }
.modal.compact .modal-title { font-size: calc(13px * var(--font-scale, 1)); }
.modal.compact .form-row { margin: 2px 0; }
.modal.compact .form-pair { gap: 4px; }
.modal.compact .form-fill { gap: 2px; }
.modal.compact .modal-actions { gap: 4px; margin-top: 2px; }
.modal.compact .modal-actions .btn { min-height: 32px; padding: 4px 10px; font-size: calc(12px * var(--font-scale, 1)); }
.modal.compact .modal-note, .modal.compact .muted { margin: 1px 0; font-size: calc(10px * var(--font-scale, 1)); }
.modal.compact input, .modal.compact select { height: 32px; padding: 4px 8px; font-size: calc(12.5px * var(--font-scale, 1)); }
.modal.compact .swap-btn { min-height: 32px; padding: 4px 8px; }

/* Compact chips everywhere: the suggestions window, chat replies and choices. */
.chips { gap: 5px; margin-top: 8px; }
.chip { min-height: 32px; padding: 4px 10px; font-size: calc(12px * var(--font-scale, 1)); }
.more-chips { margin: 0 0 8px; gap: 5px; }
.more-chips .chip { min-height: 30px; padding: 3px 10px; background: var(--paper); }
.modal .search-group-title { margin: 2px 2px 4px; }
.modal .modal-note { margin-bottom: 8px; padding: 6px 10px; font-size: calc(11.5px * var(--font-scale, 1)); line-height: 1.5; }
.modal.see-through .modal-note { background: var(--paper); }

/* Profile photo */
.ob-art-btn { display: block; align-self: center; padding: 0; background: none; border: 0; width: min(100%, 300px); cursor: pointer; }
.ob-art-btn .ob-art { width: 100%; }
.ob-art .ob-photo-ring { fill: none; stroke: #d97706; stroke-width: 3; }
.ob-art .ob-plus-dot { fill: #d97706; }
.ob-art .ob-plus { stroke: #fff; stroke-width: 2.5; stroke-linecap: round; }
.ob-photo-actions { display: flex; gap: 8px; margin-bottom: 10px; }
.ob-photo-actions button { padding: 7px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.2); color: #fff; font-weight: 700; font-size: calc(12px * var(--font-scale, 1)); }
.profile-avatar { flex: 0 0 auto; width: 38px; height: 38px; margin-inline-end: 10px; border-radius: 50%; object-fit: cover; border: 2px solid var(--gold-line, #d97706); }
.profile-avatar.empty { display: grid; place-items: center; background: var(--ok-soft); color: var(--emerald); font-weight: 800; font-size: calc(16px * var(--font-scale, 1)); }
.profile-avatar.big { width: 64px; height: 64px; font-size: calc(24px * var(--font-scale, 1)); }
.pf-photo { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

/* The add-currency window can open over the welcome. */
.modal.over-onboard { z-index: 95; }
.ob-cur.ob-cur-add { border-style: dashed; background: transparent; }
.ob-personas { display: flex; flex-direction: column; gap: 8px; }
.ob-persona { display: flex; flex-direction: column; align-items: flex-start; text-align: start; gap: 4px; width: 100%; padding: 11px 14px; border-radius: 14px; background: rgba(255, 255, 255, 0.08); border: 1.5px solid rgba(255, 255, 255, 0.16); color: #fff; cursor: pointer; transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease; }
.ob-persona b { font-size: calc(14px * var(--font-scale, 1)); color: #fff; }
.ob-persona span { font-size: calc(12px * var(--font-scale, 1)); color: rgba(255, 255, 255, 0.8); line-height: 1.45; }
.ob-persona small { font-size: calc(11px * var(--font-scale, 1)); color: rgba(255, 255, 255, 0.9); background: rgba(0, 0, 0, 0.18); padding: 3px 8px; border-radius: 999px; margin-top: 2px; }
.ob-persona.on { background: var(--gold, #d97706); border-color: #fbbf24; transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22); }
.ob-persona-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.ob-persona-tags span { padding: 4px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.14); border: 1px solid rgba(255, 255, 255, 0.22); font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 700; color: #fff; }
.ob-cur.ob-cur-add .ob-cur-sym { color: var(--gold, #d97706); }

/* Multi-dialect welcome showcase & pitch simulator */
.ob-hero-anim { display: flex; align-items: center; gap: 8px; animation: obHeroCycle 0.55s cubic-bezier(.2, .85, .25, 1) both; }
.ob-hero-flag { display: inline-block; font-size: calc(24px * var(--font-scale, 1)); animation: obBob 2.2s ease-in-out infinite; }
@keyframes obHeroCycle { 0% { opacity: 0; transform: translateY(8px) scale(0.97); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
.ob-dialect-showcase { margin: 0 0 10px; padding: 10px 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.18); border: 1px solid rgba(251, 191, 36, 0.35); }
.ob-greet-banner { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ob-greet-flag { font-size: calc(26px * var(--font-scale, 1)); line-height: 1; }
.ob-greet-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ob-greet-text b { font-size: calc(13.5px * var(--font-scale, 1)); color: #fde68a; }
.ob-greet-text span { font-size: calc(11.5px * var(--font-scale, 1)); color: rgba(255, 255, 255, 0.85); }
.ob-greet-text code { background: rgba(255, 255, 255, 0.15); padding: 1px 5px; border-radius: 4px; font-size: calc(10.5px * var(--font-scale, 1)); }
.ob-greet-pills { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.ob-greet-pill { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); color: #fff; font-size: calc(11.5px * var(--font-scale, 1)); white-space: nowrap; cursor: pointer; }
.ob-greet-pill.on { background: var(--gold, #d97706); border-color: #fbbf24; font-weight: 800; }

.ob-pitch-badge { display: inline-block; padding: 4px 12px; border-radius: 999px; background: rgba(251, 191, 36, 0.2); border: 1px solid #fbbf24; color: #fde68a; font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 800; margin-bottom: 6px; }
.ob-sim-box { padding: 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.22); border: 1px solid rgba(255, 255, 255, 0.16); }
.ob-sim-title { font-size: calc(12px * var(--font-scale, 1)); font-weight: 700; color: #fde68a; margin-bottom: 8px; }
.ob-sim-chips { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.ob-sim-chip { text-align: start; padding: 8px 11px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.16); color: #fff; font-size: calc(12px * var(--font-scale, 1)); font-weight: 600; cursor: pointer; }
.ob-sim-chip.on { background: var(--gold, #d97706); border-color: #fbbf24; font-weight: 800; }
.ob-sim-result { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.95); color: #064e3b; }
.ob-sim-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 800; }
.ob-sim-tag { background: #d97706; color: #fff; padding: 2px 8px; border-radius: 999px; font-size: calc(10.5px * var(--font-scale, 1)); }
.ob-sim-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; border-top: 1px dashed rgba(6, 78, 59, 0.2); font-size: calc(12px * var(--font-scale, 1)); }
.ob-sim-extra { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(6, 78, 59, 0.15); font-size: calc(11px * var(--font-scale, 1)); font-weight: 700; color: #047857; }

/* Dialect tabs, cards & collapsible unavailable locales */
.ob-lang-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 8px; padding-bottom: 2px; }
.ob-lang-tab { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.18); color: #fff; font-size: calc(12px * var(--font-scale, 1)); font-weight: 700; white-space: nowrap; cursor: pointer; }
.ob-lang-tab.on { background: #fff; color: var(--emerald, #064e3b); border-color: #fff; }
.ob-lang-tab.ob-lang-more { border-style: dashed; border-color: #fbbf24; color: #fde68a; background: rgba(251, 191, 36, 0.14); }
.ob-lang-tab.ob-lang-more.on { background: var(--gold, #d97706); color: #fff; border-style: solid; border-color: #fbbf24; }
.ob-dialect-grid { grid-template-columns: repeat(auto-fill, minmax(145px, 1fr)); }
.ob-dialect-card { align-items: stretch; text-align: start; padding: 10px 12px; gap: 4px; }
.ob-dl-top { display: flex; align-items: center; gap: 6px; width: 100%; }
.ob-dl-flag { font-size: calc(18px * var(--font-scale, 1)); line-height: 1; }
.ob-dl-code { margin-inline-start: auto; font-size: calc(18px * var(--font-scale, 1)); line-height: 1; background: rgba(0, 0, 0, 0.18); padding: 3px 7px; border-radius: 8px; }
.ob-dl-greet { font-size: calc(11px * var(--font-scale, 1)); color: rgba(255, 255, 255, 0.85); line-height: 1.4; }
.ob-more-dialects-wrap { margin-top: 10px; }
.ob-more-toggle { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.1); border: 1px dashed rgba(255, 255, 255, 0.35); color: #fde68a; font-size: calc(12.5px * var(--font-scale, 1)); font-weight: 700; cursor: pointer; }
.ob-unavailable-box { margin-top: 8px; padding: 10px; border-radius: 12px; background: rgba(0, 0, 0, 0.24); border: 1px solid rgba(255, 255, 255, 0.16); }
.ob-unavailable-banner { font-size: calc(11.5px * var(--font-scale, 1)); font-weight: 700; color: #fde68a; margin-bottom: 8px; line-height: 1.5; }
.ob-unavailable-list { display: flex; flex-direction: column; gap: 6px; max-height: 210px; overflow-y: auto; }
.ob-unavailable-item { display: flex; flex-direction: column; align-items: flex-start; text-align: start; gap: 3px; width: 100%; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.08); border: 1px solid rgba(255, 255, 255, 0.15); color: #fff; cursor: pointer; }
.ob-unavailable-item:hover { background: rgba(22, 163, 74, 0.28); border-color: #4ade80; }
.ob-unav-main { display: flex; align-items: center; gap: 8px; width: 100%; }
.ob-unav-main b { font-size: calc(12.5px * var(--font-scale, 1)); }
.ob-unav-main code { margin-inline-start: auto; background: rgba(0, 0, 0, 0.3); padding: 2px 6px; border-radius: 6px; color: #fde68a; font-size: calc(11px * var(--font-scale, 1)); }
.ob-unavailable-item small { font-size: calc(10.5px * var(--font-scale, 1)); color: #bbf7d0; line-height: 1.4; }

/* Suggested top-3 currencies, bank chips & summary card */
.ob-suggested-wrap { margin-bottom: 10px; padding: 10px; border-radius: 14px; background: rgba(0, 0, 0, 0.18); border: 1px solid rgba(251, 191, 36, 0.4); }
.ob-suggested-title { font-size: calc(12px * var(--font-scale, 1)); font-weight: 700; color: #fde68a; margin-bottom: 8px; }
.ob-suggested-grid { grid-template-columns: repeat(3, 1fr); }
.ob-cur-suggested { border-color: rgba(251, 191, 36, 0.5); }
.ob-cur-badge { font-size: calc(9.5px * var(--font-scale, 1)); font-weight: 800; color: #fde68a; background: rgba(0, 0, 0, 0.22); padding: 1px 6px; border-radius: 999px; }
.ob-bank-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ob-bank-chip { padding: 6px 11px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.22); color: #fff; font-size: calc(12px * var(--font-scale, 1)); font-weight: 700; cursor: pointer; }
.ob-bank-chip.on { background: var(--gold, #d97706); border-color: #fbbf24; }
.ob-summary { margin-bottom: 10px; padding: 10px 12px; border-radius: 14px; background: rgba(0, 0, 0, 0.2); border: 1px solid rgba(255, 255, 255, 0.18); }
.ob-summary-title { font-size: calc(12.5px * var(--font-scale, 1)); font-weight: 800; color: #fde68a; margin-bottom: 6px; }
.ob-summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: calc(11.5px * var(--font-scale, 1)); }
.ob-summary-grid > div { display: flex; flex-direction: column; gap: 1px; }
.ob-summary-grid span { color: rgba(255, 255, 255, 0.7); font-size: calc(10.5px * var(--font-scale, 1)); }

/* The dialect step's microphone */
.ob-art .ob-mic-arc { fill: none; stroke: #fff; stroke-width: 6; stroke-linecap: round; }
.ob-art .ob-wave { fill: none; stroke: #fbbf24; stroke-width: 4; stroke-linecap: round; opacity: 0; animation: obWave 1.8s ease-out infinite; }
.ob-art .ob-w2 { animation-delay: 0.35s; }
@keyframes obWave { 0% { opacity: 0; } 30% { opacity: 1; } 100% { opacity: 0; } }

/* The last welcome step: bars that grow, a line that climbs, stars that twinkle. */
.ob-art .ob-bar { fill: rgba(255, 255, 255, 0.92); transform-box: fill-box; transform-origin: bottom; animation: obRise 0.7s cubic-bezier(.2, .9, .3, 1.2) both; }
.ob-art .ob-b2 { animation-delay: 0.12s; }
.ob-art .ob-b3 { animation-delay: 0.24s; }
.ob-art .ob-b4 { animation-delay: 0.36s; fill: #fbbf24; }
.ob-art .ob-star { fill: #fbbf24; transform-box: fill-box; transform-origin: center; animation: obTwinkle 1.8s ease-in-out infinite; }
.ob-art .ob-s2 { animation-delay: 0.5s; }
.ob-art .ob-s3 { animation-delay: 1s; }
.ob-finale { font-size: calc(15px * var(--font-scale, 1)); color: #fff; animation: obIn 0.6s ease both; }
.ob-finale + .ob-finale { animation-delay: 0.25s; }
.ob-finale + .ob-finale + .ob-finale { animation-delay: 0.5s; }
@keyframes obRise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes obTwinkle { 0%, 100% { opacity: 0.35; transform: scale(0.7); } 50% { opacity: 1; transform: scale(1.15); } }

/* Share a typed sentence and its reply to WhatsApp */
.user-row { display: flex; align-items: center; gap: 6px; max-width: 100%; }
.share-wa { flex: 0 0 auto; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid var(--line); background: var(--paper); color: #16a34a; opacity: 0.75; }
.share-wa:hover, .share-wa:focus-visible { opacity: 1; }
.share-wa .ui-icon { width: calc(17px * var(--font-scale, 1)); height: calc(17px * var(--font-scale, 1)); stroke-width: 3.5; }

/* User experience improvement program: what is and isn't collected, side by side, and the
   report shown exactly as it is sent. */
.uxp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0 10px; }
.uxp-cols > div { padding: 10px 12px; border-radius: 12px; background: var(--sand); font-size: calc(12.5px * var(--font-scale, 1)); line-height: 1.7; }
.uxp-cols ul { margin: 4px 0 0; padding-inline-start: 18px; }
@media (max-width: 420px) { .uxp-cols { grid-template-columns: 1fr; } }
.uxp-report { font-family: inherit; max-height: 46vh; overflow: auto; margin: 6px 0 10px; padding: 10px 12px; border-radius: 12px; background: var(--sand); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; font-size: calc(11.5px * var(--font-scale, 1)); line-height: 1.6; }

/* Owner edition, activation codes: the two steps, payment then codes. */
.owner-steps { display: flex; gap: 6px; list-style: none; margin: 0 0 10px; padding: 0; counter-reset: none; }
.owner-steps li { flex: 1 1 0; padding: 8px 10px; border-radius: 10px; background: var(--sand); color: var(--muted); font-size: calc(12.5px * var(--font-scale, 1)); font-weight: 700; text-align: center; border: 1px solid transparent; }
.owner-steps li.active { background: var(--paper); color: var(--emerald); border-color: var(--emerald); }
.owner-steps li.done { color: var(--emerald); }
.owner-steps li.done::before { content: "✓ "; }
[data-theme="dark"] .owner-steps li.active { color: var(--gold); border-color: var(--gold); }
.owner-paid-note { border-inline-start: 3px solid var(--emerald); font-weight: 600; }

/* Privacy policy and terms of use sheets */
.legal-text { line-height: 1.8; color: var(--ink); }
.legal-text h3 { margin: 14px 0 4px; font-size: calc(14px * var(--font-scale, 1)); font-weight: 700; }
.legal-text p { margin: 0 0 6px; font-size: calc(13px * var(--font-scale, 1)); }
.legal-text .legal-date { color: var(--muted); font-size: calc(11px * var(--font-scale, 1)); }

/* Entry edit sheet: the card is solid (the draft behind showed through over the labels),
   kind, date and due date share a row, the "+" button matches the selects so the account labels line up. */
.modal.see-through.see-85.edit-sheet .modal-card { background: var(--sand); }
.form-pair.edit-top { grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); }
.modal.compact .select-with-add .btn { height: 32px; min-height: 32px; padding: 0 8px; }
.edit-hint { margin: 2px 2px 0; font-size: calc(11px * var(--font-scale, 1)); line-height: 1.5; color: var(--muted); }
/* The report's ⋯ menu. It sits under the toolbar (white text), so it sets its own colours,
   and opens toward the screen from the button at the far left. */
.report-menu-list { position: absolute; top: calc(100% + 6px); left: 0; right: auto; z-index: 1000; min-width: 210px; max-width: calc(100vw - 24px); max-height: 60vh; overflow-y: auto; padding: 4px 0; background: var(--paper); color: var(--ink); border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18); text-align: right; }
.report-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px 14px; border: 0; background: transparent; color: inherit; font: inherit; font-size: calc(14px * var(--font-scale, 1)); text-align: right; cursor: pointer; }
.report-menu-item .ui-icon { flex: none; width: calc(19px * var(--font-scale, 1)); height: calc(19px * var(--font-scale, 1)); color: var(--emerald); stroke-width: 3.6; }
.report-menu-label { flex: 1; }
.report-menu-state { flex: none; color: var(--emerald); font-weight: 700; font-size: calc(12.5px * var(--font-scale, 1)); }
.report-menu-item:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.report-menu-item:active { background: var(--line); }
@media (hover: hover) { .report-menu-item:hover { background: var(--line); } }
.report-menu-sep { height: 1px; margin: 4px 0; background: var(--line); }

.account-general-alert { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--danger-soft, rgba(185,28,28,.12)); color: var(--danger, #e53935); font-size: calc(12px * var(--font-scale, 1)); font-weight: 800; cursor: pointer; margin-inline-start: 6px; }

.action-btn.listening {
  background: var(--danger, #b91c1c);
  animation: pulse-mic 1s ease-in-out infinite;
}
@keyframes pulse-mic {
  0%, 100% { transform: scale(1); box-shadow: 0 4px 12px rgba(185, 28, 28, 0.4); }
  50% { transform: scale(1.08); box-shadow: 0 6px 18px rgba(185, 28, 28, 0.6); }
}


.due-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 2px 0 10px; padding-inline-start: 2px; }
.due-btn { min-height: 30px !important; padding: 4px 10px !important; font-size: calc(10.5px * var(--font-scale, 1)) !important; border-radius: 999px !important; background: var(--sand) !important; border: 1px solid var(--line-strong) !important; color: var(--ink) !important; font-weight: 600 !important; }
.due-btn:hover, .due-btn:focus-visible { background: var(--gold-soft) !important; border-color: var(--gold-line) !important; color: var(--gold) !important; }

.theme-dot { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }

#radarPrefsList .row { padding: 4px 0 !important; gap: 4px !important; min-height: 32px; }
#radarPrefsList .btn.ghost.small { min-height: 26px !important; padding: 2px 6px !important; font-size: calc(10px * var(--font-scale, 1)) !important; }
#radarPrefsList label { font-size: calc(11px * var(--font-scale, 1)) !important; }
#radarPrefsList input[type="checkbox"] { width: 16px; height: 16px; }

/* Two-column settings layout on wider screens */
@media (min-width: 640px) {
  #settingsBody { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  #settingsBody .settings-hero { grid-column: 1 / -1; }
  #settingsBody .settings-quick-grid { grid-column: 1 / -1; }
  #settingsBody .settings-search-box { grid-column: 1 / -1; }
  #settingsBody .settings-tabs { grid-column: 1 / -1; }
  #settingsBody .group-title { grid-column: 1 / -1; }
  #settingsBody .card { margin-bottom: 0; }
}

/* Two-column layout for dashboard/accounts on wider screens */
@media (min-width: 768px) {
  #radar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  #radar .card { margin-bottom: 0; }
  #accounts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
  #accounts .card { margin-bottom: 0; }
  #accounts .filters { grid-column: 1 / -1; }
}
