/* ==========================================================================
   Savely — styles
   ========================================================================== */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #f4f5f9;
  --surface: #ffffff;
  --surface-2: #f1f2f7;
  --surface-3: #e7e9f1;
  --text: #151821;
  --muted: #6b7180;
  --border: rgba(20, 24, 40, 0.07);
  --border-strong: rgba(20, 24, 40, 0.12);

  --accent-base: #5b5bf6;
  --accent: var(--accent-base);
  --accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
  --accent-bar: color-mix(in srgb, var(--accent) 34%, transparent);
  --on-accent: #ffffff;

  --good: #16a34a;
  --warn: #f59e0b;
  --bad: #ef4444;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 30px -12px rgba(16, 24, 40, 0.12);
  --shadow-lg: 0 24px 60px -16px rgba(16, 24, 40, 0.28);

  --radius: 22px;
  --radius-sm: 14px;
  --ease: cubic-bezier(0.22, 0.9, 0.24, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --header-h: 68px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0d0f14;
  --surface: #161920;
  --surface-2: #1e222b;
  --surface-3: #282d38;
  --text: #edeff5;
  --muted: #9198a7;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  --accent: color-mix(in srgb, var(--accent-base) 70%, #ffffff);
  --accent-soft: color-mix(in srgb, var(--accent) 17%, transparent);
  --accent-bar: color-mix(in srgb, var(--accent) 36%, transparent);

  --good: #34d27a;
  --warn: #fbbf24;
  --bad: #f87171;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 32px -14px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

/* Smooth theme switch (class is added briefly by JS) */
html.theme-anim,
html.theme-anim *,
html.theme-anim *::before,
html.theme-anim *::after {
  transition: background-color 0.35s ease, color 0.35s ease, border-color 0.35s ease, fill 0.35s ease, box-shadow 0.35s ease !important;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body.no-scroll { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -0.015em; }
svg { flex: none; }

/* Line icons */
.nav-btn svg, .icon-btn svg, .btn svg, .search svg, .fab svg {
  width: 20px; height: 20px;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.btn svg { width: 18px; height: 18px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.ellipsis { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ==========================================================================
   Top bar & navigation
   ========================================================================== */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-inner {
  max-width: 1120px; margin: 0 auto;
  height: var(--header-h);
  padding: 0 20px;
  display: flex; align-items: center; gap: 16px;
}

.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 18px; letter-spacing: -0.02em; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 16px -6px var(--accent);
  transition: transform 0.4s var(--spring);
}
.brand:hover .brand-mark { transform: rotate(-8deg) scale(1.05); }
.brand-mark svg { width: 22px; height: 22px; }

.nav {
  position: relative;
  display: flex; gap: 2px;
  margin-left: auto;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}
.nav-btn {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  color: var(--muted);
  transition: color 0.25s, transform 0.15s;
}
.nav-btn:hover { color: var(--text); }
.nav-btn:active { transform: scale(0.96); }
.nav-btn.active { color: var(--text); }
.nav-btn svg { width: 18px; height: 18px; }

.theme-toggle { position: relative; overflow: hidden; }
.theme-toggle svg { position: absolute; transition: transform 0.5s var(--ease), opacity 0.3s; }
:root[data-theme="light"] .theme-toggle .moon { transform: translateY(0) rotate(0); opacity: 1; }
:root[data-theme="light"] .theme-toggle .sun { transform: translateY(120%) rotate(90deg); opacity: 0; }
:root[data-theme="dark"] .theme-toggle .sun { transform: translateY(0) rotate(0); opacity: 1; }
:root[data-theme="dark"] .theme-toggle .moon { transform: translateY(-120%) rotate(-90deg); opacity: 0; }

/* Shared sliding indicator for segmented controls & nav */
.seg-ind {
  position: absolute; z-index: 0;
  top: 4px; bottom: 4px; left: 0;
  width: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}
.seg-ind.ready { transition: transform 0.4s var(--ease), width 0.4s var(--ease); }

/* ==========================================================================
   Layout
   ========================================================================== */

main {
  max-width: 1120px;
  margin: 0 auto;
  padding: 12px 20px 120px;
}

.view { display: none; }
.view.active { display: block; animation: viewIn 0.45s var(--ease) both; }
.view.active .card { animation: cardIn 0.55s var(--ease) both; animation-delay: calc(var(--i, 0) * 55ms); }

@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px) scale(0.99); } to { opacity: 1; transform: none; } }

.page-head { margin: 12px 0 20px; }
.page-head h1 { font-size: 28px; font-weight: 750; letter-spacing: -0.025em; }
.page-head p { margin: 4px 0 0; }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  min-width: 0;
}
.card h2 { font-size: 16px; font-weight: 680; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-sub { margin: 3px 0 0; color: var(--muted); font-size: 13px; }

.overview-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.welcome-slot:empty { display: none; }

@media (min-width: 760px) {
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welcome-slot, .recent-card { grid-column: 1 / -1; }
}
@media (min-width: 1040px) {
  .overview-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .welcome-slot { grid-column: 1 / -1; }
  .budget-card { grid-column: span 5; }
  .period-card { grid-column: span 7; }
  .donut-card { grid-column: span 5; }
  .bars-card { grid-column: span 7; }
  .recent-card { grid-column: 1 / -1; }
}

/* ==========================================================================
   Buttons & inputs
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px;
  border-radius: 13px;
  font-size: 14px; font-weight: 620;
  background: var(--surface-2);
  color: var(--text);
  white-space: nowrap;
  transition: transform 0.15s var(--ease), background-color 0.2s, box-shadow 0.2s, opacity 0.2s, filter 0.2s;
  user-select: none;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 8px 18px -8px var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--bad); color: #fff; box-shadow: 0 8px 18px -8px var(--bad); }
.btn.danger:hover { filter: brightness(1.06); }
.btn.danger-outline { background: transparent; color: var(--bad); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--bad) 45%, transparent); }
.btn.danger-outline:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger-text { color: var(--bad); }
.btn.small { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 10px; gap: 6px; }
.btn.small svg { width: 16px; height: 16px; }

.link-btn {
  display: inline-flex; align-items: center;
  padding: 5px 10px; margin: -5px -10px;
  border-radius: 9px;
  font-size: 13px; font-weight: 640;
  color: var(--accent);
  transition: background-color 0.2s;
  white-space: nowrap;
}
.link-btn:hover { background: var(--accent-soft); }

.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px;
  color: var(--muted);
  transition: background-color 0.2s, color 0.2s, transform 0.15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }

.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
select.input {
  appearance: none; -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a90a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  cursor: pointer;
}
input[type="date"].input, input[type="datetime-local"].input { min-width: 0; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 18px; min-width: 0; }
.label { font-size: 13px; font-weight: 620; color: var(--muted); }
.label em { font-style: normal; font-weight: 500; opacity: 0.75; }
.field-error {
  display: block;
  color: var(--bad);
  font-size: 13px; font-weight: 550;
  min-height: 0;
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height 0.25s var(--ease), opacity 0.2s;
}
.field.has-error .field-error { max-height: 40px; opacity: 1; }

.money-input, .amount-input {
  display: flex; align-items: center; gap: 6px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.money-input { height: 48px; padding: 0 14px; }
.money-input input, .amount-input input {
  flex: 1; min-width: 0;
  border: 0; background: none; outline: none;
  font-variant-numeric: tabular-nums;
}
.money-input input { font-size: 18px; font-weight: 650; }
.money-input .cur, .amount-input .cur { color: var(--muted); font-weight: 650; }
.money-input:focus-within, .amount-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); background: var(--surface); }
.field.has-error .money-input, .field.has-error .amount-input {
  border-color: var(--bad);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--bad) 14%, transparent);
  animation: shake 0.42s;
}
@keyframes shake {
  20% { transform: translateX(-6px); } 40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); } 80% { transform: translateX(2px); }
}

.amount-input { height: 72px; padding: 0 18px; border-radius: 18px; }
.amount-input .cur { font-size: 26px; }
.amount-input input { font-size: 34px; font-weight: 750; letter-spacing: -0.02em; }

/* Segmented control */
.segmented {
  position: relative;
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-2);
}
.segmented button {
  position: relative; z-index: 1;
  height: 36px; padding: 0 16px;
  border-radius: 999px;
  font-size: 14px; font-weight: 620;
  color: var(--muted);
  white-space: nowrap;
  transition: color 0.25s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { color: var(--text); }
.segmented.small button { height: 30px; padding: 0 12px; font-size: 13px; }
.segmented.full { display: flex; width: 100%; }
.segmented.full button { flex: 1; }
.period-card .segmented { display: flex; width: 100%; }
.period-card .segmented button { flex: 1; padding: 0 8px; }

/* Chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border-strong);
  font-size: 14px; font-weight: 600;
  transition: border-color 0.2s, background-color 0.2s, transform 0.2s var(--spring), color 0.2s;
}
.chip:hover { background: var(--surface-2); }
.chip:active { transform: scale(0.95); }
.chip.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

.chip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
}
.cat-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 72px; padding: 10px 6px;
  border-radius: 16px;
  border: 1.5px solid var(--border-strong);
  font-size: 12.5px; font-weight: 620;
  text-align: center;
  transition: border-color 0.2s, background-color 0.2s, transform 0.25s var(--spring), box-shadow 0.2s;
}
.cat-chip .em { font-size: 22px; line-height: 1; transition: transform 0.3s var(--spring); }
.cat-chip span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-chip:hover { background: var(--surface-2); }
.cat-chip:active { transform: scale(0.95); }
.cat-chip.selected {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  box-shadow: 0 6px 16px -10px var(--c);
}
.cat-chip.selected .em { transform: scale(1.15); }

/* Collapsible helper */
.collapse { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 0.35s var(--ease), opacity 0.25s; }
.collapse > .collapse-inner { overflow: hidden; min-height: 0; }
.collapse.collapsed { grid-template-rows: 0fr; opacity: 0; }

/* ==========================================================================
   Budget card
   ========================================================================== */

.budget-card { --state: var(--good); }
.budget-card[data-state="warn"] { --state: var(--warn); }
.budget-card[data-state="bad"] { --state: var(--bad); }
.budget-card[data-state="none"] { --state: var(--muted); }

.budget-body { display: flex; align-items: center; gap: 24px; }
.ring-wrap { position: relative; width: 168px; height: 168px; flex: none; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; }
.ring-track { stroke: var(--surface-2); }
.ring-bar {
  stroke: var(--state);
  stroke-linecap: round;
  transition: stroke-dashoffset 1.2s var(--ease), stroke 0.5s, opacity 0.3s;
  filter: drop-shadow(0 4px 8px color-mix(in srgb, var(--state) 35%, transparent));
}
.ring-bar.zero { opacity: 0; }
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.ring-pct { font-size: 34px; font-weight: 780; letter-spacing: -0.03em; color: var(--state); transition: color 0.5s; }
.ring-label { font-size: 12px; color: var(--muted); font-weight: 550; }

.budget-stats { flex: 1; display: grid; gap: 14px; min-width: 0; }
.bstat { display: flex; flex-direction: column; min-width: 0; }
.bstat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.bstat strong { font-size: 22px; font-weight: 720; letter-spacing: -0.02em; }
.bstat small { font-size: 12.5px; }
.state-color { color: var(--state); transition: color 0.5s; }

.budget-status {
  display: flex; align-items: center; gap: 10px;
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13.5px; font-weight: 600;
  background: color-mix(in srgb, var(--state) 11%, transparent);
  color: var(--text);
  transition: background-color 0.5s;
}
.budget-status .dot-ind {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--state);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--state) 22%, transparent);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--state) 6%, transparent); } }

@media (max-width: 420px) {
  .budget-body { gap: 16px; }
  .ring-wrap { width: 132px; height: 132px; }
  .ring-pct { font-size: 28px; }
  .bstat strong { font-size: 19px; }
}

/* ==========================================================================
   Period / stats
   ========================================================================== */

.period-hero {
  display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap;
  gap: 12px;
  margin: 22px 0 18px;
}
.big-number { font-size: 44px; font-weight: 780; letter-spacing: -0.035em; line-height: 1.1; margin: 2px 0; }

.compare {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px; font-weight: 640;
  background: var(--surface-2);
  color: var(--muted);
  transition: background-color 0.3s, color 0.3s;
}
.compare:empty { display: none; }
.compare.good { color: var(--good); background: color-mix(in srgb, var(--good) 12%, transparent); }
.compare.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, transparent); }
.compare .arrow { font-size: 15px; line-height: 1; }

.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat {
  display: flex; flex-direction: column; gap: 1px;
  padding: 14px;
  border-radius: 16px;
  background: var(--surface-2);
  min-width: 0;
  transition: background-color 0.2s;
}
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.stat strong { font-size: 19px; font-weight: 720; letter-spacing: -0.015em; }
.stat small { font-size: 12.5px; min-height: 1.2em; }

.pill {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px; font-weight: 620;
  background: var(--surface-2);
  color: var(--muted);
}

/* ==========================================================================
   Charts
   ========================================================================== */

.donut-layout { display: flex; flex-direction: column; align-items: center; gap: 20px; }
.donut-wrap { position: relative; width: 210px; height: 210px; flex: none; }
.donut { width: 100%; height: 100%; overflow: visible; }
.donut-track { stroke: var(--surface-2); }
.donut-seg { cursor: pointer; transition: opacity 0.25s, stroke-width 0.25s var(--ease); }
.donut-seg.dim { opacity: 0.28; }
.donut-seg.hl { stroke-width: 29px; }
.donut-center {
  position: absolute; inset: 40px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; pointer-events: none;
}
.donut-center strong { font-size: 22px; font-weight: 760; letter-spacing: -0.02em; }
.donut-center .muted { max-width: 110px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.donut-emoji { font-size: 20px; line-height: 1; height: 0; opacity: 0; transition: opacity 0.2s, height 0.2s; }
.donut-emoji.show { height: 24px; opacity: 1; }

.legend { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 2px; }
.legend li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: 11px;
  font-size: 14px;
  cursor: default;
  transition: background-color 0.2s, opacity 0.25s;
  animation: fadeUp 0.4s var(--ease) both;
  animation-delay: calc(var(--d, 0) * 40ms);
}
.legend li.legend-empty { display: block; padding: 0; animation: none; }
.legend li.legend-empty:hover { background: none; }
.legend li:hover, .legend li.hl { background: var(--surface-2); }
.legend.has-hl li:not(.hl) { opacity: 0.5; }
.legend .lg-em {
  width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; font-size: 15px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
}
.legend .lg-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend .lg-amt { font-weight: 650; font-variant-numeric: tabular-nums; }
.legend .lg-pct { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; width: 38px; text-align: right; }
.legend .lg-bar { grid-column: 2 / -1; height: 4px; border-radius: 4px; background: var(--surface-2); overflow: hidden; margin-top: -4px; }
.legend .lg-bar i { display: block; height: 100%; border-radius: inherit; background: var(--c); transform-origin: left; animation: growX 0.8s var(--ease) both; animation-delay: calc(var(--d, 0) * 40ms + 100ms); }
@keyframes growX { from { transform: scaleX(0); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }

@media (min-width: 560px) and (max-width: 759px), (min-width: 1040px) and (max-width: 1100px) {
  .donut-layout { flex-direction: row; align-items: center; }
}

.bars-wrap { position: relative; width: 100%; height: 220px; }
.bars { display: block; width: 100%; height: 220px; overflow: visible; touch-action: pan-y; }
.bars .grid line { stroke: var(--border-strong); stroke-dasharray: 2 4; }
.bars .grid line:first-of-type { stroke-dasharray: none; }
.bars text { fill: var(--muted); font-size: 11px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.bars .labels text.today { fill: var(--accent); font-weight: 700; }
.bars .bar { fill: var(--accent-bar); transition: fill 0.2s, opacity 0.2s; }
.bars .bar.today { fill: var(--accent); }
.bars .bar.future { opacity: 0.45; }
.bars .bar.hover { fill: var(--accent); opacity: 1; }
.bars .ref line { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 5 4; }
.bars .ref text { fill: var(--warn); font-weight: 650; font-size: 11px; paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.bars-empty {
  position: absolute; left: 48px; right: 0; top: 40%;
  text-align: center; color: var(--muted); font-size: 13.5px; font-weight: 550;
  pointer-events: none;
  animation: fadeUp 0.4s var(--ease) both;
}

.chart-tip {
  position: absolute; z-index: 5;
  left: 0; top: 0;
  padding: 7px 11px;
  border-radius: 11px;
  background: var(--text);
  color: var(--bg);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 6px)) scale(0.94);
  transform-origin: bottom center;
  transition: opacity 0.15s, transform 0.2s var(--ease), left 0.18s var(--ease), top 0.18s var(--ease);
  box-shadow: var(--shadow-lg);
}
.chart-tip.show { opacity: 1; transform: translate(-50%, calc(-100% - 10px)) scale(1); }
.chart-tip strong { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.chart-tip span { opacity: 0.75; }

/* ==========================================================================
   Transactions
   ========================================================================== */

.tx-list { list-style: none; margin: 0; padding: 0; }
.tx {
  display: flex; align-items: center; gap: 12px;
  margin: 0 -12px;
  padding: 10px 12px;
  border-radius: 15px;
  cursor: pointer;
  outline-offset: -2px;
  overflow: hidden;
  transition: background-color 0.2s, transform 0.18s var(--ease), height 0.3s var(--ease), padding 0.3s var(--ease), opacity 0.25s, margin 0.3s var(--ease);
}
.tx:hover { background: var(--surface-2); }
.tx:active { transform: scale(0.985); }
.tx.enter { animation: txIn 0.45s var(--ease) both; animation-delay: var(--d, 0ms); }
.tx.flash { animation: txIn 0.45s var(--ease) both, flash 1.6s ease 0.2s; }
.tx.leaving { height: 0 !important; padding-top: 0; padding-bottom: 0; opacity: 0; transform: translateX(40px); pointer-events: none; }
@keyframes txIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes flash { 0%, 100% { background-color: transparent; } 25% { background-color: var(--accent-soft); } }

.tx-icon {
  flex: none;
  width: 42px; height: 42px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-size: 20px;
  background: color-mix(in srgb, var(--c) 17%, transparent);
  transition: transform 0.3s var(--spring);
}
.tx:hover .tx-icon { transform: scale(1.06) rotate(-4deg); }
.tx-main { flex: 1; min-width: 0; }
.tx-title { display: flex; align-items: center; gap: 6px; font-weight: 640; overflow: hidden; white-space: nowrap; }
.tx-title > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.tx-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-sub .sep { margin: 0 6px; opacity: 0.5; }
.tx-note { color: var(--text); opacity: 0.8; }
.tx-amt { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 15px; }
.tx-amt.income { color: var(--good); }
.tag {
  flex: none;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  background: var(--surface-3); color: var(--muted);
}

.list-card { padding: 6px 22px 14px; }
.day-group + .day-group { margin-top: 2px; }
.day-head {
  position: sticky; top: var(--header-h); z-index: 2;
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 14px 0 6px;
  font-size: 13px; font-weight: 680;
  color: var(--muted);
  background: var(--surface);
}
.day-head .day-total { font-variant-numeric: tabular-nums; font-weight: 600; }
.day-head .day-total .inc { color: var(--good); margin-left: 8px; }

/* Activity toolbar & filters */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.search {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  height: 46px; padding: 0 14px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; outline: none; background: none; color: var(--text); height: 100%; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.filter-btn { height: 46px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-sm); }
.filter-btn[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.badge {
  display: inline-grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  font-size: 11.5px; font-weight: 750;
  background: var(--accent); color: var(--on-accent);
  animation: pop 0.35s var(--spring);
}
.badge[hidden] { display: none; }
@keyframes pop { from { transform: scale(0.4); opacity: 0; } }

.filters { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 0.38s var(--ease), opacity 0.25s, margin 0.38s var(--ease); }
.filters.open { grid-template-rows: 1fr; opacity: 1; margin-bottom: 14px; }
.filters-inner { overflow: hidden; min-height: 0; }
.filters.open .filters-inner { overflow: visible; }
.filters-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  padding: 18px 18px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  border-bottom: 0;
}
.filters-grid .field { margin-bottom: 0; }
.filters-foot {
  display: flex; justify-content: flex-end;
  padding: 12px 22px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
}

/* Empty states */
.empty {
  text-align: center;
  padding: 36px 16px 30px;
  color: var(--muted);
  animation: fadeUp 0.5s var(--ease) both;
}
.empty .empty-art { width: 92px; height: 92px; margin: 0 auto 14px; animation: float 4s ease-in-out infinite; }
.empty h3 { color: var(--text); font-size: 16px; font-weight: 680; margin-bottom: 4px; }
.empty p { margin: 0 auto 16px; max-width: 320px; font-size: 14px; }
.empty .btn-row { justify-content: center; }
.empty.compact { padding: 18px 8px; }
.empty.compact .empty-art { width: 64px; height: 64px; margin-bottom: 10px; }
@keyframes float { 50% { transform: translateY(-6px); } }

.welcome {
  display: flex; align-items: center; gap: 22px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 14%, var(--surface)), var(--surface) 70%);
}
.welcome .empty-art { width: 96px; height: 96px; flex: none; animation: float 4s ease-in-out infinite; }
.welcome h2 { font-size: 20px; margin-bottom: 4px; }
.welcome p { margin: 0 0 14px; color: var(--muted); }
@media (max-width: 560px) { .welcome { flex-direction: column; text-align: center; } .welcome .btn-row { justify-content: center; } }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ==========================================================================
   Settings
   ========================================================================== */

.settings-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.goal-form { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; }
.goal-form .field { flex: 1; margin: 0; }
.goal-form .btn { height: 48px; }

.setting-row {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 12px 16px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.card h2 + .setting-row { margin-top: 14px; }
.setting-row:last-child { padding-bottom: 0; }
.row-title { display: block; font-weight: 620; }
.row-sub { display: block; font-size: 13px; color: var(--muted); }
.setting-row select.input { width: auto; min-width: 150px; }
.currency-ctl { display: flex; align-items: center; gap: 8px; }
.currency-ctl .chip { width: 38px; padding: 0; justify-content: center; }
.currency-input { width: 64px; text-align: center; font-weight: 650; padding: 0 8px; }

.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-item {
  display: flex; align-items: center; gap: 12px;
  margin: 0 -10px;
  padding: 8px 10px;
  border-radius: 14px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.15s;
  animation: fadeUp 0.4s var(--ease) both;
  animation-delay: calc(var(--d, 0) * 30ms);
}
.cat-item:hover { background: var(--surface-2); }
.cat-item:active { transform: scale(0.99); }
.cat-item .tx-icon { width: 38px; height: 38px; font-size: 18px; border-radius: 12px; }
.cat-item .cat-name { flex: 1; font-weight: 620; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-item .cat-count { font-size: 13px; color: var(--muted); white-space: nowrap; }
.cat-item .swatch-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.cat-item svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.btn-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.sub-title { font-size: 14px; font-weight: 680; margin-top: 26px; }
.danger-title { color: var(--bad); }
.sub-title + .card-sub { margin-top: 2px; }
.sub-title + .btn { margin-top: 10px; }
.footer-note { text-align: center; color: var(--muted); font-size: 12.5px; margin: 32px 0 0; }

/* ==========================================================================
   FAB
   ========================================================================== */

.fab {
  position: fixed; z-index: 45;
  right: max(24px, calc((100vw - 1120px) / 2 + 4px));
  bottom: calc(28px + env(safe-area-inset-bottom));
  width: 60px; height: 60px;
  border-radius: 20px;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 14px 30px -10px var(--accent), 0 4px 10px -4px rgba(0, 0, 0, 0.2);
  transition: transform 0.35s var(--spring), box-shadow 0.25s, border-radius 0.35s var(--ease);
  animation: fabIn 0.6s var(--spring) 0.2s both;
}
.fab svg { width: 26px; height: 26px; stroke-width: 2.4; transition: transform 0.4s var(--spring); }
.fab:hover { transform: translateY(-3px); border-radius: 24px; box-shadow: 0 20px 36px -12px var(--accent), 0 4px 10px -4px rgba(0, 0, 0, 0.2); }
.fab:hover svg { transform: rotate(90deg); }
.fab:active { transform: scale(0.92); }
@keyframes fabIn { from { transform: scale(0) rotate(-90deg); } }

/* ==========================================================================
   Modals / sheets
   ========================================================================== */

.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(8, 10, 18, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity 0.32s ease;
}
.sheet {
  position: relative;
  width: 100%; max-width: 560px;
  max-height: min(92vh, 900px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  border-radius: 26px 26px 0 0;
  padding: 6px 22px calc(22px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 0.42s var(--ease);
  outline: none;
}
.sheet-sm { max-width: 420px; }
.modal.open .modal-backdrop { opacity: 1; }
.modal.open .sheet { transform: none; }
.modal.closing .modal-backdrop { opacity: 0; }
.modal.closing .sheet { transform: translateY(100%); transition-duration: 0.3s; }

.sheet-handle { width: 40px; height: 5px; border-radius: 5px; background: var(--surface-3); margin: 6px auto 10px; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.sheet-head h2 { font-size: 19px; font-weight: 720; }
.sheet-head .icon-btn svg { width: 20px; height: 20px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 22px; }
.sheet-actions .btn { flex: 1; }
.sheet-actions .spacer { display: none; }
.sheet-actions[hidden], .confirm-bar[hidden] { display: none; }
.recent-card .tx-list > li:not(.tx) { list-style: none; }

@media (min-width: 720px) {
  .modal { align-items: center; padding: 24px; }
  .sheet {
    border-radius: 26px;
    padding: 22px 26px 26px;
    transform: translateY(24px) scale(0.96);
    opacity: 0;
    transition: transform 0.38s var(--ease), opacity 0.25s ease;
  }
  .modal.open .sheet { transform: none; opacity: 1; }
  .modal.closing .sheet { transform: translateY(12px) scale(0.97); opacity: 0; transition-duration: 0.22s; }
  .sheet-handle { display: none; }
  .sheet-actions .btn { flex: 0 0 auto; min-width: 120px; }
  .sheet-actions .spacer { display: block; flex: 1; }
  .sheet-actions { justify-content: flex-end; }
}

.form-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 12px; }
@media (min-width: 520px) { .form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.confirm-msg { margin: 0; color: var(--muted); font-size: 15px; }

/* Detail panel */
.detail-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 0 18px; }
.detail-icon {
  width: 68px; height: 68px;
  border-radius: 22px;
  display: grid; place-items: center;
  font-size: 34px;
  background: color-mix(in srgb, var(--c) 18%, transparent);
  animation: popIn 0.5s var(--spring) both;
}
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } }
.detail-amt { font-size: 38px; font-weight: 790; letter-spacing: -0.03em; margin-top: 12px; font-variant-numeric: tabular-nums; }
.detail-amt.income { color: var(--good); }
.detail-list { margin: 0; border-radius: 18px; background: var(--surface-2); padding: 4px 16px; }
.detail-list > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.detail-list > div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: 14px; flex: none; }
.detail-list dd { margin: 0; font-weight: 620; text-align: right; overflow-wrap: anywhere; }

.confirm-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 22px;
  padding: 14px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--bad) 10%, transparent);
  animation: fadeUp 0.3s var(--ease) both;
}
.confirm-bar p { flex: 1 1 180px; margin: 0; font-weight: 620; font-size: 14px; }
.confirm-bar .field { margin: 8px 0 0; flex-basis: 100%; }

/* Category editor */
.cat-preview { display: flex; justify-content: center; margin-bottom: 18px; }
.cat-preview .tx-icon { width: 64px; height: 64px; font-size: 32px; border-radius: 20px; transition: background-color 0.3s; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; margin-top: 8px; }
.emoji-grid button {
  height: 40px; border-radius: 11px; font-size: 20px;
  transition: background-color 0.2s, transform 0.2s var(--spring);
}
.emoji-grid button:hover { background: var(--surface-2); transform: scale(1.12); }
.emoji-grid button.selected { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.emoji-input { width: 72px; text-align: center; font-size: 20px; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch {
  position: relative;
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--c);
  transition: transform 0.25s var(--spring), box-shadow 0.2s;
}
.swatch:hover { transform: scale(1.1); }
.swatch.selected { box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--c); }
.swatch.custom { overflow: hidden; background: conic-gradient(#f43f5e, #f59e0b, #22c55e, #06b6d4, #6366f1, #d946ef, #f43f5e); cursor: pointer; }
.swatch.custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; border: 0; padding: 0; }

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-region {
  position: fixed; z-index: 200;
  left: 50%; bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 13px 14px 13px 18px;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  font-size: 14px; font-weight: 560;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transition: transform 0.35s var(--spring), opacity 0.25s;
}
.toast.show { opacity: 1; transform: none; }
.toast.hide { opacity: 0; transform: translateY(8px) scale(0.97); transition: transform 0.25s var(--ease), opacity 0.2s; }
.toast .msg { flex: 1; }
.toast.error { background: var(--bad); color: #fff; }
.toast-btn {
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 700; font-size: 13.5px;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  transition: transform 0.15s;
}
:root[data-theme="light"] .toast-btn { color: color-mix(in srgb, var(--accent) 55%, #ffffff); }
.toast-btn:active { transform: scale(0.94); }
.toast-progress {
  position: absolute; left: 0; bottom: 0; height: 3px; width: 100%;
  background: var(--accent);
  transform-origin: left;
  animation: shrink linear forwards;
}
@keyframes shrink { to { transform: scaleX(0); } }

/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 719px) {
  :root { --header-h: 60px; }
  /* backdrop-filter would become the containing block for the fixed bottom nav */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .topbar-inner { padding: 0 16px; }
  main { padding: 6px 16px calc(150px + env(safe-area-inset-bottom)); }

  .nav {
    position: fixed; z-index: 50;
    left: 12px; right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    margin: 0;
    padding: 6px;
    border-radius: 24px;
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: saturate(1.6) blur(18px);
    -webkit-backdrop-filter: saturate(1.6) blur(18px);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  .nav .seg-ind { top: 6px; bottom: 6px; border-radius: 18px; background: var(--accent-soft); box-shadow: none; }
  .nav-btn { flex: 1; flex-direction: column; justify-content: center; gap: 3px; height: 54px; padding: 0; border-radius: 18px; font-size: 11.5px; }
  .nav-btn.active { color: var(--accent); }
  .nav-btn svg { width: 22px; height: 22px; }
  .theme-toggle { margin-left: auto; }

  .fab { right: 18px; bottom: calc(96px + env(safe-area-inset-bottom)); width: 58px; height: 58px; }
  .toast-region { bottom: calc(166px + env(safe-area-inset-bottom)); }

  .card { padding: 18px; border-radius: 20px; }
  .list-card { padding: 4px 16px 10px; }
  .tx { margin: 0 -8px; padding: 9px 8px; }
  .big-number { font-size: 38px; }
  .page-head h1 { font-size: 24px; }
  .period-card .segmented button { font-size: 13px; }
  .stat { padding: 12px; }
  .stat strong { font-size: 17px; }
  .toolbar .filter-btn span:not(.badge) { display: none; }
  .toolbar .filter-btn { padding: 0 14px; }
}

@media (max-width: 380px) {
  .budget-body { flex-direction: column; align-items: stretch; }
  .ring-wrap { margin: 0 auto; }
  .budget-stats { grid-template-columns: 1fr 1fr; }
  .budget-stats .bstat:last-child { grid-column: 1 / -1; }
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   v2/v3 additions: periods, money, settings, customization
   ========================================================================== */

.min0 { min-width: 0; }
.card[hidden], .widget[hidden] { display: none !important; }
.good-text { color: var(--good); }
.bad-text { color: var(--bad); }
.link-text { color: var(--accent); font-weight: 600; }
.head-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.full-btn { width: 100%; margin-top: 12px; }
.pill-btn { cursor: pointer; border: 0; transition: background-color .2s, color .2s; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill-btn:hover { background: var(--accent-soft); color: var(--accent); }
.list-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 8px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0 4px; }
.list-head .list-title { margin: 8px 0; }
.empty-line { padding: 10px 0; }
.notice { margin: 12px 0 0; padding: 10px 14px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; }
.warn-notice { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.period-info { margin: 0 0 14px; font-size: 13.5px; color: var(--muted); }
.period-info.strong { color: var(--text); font-weight: 600; }
.flash-card { animation: flashCard 1.4s ease; }
@keyframes flashCard { 25% { box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow); } }

/* State colors shared by budget-style cards */
#todayCard { --state: var(--good); }
#todayCard[data-state="warn"] { --state: var(--warn); }
#todayCard[data-state="bad"] { --state: var(--bad); }
#todayCard[data-state="none"] { --state: var(--muted); }

/* Dashboard grid: 2 columns on desktop, wide widgets span both, gaps filled densely */
@media (min-width: 900px) {
  .overview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; grid-auto-flow: row dense; }
  .overview-grid > .widget { grid-column: auto !important; }
  .overview-grid > .w-wide, .overview-grid > .welcome-slot, .overview-grid > .dash-foot { grid-column: 1 / -1 !important; }
}
@media (max-width: 899px) {
  .overview-grid > .widget { grid-column: 1 / -1 !important; }
}
.dash-foot { display: flex; justify-content: center; padding: 6px 0 0; }

/* Banner (backup reminder / data problems) */
.banner-slot:empty { display: none; }
.banner {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 14px;
  margin: 4px 0 16px; padding: 12px 16px;
  border-radius: 16px; font-size: 14px; font-weight: 560;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  animation: fadeUp .4s var(--ease) both;
}
.banner.danger { background: color-mix(in srgb, var(--bad) 12%, transparent); border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.banner-actions { display: flex; gap: 8px; }
.recovery-options { display: grid; gap: 10px; margin-top: 18px; }

/* Today card */
.meter { height: 10px; border-radius: 10px; background: var(--surface-2); overflow: hidden; margin: 14px 0 12px; }
.meter i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--state); transition: width 1s var(--ease), background-color .4s; }
.today-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; color: var(--muted); }
.today-row strong { color: var(--text); margin-left: 4px; }
#todayLeft { margin-top: 2px; }

/* Period card */
.viewing-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: -6px 0 14px; padding: 8px 12px; border-radius: 12px;
  background: var(--surface-2); font-size: 13px; font-weight: 600; color: var(--muted);
  animation: fadeUp .3s var(--ease) both;
}
.projection { display: flex; align-items: center; gap: 8px; margin-top: 16px; font-size: 14px; color: var(--muted); }
.projection .arrow { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 9px; background: var(--surface-2); font-weight: 800; flex: none; }
.projection.good strong { color: var(--good); }
.projection.bad strong { color: var(--bad); }
.projection.good .arrow { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); }
.projection.bad .arrow { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }
.budget-card .budget-status, #todayCard .budget-status { margin-top: 14px; }

/* Day strip */
.legend-mini { display: flex; gap: 12px; font-size: 12px; color: var(--muted); font-weight: 600; flex: none; }
.lm::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 3px; margin-right: 5px; vertical-align: 1px; }
.lm.under::before { background: var(--good); }
.lm.over::before { background: var(--bad); }
.day-strip {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; margin: 0 -4px;
  scroll-snap-type: x proximity; scroll-behavior: smooth; overscroll-behavior-x: contain;
  scrollbar-width: thin;
}
.day-chip {
  flex: none; width: 78px; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; border-radius: 16px;
  background: var(--surface-2); border: 1.5px solid transparent;
  --tone: var(--good);
  transition: transform .2s var(--spring), border-color .2s, background-color .2s;
  animation: fadeUp .4s var(--ease) both; animation-delay: calc(var(--d, 0) * 25ms);
}
.day-chip:hover { transform: translateY(-3px); }
.day-chip:active { transform: scale(.96); }
.day-chip.over { --tone: var(--bad); }
.day-chip.future { --tone: var(--muted); opacity: .8; }
.day-chip.today { border-color: var(--accent); background: var(--surface); box-shadow: 0 8px 20px -12px var(--accent); }
.dc-wd { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.dc-d { position: relative; font-size: 18px; font-weight: 760; }
.dc-bill { position: absolute; right: -16px; top: -2px; font-size: 11px; font-style: normal; }
.dc-custom { position: absolute; left: -9px; top: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.dc-bar { width: 10px; height: 44px; border-radius: 6px; background: color-mix(in srgb, var(--tone) 16%, transparent); display: flex; align-items: flex-end; overflow: hidden; }
.dc-bar i { display: block; width: 100%; border-radius: 6px; background: var(--tone); transform-origin: bottom; animation: growY .7s var(--ease) both; animation-delay: calc(var(--d, 0) * 25ms + 120ms); }
@keyframes growY { from { transform: scaleY(0); } }
.dc-amt { font-size: 12.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dc-diff { font-size: 11.5px; font-weight: 650; color: var(--tone); font-variant-numeric: tabular-nums; }
.strip-empty { width: 100%; }

/* Category budgets */
.cb-list, .bill-list, .goal-list, .acc-list, .period-list, .sort-list { list-style: none; margin: 0; padding: 0; }
.cb-row { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; --tone: var(--good); animation: fadeUp .4s var(--ease) both; animation-delay: calc(var(--d, 0) * 40ms); }
.cb-row.warn { --tone: var(--warn); }
.cb-row.bad { --tone: var(--bad); }
.cb-row .lg-em { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, transparent); flex: none; }
.cb-main { flex: 1; min-width: 0; }
.cb-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.cb-name { font-weight: 640; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cb-amt { font-weight: 650; white-space: nowrap; }
.cb-track { height: 7px; border-radius: 7px; background: var(--surface-2); overflow: hidden; margin: 6px 0 4px; }
.cb-track i { display: block; height: 100%; border-radius: inherit; background: var(--tone); transform-origin: left; animation: growX .8s var(--ease) both; transition: width .6s var(--ease); }
.cb-foot { font-size: 12.5px; color: var(--muted); }
.cb-foot strong { color: var(--bad); }

/* Quick add */
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.preset-empty { grid-column: 1 / -1; }
.preset-btn {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px; border-radius: 16px; text-align: left;
  background: color-mix(in srgb, var(--c) 10%, var(--surface-2));
  border: 1.5px solid transparent;
  transition: transform .2s var(--spring), border-color .2s, box-shadow .2s;
  animation: fadeUp .4s var(--ease) both; animation-delay: calc(var(--d, 0) * 35ms);
}
.preset-btn:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 45%, transparent); box-shadow: 0 10px 20px -14px var(--c); }
.preset-btn:active { transform: scale(.95); }
.preset-btn.pop { animation: presetPop .45s var(--spring); }
@keyframes presetPop { 40% { transform: scale(.9); } 100% { transform: scale(1); } }
.pb-em { font-size: 22px; }
.pb-name { font-weight: 650; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-amt { font-size: 13px; font-weight: 700; color: var(--muted); }
.pb-amt.income { color: var(--good); }

/* Bills */
.bill-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; margin: 0 -10px; border-radius: 14px; cursor: pointer; transition: background-color .2s; animation: fadeUp .4s var(--ease) both; animation-delay: calc(var(--d, 0) * 35ms); }
.bill-row:hover { background: var(--surface-2); }
.bill-row .lg-em { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, transparent); flex: none; }
.bill-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.bill-name { font-weight: 640; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bill-amt { font-weight: 700; text-align: right; white-space: nowrap; }
.bill-amt small { display: block; font-size: 11px; font-weight: 650; color: var(--warn); }
.bill-more { padding: 6px 0 0; }

/* Period lists */
.period-row {
  position: relative; padding: 12px 14px; margin-bottom: 8px; border-radius: 16px;
  background: var(--surface-2); cursor: pointer; --tone: var(--good);
  transition: transform .15s, background-color .2s;
  animation: fadeUp .35s var(--ease) both;
}
.period-row:hover { background: var(--surface-3); }
.period-row:active { transform: scale(.99); }
.period-row.warn { --tone: var(--warn); }
.period-row.bad { --tone: var(--bad); }
.pr-top { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.pr-name { font-weight: 680; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pr-result { margin-left: auto; font-weight: 650; font-size: 13.5px; white-space: nowrap; }
.pr-sub { margin-top: 2px; }
.pr-track { height: 5px; border-radius: 5px; background: color-mix(in srgb, var(--tone) 15%, transparent); overflow: hidden; margin-top: 8px; }
.pr-track i { display: block; height: 100%; border-radius: inherit; background: var(--tone); }
.pr-activate { margin-top: 8px; }
.active-tag { background: var(--accent-soft) !important; color: var(--accent) !important; }

/* Switches, checks, ranges, folds */
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; cursor: pointer; }
.switch { position: relative; flex: none; width: 46px; height: 28px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); transition: background-color .25s; }
.switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.25); transition: transform .3s var(--spring); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(18px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.check-list { display: grid; gap: 6px; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); cursor: pointer; font-weight: 600; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.check small { margin-left: auto; color: var(--muted); }
.range { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 6px; margin: 0 0 6px;
  background: linear-gradient(to right, var(--accent) var(--p, 50%), var(--surface-3) var(--p, 50%)); outline: none; }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 2px 6px rgba(0,0,0,.2); cursor: pointer; transition: transform .2s var(--spring); }
.range::-webkit-slider-thumb:active { transform: scale(1.2); }
.range::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); cursor: pointer; }
.warn-row { border-top: 1px solid var(--border); transition: opacity .25s; }
.warn-row.off .range { opacity: .35; pointer-events: none; }
.fold { border-top: 1px solid var(--border); padding: 4px 0; }
.fold summary { cursor: pointer; list-style: none; padding: 12px 0; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.fold summary::-webkit-details-marker { display: none; }
.fold summary::before { content: '›'; display: inline-block; width: 14px; font-size: 18px; color: var(--muted); transition: transform .25s var(--ease); }
.fold[open] summary::before { transform: rotate(90deg); }
.fold[open] > :not(summary) { animation: fadeUp .3s var(--ease) both; }
.limit-list, .override-list { display: grid; gap: 6px; max-height: 340px; overflow-y: auto; padding: 2px; }
.limit-row, .ov-row { display: flex; align-items: center; gap: 10px; }
.limit-row .lg-em { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 18%, transparent); flex: none; }
.limit-name, .ov-day { flex: 1; min-width: 0; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ov-row.custom .ov-day { color: var(--accent); }
.money-input.small { height: 40px; width: 140px; flex: none; padding: 0 10px; border-radius: 11px; }
.money-input.small input { font-size: 15px; }
.custom-row { display: flex; gap: 8px; align-items: center; }
.custom-row .money-input { flex: 1; }
.custom-day { margin-top: 16px; }
.quick-ranges { margin: -4px 0 14px; }
.scroll-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.scroll-row .chip { flex: none; }
.setting-row.stack { flex-direction: column; align-items: flex-start; }
.inline-ctl { display: flex; gap: 6px; }
.input.mini { width: 70px; flex: none; }

/* Choice dialog */
.choice-list { display: grid; gap: 8px; margin-top: 16px; }
.choice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface-2); cursor: pointer; border: 1.5px solid transparent; transition: border-color .2s, background-color .2s; }
.choice input { position: absolute; opacity: 0; }
.choice-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); flex: none; transition: border .2s, box-shadow .2s; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input:checked + .choice-dot { border: 6px solid var(--accent); }
.choice input:focus-visible + .choice-dot { box-shadow: 0 0 0 3px var(--accent-soft); }
.choice-text { display: flex; flex-direction: column; }
.choice-text small { color: var(--muted); }

/* Sortable lists */
.sort-item {
  display: flex; align-items: center; gap: 12px;
  margin: 0 -10px; padding: 8px 10px; border-radius: 14px;
  background: var(--surface); position: relative;
  transition: background-color .2s, opacity .2s;
}
.sort-item[data-edit] { cursor: pointer; }
.sort-item[data-edit]:hover { background: var(--surface-2); }
.sort-item .tx-icon { width: 38px; height: 38px; font-size: 18px; border-radius: 12px; }
.sort-item > svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.si-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.si-title { font-weight: 640; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted-item { opacity: .6; }
.drag-handle { width: 28px; height: 36px; flex: none; display: grid; place-items: center; color: var(--muted); cursor: grab; touch-action: none; border-radius: 8px; }
.drag-handle:hover { background: var(--surface-2); color: var(--text); }
.drag-handle svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.sorting > * { transition: transform .22s var(--ease); }
.sorting > .dragging { transition: none; z-index: 5; background: var(--surface); box-shadow: var(--shadow-lg); cursor: grabbing; }
.sorting .drag-handle { cursor: grabbing; }

/* Settings jump nav */
.settings-jump { display: flex; gap: 6px; overflow-x: auto; margin: -6px 0 16px; padding-bottom: 4px; scrollbar-width: none; }
.settings-jump a { flex: none; padding: 7px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 620; color: var(--muted); transition: color .2s, background-color .2s; }
.settings-jump a:hover { color: var(--accent); background: var(--accent-soft); }
.info-list { margin: 14px 0 0; padding: 4px 14px; border-radius: 14px; background: var(--surface-2); }
.info-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.info-list > div:last-child { border-bottom: 0; }
.info-list dt { color: var(--muted); }
.info-list dd { margin: 0; font-weight: 600; text-align: right; }

/* Line charts */
.mini-chart, .chart-box { position: relative; width: 100%; margin-top: 8px; }
.line-chart { display: block; width: 100%; overflow: visible; touch-action: pan-y; }
.line-path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.line-area { opacity: .9; }
.line-stop-a { stop-color: var(--accent); stop-opacity: .28; }
.line-stop-b { stop-color: var(--accent); stop-opacity: 0; }
.line-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2.5; transition: cx .15s, cy .15s; }
.line-zero { stroke: var(--bad); stroke-dasharray: 3 4; opacity: .6; }
.line-chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }

/* Hide amounts */
.eye-btn .eye-closed { display: none; }
:root[data-hide-balances] .eye-btn .eye-open { display: none; }
:root[data-hide-balances] .eye-btn .eye-closed { display: block; }
.secret { transition: filter .3s var(--ease); }
:root[data-hide-balances] .secret { filter: blur(7px); user-select: none; }
:root[data-hide-balances] .line-chart { filter: blur(4px); }

/* Accounts */
.acc-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; margin: 0 -10px; border-radius: 14px; cursor: pointer; background: var(--surface); transition: background-color .2s, transform .15s; }
.acc-row:hover { background: var(--surface-2); }
.acc-row:active { transform: scale(.99); }
.acc-row .tx-icon { background: color-mix(in srgb, var(--c) 18%, transparent); }
.acc-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.acc-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-bal { font-weight: 720; white-space: nowrap; }
.acc-bal.neg { color: var(--bad); }
.acc-row.low .acc-bal { color: var(--bad); }
.acc-row.low .tx-icon { box-shadow: 0 0 0 2px var(--bad); }
.acc-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 0 8px; }
.acc-actions { justify-content: center; }
.acc-actions .btn svg { width: 16px; height: 16px; }

/* Goals */
.goal-card { padding: 14px; border-radius: 18px; background: var(--surface-2); margin-bottom: 10px; cursor: pointer; transition: transform .2s var(--spring), box-shadow .2s; animation: fadeUp .4s var(--ease) both; }
.goal-card:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -18px var(--c); }
.goal-card.compact { padding: 12px; }
.goal-top { display: flex; align-items: center; gap: 12px; }
.goal-emoji { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-size: 21px; background: color-mix(in srgb, var(--c) 20%, transparent); flex: none; }
.goal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.goal-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.goal-pct { font-weight: 780; font-size: 18px; color: var(--c); }
.goal-track { height: 10px; border-radius: 10px; background: color-mix(in srgb, var(--c) 14%, transparent); overflow: hidden; margin: 12px 0 8px; }
.goal-track i {
  display: block; height: 100%; width: var(--w); border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--c) 70%, #fff), var(--c));
  animation: goalGrow 1.1s var(--ease) both; transition: width .8s var(--ease);
  position: relative; overflow: hidden;
}
.goal-track i::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent); transform: translateX(-100%); animation: shine 2.8s ease-in-out 1.2s infinite; }
@keyframes goalGrow { from { width: 0; } }
@keyframes shine { 60%, 100% { transform: translateX(100%); } }
.goal-foot { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; font-size: 14px; font-weight: 650; }
.goal-actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.goal-actions .icon-btn { margin-left: auto; }
.goal-card.done .goal-track i { background: linear-gradient(90deg, var(--good), color-mix(in srgb, var(--good) 70%, #fff)); }
.goal-card.celebrate { animation: celebrate .9s var(--spring); }
@keyframes celebrate { 30% { transform: scale(1.04) rotate(-1deg); } 60% { transform: scale(.98) rotate(1deg); } }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: 300; pointer-events: none; }

/* Money view */
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.money-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.money-col { display: grid; gap: 16px; min-width: 0; }
.money-col[hidden] { display: none; }
@media (min-width: 900px) { .money-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
#savingsSummary { margin-bottom: 14px; }
.rule { border-top: 1px solid var(--border); }
.rule .rule-body { display: none; padding-bottom: 6px; }
.rule.on .rule-body { display: grid; animation: fadeUp .3s var(--ease) both; }
.rule .rule-example { display: none; margin: -6px 0 12px; }
.rule.on .rule-example { display: block; }

/* Transactions: neutral amounts for transfers and corrections */
.tx-amt.transfer, .tx-amt.adjust { color: var(--muted); }
.detail-amt.transfer { color: var(--muted); }

/* Toasts */
.toast.warn { background: var(--warn); color: #1d1300; }

/* ---------------- Compact layout ---------------- */
:root[data-density="compact"] { font-size: 14px; }
:root[data-density="compact"] body { font-size: 14px; }
:root[data-density="compact"] .card { padding: 15px; border-radius: 18px; }
:root[data-density="compact"] .overview-grid, :root[data-density="compact"] .settings-grid, :root[data-density="compact"] .money-grid, :root[data-density="compact"] .money-col { gap: 10px; }
:root[data-density="compact"] .card-head { margin-bottom: 12px; }
:root[data-density="compact"] .big-number { font-size: 34px; }
:root[data-density="compact"] .tx { padding-top: 6px; padding-bottom: 6px; }
:root[data-density="compact"] .tx-icon { width: 36px; height: 36px; font-size: 17px; }
:root[data-density="compact"] .ring-wrap { width: 140px; height: 140px; }
:root[data-density="compact"] .ring-pct { font-size: 28px; }
:root[data-density="compact"] .stat { padding: 10px; }
:root[data-density="compact"] .btn { height: 40px; }
:root[data-density="compact"] .day-chip { width: 68px; padding: 8px 4px; }
:root[data-density="compact"] .setting-row, :root[data-density="compact"] .switch-row { padding: 9px 0; }

/* ---------------- Animation speed ---------------- */
:root[data-motion="fast"] *, :root[data-motion="fast"] *::before, :root[data-motion="fast"] *::after {
  transition-duration: .16s !important;
  animation-duration: .22s !important;
  animation-delay: 0s !important;
}
:root[data-motion="fast"] .empty-art, :root[data-motion="fast"] .dot-ind, :root[data-motion="fast"] .goal-track i::after { animation-duration: 4s !important; }
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after {
  animation-duration: .001ms !important;
  animation-delay: 0s !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  transition-delay: 0s !important;
  scroll-behavior: auto !important;
}

/* ---------------- Mobile tweaks for new screens ---------------- */
@media (max-width: 719px) {
  .nav-btn { font-size: 10.5px; }
  .money-input.small { width: 120px; }
  .goal-actions .btn { flex: 1; }
  .legend-mini { display: none; }
  .banner { margin-top: 0; }
  .period-card .segmented button { padding: 0 4px; }
  .head-actions .link-btn { padding: 5px 6px; margin: -5px -4px; }
}

/* Reduced motion always wins over the animation-speed setting */
@media (prefers-reduced-motion: reduce) {
  :root[data-motion] *, :root[data-motion] *::before, :root[data-motion] *::after { animation-duration: .001ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* The hidden attribute always wins over component display rules */
[hidden] { display: none !important; }
