/* ThriftyKimi — cash flow record
   Theme tokens aligned with suite apps (pamperedkimi / agilesoba). */

:root,
html[data-theme="default"] {
  --ink: #14201c;
  --ink-soft: #3d4f47;
  --muted: #6b7c74;
  --paper: #f3f6f2;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --line: rgba(20, 32, 28, 0.1);
  --accent: #0f7a5f;
  --accent-deep: #0a5543;
  --accent-hover: #0a5543;
  --accent-soft: #d8f0e7;
  --accent-rgb: 15, 122, 95;
  --ink-rgb: 20, 32, 28;
  --warn: #b45309;
  --warn-soft: #fff1df;
  --danger: #b42318;
  --ok: #0f7a5f;
  --ok-soft: #d8f0e7;
  --income: #1b8a5a;
  --expense: #c62828;
  --fab-idle: var(--accent);
  --radius: 14px;
  --shadow: 0 18px 50px rgba(20, 32, 28, 0.08);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", system-ui, sans-serif;
  --bg-glow-1: #c8e8dc;
  --bg-glow-2: #dce8f5;
  --bg-mid: #eef4ef;
  --bg-end: #e8efe9;
  --topbar-bg: rgba(243, 246, 242, 0.7);
  --nav-bg: rgba(255, 255, 255, 0.75);
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-bg-soft: rgba(255, 255, 255, 0.7);
  --muted-surface: #f7f7f5;
  --brand-end: #1d6b9f;
  --modal-backdrop: rgba(20, 32, 28, 0.45);
  --nav-active-fg: #ffffff;
  --logo-ks: #1d2b4d;
  --networth-from: #0a5543;
  --networth-to: #1d6b9f;
}

html[data-theme="blue"] {
  --ink: #132428;
  --ink-soft: #3a555c;
  --muted: #6a8288;
  --paper: #f2f7f8;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --line: rgba(19, 36, 40, 0.1);
  --accent: #308695;
  --accent-deep: #246a76;
  --accent-hover: #246a76;
  --accent-soft: #d5ebee;
  --accent-rgb: 48, 134, 149;
  --ink-rgb: 19, 36, 40;
  --warn: #b45309;
  --warn-soft: #fff1df;
  --danger: #b42318;
  --ok: #308695;
  --ok-soft: #d5ebee;
  --shadow: 0 18px 50px rgba(19, 36, 40, 0.08);
  --bg-glow-1: #c5e4e9;
  --bg-glow-2: #d7e4f2;
  --bg-mid: #eef5f6;
  --bg-end: #e6f0f2;
  --topbar-bg: rgba(242, 247, 248, 0.7);
  --nav-bg: rgba(255, 255, 255, 0.75);
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-bg-soft: rgba(255, 255, 255, 0.7);
  --muted-surface: #f5f8f9;
  --brand-end: #1d6b9f;
  --modal-backdrop: rgba(19, 36, 40, 0.45);
  --nav-active-fg: #ffffff;
  --networth-from: #246a76;
  --networth-to: #1d6b9f;
}

html[data-theme="red"] {
  --ink: #2a1418;
  --ink-soft: #5c3a41;
  --muted: #8a6a70;
  --paper: #f8f3f4;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --line: rgba(42, 20, 24, 0.1);
  --accent: #d45769;
  --accent-deep: #a83d4c;
  --accent-hover: #a83d4c;
  --accent-soft: #f8dce1;
  --accent-rgb: 212, 87, 105;
  --ink-rgb: 42, 20, 24;
  --warn: #b45309;
  --warn-soft: #fff1df;
  --danger: #b42318;
  --ok: #0f7a5f;
  --ok-soft: #d8f0e7;
  --shadow: 0 18px 50px rgba(42, 20, 24, 0.08);
  --bg-glow-1: #f0d0d6;
  --bg-glow-2: #e8dce8;
  --bg-mid: #f7eef0;
  --bg-end: #f3e8ea;
  --topbar-bg: rgba(248, 243, 244, 0.7);
  --nav-bg: rgba(255, 255, 255, 0.75);
  --card-bg: rgba(255, 255, 255, 0.85);
  --muted-surface: #f7f2f3;
  --brand-end: #9b4d7a;
  --modal-backdrop: rgba(42, 20, 24, 0.45);
  --nav-active-fg: #ffffff;
  --networth-from: #a83d4c;
  --networth-to: #9b4d7a;
}

html[data-theme="grey"] {
  --ink: #22262b;
  --ink-soft: #4a525c;
  --muted: #7a828c;
  --paper: #f2f3f5;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --line: rgba(34, 38, 43, 0.1);
  --accent: #5c6570;
  --accent-deep: #3e4650;
  --accent-hover: #3e4650;
  --accent-soft: #e4e7eb;
  --accent-rgb: 92, 101, 112;
  --ink-rgb: 34, 38, 43;
  --warn: #b45309;
  --warn-soft: #fff1df;
  --danger: #b42318;
  --ok: #5c6570;
  --ok-soft: #e4e7eb;
  --shadow: 0 18px 50px rgba(34, 38, 43, 0.08);
  --bg-glow-1: #dde1e6;
  --bg-glow-2: #e8eaee;
  --bg-mid: #f1f2f4;
  --bg-end: #e9ebef;
  --topbar-bg: rgba(242, 243, 245, 0.78);
  --nav-bg: rgba(255, 255, 255, 0.75);
  --card-bg: rgba(255, 255, 255, 0.85);
  --muted-surface: #f6f7f8;
  --brand-end: #7a828c;
  --modal-backdrop: rgba(34, 38, 43, 0.45);
  --nav-active-fg: #ffffff;
  --networth-from: #3e4650;
  --networth-to: #7a828c;
}

html[data-theme="mono"] {
  --ink: #0a0a0a;
  --ink-soft: #2a2a2a;
  --muted: #666666;
  --paper: #ffffff;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --line: rgba(0, 0, 0, 0.18);
  --accent: #111111;
  --accent-deep: #000000;
  --accent-hover: #000000;
  --accent-soft: #ececec;
  --accent-rgb: 17, 17, 17;
  --ink-rgb: 10, 10, 10;
  --warn: #222222;
  --warn-soft: #f0f0f0;
  --danger: #000000;
  --ok: #222222;
  --ok-soft: #e8e8e8;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.1);
  --bg-glow-1: #f5f5f5;
  --bg-glow-2: #eeeeee;
  --bg-mid: #fafafa;
  --bg-end: #f0f0f0;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --nav-bg: rgba(255, 255, 255, 0.75);
  --card-bg: #ffffff;
  --muted-surface: #f4f4f4;
  --brand-end: #333333;
  --modal-backdrop: rgba(0, 0, 0, 0.5);
  --nav-active-fg: #ffffff;
  --networth-from: #111111;
  --networth-to: #333333;
}

html[data-mode="dark"] {
  --ink: #e7efea;
  --ink-soft: #b7c7bf;
  --muted: #8a9a92;
  --paper: #101614;
  --surface: rgba(28, 36, 32, 0.78);
  --surface-solid: #1a2220;
  --line: rgba(231, 239, 234, 0.12);
  --ink-rgb: 231, 239, 234;
  --warn: #f0b35a;
  --warn-soft: #3a2c18;
  --danger: #f07167;
  --ok: #3dba95;
  --ok-soft: #1c3d33;
  --income: #3dba95;
  --expense: #f07167;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --bg-glow-1: #1a3a30;
  --bg-glow-2: #1a2a3a;
  --bg-mid: #121a17;
  --bg-end: #0e1412;
  --topbar-bg: rgba(16, 22, 20, 0.85);
  --nav-bg: rgba(26, 34, 32, 0.9);
  --card-bg: rgba(26, 34, 32, 0.92);
  --card-bg-soft: rgba(26, 34, 32, 0.75);
  --muted-surface: #151c1a;
  --modal-backdrop: rgba(0, 0, 0, 0.55);
  --nav-active-fg: #101614;
  --logo-ks: #f2eee3;
  --networth-from: #1c3d33;
  --networth-to: #1a2a3a;
  color-scheme: dark;
}

html[data-mode="dark"][data-theme="default"] {
  --accent: #3dba95;
  --accent-deep: #7ee0c0;
  --accent-hover: #2fa882;
  --accent-soft: #1c3d33;
  --accent-rgb: 61, 186, 149;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  color-scheme: light;
  touch-action: manipulation;
}

html[data-mode="dark"] {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-glow-1) 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, var(--bg-glow-2) 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-mid) 0%, var(--paper) 40%, var(--bg-end) 100%);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.bg-grid {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(var(--ink-rgb), 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--ink-rgb), 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.55), transparent 85%);
  z-index: 0;
}

.suite-topbar,
.app-main {
  position: relative;
  z-index: 1;
}

.suite-topbar {
  position: relative;
  width: min(960px, calc(100% - 2rem));
  margin: calc(1rem + env(safe-area-inset-top, 0px)) auto 0;
  margin-bottom: 0;
  z-index: 40;
}

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.55rem 1rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--ink);
}

.btn[hidden] {
  display: none !important;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-soft);
}

.btn-ghost:hover {
  background: var(--card-bg-soft);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
}

.btn-block {
  width: 100%;
  margin-top: 0.75rem;
}

.btn.danger,
.danger {
  color: var(--danger);
}

.app-main {
  width: min(720px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2rem;
}

.tab-page[hidden] {
  display: none !important;
}

.hero {
  margin-bottom: 1rem;
}

.hero.compact {
  margin-bottom: 1.25rem;
}

.page-kicker {
  margin: 0 0 0.35rem;
  color: var(--accent-deep);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.85rem, 4.5vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  background: linear-gradient(120deg, var(--ink) 30%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero.compact .hero-brand {
  font-size: clamp(1.55rem, 4vw, 2rem);
}

.hero-sub {
  margin: 0.45rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 34rem;
}

.hero {
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.panel {
  margin: 1rem 0;
  padding: 1.15rem 1.25rem 1.3rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  animation: rise 0.65s ease 0.08s both;
}

.panel-head {
  margin-bottom: 0.85rem;
}

.panel-head.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.panel h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  letter-spacing: -0.02em;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.center-hint {
  text-align: center;
  margin: 1rem 0 2rem;
}

.center-hint a {
  color: var(--accent);
}

.empty-hint {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem 1rem;
  margin: 0;
}

/* —— Toolbars —— */

.home-toolbar,
.page-toolbar,
.tx-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.period-btn,
.date-label-btn {
  font: inherit;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.35rem 0.25rem;
}

.chev {
  font-size: 0.7rem;
  color: var(--accent-deep);
  opacity: 0.9;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: 0.15rem;
}

.date-label {
  font-weight: 600;
  min-width: 6.5rem;
  text-align: center;
  font-size: 0.95rem;
}

.icon-btn {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 1.15rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  /* Easier to hit below the status bar on iPhone */
  touch-action: manipulation;
}

.icon-btn.accent {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
  font-weight: 700;
  font-size: 1.35rem;
}

.icon-btn.ghost {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.95rem;
}

.toolbar-spacer {
  width: 2rem;
  flex-shrink: 0;
}

.home-mark {
  width: 2rem;
  height: 2rem;
}

/* —— Home expense / income —— */

.flow-hero {
  text-align: center;
  margin: 0.35rem 0 1.1rem;
}

.flow-toggle {
  display: inline-flex;
  gap: 0.2rem;
  padding: 0.2rem;
  border-radius: 999px;
  background: var(--muted-surface);
  border: 1px solid var(--line);
  margin-bottom: 0.65rem;
}

.flow-toggle-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  min-width: 5.5rem;
}

.flow-toggle-btn.is-active {
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(var(--ink-rgb), 0.08);
}

.flow-hero.is-income .flow-toggle-btn.is-active {
  color: var(--income);
}

.flow-hero.is-expense .flow-toggle-btn.is-active {
  color: var(--expense);
}

.flow-total {
  margin: 0;
  font-weight: 700;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.flow-hero.is-income .flow-total {
  color: var(--income);
}

.flow-hero.is-expense .flow-total {
  color: var(--expense);
}

.cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.cat-card {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem 0.5rem 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  text-align: center;
  color: inherit;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  animation: cat-in 0.35s ease both;
}

.cat-card:nth-child(1) { animation-delay: 0.02s; }
.cat-card:nth-child(2) { animation-delay: 0.05s; }
.cat-card:nth-child(3) { animation-delay: 0.08s; }
.cat-card:nth-child(4) { animation-delay: 0.11s; }
.cat-card:nth-child(5) { animation-delay: 0.14s; }
.cat-card:nth-child(6) { animation-delay: 0.17s; }

.cat-card:active {
  transform: scale(0.97);
}

@keyframes cat-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.cat-card-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  line-height: 1.2;
  min-height: 1.7em;
}

.cat-icon {
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.15rem;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--cat-tint, var(--muted-surface, #eee));
}

.cat-icon--photo {
  padding: 0;
  box-shadow: 0 0 0 1.5px color-mix(in srgb, var(--cat-tint, transparent) 55%, transparent);
}

.cat-icon--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: inherit;
}

.field-block {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.symbol-field {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.symbol-preview {
  width: min(100%, 9.5rem);
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #f3f1ec;
  align-self: center;
  cursor: pointer;
}

.symbol-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.symbol-photo-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.4rem;
}

.symbol-photo-actions .hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  text-align: center;
}

.btn-block {
  width: 100%;
}

.symbol-pick--custom {
  border-style: dashed;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface, #fff));
}

.symbol-pick-plus {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 1.55rem;
  font-weight: 500;
  line-height: 1;
  color: var(--accent-deep, var(--accent));
  background: color-mix(in srgb, var(--accent) 14%, #fff);
}

.symbol-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
}

.symbol-pick {
  appearance: none;
  -webkit-appearance: none;
  border: 1.5px solid var(--line);
  background: var(--surface, #fff);
  border-radius: 12px;
  padding: 0.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
  min-width: 0;
  aspect-ratio: 1;
}

.symbol-pick img {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 999px;
  object-fit: cover;
  display: block;
  background: #f3f1ec;
  flex-shrink: 0;
}

.symbol-pick.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 28%, transparent);
}

.symbol-pick:active {
  transform: scale(0.96);
}

.form-stack input[type="color"] {
  padding: 0.25rem;
  min-height: 2.6rem;
  cursor: pointer;
}

.cat-card-amt {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--ink);
}

.cat-card-amt.is-zero {
  color: var(--muted);
  font-weight: 500;
}

/* —— Account —— */

.networth-card {
  background: linear-gradient(135deg, var(--networth-from), var(--networth-to));
  color: #fff;
  border-radius: 18px;
  padding: 1rem 1.15rem 1.1rem;
  margin-bottom: 1rem;
  box-shadow: 0 12px 32px rgba(var(--accent-rgb), 0.28);
  animation: fade-up 0.4s ease both;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.networth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.networth-title {
  font-weight: 600;
  font-size: 0.95rem;
  opacity: 0.95;
}

.networth-spacer {
  width: 2.25rem;
}

.networth-value {
  margin: 0.65rem 0 0.9rem;
  text-align: center;
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.networth-value.is-hidden,
.nw-num.is-hidden,
.acct-bal.is-hidden {
  filter: blur(7px);
  user-select: none;
}

.networth-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  opacity: 0.95;
}

.nw-label {
  display: block;
  opacity: 0.75;
  margin-bottom: 0.15rem;
}

.nw-num {
  font-weight: 650;
}

.nw-right {
  text-align: right;
}

.acct-section {
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  border-radius: 16px;
  margin-bottom: 0.85rem;
  overflow: hidden;
}

.acct-section-head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.acct-section-title {
  font-weight: 650;
  color: var(--accent-deep);
}

.acct-section-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.acct-section-meta.owed {
  color: var(--expense);
}

.acct-section.is-collapsed .acct-list {
  display: none;
}

.acct-section.is-collapsed .chev {
  transform: rotate(-90deg);
  display: inline-block;
}

.acct-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.acct-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--line);
  cursor: pointer;
}

.acct-row:active {
  background: var(--muted-surface);
}

.acct-summary {
  margin-bottom: 0.75rem;
}

.acct-summary-hero {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.35rem 0.15rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.acct-summary-meta {
  flex: 1;
  min-width: 0;
}

.acct-summary-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.acct-summary-type {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.15rem;
}

.acct-summary-bal {
  font-weight: 700;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.acct-summary-totals {
  margin: 0.35rem 0 0.75rem;
}

.acct-summary-list {
  padding-bottom: 1.5rem;
}

.acct-info {
  flex: 1;
  min-width: 0;
}

.acct-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.acct-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.acct-right {
  text-align: right;
}

.acct-bal {
  font-weight: 700;
  font-size: 0.95rem;
}

.acct-avl {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

/* —— Calendar / transactions —— */

.calendar-card {
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  border-radius: 16px;
  padding: 0.65rem 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.cal-weekdays,
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-weekday {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.25rem 0;
}

.cal-cell {
  appearance: none;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 0.35rem 0.1rem 0.4rem;
  min-height: 3.4rem;
  cursor: pointer;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
  position: relative;
}

.cal-cell.is-other {
  opacity: 0.35;
}

.cal-cell.is-selected {
  background: var(--accent-soft);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.cal-cell.is-selected .cal-in,
.cal-cell.is-selected .cal-out {
  color: inherit;
  opacity: 0.85;
}

.cal-day {
  font-weight: 650;
  font-size: 0.9rem;
}

.cal-in {
  font-size: 0.55rem;
  color: var(--income);
  font-weight: 600;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-out {
  font-size: 0.55rem;
  color: var(--expense);
  font-weight: 600;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cal-dot {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
}

.cal-cell.is-selected .cal-dot {
  background: var(--accent);
}

.day-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding: 0.5rem 0.25rem 0.85rem;
  text-align: center;
}

.sum-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.sum-value {
  font-weight: 700;
  font-size: 0.95rem;
}

.sum-value.income {
  color: var(--income);
}

.sum-value.expense {
  color: var(--expense);
}

.sum-value.balance {
  color: var(--ink);
}

.tx-list-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  border-radius: 16px;
  margin-bottom: 4.5rem;
  overflow: hidden;
}

.tx-day-head {
  display: flex;
  justify-content: space-between;
  padding: 0.65rem 1rem 0.35rem;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--ink-soft);
}

.tx-day-out {
  color: var(--expense);
}

.tx-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 1rem;
  border-top: 1px solid var(--line);
  cursor: pointer;
  width: 100%;
  border-left: none;
  border-right: none;
  border-bottom: none;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
}

.tx-row:first-of-type {
  border-top: 1px solid var(--line);
}

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

.tx-cat {
  font-weight: 650;
  font-size: 0.95rem;
}

.tx-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.tx-amt-col {
  text-align: right;
}

.tx-amt {
  font-weight: 700;
  font-size: 0.95rem;
}

.tx-amt.is-expense {
  color: var(--expense);
}

.tx-amt.is-income {
  color: var(--income);
}

.tx-time {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.tx-acct-ico {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 0.65rem;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  padding: 0;
}

.tx-seg {
  position: fixed;
  left: 50%;
  bottom: calc(72px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  /* suite-aligned floating segment */
  display: flex;
  gap: 0.2rem;
  padding: 0.25rem;
  background: var(--nav-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 45;
  backdrop-filter: blur(10px);
}

.tx-seg[hidden] {
  display: none !important;
}

.tx-seg-btn {
  border: none;
  background: transparent;
  font: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-soft);
}

.tx-seg-btn.is-active {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--accent-deep);
}

/* —— Settings —— */

.settings-card {
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  border-radius: 16px;
  margin-bottom: 0.85rem;
  overflow: hidden;
}

.settings-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: none;
  border-top: 1px solid var(--line);
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.settings-row:first-child {
  border-top: none;
}

.settings-row.static {
  cursor: default;
}

.settings-ico {
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.settings-ico--photo {
  padding: 0;
  background: #f3f1ec;
}

.settings-ico--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.settings-meta {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.85rem;
}

.settings-row .chev {
  margin-left: 0.35rem;
  color: var(--muted);
}

.settings-row .settings-meta + .chev {
  margin-left: 0.35rem;
}

.settings-row > span:nth-child(2) {
  flex: 1;
  font-weight: 550;
}

/* —— Bottom nav + FAB —— */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  gap: 0.15rem;
  padding: 0.45rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom));
  background: var(--nav-bg);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.nav-item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 650;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.35rem 0.15rem;
  cursor: pointer;
}

.nav-item.is-active {
  color: var(--accent-deep);
}

.nav-icon {
  font-size: 1.1rem;
  line-height: 1;
  width: auto;
  height: auto;
  display: block;
  border-radius: 0;
  background: transparent;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 650;
}

.fab-transfer {
  position: fixed;
  right: max(1rem, calc((100% - min(720px, 100%)) / 2 + 1rem));
  bottom: calc(78px + env(safe-area-inset-bottom));
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 999px;
  border: none;
  background: var(--fab-idle, var(--accent));
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(var(--accent-rgb), 0.35);
  z-index: 48;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease, background 0.2s ease;
}

.fab-transfer:active {
  transform: scale(0.95);
}

.fab-transfer[hidden] {
  display: none !important;
}

/* —— Sheets —— */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  /* Keep sheet chrome below the notch / status bar in iOS standalone */
  padding-top: env(safe-area-inset-top, 0px);
  box-sizing: border-box;
  background: var(--modal-backdrop);
  backdrop-filter: blur(3px);
  z-index: 80;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: backdrop-in 0.2s ease;
}

.sheet-backdrop[hidden] {
  display: none !important;
}

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sheet {
  width: min(720px, 100%);
  max-height: min(92vh, calc(100vh - env(safe-area-inset-top, 0px) - 0.5rem), 920px);
  max-height: min(92dvh, calc(100dvh - env(safe-area-inset-top, 0px) - 0.5rem), 920px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-solid);
  border-radius: 18px 18px 0 0;
  padding: 0.75rem 1rem calc(1rem + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(var(--ink-rgb), 0.22);
  animation: sheet-up 0.28s ease;
}

.sheet-full {
  max-height: calc(100vh - env(safe-area-inset-top, 0px) - 0.35rem);
  max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 0.35rem);
  min-height: min(70vh, calc(100dvh - env(safe-area-inset-top, 0px) - 0.35rem));
}

.sheet-short {
  max-height: 50vh;
}

.entry-sheet {
  padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
}

@keyframes sheet-up {
  from {
    transform: translateY(24px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  background: var(--surface-solid);
  padding: 0.15rem 0 0.45rem;
  min-height: 2.75rem;
}

.sheet-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet-head-spacer {
  width: 2.25rem;
}

.entry-amount {
  text-align: center;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin: 0.5rem 0 0.85rem;
}

.subcat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
  min-height: 0.5rem;
}

.chip {
  border: none;
  background: var(--muted-surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 550;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}

.chip.is-active {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  color: var(--accent-deep);
}

.entry-toolbar {
  display: flex;
  gap: 0.25rem;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 0.35rem 0.25rem;
  margin-bottom: 0.65rem;
  overflow-x: auto;
}

html[data-mode="dark"] .entry-toolbar {
  background: var(--accent-soft);
}

.entry-tool {
  flex: 1;
  min-width: 3.5rem;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.65rem;
  color: var(--ink-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 0.2rem;
  cursor: pointer;
}

.entry-tool span:first-child {
  font-size: 0.95rem;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
}

.keypad button {
  font: inherit;
  font-size: 1.25rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--muted-surface);
  color: var(--ink);
  border-radius: 12px;
  min-height: 3.1rem;
  cursor: pointer;
}

.keypad button:active {
  transform: scale(0.97);
}

.keypad .key-ok {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-size: 1.4rem;
}

.mgr-scroll {
  padding-bottom: 2rem;
}

.mgr-section {
  background: var(--muted-surface);
  border-radius: 14px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.mgr-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-weight: 700;
}

.mgr-section-head .accent-plus {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
}

.mgr-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-top: 1px solid var(--line);
  background: var(--surface-solid);
}

.mgr-row-name {
  flex: 1;
  font-weight: 550;
}

.mgr-more {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-stack label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.form-stack input,
.form-stack select,
.form-stack textarea {
  font: inherit;
  font-weight: 500;
  color: var(--ink);
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--muted-surface);
}

.picker-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.picker-item {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--muted-surface);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.picker-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.note-input {
  width: 100%;
  font: inherit;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--muted-surface);
  color: var(--ink);
  resize: vertical;
}

.tx-detail-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.5rem;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.95rem;
}

.detail-row span:first-child {
  color: var(--muted);
}

.detail-row strong {
  font-weight: 650;
  text-align: right;
}

/* —— Budget —— */

.budget-title-label {
  font-weight: 700;
  font-size: 1.05rem;
  min-width: 4rem;
}

.budget-summary {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.85rem;
  animation: fade-up 0.4s ease both;
}

.budget-summary-ring {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.budget-ring-track,
.budget-ring-fill {
  fill: none;
  stroke-width: 10;
  stroke-linecap: round;
}

.budget-ring-track {
  stroke: var(--muted-surface);
}

.budget-ring-fill {
  stroke: var(--accent);
  stroke-dasharray: 326.73;
  stroke-dashoffset: 326.73;
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
  transition: stroke-dashoffset 0.45s ease, stroke 0.3s ease;
}

.budget-ring-fill.is-warn {
  stroke: var(--warn);
}

.budget-ring-fill.is-over {
  stroke: var(--expense);
}

.budget-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.budget-ring-pct {
  font-weight: 750;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.budget-ring-sub {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
}

.budget-summary-stats {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.budget-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.5rem;
}

.budget-card {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  animation: cat-in 0.3s ease both;
}

.budget-card:active {
  transform: scale(0.99);
}

.budget-card-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.55rem;
}

.budget-card-name {
  flex: 1;
  font-weight: 650;
  font-size: 0.95rem;
}

.budget-card-amt {
  font-weight: 700;
  font-size: 0.9rem;
}

.budget-card-amt.is-over {
  color: var(--expense);
}

.budget-bar {
  height: 8px;
  border-radius: 999px;
  background: var(--muted-surface);
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.budget-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
  width: 0;
  transition: width 0.35s ease, background 0.3s ease;
}

.budget-bar-fill.is-warn {
  background: var(--warn);
}

.budget-bar-fill.is-over {
  background: var(--expense);
}

.budget-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 550;
}

.budget-card-meta .left-ok {
  color: var(--income);
}

.budget-card-meta .left-over {
  color: var(--expense);
}

.entry-budget {
  margin: 0 0 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}

.entry-budget.is-warn {
  background: var(--warn-soft);
}

.entry-budget.is-over {
  background: color-mix(in srgb, var(--expense) 12%, transparent);
}

.entry-budget-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 650;
  color: var(--income);
  margin-bottom: 0.35rem;
}

.entry-budget.is-warn .entry-budget-meta {
  color: var(--warn);
}

.entry-budget.is-over .entry-budget-meta {
  color: var(--expense);
}

.entry-budget-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(var(--ink-rgb), 0.08);
  overflow: hidden;
}

.entry-budget-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--income);
  width: 0;
  transition: width 0.25s ease, background 0.2s ease;
}

.entry-budget.is-warn .entry-budget-fill {
  background: var(--warn);
}

.entry-budget.is-over .entry-budget-fill {
  background: var(--expense);
}

@media (min-width: 640px) {
  .sheet-backdrop {
    align-items: center;
  }

  .sheet {
    border-radius: 20px;
    max-height: min(88vh, 860px);
  }
}
