:root {
  color-scheme: dark;
  --bg: #080706;
  --bg-soft: #11100e;
  --panel: #171411;
  --panel-raised: #201b16;
  --line: #34291f;
  --text: #f8f2ea;
  --muted: #aa9b8b;
  --muted-strong: #d6c3ae;
  --orange: #ff7a1a;
  --orange-strong: #ff9a3d;
  --orange-soft: rgba(255, 122, 26, 0.14);
  --green: #45d483;
  --yellow: #ffd166;
  --red: #ff6b6b;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  --sidebar-width: 288px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Keep hidden form fields truly hidden even when generic label/input styles apply. */
[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 122, 26, 0.12), transparent 30rem),
    linear-gradient(145deg, #050403 0%, #100c08 48%, #050403 100%);
  color: var(--text);
}

body.light-mode {
  color-scheme: light;
  --bg: #fffaf4;
  --bg-soft: #fff3e5;
  --panel: #ffffff;
  --panel-raised: #fff7ed;
  --line: #f0d9c0;
  --text: #1f160f;
  --muted: #7a6652;
  --muted-strong: #4b3624;
  --orange-soft: rgba(255, 122, 26, 0.12);
  --shadow: 0 18px 50px rgba(107, 63, 22, 0.12);
  background:
    radial-gradient(circle at 12% 0%, rgba(255, 122, 26, 0.18), transparent 30rem),
    linear-gradient(145deg, #fff8ef 0%, #fffdf9 48%, #ffe7ce 100%);
}

.currency-field {
  position: relative;
  display: grid;
}

.currency-prefix {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 2;
  color: var(--muted-strong);
  font-weight: 850;
  pointer-events: none;
  transform: translateY(-50%);
}

.currency-field input {
  padding-left: 36px;
}

.optional-label {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(8, 7, 6, 0.84);
  backdrop-filter: blur(18px);
}

.light-mode .sidebar {
  background: rgba(255, 250, 244, 0.88);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  overflow: hidden;
  border: 1px solid rgba(255, 122, 26, 0.5);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.22), transparent), #130d09;
  color: var(--orange-strong);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand-mark img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* The Rising Stack, inline so each theme can recolor the bars for contrast. */
.brand-stack {
  flex: none;
  width: 46px;
  height: 46px;
}

.brand-stack .bar-low { fill: #7d766b; }
.brand-stack .bar-mid { fill: #cfc6b8; }
.brand-stack .bar-top { fill: var(--orange); }

.light-mode .brand-stack .bar-low { fill: #55503f; }
.light-mode .brand-stack .bar-mid { fill: #99927e; }

.auth-stack {
  width: 64px;
  height: 64px;
}

.brand-word {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
}

.logo-mark {
  position: relative;
  background: #130d09;
}

.logo-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.brand-dot {
  color: var(--orange);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list a {
  position: relative;
  overflow: hidden;
  padding: 11px 12px 11px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted-strong);
}

.nav-list a::before {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 5px;
  width: 3px;
  border-radius: 999px;
  background: transparent;
  content: "";
}

.nav-list a:hover,
.nav-list a.active {
  border-color: rgba(255, 122, 26, 0.28);
  background: var(--orange-soft);
  color: var(--text);
}

.nav-list a.active::before {
  background: var(--orange-strong);
  box-shadow: 0 0 14px rgba(255, 122, 26, 0.7);
}

.sync-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid rgba(255, 122, 26, 0.2);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--panel-raised), var(--panel));
  box-shadow: var(--shadow);
}

.sync-card h2 {
  margin: 6px 0;
  font-size: 1.45rem;
}

.sync-card p:last-of-type {
  color: var(--muted);
  line-height: 1.5;
}

.main-content {
  display: grid;
  align-content: start;
  gap: 22px;
  min-width: 0;
  padding: 26px;
}

.app-view {
  min-width: 0;
}

.app-view[hidden] {
  display: none;
}

.app-view.active {
  display: grid;
  gap: 22px;
  animation: viewEnter 280ms ease-out;
}

.focused-panel {
  min-height: calc(100vh - 260px);
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0 4px;
}

.topbar-copy {
  display: grid;
  gap: 8px;
}

.month-range {
  margin: 0;
  color: var(--muted-strong);
  font-size: 0.95rem;
  font-weight: 650;
}

.topbar h1 {
  max-width: 720px;
  margin: 4px 0 0;
  font-size: clamp(2rem, 4vw, 4.25rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.topbar-controls,
.topbar-actions,
.filter-group,
.month-switcher,
.chart-layout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.topbar-controls {
  justify-content: flex-end;
}

.month-switcher {
  border: 1px solid rgba(255, 122, 26, 0.28);
  border-radius: var(--radius);
  padding: 7px;
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.14), rgba(255, 255, 255, 0.035)), var(--panel);
  box-shadow: var(--shadow);
}

.month-select-shell {
  display: grid;
  min-width: 190px;
  gap: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.month-select-shell select {
  min-height: 34px;
  border: 0;
  padding: 0 4px;
  background: transparent;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.profile-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  border: 1px solid rgba(255, 122, 26, 0.42);
  border-radius: var(--radius);
  padding: 0 12px 0 8px;
  background: var(--orange-soft);
  color: var(--text);
  font-weight: 800;
}

.profile-button.signed-in {
  border-color: rgba(69, 212, 131, 0.44);
}

.profile-avatar {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--orange-strong));
  color: #160901;
  font-size: 0.78rem;
}

.profile-button.signed-in .profile-avatar {
  background: linear-gradient(135deg, var(--green), #86efac);
}

.chart-select-shell {
  display: grid;
  min-width: 170px;
  gap: 4px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.chart-select-shell select {
  min-height: 38px;
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.chart-export-button {
  align-self: flex-end;
  min-height: 38px;
}

.dashboard-visualization {
  overflow: hidden;
}

.chart-layout {
  align-items: stretch;
}

.chart-stage {
  flex: 1 1 520px;
  min-height: 300px;
  border: 1px solid rgba(255, 122, 26, 0.16);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.08), rgba(255, 255, 255, 0.025));
}

.chart-summary {
  display: grid;
  flex: 0 1 260px;
  gap: 10px;
}

.chart-stat {
  display: grid;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--panel-raised);
}

.chart-stat span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.chart-stat strong {
  color: var(--text);
  font-size: 1.1rem;
}

.chart-svg {
  display: block;
  width: 100%;
  height: 300px;
}

.chart-label {
  fill: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

.chart-value {
  fill: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.chart-bar {
  fill: var(--orange);
  opacity: 0.92;
}

.chart-bar-income {
  fill: var(--green);
}

.chart-bar-expense {
  fill: var(--orange);
}

.chart-stat-income {
  border-color: rgba(69, 212, 131, 0.32);
}

.chart-stat-expense {
  border-color: rgba(255, 122, 26, 0.32);
}

.chart-axis {
  stroke: var(--line);
  stroke-width: 2;
}

.chart-line {
  fill: none;
  stroke: var(--orange-strong);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

.chart-line-income {
  stroke: var(--green);
}

.chart-line-expense {
  stroke: var(--orange-strong);
}

.chart-donut-hole {
  fill: var(--panel);
}

.bill-stars {
  color: var(--orange-strong);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.bill-adjustment {
  color: var(--orange-strong);
}

.bill-note {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(255, 122, 26, 0.22);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--orange-soft);
}

.bill-note strong {
  color: var(--text);
}

.bill-note ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
  color: var(--muted-strong);
  font-size: 0.88rem;
}

.chart-empty {
  display: grid;
  min-height: 300px;
  place-items: center;
  padding: 20px;
  color: var(--muted-strong);
  text-align: center;
}

.month-arrow:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  transform: none;
}

.button,
.icon-button,
.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--panel-raised);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button {
  padding: 0 16px;
  font-weight: 750;
}

.button:hover,
.icon-button:hover,
.chip:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 122, 26, 0.55);
}

.button.primary {
  border-color: rgba(255, 122, 26, 0.72);
  background: linear-gradient(135deg, var(--orange), #d84f08);
  color: #160901;
}

.button.secondary {
  background: var(--panel);
}

.button.ghost {
  background: transparent;
}

.button.danger {
  border-color: rgba(255, 107, 107, 0.7);
  background: rgba(255, 107, 107, 0.13);
  color: var(--red);
}

.button.full {
  width: 100%;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 1.2rem;
}

.chip {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted-strong);
}

.chip.active {
  border-color: rgba(255, 122, 26, 0.48);
  background: var(--orange-soft);
  color: var(--text);
}

.eyebrow {
  margin: 0;
  color: var(--orange-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(300px, 1.4fr) repeat(3, minmax(180px, 1fr));
  gap: 16px;
}

.navigation-target {
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.summary-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent), var(--panel);
  box-shadow: var(--shadow);
}

.summary-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 178px;
  padding: 18px;
}

.summary-panel h2 {
  margin: 12px 0 8px;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  letter-spacing: 0;
}

.primary-summary {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.22), rgba(255, 122, 26, 0.02)), var(--panel);
}

.primary-summary::after {
  position: absolute;
  right: -36px;
  bottom: -56px;
  width: 210px;
  height: 210px;
  border: 1px solid rgba(255, 122, 26, 0.18);
  border-radius: 50%;
  content: "";
}

.cashflow-meter {
  position: relative;
  z-index: 1;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.cashflow-meter span {
  display: block;
  width: 72%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--green));
}

.trend {
  margin: 0;
  font-weight: 700;
}

.trend.positive {
  color: var(--green);
}

.trend.warning {
  color: var(--yellow);
}

.trend.critical {
  color: var(--red);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel.attention-pulse,
.budget-item.attention-pulse,
.transaction-row.attention-pulse {
  animation: attentionPulse 1400ms ease;
  border-color: rgba(255, 122, 26, 0.85);
}

.panel.wide {
  min-height: 380px;
}

.nav-twinkle {
  animation: navTwinkle 620ms ease-in-out 2;
  border-color: rgba(255, 154, 61, 0.9);
}

@keyframes viewEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes navTwinkle {
  0%,
  100% {
    border-color: var(--line);
    box-shadow: var(--shadow);
  }

  50% {
    border-color: rgba(255, 184, 102, 0.98);
    box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.12), 0 0 28px rgba(255, 122, 26, 0.34), var(--shadow);
  }
}

@keyframes attentionPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 122, 26, 0.38), var(--shadow);
  }

  100% {
    box-shadow: 0 0 0 18px rgba(255, 122, 26, 0), var(--shadow);
  }
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 5px 0 0;
  font-size: 1.28rem;
  letter-spacing: 0;
}

.budget-list,
.goal-list,
.bill-list,
.insight-list {
  display: grid;
  gap: 12px;
}

.budget-item,
.goal-item,
.bill-item,
.insight-item {
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius);
  background: var(--panel-raised);
}

.budget-item,
.goal-item,
.bill-item,
.insight-item {
  padding: 13px;
}

.empty-state,
.empty-table-state {
  padding: 18px;
  border: 1px dashed rgba(255, 122, 26, 0.24);
  border-radius: var(--radius);
  background: rgba(255, 122, 26, 0.06);
  color: var(--muted-strong);
}

.empty-state p {
  margin: 6px 0 0;
  line-height: 1.5;
}

.empty-table-state {
  text-align: center;
}

.budget-meta,
.goal-meta,
.bill-item,
.insight-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.goal-actions,
.bill-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.budget-title,
.goal-title,
.bill-title {
  display: grid;
  gap: 3px;
}

.budget-title small,
.goal-title small,
.bill-title small {
  color: var(--muted);
}

.progress {
  height: 10px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--orange-strong));
}

.progress.good span {
  background: linear-gradient(90deg, var(--green), #8af2b4);
}

.progress.warning span {
  background: linear-gradient(90deg, var(--yellow), var(--orange));
}

.progress.danger span {
  background: linear-gradient(90deg, var(--red), var(--orange));
}

.bill-date,
.status-pill {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 122, 26, 0.12);
  color: var(--orange-strong);
  font-size: 0.78rem;
  font-weight: 750;
}

.status-pill.ok,
.status-pill.good {
  background: rgba(69, 212, 131, 0.12);
  color: var(--green);
}

.status-pill.review,
.status-pill.warning {
  background: rgba(255, 209, 102, 0.13);
  color: var(--yellow);
}

.status-pill.danger {
  background: rgba(255, 91, 91, 0.13);
  color: var(--red);
}

button.status-pill {
  border: 0;
  cursor: pointer;
}

button.status-pill:hover {
  filter: brightness(1.08);
}

.transaction-wrap {
  overflow-x: auto;
}

.transaction-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.delete-warning {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 107, 107, 0.22);
  border-radius: var(--radius);
  padding: 13px;
  background: rgba(255, 107, 107, 0.08);
}

.delete-warning strong {
  color: var(--red);
}

.delete-warning span,
.delete-warning p {
  margin: 0;
  color: var(--muted-strong);
}

table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(255, 122, 26, 0.06);
}

.amount-cell {
  text-align: right;
}

.amount-income {
  color: var(--green);
  font-weight: 800;
}

.amount-expense {
  color: var(--text);
  font-weight: 750;
}

.transaction-form {
  display: grid;
  gap: 13px;
}

.form-note {
  margin: -3px 0 1px;
  font-size: 0.84rem;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted-strong);
  font-size: 0.9rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 13px;
  outline: none;
  background: var(--bg-soft);
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 122, 26, 0.78);
  box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.16);
}

textarea {
  resize: vertical;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: blur(10px);
}

.modal {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: 18px;
  box-shadow: var(--shadow);
}

.modal .panel-header {
  margin-bottom: 14px;
}

.auth-note {
  margin: 0 0 14px;
  line-height: 1.5;
}

.cloud-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 122, 26, 0.24);
  border-radius: var(--radius);
  background: var(--panel-raised);
}

.cloud-status span,
.cloud-status strong {
  display: block;
}

.cloud-status span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cloud-status strong {
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.cloud-status.signed-in {
  border-color: rgba(69, 212, 131, 0.32);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 10;
  max-width: 360px;
  padding: 13px 15px;
  border: 1px solid rgba(255, 122, 26, 0.28);
  border-radius: var(--radius);
  background: var(--panel-raised);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sync-card {
    margin-top: 0;
  }

  .hero-grid,
  .layout-grid {
    grid-template-columns: 1fr 1fr;
  }

  .primary-summary,
  .panel.wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .focused-panel {
    min-height: 0;
  }

  .main-content,
  .sidebar {
    padding: 18px;
  }

  .sidebar {
    gap: 18px;
  }

  .topbar,
  .topbar-controls,
  .panel-header,
  .budget-meta,
  .goal-meta,
  .bill-item,
  .insight-item {
    flex-direction: column;
    align-items: stretch;
  }

  .goal-actions,
  .bill-actions,
  .topbar-controls,
  .month-switcher {
    justify-content: flex-start;
  }

  .month-select-shell {
    flex: 1 1 180px;
    min-width: 0;
  }

  .topbar h1 {
    font-size: 2.25rem;
  }

  .hero-grid,
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .chart-layout,
  .chart-controls {
    flex-direction: column;
  }

  .chart-export-button {
    width: 100%;
  }

  .chart-summary {
    grid-template-columns: 1fr 1fr;
  }

  .nav-list {
    grid-template-columns: 1fr 1fr;
  }

  .sync-card {
    display: none;
  }


  .topbar-actions,
  .filter-group {
    width: 100%;
  }

  .topbar-actions .button,
  .filter-group .chip {
    flex: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-view.active {
    animation: none;
  }
}


.auth-checking .app-shell {
  visibility: hidden;
}

.auth-locked {
  display: grid;
  min-height: 100vh;
}

.auth-locked .app-shell {
  display: none;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 460px);
  gap: 32px;
  align-items: center;
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 48px 0;
}

.auth-screen[hidden] {
  display: none;
}

.auth-brand-panel,
.auth-card {
  border: 1px solid rgba(255, 122, 26, 0.24);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--panel-raised), var(--panel));
  box-shadow: var(--shadow);
}

.auth-brand-panel {
  display: grid;
  align-content: center;
  min-height: 520px;
  padding: 40px;
}

.auth-logo-mark {
  width: 72px;
  height: 72px;
  margin-bottom: 28px;
}

.auth-brand-panel h1 {
  max-width: 620px;
  margin: 8px 0 14px;
  font-size: clamp(2.4rem, 5vw, 5.2rem);
  line-height: 0.98;
}

.auth-brand-panel p:last-child {
  max-width: 600px;
  color: var(--muted-strong);
  font-size: 1.05rem;
  line-height: 1.7;
}

.auth-card {
  padding: 26px;
}

.auth-card h2 {
  margin: 8px 0 8px;
  font-size: 2rem;
}

.auth-toggle {
  width: 100%;
  margin-top: 14px;
  border: 0;
  background: transparent;
  color: var(--orange-strong);
  font: inherit;
  font-weight: 800;
}

@media (max-width: 860px) {
  .auth-screen {
    grid-template-columns: 1fr;
    width: min(100% - 28px, 520px);
    padding: 24px 0;
  }

  .auth-brand-panel {
    min-height: auto;
    padding: 26px;
  }

  .auth-brand-panel h1 {
    font-size: 2.4rem;
  }
}

/* Premium fintech redesign layer. This section intentionally overrides the first UI pass without changing app logic. */
:root {
  color-scheme: dark;
  --bg: #050505;
  --bg-soft: #0a0b0d;
  --panel: rgba(16, 18, 22, 0.82);
  --panel-raised: rgba(23, 26, 32, 0.9);
  --panel-solid: #111318;
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #fbfaf7;
  --muted: #919aa8;
  --muted-strong: #d1d7e0;
  --orange: #ff7a1a;
  --orange-strong: #ffb36b;
  --orange-soft: rgba(255, 122, 26, 0.13);
  --green: #4ade80;
  --yellow: #fbbf24;
  --red: #fb7185;
  --shadow: 0 26px 72px rgba(0, 0, 0, 0.42);
  --shadow-soft: 0 16px 38px rgba(0, 0, 0, 0.3);
  --focus-ring: 0 0 0 4px rgba(255, 122, 26, 0.16);
  --glow-orange: 0 0 0 1px rgba(255, 122, 26, 0.18), 0 18px 48px rgba(255, 122, 26, 0.14);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 304px;
}

::selection {
  background: rgba(255, 122, 26, 0.35);
  color: var(--text);
}

html {
  background: #050505;
}

body {
  position: relative;
  overflow-x: hidden;
  background:
    linear-gradient(115deg, rgba(255, 122, 26, 0.15), transparent 27rem),
    linear-gradient(235deg, rgba(74, 222, 128, 0.07), transparent 24rem),
    linear-gradient(135deg, #050505 0%, #0b0c0f 48%, #050505 100%);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px),
    linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.035) 48%, transparent 49%);
  background-position: center top;
  background-size: 68px 68px, 68px 68px, 420px 420px;
  mask-image: linear-gradient(to bottom, black, black 44%, transparent 100%);
  content: "";
}

body.light-mode {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-soft: #eef3f7;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-raised: rgba(255, 255, 255, 0.96);
  --panel-solid: #ffffff;
  --line: rgba(15, 23, 42, 0.11);
  --line-strong: rgba(15, 23, 42, 0.18);
  --text: #101828;
  --muted: #667085;
  --muted-strong: #344054;
  --orange-soft: rgba(255, 122, 26, 0.1);
  --shadow: 0 22px 58px rgba(15, 23, 42, 0.11);
  --shadow-soft: 0 14px 34px rgba(15, 23, 42, 0.08);
  background:
    linear-gradient(115deg, rgba(255, 122, 26, 0.14), transparent 26rem),
    linear-gradient(235deg, rgba(74, 222, 128, 0.12), transparent 22rem),
    linear-gradient(135deg, #f8fafc 0%, #fff7ed 55%, #f8fafc 100%);
}

body.light-mode::before {
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
}

.app-shell {
  isolation: isolate;
}

.sidebar {
  top: 12px;
  height: calc(100vh - 24px);
  margin: 12px 0 12px 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(18, 20, 24, 0.9), rgba(8, 9, 11, 0.82));
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(24px) saturate(1.18);
}

.light-mode .sidebar {
  background: rgba(255, 255, 255, 0.78);
}

.brand {
  min-height: 64px;
  padding: 10px;
  border: 1px solid rgba(255, 122, 26, 0.2);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.15), rgba(255, 255, 255, 0.035));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 48px;
  height: 48px;
  border-color: rgba(255, 179, 107, 0.46);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.35), rgba(255, 179, 107, 0.08));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 16px 34px rgba(255, 122, 26, 0.18);
}

.logo-mark img,
.auth-logo-mark img {
  transform: scale(1.06);
}

.brand strong {
  font-size: 1.04rem;
  letter-spacing: 0;
}

.brand small {
  color: var(--muted-strong);
}

.nav-list {
  gap: 9px;
}

.nav-list a {
  min-height: 48px;
  border-radius: 12px;
  padding: 13px 14px 13px 18px;
  color: var(--muted-strong);
  font-weight: 820;
  letter-spacing: 0;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.nav-list a::before {
  top: 12px;
  bottom: 12px;
  left: 8px;
  width: 4px;
  border-radius: 999px;
}

.nav-list a:hover {
  transform: translateX(3px);
  border-color: rgba(255, 179, 107, 0.22);
  background: rgba(255, 255, 255, 0.05);
}

.nav-list a.active {
  border-color: rgba(255, 122, 26, 0.48);
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.24), rgba(255, 255, 255, 0.052));
  box-shadow: var(--glow-orange);
  color: var(--text);
}

.nav-list a.active::before {
  background: linear-gradient(180deg, var(--orange-strong), var(--orange));
  box-shadow: 0 0 18px rgba(255, 122, 26, 0.72);
}

.sync-card {
  border-radius: 14px;
  border-color: rgba(255, 179, 107, 0.25);
  background:
    linear-gradient(135deg, rgba(255, 122, 26, 0.16), transparent 55%),
    linear-gradient(160deg, rgba(31, 33, 39, 0.94), rgba(12, 13, 16, 0.86));
  box-shadow: var(--shadow-soft);
}

.light-mode .sync-card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.95), rgba(255, 247, 237, 0.9));
}

.main-content {
  gap: 22px;
  padding: 28px 30px 34px 24px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, auto);
  align-items: start;
  margin: -10px -6px 0;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 16px;
  background: linear-gradient(180deg, rgba(5, 5, 5, 0.9), rgba(5, 5, 5, 0.58));
  backdrop-filter: blur(22px) saturate(1.12);
}

.light-mode .topbar {
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.92), rgba(248, 250, 252, 0.62));
}

.topbar-copy {
  gap: 9px;
}

.topbar h1 {
  max-width: 680px;
  font-size: clamp(2.15rem, 3vw, 3.85rem);
  letter-spacing: 0;
  line-height: 0.98;
}

.month-range {
  max-width: 640px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-proof-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-proof-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--muted-strong);
  font-size: 0.78rem;
  font-weight: 780;
  backdrop-filter: blur(14px);
}


.eyebrow {
  color: var(--orange-strong);
  letter-spacing: 0.16em;
}

.topbar-controls {
  display: grid;
  justify-items: end;
  gap: 12px;
}

.topbar-actions {
  justify-content: flex-end;
}

.month-switcher,
.profile-button,
.button,
.icon-button,
.chip,
.chart-select-shell select,
input,
select,
textarea {
  border-radius: 10px;
}

.month-switcher,
.profile-button {
  border-color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: none;
  backdrop-filter: blur(16px);
}

.month-switcher {
  padding: 6px;
}

.month-select-shell {
  min-width: 184px;
}

.profile-button {
  min-height: 44px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.profile-button:hover,
.month-switcher:hover {
  border-color: rgba(255, 122, 26, 0.42);
}

.profile-avatar {
  width: 30px;
  height: 30px;
  box-shadow: 0 12px 24px rgba(255, 122, 26, 0.24);
}

.button,
.icon-button,
.chip {
  border-color: rgba(255, 255, 255, 0.105);
  background: rgba(255, 255, 255, 0.052);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

.button:hover,
.icon-button:hover,
.chip:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 179, 107, 0.48);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 14px 30px rgba(0, 0, 0, 0.18);
}

.button:focus-visible,
.icon-button:focus-visible,
.chip:focus-visible,
.profile-button:focus-visible,
.nav-list a:focus-visible,
.auth-toggle:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring), var(--glow-orange);
}

.button.primary {
  border-color: rgba(255, 179, 107, 0.78);
  background: linear-gradient(135deg, #ffb36b 0%, #ff7a1a 44%, #ee5d0d 100%);
  box-shadow: 0 18px 34px rgba(255, 122, 26, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  color: #160901;
}

.button.secondary {
  color: var(--red);
}

body.light-mode .button.secondary {
  background: rgba(255, 107, 107, 0.1);
  border-color: rgba(214, 69, 69, 0.4);
  color: #c03535;
}

.button.ghost {
  background: rgba(255, 255, 255, 0.034);
}

.chip.active {
  border-color: rgba(255, 179, 107, 0.5);
  background: rgba(255, 122, 26, 0.18);
  box-shadow: var(--glow-orange);
}

.app-view.active {
  display: grid;
  gap: 20px;
  animation: premiumViewEnter 420ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-view.active > * {
  animation: surfaceEnter 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.app-view.active > *:nth-child(2) {
  animation-delay: 70ms;
}

body[data-view-direction="back"] .app-view.active {
  animation-name: premiumViewEnterBack;
}

.hero-grid {
  grid-template-columns: minmax(360px, 1.45fr) repeat(3, minmax(180px, 1fr));
  gap: 16px;
  align-items: stretch;
}

.summary-panel,
.panel,
.auth-brand-panel,
.auth-card,
.modal {
  position: relative;
  overflow: hidden;
  border-color: var(--line);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.075), transparent 44%),
    var(--panel);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(22px) saturate(1.1);
}

.summary-panel::before,
.panel::before,
.auth-brand-panel::before,
.auth-card::before,
.modal::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), transparent 28%, transparent 76%, rgba(255, 122, 26, 0.07));
  content: "";
}

.summary-panel > *,
.panel > *,
.auth-brand-panel > *,
.auth-card > *,
.modal > * {
  position: relative;
  z-index: 1;
}

.summary-panel {
  display: flex;
  min-height: 176px;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
  transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

.summary-panel:hover,
.panel:hover {
  border-color: rgba(255, 179, 107, 0.26);
}

.summary-panel:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow), var(--glow-orange);
}

.primary-summary {
  min-height: 260px;
  background:
    linear-gradient(145deg, rgba(255, 122, 26, 0.32), rgba(255, 255, 255, 0.052) 48%, rgba(74, 222, 128, 0.08)),
    var(--panel-solid);
}

.primary-summary::after {
  right: -70px;
  bottom: -88px;
  width: 250px;
  height: 250px;
  border-color: rgba(255, 179, 107, 0.28);
  box-shadow: inset 0 0 42px rgba(255, 122, 26, 0.1);
}

.summary-panel h2 {
  margin-top: 12px;
  font-size: clamp(1.95rem, 2.6vw, 3.15rem);
  letter-spacing: 0;
}

.primary-summary h2 {
  font-size: clamp(3rem, 4.3vw, 5.2rem);
  line-height: 0.9;
}

.summary-panel .muted,
.summary-panel .trend {
  line-height: 1.45;
}

.cashflow-meter {
  height: 14px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.24);
}

.cashflow-meter span {
  box-shadow: 0 0 24px rgba(74, 222, 128, 0.28);
}

.panel {
  padding: 20px;
}

.panel.wide {
  min-height: 420px;
}

.focused-panel {
  width: min(100%, 1080px);
}

.layout-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.65fr);
  gap: 16px;
}

.panel-header {
  gap: 14px;
}

.panel-header h2 {
  font-size: 1.38rem;
  letter-spacing: 0;
}

.dashboard-visualization {
  min-height: 460px;
}

.chart-controls {
  align-items: end;
  gap: 10px;
}

.chart-select-shell {
  min-width: 180px;
}

.chart-select-shell select {
  min-height: 42px;
}

.chart-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 0.28fr);
  align-items: stretch;
  gap: 16px;
}

.chart-stage {
  min-height: 354px;
  border-color: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(255, 122, 26, 0.12), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.018));
}

.chart-svg {
  height: 354px;
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.16));
}

.chart-label {
  fill: var(--muted-strong);
  font-weight: 760;
}

.chart-value {
  fill: var(--text);
  font-weight: 850;
}

.chart-axis {
  stroke: rgba(255, 255, 255, 0.14);
}

.light-mode .chart-axis {
  stroke: rgba(15, 23, 42, 0.16);
}

.chart-line {
  stroke-width: 4;
  filter: drop-shadow(0 5px 12px rgba(0, 0, 0, 0.18));
}

.chart-stat,
.budget-item,
.goal-item,
.bill-item,
.insight-item,
.empty-state,
.empty-table-state,
.bill-note,
.delete-warning {
  border-radius: 12px;
  border-color: rgba(255, 255, 255, 0.085);
  background: rgba(255, 255, 255, 0.044);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
}

.chart-stat {
  padding: 14px;
}

.chart-stat strong {
  margin-top: 6px;
}

.budget-item,
.goal-item,
.bill-item,
.insight-item {
  padding: 14px;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.budget-item:hover,
.goal-item:hover,
.bill-item:hover,
.insight-item:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 179, 107, 0.24);
  background: rgba(255, 255, 255, 0.065);
}

.goal-title,
.budget-title,
.bill-title {
  min-width: 0;
}

.goal-title strong,
.budget-title strong,
.bill-title strong,
.insight-item strong {
  letter-spacing: 0;
}

.progress {
  height: 12px;
  padding: 3px;
  background: rgba(0, 0, 0, 0.24);
}

.light-mode .progress {
  background: rgba(15, 23, 42, 0.08);
}

.bill-date,
.status-pill {
  min-height: 32px;
  padding: 7px 11px;
  border-radius: 999px;
  background: rgba(255, 122, 26, 0.14);
  font-weight: 840;
}

.status-pill.ok {
  background: rgba(74, 222, 128, 0.14);
  color: var(--green);
}

.status-pill.review {
  background: rgba(251, 191, 36, 0.14);
  color: var(--yellow);
}

.status-pill.danger,
.button.danger {
  background: rgba(251, 113, 133, 0.13);
  color: var(--red);
}

.transaction-wrap {
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

table {
  min-width: 1040px;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  border-bottom-color: rgba(255, 255, 255, 0.075);
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(255, 255, 255, 0.052);
  color: var(--muted-strong);
  backdrop-filter: blur(12px);
}

tbody tr {
  transition: background 160ms ease, transform 160ms ease;
}

tbody tr:hover {
  background: rgba(255, 122, 26, 0.08);
}

.amount-income {
  color: var(--green);
}

.amount-expense {
  color: var(--orange-strong);
}

input,
select,
textarea {
  border-color: rgba(255, 255, 255, 0.11);
  background: rgba(255, 255, 255, 0.055);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

body:not(.light-mode) select option {
  background: #101216;
  color: var(--text);
}

input:hover,
select:hover,
textarea:hover {
  border-color: rgba(255, 179, 107, 0.28);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(255, 179, 107, 0.76);
  box-shadow: var(--focus-ring), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.075);
}

.currency-prefix {
  color: var(--orange-strong);
}

.modal-overlay {
  background: rgba(3, 4, 6, 0.68);
  backdrop-filter: blur(18px) saturate(1.08);
}

.modal {
  width: min(540px, 100%);
  padding: 22px;
  animation: modalEnter 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.toast {
  border-radius: 12px;
  border-color: rgba(255, 179, 107, 0.36);
  background: rgba(17, 19, 23, 0.92);
  backdrop-filter: blur(18px);
}

.light-mode .toast {
  background: rgba(255, 255, 255, 0.94);
}

.auth-screen {
  width: min(1120px, calc(100% - 44px));
  gap: 22px;
}

.auth-brand-panel {
  min-height: 590px;
  padding: 46px;
  background:
    linear-gradient(135deg, rgba(255, 122, 26, 0.22), transparent 45%),
    linear-gradient(220deg, rgba(74, 222, 128, 0.1), transparent 42%),
    linear-gradient(150deg, rgba(27, 29, 35, 0.96), rgba(7, 8, 10, 0.86));
}

.light-mode .auth-brand-panel {
  background:
    linear-gradient(135deg, rgba(255, 122, 26, 0.16), transparent 45%),
    linear-gradient(220deg, rgba(74, 222, 128, 0.12), transparent 42%),
    rgba(255, 255, 255, 0.88);
}

.auth-logo-mark {
  width: 78px;
  height: 78px;
  border-radius: 16px;
}

.auth-brand-panel h1 {
  max-width: 660px;
  font-size: clamp(3rem, 5.4vw, 6rem);
  letter-spacing: 0;
  line-height: 0.9;
}

.auth-brand-panel p:last-of-type {
  max-width: 560px;
  line-height: 1.65;
}

.auth-proof-strip {
  margin-top: 18px;
}

.auth-card {
  padding: 30px;
}

.auth-card h2 {
  font-size: 2.15rem;
  letter-spacing: 0;
}

.auth-toggle {
  min-height: 42px;
  border-radius: 10px;
  transition: background 160ms ease, color 160ms ease;
}

.auth-toggle:hover {
  background: rgba(255, 122, 26, 0.08);
}

.panel.attention-pulse,
.budget-item.attention-pulse,
.transaction-row.attention-pulse {
  animation: attentionPulse 1300ms ease;
  border-color: rgba(255, 179, 107, 0.9);
}

.nav-twinkle {
  animation: navTwinkle 620ms ease-in-out 2;
  border-color: rgba(255, 179, 107, 0.95);
}

/* Directional 3D view transitions: navigating forward swings the page in from the right,
   navigating back swings it in from the left — like turning panes in space. */
@supports (view-transition-name: root) {
  ::view-transition-old(root) {
    animation: premiumRootOut 280ms cubic-bezier(0.5, 0, 0.75, 0) both;
  }

  ::view-transition-new(root) {
    animation: premiumRootInForward 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
  }

  html[data-view-direction="back"]::view-transition-old(root) {
    animation-name: premiumRootOutBack;
  }

  html[data-view-direction="back"]::view-transition-new(root) {
    animation-name: premiumRootInBack;
  }
}

@keyframes premiumRootOut {
  from {
    opacity: 1;
    filter: blur(0);
    transform: perspective(1400px) rotateY(0deg) translateZ(0);
  }

  to {
    opacity: 0;
    filter: blur(8px);
    transform: perspective(1400px) rotateY(-5deg) translateX(-42px) translateZ(-90px);
  }
}

@keyframes premiumRootInForward {
  from {
    opacity: 0;
    filter: blur(12px);
    transform: perspective(1400px) rotateY(6deg) translateX(56px) translateZ(-110px);
  }

  60% {
    filter: blur(0);
  }

  to {
    opacity: 1;
    filter: blur(0);
    transform: perspective(1400px) rotateY(0deg) translateX(0) translateZ(0);
  }
}

@keyframes premiumRootOutBack {
  from {
    opacity: 1;
    filter: blur(0);
    transform: perspective(1400px) rotateY(0deg) translateZ(0);
  }

  to {
    opacity: 0;
    filter: blur(8px);
    transform: perspective(1400px) rotateY(5deg) translateX(42px) translateZ(-90px);
  }
}

@keyframes premiumRootInBack {
  from {
    opacity: 0;
    filter: blur(12px);
    transform: perspective(1400px) rotateY(-6deg) translateX(-56px) translateZ(-110px);
  }

  60% {
    filter: blur(0);
  }

  to {
    opacity: 1;
    filter: blur(0);
    transform: perspective(1400px) rotateY(0deg) translateX(0) translateZ(0);
  }
}

@keyframes premiumViewEnter {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(16px) scale(0.988);
  }

  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@keyframes premiumViewEnterBack {
  from {
    opacity: 0;
    filter: blur(8px);
    transform: translateY(-10px) scale(0.988);
  }

  to {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0) scale(1);
  }
}

@keyframes surfaceEnter {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes modalEnter {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes navTwinkle {
  0%,
  100% {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-soft);
  }

  50% {
    border-color: rgba(255, 179, 107, 0.48);
    box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.055), 0 0 18px rgba(255, 122, 26, 0.16), var(--shadow-soft);
  }
}

@media (max-width: 1240px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-controls {
    justify-items: start;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .hero-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .primary-summary {
    grid-column: 1 / -1;
  }

  .chart-layout,
  .layout-grid {
    grid-template-columns: 1fr;
  }

  .chart-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1120px) {
  .sidebar {
    position: static;
    height: auto;
    margin: 12px;
  }

  .main-content {
    padding: 18px 24px 28px;
  }

  .topbar {
    position: relative;
    margin: 0;
  }
}

@media (max-width: 760px) {
  :root {
    --radius: 10px;
  }

  .main-content,
  .sidebar {
    padding: 16px;
  }

  .sidebar {
    margin: 10px;
  }

  .topbar h1 {
    font-size: 2.3rem;
    line-height: 1;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .summary-panel,
  .panel,
  .auth-brand-panel,
  .auth-card,
  .modal {
    border-radius: 12px;
  }

  .primary-summary h2 {
    font-size: 3.05rem;
  }

  .topbar-actions,
  .chart-controls,
  .auth-proof-strip {
    width: 100%;
  }

  .topbar-actions .button,
  .topbar-actions .profile-button,
  .month-switcher,
  .chart-select-shell,
  .chart-export-button {
    width: 100%;
  }

  .month-switcher {
    justify-content: space-between;
  }

  .chart-summary {
    grid-template-columns: 1fr;
  }

  .auth-screen {
    width: min(100% - 28px, 540px);
  }

  .auth-brand-panel,
  .auth-card {
    padding: 24px;
  }

  .auth-brand-panel h1 {
    font-size: 2.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-view.active,
  .app-view.active > *,
  .modal,
  .nav-twinkle,
  .panel.attention-pulse,
  .budget-item.attention-pulse,
  .transaction-row.attention-pulse {
    animation: none;
  }

  .button,
  .icon-button,
  .chip,
  .summary-panel,
  .budget-item,
  .goal-item,
  .bill-item,
  .insight-item,
  .nav-list a {
    transition: none;
  }
}


/* Premium refinement pass: market-style charts, polished month controls, and quieter trust messaging. */
.month-switcher {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(190px, 1fr) 40px;
  align-items: center;
  gap: 8px;
  min-height: 58px;
  border: 1px solid rgba(255, 179, 107, 0.22);
  border-radius: 16px;
  padding: 7px;
  background:
    linear-gradient(135deg, rgba(255, 122, 26, 0.12), rgba(255, 255, 255, 0.04)),
    rgba(255, 255, 255, 0.045);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 14px 32px rgba(0, 0, 0, 0.18);
}

.month-switcher::before {
  position: absolute;
  inset: 8px auto 8px 53px;
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
  content: "";
}

.month-switcher::after {
  position: absolute;
  inset: 8px 53px 8px auto;
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
  content: "";
}

.month-arrow {
  width: 40px;
  min-width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 900;
}

.month-arrow:disabled {
  cursor: not-allowed;
  opacity: 0.38;
  transform: none;
}

.month-select-shell {
  position: relative;
  min-width: 0;
  padding: 0 28px 0 4px;
}

.month-select-shell::after {
  position: absolute;
  right: 8px;
  bottom: 7px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--orange-strong);
  border-bottom: 2px solid var(--orange-strong);
  pointer-events: none;
  transform: rotate(45deg);
  content: "";
}

.month-select-shell span {
  color: var(--orange-strong);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
}

.month-select-shell select {
  width: 100%;
  min-height: 30px;
  appearance: none;
  color: var(--text);
  font-size: 1.04rem;
  letter-spacing: 0;
}

.trust-ribbon {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 4px auto 0;
  padding: 4px;
  color: var(--muted);
}

.trust-ribbon span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 999px;
  padding: 5px 10px;
  background: rgba(255, 255, 255, 0.032);
  font-size: 0.72rem;
  font-weight: 760;
}

.trust-ribbon span:first-child {
  color: var(--orange-strong);
}

.chart-stage {
  position: relative;
  min-height: 378px;
  background:
    radial-gradient(circle at 24% 18%, rgba(255, 122, 26, 0.15), transparent 18rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.018));
}

.chart-stage::before {
  position: absolute;
  inset: 14px;
  border-radius: 10px;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 92%);
  content: "";
}

.chart-svg-market {
  height: 378px;
}

.chart-market-grid {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-dasharray: 3 8;
}

.chart-area {
  pointer-events: none;
}

.chart-line-market {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4.5;
}

.chart-endpoint {
  stroke-width: 3;
  fill: var(--panel-solid);
}

.chart-endpoint-income {
  fill: #4ade80;
  stroke: rgba(74, 222, 128, 0.34);
}

.chart-endpoint-expense {
  fill: #ff7a1a;
  stroke: rgba(255, 122, 26, 0.34);
}

.chart-market-badge rect,
.chart-legend-pill rect {
  fill: rgba(255, 255, 255, 0.07);
  stroke: rgba(255, 255, 255, 0.1);
}

.chart-market-badge text {
  fill: var(--text);
  font-size: 0.78rem;
  font-weight: 850;
}

.chart-badge-positive {
  fill: var(--green);
}

.chart-badge-negative {
  fill: var(--red);
}

.chart-legend-pill text {
  font-size: 0.72rem;
}

.nav-twinkle {
  animation: navTwinkle 620ms ease-in-out 2;
}

@keyframes navTwinkle {
  0%,
  100% {
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-soft);
  }

  50% {
    border-color: rgba(255, 179, 107, 0.46);
    box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.055), 0 0 18px rgba(255, 122, 26, 0.14), var(--shadow-soft);
  }
}

body.light-mode .trust-ribbon span,
body.light-mode .chart-market-badge rect,
body.light-mode .chart-legend-pill rect {
  background: rgba(255, 255, 255, 0.72);
  fill: rgba(255, 255, 255, 0.72);
  stroke: rgba(15, 23, 42, 0.1);
}

@media (max-width: 760px) {
  .month-switcher {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
  }

  .trust-ribbon {
    justify-content: flex-start;
  }
}

/* ============================================================= */
/* Premium polish layer v5 — refinement pass + new components.   */
/* Uses existing tokens only; base orange/black palette unchanged. */
/* ============================================================= */

/* Tabular figures make money read clean and aligned across rows. */
.summary-panel h2,
.amount-cell,
.chart-value,
.chart-stat strong,
.status-pill,
.budget-title small,
.goal-title small,
.bill-title small,
.deleted-meta small,
.month-select-shell select {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.primary-summary h2 {
  text-shadow: 0 2px 22px rgba(0, 0, 0, 0.3);
}

.light-mode .primary-summary h2 {
  text-shadow: 0 2px 16px rgba(255, 122, 26, 0.16);
}

/* Refined, quiet scrollbars that match the surface. */
.transaction-wrap,
.deleted-list,
.main-content {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 122, 26, 0.42) transparent;
}

.transaction-wrap::-webkit-scrollbar,
.deleted-list::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.transaction-wrap::-webkit-scrollbar-thumb,
.deleted-list::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background: rgba(255, 122, 26, 0.4);
  background-clip: content-box;
}

.transaction-wrap::-webkit-scrollbar-thumb:hover,
.deleted-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 122, 26, 0.62);
  background-clip: content-box;
}

/* Tactile feedback on the small action pills (Edit / Delete / Add saved). */
button.status-pill {
  transition: transform 150ms ease, filter 150ms ease, background 150ms ease;
}

button.status-pill:hover {
  transform: translateY(-1px);
  filter: brightness(1.1);
}

button.status-pill:active {
  transform: translateY(0);
}

button.status-pill:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

/* Buttons mid-request read clearly as unavailable. */
.button:disabled,
.button[disabled] {
  cursor: progress;
  opacity: 0.62;
  transform: none;
  filter: saturate(0.85);
}

/* Budget cards gain the same action cluster as goals and bills. */
.budget-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

/* Transactions header toolbar: recycle-bin entry point + filters. */
.transaction-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.button.small {
  min-height: 34px;
  padding: 0 13px;
  font-size: 0.82rem;
}

/* Quiet text link used for "Forgot password?". */
.auth-link {
  display: inline-flex;
  align-self: flex-start;
  margin-top: 4px;
  border: 0;
  padding: 4px 2px;
  background: transparent;
  color: var(--muted-strong);
  font-size: 0.86rem;
  font-weight: 720;
  transition: color 150ms ease;
}

.auth-link:hover {
  color: var(--orange-strong);
}

.auth-link:focus-visible {
  outline: 0;
  border-radius: 6px;
  box-shadow: var(--focus-ring);
}

.auth-link[hidden] {
  display: none;
}

/* Compact confirm / reset dialogs. */
.modal-compact {
  width: min(430px, 100%);
}

.modal-message {
  margin: 0 0 18px;
  color: var(--muted-strong);
  line-height: 1.55;
}

/* Recycle-bin list. */
.deleted-list {
  display: grid;
  gap: 10px;
  max-height: min(60vh, 460px);
  overflow-y: auto;
  padding-right: 4px;
}

.deleted-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, 0.085);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.044);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.055);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.light-mode .deleted-item {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.deleted-item:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 179, 107, 0.24);
  background: rgba(255, 255, 255, 0.065);
}

.light-mode .deleted-item:hover {
  background: rgba(255, 255, 255, 0.9);
}

.deleted-meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.deleted-meta strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.deleted-meta small {
  color: var(--muted);
}

.deleted-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* Slightly warmer empty states so blank views still feel designed. */
.empty-state strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
  font-size: 1.02rem;
}

/* ============================================================= */
/* Premium polish layer v6 — display typography + chart refinement. */
/* ============================================================= */

:root {
  --font-display: "Sora", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  font-family: var(--font-body);
}

h1,
h2,
h3,
.brand strong,
.topbar h1,
.summary-panel h2,
.panel-header h2,
.sync-card h2,
.auth-card h2,
.auth-brand-panel h1,
.modal h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.018em;
}

.topbar h1,
.auth-brand-panel h1,
.primary-summary h2 {
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* Cash-flow chart legend: each series shows its own aligned total. */
.chart-legend-name {
  fill: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}

.chart-legend-amount {
  font-size: 14.5px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.chart-income-text {
  fill: var(--green);
}

.chart-expense-text {
  fill: var(--orange-strong);
}

.chart-callout-label {
  fill: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.chart-net-positive,
.chart-net-negative {
  font-size: 15px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.chart-net-positive {
  fill: var(--green);
}

.chart-net-negative {
  fill: var(--red);
}

/* Non-actionable insight status — a clear indicator, not a fake button. */
.insight-flag {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  border-radius: 999px;
  padding: 6px 12px 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted-strong);
  font-size: 0.76rem;
  font-weight: 760;
  cursor: default;
}

.light-mode .insight-flag {
  background: rgba(15, 23, 42, 0.05);
}

.insight-flag::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

.insight-flag.ok {
  color: var(--green);
}

.insight-flag.review {
  color: var(--yellow);
}

/* Spendable today — daily allowance chip inside the safe-to-spend card */
.daily-allowance {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 16px;
  padding: 11px 15px;
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.14), rgba(255, 122, 26, 0.04));
  border: 1px solid rgba(255, 122, 26, 0.24);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.daily-allowance[hidden] {
  display: none;
}

.daily-allowance-tag {
  width: 100%;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--orange-strong);
}

.daily-allowance-value {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.daily-allowance-meta {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted-strong);
}

.daily-allowance.is-critical {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.16), rgba(255, 107, 107, 0.05));
  border-color: rgba(255, 107, 107, 0.32);
}

.daily-allowance.is-critical .daily-allowance-tag {
  color: var(--red);
}

/* ============================================================
   Ultra-premium motion system
   ============================================================ */

/* --- Scroll reveal: cards float up out of depth as they enter the viewport.
   Kept deliberately cheap: no will-change or per-card perspective, so dozens of
   cards never overwhelm the compositor on low-end machines. --- */
.reveal-card {
  opacity: 0;
  transform: translateY(26px) scale(0.985);
  transition:
    opacity 640ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 640ms cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-card.in-view {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Stagger the four hero cards so the dashboard opens like a sequence, not a dump. */
.hero-grid .reveal-card:nth-child(1) { transition-delay: 0ms; }
.hero-grid .reveal-card:nth-child(2) { transition-delay: 80ms; }
.hero-grid .reveal-card:nth-child(3) { transition-delay: 160ms; }
.hero-grid .reveal-card:nth-child(4) { transition-delay: 240ms; }

/* --- 3D hover: summary cards tilt toward the light with a sheen sweep --- */
.hero-grid {
  perspective: 1600px;
}

.summary-panel {
  position: relative;
  overflow: hidden;
  transition:
    transform 320ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 320ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 320ms ease;
}

.summary-panel:hover {
  transform: translateY(-7px) rotateX(1.6deg) scale(1.015);
  border-color: rgba(255, 122, 26, 0.4);
  box-shadow:
    0 26px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px rgba(255, 122, 26, 0.12),
    0 0 44px rgba(255, 122, 26, 0.1);
}

.summary-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.07) 48%, transparent 62%);
  transform: translateX(-130%);
  transition: transform 700ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.summary-panel:hover::after {
  transform: translateX(130%);
}

body.light-mode .summary-panel:hover {
  box-shadow:
    0 22px 48px rgba(31, 20, 8, 0.16),
    0 0 0 1px rgba(255, 122, 26, 0.18);
}

/* --- Chart motion & premium chart pieces --- */
.chart-bar-track {
  fill: rgba(148, 128, 110, 0.14);
}

.chart-bar {
  animation: barGrow 720ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes barGrow {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

.chart-bar-cap {
  opacity: 0;
  animation: chartFadeIn 320ms ease-out forwards;
}

.chart-share {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.chart-pie-slice {
  stroke: var(--panel);
  stroke-width: 2.5;
  transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), filter 260ms ease;
  transform-box: fill-box;
  transform-origin: center;
}

.chart-pie-slice:hover {
  transform: scale(1.045);
  filter: brightness(1.12);
}

.chart-pie-group {
  animation: pieReveal 820ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes pieReveal {
  from {
    opacity: 0;
    transform: rotate(-42deg) scale(0.82);
  }

  to {
    opacity: 1;
    transform: rotate(0deg) scale(1);
  }
}

.chart-donut-total {
  font-family: var(--font-display);
  font-size: 21px;
  font-weight: 800;
  fill: var(--text);
  letter-spacing: -0.01em;
}

/* Opacity-only: CSS transform animations would override the SVG translate()
   positioning attribute on these groups and collapse every row onto the origin. */
.chart-legend-row {
  opacity: 0;
  animation: legendFadeIn 460ms ease-out forwards;
}

@keyframes legendFadeIn {
  to {
    opacity: 1;
  }
}

.chart-legend-value {
  font-weight: 700;
}

.chart-line-draw {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: lineDraw 1100ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes lineDraw {
  to { stroke-dashoffset: 0; }
}

.chart-area {
  opacity: 0;
  animation: chartFadeIn 700ms ease-out 420ms forwards;
}

@keyframes chartFadeIn {
  to { opacity: 1; }
}

/* --- Neutral trend state for months without data --- */
.trend.muted-trend {
  color: var(--muted);
}

/* ============================================================
   Settings hub modal
   ============================================================ */
.settings-modal {
  width: min(560px, calc(100vw - 48px));
}

.settings-group {
  margin: 0 0 18px;
  padding: 0;
  border: 0;
}

.settings-group legend {
  padding: 0;
  margin-bottom: 10px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orange-strong);
}

.settings-choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

.settings-choice {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 13px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1), border-color 200ms ease, box-shadow 200ms ease;
}

.settings-choice:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 122, 26, 0.45);
}

.settings-choice.selected {
  border-color: var(--orange);
  background: linear-gradient(135deg, rgba(255, 122, 26, 0.16), rgba(255, 122, 26, 0.04));
  box-shadow: 0 0 0 1px rgba(255, 122, 26, 0.35), 0 8px 26px rgba(255, 122, 26, 0.12);
}

.settings-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-choice-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.settings-choice-caption {
  font-size: 0.78rem;
  color: var(--muted);
}

.settings-note {
  margin: 4px 0 14px;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ============================================================
   Liquid-glass surface system
   Ambient light lives behind the UI; every major surface is a
   frosted pane with a catch-light top edge. Falls back to the
   solid panels automatically where backdrop-filter is missing.
   ============================================================ */

/* Ambient drifting light behind the glass */
body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  width: 55vw;
  height: 55vw;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  pointer-events: none;
}

body::before {
  top: -18vw;
  left: -12vw;
  background: radial-gradient(circle, rgba(255, 122, 26, 0.22), transparent 65%);
  animation: orbDriftA 46s ease-in-out infinite alternate;
}

body::after {
  right: -16vw;
  bottom: -20vw;
  background: radial-gradient(circle, rgba(74, 222, 128, 0.1), rgba(255, 122, 26, 0.06) 55%, transparent 70%);
  animation: orbDriftB 58s ease-in-out infinite alternate;
}

@keyframes orbDriftA {
  to { transform: translate(9vw, 7vh) scale(1.12); }
}

@keyframes orbDriftB {
  to { transform: translate(-8vw, -9vh) scale(1.08); }
}

body.light-mode::before {
  background: radial-gradient(circle, rgba(255, 122, 26, 0.14), transparent 65%);
}

body.light-mode::after {
  background: radial-gradient(circle, rgba(74, 222, 128, 0.1), transparent 70%);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .panel,
  .summary-panel,
  .sync-card,
  .topbar,
  .modal {
    background:
      linear-gradient(165deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.015) 45%, rgba(255, 122, 26, 0.035));
    -webkit-backdrop-filter: blur(22px) saturate(150%);
    backdrop-filter: blur(22px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.09);
    border-top-color: rgba(255, 255, 255, 0.17);
    box-shadow:
      0 24px 64px rgba(0, 0, 0, 0.38),
      inset 0 1px 0 rgba(255, 255, 255, 0.05);
  }

  .settings-choice {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
  }

  body.light-mode .panel,
  body.light-mode .summary-panel,
  body.light-mode .sync-card,
  body.light-mode .topbar,
  body.light-mode .modal {
    background: linear-gradient(165deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.5));
    border: 1px solid rgba(31, 20, 8, 0.1);
    border-top-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 20px 48px rgba(31, 20, 8, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  }

  body.light-mode .settings-choice {
    background: rgba(255, 255, 255, 0.55);
  }
}

/* ============================================================
   Money calendar
   ============================================================ */
.calendar-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.calendar-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--muted-strong);
}

.calendar-legend-item::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  box-shadow: 0 0 8px currentColor;
}

.calendar-legend-item.income::before { background: var(--green); color: var(--green); }
.calendar-legend-item.bill::before { background: var(--orange); color: var(--orange); }
.calendar-legend-item.goal::before { background: var(--yellow); color: var(--yellow); }

.calendar-note {
  margin: 2px 0 14px;
  font-size: 0.82rem;
  color: var(--muted);
}

.money-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-weekday {
  padding: 4px 2px 8px;
  text-align: center;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.calendar-day {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 76px;
  padding: 7px 7px 6px;
  border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.02);
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1), border-color 220ms ease, background 220ms ease;
}

.calendar-day.empty {
  border-color: transparent;
  background: transparent;
}

.calendar-day.weekend:not(.empty) {
  background: rgba(255, 255, 255, 0.005);
  border-style: dashed;
}

.calendar-day.has-events:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 122, 26, 0.45);
  background: rgba(255, 122, 26, 0.06);
}

.calendar-day.today {
  border-color: var(--orange);
  box-shadow: 0 0 0 1px rgba(255, 122, 26, 0.55), 0 0 24px rgba(255, 122, 26, 0.18);
}

.calendar-day-number {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--muted-strong);
}

.calendar-day.today .calendar-day-number {
  color: var(--orange-strong);
}

.calendar-event {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 1px 6px;
  border-radius: 7px;
  font-size: 0.62rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.calendar-event.income { background: rgba(69, 212, 131, 0.16); color: var(--green); }
.calendar-event.bill { background: rgba(255, 122, 26, 0.16); color: var(--orange-strong); }
.calendar-event.goal { background: rgba(255, 209, 102, 0.16); color: var(--yellow); }
.calendar-event.more { background: rgba(255, 255, 255, 0.08); color: var(--muted-strong); }

body.light-mode .calendar-day {
  border-color: rgba(31, 20, 8, 0.08);
  background: rgba(255, 255, 255, 0.4);
}

body.light-mode .calendar-day.empty {
  border-color: transparent;
  background: transparent;
}

@media (max-width: 760px) {
  .calendar-day { min-height: 58px; padding: 5px; }
  .calendar-event { font-size: 0.56rem; padding: 1px 4px; }
}

/* --- Calm mode: every premium animation steps aside for reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .reveal-card,
  .summary-panel,
  .summary-panel::after,
  .settings-choice {
    transition: none !important;
  }

  .reveal-card {
    opacity: 1;
    transform: none;
  }

  .chart-bar,
  .chart-bar-cap,
  .chart-pie-group,
  .chart-legend-row,
  .chart-line-draw,
  .chart-area {
    animation: none !important;
    opacity: 1;
    stroke-dashoffset: 0;
  }

  body::before,
  body::after,
  .calendar-day {
    animation: none !important;
    transition: none !important;
  }
}

