:root {
  color-scheme: dark;
  --bg: #0c0e11;
  --surface: #14171c;
  --surface-2: #1a1e24;
  --border: #2a3038;
  --border-soft: #1e2329;
  --text: #eceef1;
  --text-secondary: #9aa3ad;
  --muted: #6e7681;
  --accent: #3fb950;
  --accent-soft: #7ee787;
  --link: #6cb6ff;

  /* Single UI font + typography tokens */
  --font: "Plus Jakarta Sans", "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, monospace;

  --fs-metric: 25px;
  --fw-metric: 600;
  --lh-metric: 1.2;

  --fs-heading: 13px;
  --fw-heading: 500;
  --ls-heading: 0.05em;

  --fs-body: 16px;
  --fw-body: 500;
  --lh-body: 1.35;

  --fs-secondary: 13px;
  --fw-secondary: 400;
  --lh-secondary: 1.4;

  --fs-control: 14px;
  --fw-control: 500;

  --fs-chip: 12px;
  --fw-chip: 500;

  /* Shared dashboard columns — budget aligns with spend breakdown */
  --dash-gap: .85rem;
  --dash-cols: minmax(0, 1.85fr) minmax(240px, .72fr);
}

[hidden] { display: none !important }
.is-gated { visibility: hidden }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}
.auth-card {
  width: min(100%, 390px);
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(20, 23, 28, .96);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .45);
  backdrop-filter: blur(16px);
}
.auth-card > .brand-mark { display: block; margin-bottom: .85rem }
.auth-card h1,
.auth-card h2 {
  margin: 0 0 .4rem;
  font-size: 22px;
  letter-spacing: -.03em;
}
.auth-card h2 { font-size: 18px }
.auth-lead,
.auth-copy {
  margin: 0 0 1rem;
  color: var(--text-secondary);
}
.auth-status {
  min-height: 1.25rem;
  margin: 0 0 .75rem;
  color: var(--accent-soft);
}
.auth-status:empty { display: none }
.auth-status[data-kind="error"] { color: #ff7b72 }
.auth-form { display: grid; gap: .8rem }
.auth-form label {
  display: grid;
  gap: .35rem;
  color: var(--text-secondary);
  font-size: var(--fs-secondary);
}
.auth-form input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .7rem;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.auth-form input:focus {
  outline: none;
  border-color: #3f8f4a;
}
.auth-submit {
  width: 100%;
  padding: .65rem .75rem;
}
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: .75rem;
  margin: 1rem 0 0;
}
.auth-text {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--link);
  font: inherit;
  cursor: pointer;
}
.header-actions,
.account-bar {
  display: flex;
  align-items: center;
  gap: .5rem;
}
.account-email {
  max-width: 220px;
  overflow: hidden;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Reusable typography utilities */
.text-metric {
  font-family: var(--font);
  font-size: var(--fs-metric);
  font-weight: var(--fw-metric);
  line-height: var(--lh-metric);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.text-heading {
  font-family: var(--font);
  font-size: var(--fs-heading);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  text-transform: uppercase;
  color: var(--muted);
}
.text-body {
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
  letter-spacing: -0.01em;
  color: var(--text);
}
.text-secondary {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--text-secondary);
}
.text-control {
  font-family: var(--font);
  font-size: var(--fs-control);
  font-weight: var(--fw-control);
  letter-spacing: -0.005em;
}

* { box-sizing: border-box }
body {
  margin: 0;
  padding: 1.5rem 1.25rem 2.5rem;
  padding-left: max(1.25rem, env(safe-area-inset-left));
  padding-right: max(1.25rem, env(safe-area-inset-right));
  padding-bottom: max(2.5rem, env(safe-area-inset-bottom));
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-secondary);
  line-height: var(--lh-secondary);
  font-weight: var(--fw-secondary);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}
.ambient {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 70% 45% at 12% -8%, rgba(63, 185, 80, 0.09), transparent 55%),
    radial-gradient(ellipse 55% 40% at 92% 8%, rgba(108, 182, 255, 0.05), transparent 50%),
    radial-gradient(ellipse 50% 35% at 50% 100%, rgba(20, 28, 24, 0.55), transparent 60%);
}
.ambient::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
}
.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.15rem;
}
.brand-block { min-width: 0; flex: 1 }
.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: .35rem;
}
.brand-mark {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(126, 231, 135, 0.08), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.brand-text h1 {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--font);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin: 0;
  color: var(--text);
  line-height: 1.15;
}
.brand-name {
  background: linear-gradient(120deg, #f2f4f6 0%, #c8d0d8 55%, #8fd99a 130%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-tag {
  margin: .12rem 0 0;
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--muted);
  letter-spacing: 0;
}
.sub {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--text-secondary);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.sub code {
  font-family: var(--font);
  font-size: inherit;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  padding: 0;
}
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: p 2s infinite;
}
@keyframes p { 50% { opacity: .28 } }
.gear {
  background: rgba(20, 23, 28, 0.85);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: .42rem .72rem;
  font-family: var(--font);
  font-size: var(--fs-control);
  font-weight: var(--fw-control);
  cursor: pointer;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}
.gear:hover { color: var(--text); border-color: #3a424c }

.month-filter { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap }
.month-select { max-width: 100%; min-width: 0 }
.month-filter-label {
  font-family: var(--font);
  font-size: var(--fs-heading);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  text-transform: uppercase;
  color: var(--muted);
}
.month-select, .tx-filter {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .38rem 1.85rem .38rem .65rem;
  font-family: var(--font);
  font-size: var(--fs-control);
  font-weight: var(--fw-control);
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236e7681' d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
}
.month-select:hover, .tx-filter:hover, .tx-search:hover { border-color: #3a424c }
.month-select:focus, .tx-filter:focus, .tx-search:focus { outline: none; border-color: #3f8f4a }

.kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .65rem;
  margin-bottom: 0;
  align-items: stretch;
}
.kpi {
  background: linear-gradient(180deg, rgba(26, 30, 36, 0.95) 0%, var(--surface) 100%);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: .65rem .8rem .6rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: 100%;
  min-height: 0;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}
.kpi .val {
  font-family: var(--font);
  font-size: var(--fs-metric);
  font-weight: var(--fw-metric);
  line-height: var(--lh-metric);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.kpi .lbl {
  font-family: var(--font);
  font-size: var(--fs-heading);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  text-transform: uppercase;
  color: var(--muted);
  margin-top: .18rem;
}
.kpi-sub {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--text-secondary);
  margin-top: .28rem;
}
.kpi-budget {
  justify-content: flex-start;
  gap: 0;
  min-width: 0;
}
.budget-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
}
.budget-pct {
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: var(--fw-metric);
  line-height: var(--lh-metric);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.budget-pct.over { color: #d2a8a2 }
.budget-meta {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--text-secondary);
  margin-top: .28rem;
}
.budget-meta .budget-amt {
  font-variant-numeric: tabular-nums;
  font-weight: var(--fw-secondary);
}
.budget-over { color: #d2a8a2 }
.budget-bar {
  height: 3px;
  background: var(--border-soft);
  border-radius: 99px;
  overflow: hidden;
  margin-top: .35rem;
  width: 100%;
}
.budget-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #2f8f45, var(--accent-soft));
  border-radius: 99px;
  transition: width .25s ease;
}
.budget-bar span.over { background: #c97870 }
.budget-foot {
  display: flex;
  align-items: center;
  gap: .35rem;
  margin-top: .35rem;
  flex-wrap: wrap;
}
.budget-updated {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--muted);
}
.budget-updated:not([hidden])::after {
  content: "·";
  margin-left: .35rem;
  color: var(--border);
}
.budget-edit-link {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font);
  font-size: var(--fs-control);
  font-weight: var(--fw-control);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
}
.budget-edit-link:hover { color: var(--accent-soft) }

.budget-dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(360px, calc(100vw - 2rem));
  font-family: var(--font);
}
.budget-dialog::backdrop { background: rgba(0,0,0,.55) }
.budget-dialog form { padding: 1.1rem 1.15rem 1rem }
.budget-dialog h2 {
  margin: 0 0 .35rem;
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: var(--fw-metric);
  letter-spacing: -0.01em;
  line-height: var(--lh-body);
}
.budget-dialog-hint {
  margin: 0 0 .9rem;
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--muted);
}
.budget-dialog-label {
  display: block;
  font-family: var(--font);
  font-size: var(--fs-heading);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .35rem;
}
.budget-dialog input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .5rem .65rem;
  font-family: var(--font);
  font-size: var(--fs-control);
  font-weight: var(--fw-control);
  margin-bottom: 1rem;
}
.budget-dialog-actions { display: flex; justify-content: flex-end; gap: .45rem }
.btn-ghost, .btn-primary {
  border-radius: 8px;
  padding: .4rem .75rem;
  font-family: var(--font);
  font-size: var(--fs-control);
  font-weight: var(--fw-control);
  cursor: pointer;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.btn-primary {
  background: #243528;
  border: 1px solid #2f4a36;
  color: var(--accent-soft);
}

.dot.ok { background: var(--accent) }
.dot.idle { background: var(--muted); animation: none }

.site-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  margin-top: 1.75rem;
  padding-top: .25rem;
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--muted);
  letter-spacing: 0;
}
.foot-mark {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .7;
  box-shadow: 0 0 10px rgba(63, 185, 80, 0.45);
}

.dash-grid {
  display: grid;
  grid-template-columns: var(--dash-cols);
  gap: var(--dash-gap);
  align-items: start;
}
.dash-main {
  display: flex;
  flex-direction: column;
  gap: var(--dash-gap);
  min-width: 0;
}

.panel {
  background: linear-gradient(180deg, rgba(22, 26, 32, 0.98) 0%, var(--surface) 40%);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 0;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
}
.panel-h {
  padding: .72rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--font);
  font-size: var(--fs-heading);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: .45rem;
}
.panel-h .dim {
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: none;
}

.tx-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  padding: .65rem .9rem;
  border-bottom: 1px solid var(--border-soft);
}
.tx-search {
  flex: 1 1 160px;
  min-width: 140px;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: .45rem .65rem;
  font-family: var(--font);
  font-size: var(--fs-control);
  font-weight: var(--fw-control);
  line-height: 1.25;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  appearance: none;
  -webkit-appearance: none;
}
.tx-search::-webkit-search-decoration,
.tx-search::-webkit-search-cancel-button,
.tx-search::-webkit-search-results-button,
.tx-search::-webkit-search-results-decoration {
  -webkit-appearance: none;
  appearance: none;
}
.tx-scroll {
  max-height: min(68vh, 720px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font);
  font-size: var(--fs-body);
  min-width: 640px;
}
.tx-panel,
.breakdown-panel,
.dash-main,
.kpi {
  min-width: 0;
}
th {
  text-align: left;
  padding: .65rem 1rem;
  font-family: var(--font);
  font-size: var(--fs-heading);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
th.num, td.num { text-align: right }
td {
  padding: .78rem 1rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none }
tr:hover td { background: rgba(255,255,255,.015) }
tr.expandable { cursor: pointer }
tr.expandable .chev { color: var(--muted); font-size: .65rem; width: .9rem; display: inline-block }
tr.detail-row td {
  background: #12151a;
  padding: .55rem .9rem .8rem 2.1rem;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
.details-block { max-width: 34rem }
.details-title {
  font-family: var(--font);
  font-size: var(--fs-heading);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .4rem;
}
.details-lines {
  display: flex;
  flex-direction: column;
  gap: .22rem;
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--text-secondary);
}
.details-empty {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  color: var(--muted);
  padding: .1rem 0;
}
.att-links { margin-top: .45rem; display: flex; flex-wrap: wrap; gap: .4rem .55rem }
.att-link {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-control);
  color: var(--link);
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .15rem .4rem;
  background: var(--bg);
}
.att-link:hover { border-color: #3a5a7a }

.merchant { display: flex; flex-direction: column; gap: .12rem; line-height: var(--lh-body) }
.merchant-name {
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  letter-spacing: -0.01em;
  line-height: var(--lh-body);
  color: var(--text);
}
.merchant-sub {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--muted);
}
.inv-view {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-control);
  color: var(--accent-soft);
  text-decoration: none;
}
.inv-view:hover { text-decoration: underline }
.inv-empty {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--muted);
}
.amt {
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}
.date-cell {
  font-family: var(--font);
  font-size: var(--fs-body);
  font-weight: var(--fw-body);
  line-height: var(--lh-body);
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}
.cat {
  font-family: var(--font);
  font-size: var(--fs-chip);
  font-weight: var(--fw-chip);
  letter-spacing: 0.01em;
  line-height: 1.25;
  padding: .18rem .48rem;
  border-radius: 5px;
  background: #1a1f26;
  color: var(--text-secondary);
  white-space: nowrap;
}
.cat-transport { background: #141c28; color: #7aa8d4 }
.cat-food-delivery { background: #221c16; color: #c99a6a }
.cat-grocery { background: #162018; color: #7aab84 }
.cat-mobile { background: #1c1824; color: #a98cc4 }
.cat-insurance { background: #161c24; color: #8eaccc }
.cat-entertainment { background: #22181c; color: #c98a86 }
.cat-subscriptions { background: #181c24; color: #8eacd4 }
.cat-shopping { background: #201c14; color: #b8a06a }
.cat-travel { background: #141e20; color: #6eafb4 }
.cat-payments { background: #1e1a14; color: #b8a06a }
.cat-other { background: #1a1f26; color: var(--text-secondary) }

.dim { color: var(--muted) }
.empty {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  color: var(--muted);
  text-align: center;
  padding: 2.2rem 1rem;
}

.breakdown-panel {
  position: sticky;
  top: .75rem;
  align-self: start;
}
.breakdown-body { padding: .85rem .9rem 1rem }
.breakdown-toggle {
  display: flex;
  gap: .25rem;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: .18rem;
  margin-bottom: .9rem;
}
.bd-tab {
  flex: 1;
  border: 0;
  background: transparent;
  font-family: var(--font);
  font-size: var(--fs-control);
  font-weight: var(--fw-control);
  color: var(--muted);
  padding: .35rem .4rem;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 0;
}
.bd-tab.active {
  background: var(--surface-2);
  color: var(--text);
}
.donut-wrap {
  position: relative;
  width: 180px;
  height: 180px;
  margin: .25rem auto .75rem;
}
.donut-wrap::before {
  content: "";
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(63, 185, 80, 0.08) 0%, transparent 70%);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
  transition: opacity .35s ease;
}
.donut-wrap.has-data::before { opacity: 1 }
.donut-wrap canvas {
  position: relative;
  z-index: 1;
  width: 100% !important;
  height: 100% !important;
  display: block;
}
.donut-center {
  position: absolute;
  inset: 32%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  text-align: center;
  overflow: hidden;
  padding: .15rem;
  box-sizing: border-box;
}
.donut-total {
  font-family: var(--font);
  font-size: .88rem;
  font-weight: var(--fw-metric);
  line-height: 1.05;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.donut-total.is-long { font-size: .78rem }
.donut-label {
  font-family: var(--font);
  font-size: .58rem;
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  text-transform: uppercase;
  color: var(--muted);
  margin-top: .15rem;
}
.bd-list { display: flex; flex-direction: column; gap: .5rem }
.bd-row {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  gap: .5rem;
  align-items: center;
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
}
.bd-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.bd-name {
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--fw-secondary);
}
.bd-amt {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-body);
  line-height: var(--lh-secondary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.bd-pct {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 2.4rem;
  text-align: right;
}
.bd-empty {
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  color: var(--muted);
  text-align: center;
  padding: 1rem .5rem;
}

.poll-panel { display: none; margin-bottom: 1rem }
.poll-panel.open { display: block }
.stat-box {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: .7rem .8rem;
}
.stat-box .n {
  font-family: var(--font);
  font-size: var(--fs-metric);
  font-weight: var(--fw-metric);
  line-height: var(--lh-metric);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--accent-soft);
}
.stat-box .t {
  font-family: var(--font);
  font-size: var(--fs-heading);
  font-weight: var(--fw-heading);
  letter-spacing: var(--ls-heading);
  text-transform: uppercase;
  color: var(--muted);
}
#recv-last {
  margin-top: .4rem;
  font-family: var(--font);
  font-size: var(--fs-secondary);
  font-weight: var(--fw-secondary);
  line-height: var(--lh-secondary);
  color: var(--muted);
}
.fetch-log {
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  margin: 0 1rem 1rem;
  padding: .5rem .55rem;
  max-height: 14rem;
  overflow: auto;
  font: 12px/1.4 var(--font-mono);
  color: var(--muted);
}
.fetch-log .line { margin: 0 0 .2rem; word-break: break-word }
.fetch-log .recv { color: var(--accent) }
.fetch-log .err { color: #f85149 }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: 1fr }
  .breakdown-panel { position: static }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)) }
}

@media (max-width: 720px) {
  body {
    padding: 1rem .85rem 2rem;
    padding-left: max(.85rem, env(safe-area-inset-left));
    padding-right: max(.85rem, env(safe-area-inset-right));
    padding-bottom: max(2rem, env(safe-area-inset-bottom));
  }

  .brand-tag { display: none }
  .brand-mark { width: 32px; height: 32px }
  .brand-text h1 { font-size: 20px }
  .top { gap: .65rem; margin-bottom: .9rem }

  .month-filter { width: 100% }
  .month-select {
    flex: 1;
    width: 100%;
    min-height: 42px;
    height: 42px;
  }

  .kpis {
    grid-template-columns: 1fr 1fr;
    gap: .55rem;
  }
  .kpis .kpi-budget {
    grid-column: 1 / -1;
  }

  .kpi { padding: .6rem .7rem .55rem }
  .kpi .val { font-size: 22px }

  .tx-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: .5rem;
  }
  .tx-filter,
  .tx-search {
    width: 100%;
    flex: 0 0 auto;
    min-width: 0;
    max-width: 100%;
  }
  .tx-search {
    height: 42px;
    min-height: 42px;
    max-height: 42px;
    padding: 0 .75rem;
    line-height: 42px;
  }
  .tx-filter {
    height: 42px;
    min-height: 42px;
  }
  .gear,
  .bd-tab {
    min-height: 42px;
  }
  .bd-tab { display: flex; align-items: center; justify-content: center }

  .tx-scroll {
    max-height: min(70vh, 560px);
    border-radius: 0 0 12px 12px;
  }

  .panel-h { padding: .65rem .85rem }
  th, td { padding: .7rem .75rem }
  tr.detail-row td { padding-left: 1.25rem }

  .budget-dialog {
    width: calc(100vw - 1.5rem);
    max-width: 100%;
    margin: auto;
  }

  .site-foot { margin-top: 1.25rem }
}

@media (max-width: 480px) {
  .kpi .val { font-size: 20px }
  .budget-pct { font-size: 15px }

  .sub { font-size: 12px; line-height: 1.45 }

  table { min-width: 560px }
  .merchant-name,
  .amt,
  .date-cell { font-size: 15px }

  .donut-wrap {
    width: 160px;
    height: 160px;
  }
}

code {
  background: #1a1f26;
  padding: .08rem .28rem;
  border-radius: 4px;
  font-size: inherit;
  font-family: var(--font-mono);
}
