/* ==========================================================================
   Budget Dog — design system
   Concept: "Signal" — a cool, precise, dark instrument panel for money.
   Sharp geometric grotesk (Bricolage Grotesque) headings + a clean grotesk
   body (Hanken Grotesk) + tabular mono readouts (IBM Plex Mono), over a
   graphite near-black ground, lit by a single electric-indigo accent.
   ========================================================================== */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url("/fonts/bricolage-grotesque.woff2") format("woff2");
}
@font-face {
  font-family: "Hanken Grotesk";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/hanken-grotesk.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-500.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/fonts/ibm-plex-mono-600.woff2") format("woff2");
}

:root {
  /* ground */
  --bg: #06070a;
  --bg-glow: #0b0e16;
  --surface: #10131b;
  --surface-raised: #161a24;
  --surface-hover: #1d2230;
  --border: #242a38;
  --border-soft: #181d28;

  /* ink */
  --text: #eef1f6;
  --text-muted: #8b93a3;
  --text-faint: #565e6e;

  /* accent — signal blue */
  --accent: #5b7fff;
  --accent-bright: #8aa8ff;
  --accent-dim: #3f5bcf;
  --accent-ink: #050815;
  --accent-12: rgba(91, 127, 255, 0.12);
  --accent-24: rgba(91, 127, 255, 0.24);

  /* signal colors */
  --positive: #4ade9a;
  --positive-12: rgba(74, 222, 154, 0.14);
  --negative: #ff7a6b;
  --negative-12: rgba(255, 122, 107, 0.14);
  --info: #7fd4e8;
  --info-12: rgba(127, 212, 232, 0.14);

  /* type */
  --font-display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --font-body:
    "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  --font-mono:
    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.45), 0 14px 32px -18px rgba(0, 0, 0, 0.7);
  --shadow-pop: 0 10px 28px -8px rgba(0, 0, 0, 0.6), 0 2px 10px rgba(0, 0, 0, 0.4);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --sidebar-w: 236px;
  --bottom-nav-h: 64px;
  --topbar-h: 56px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background-image:
    radial-gradient(620px 380px at 90% -8%, rgba(91, 127, 255, 0.12), transparent 60%),
    radial-gradient(460px 340px at -6% 22%, rgba(74, 222, 154, 0.05), transparent 55%);
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* fine instrument-panel dot grid for atmosphere/depth */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
  background-image: radial-gradient(rgba(139, 147, 163, 0.14) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: radial-gradient(900px 700px at 78% 0%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(900px 700px at 78% 0%, #000 0%, transparent 72%);
}

a {
  color: var(--accent-bright);
  text-decoration: none;
}
a:hover {
  color: var(--accent);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
  margin: 0 0 4px;
  color: var(--text);
}
h1 {
  font-size: 1.9rem;
  line-height: 1.15;
  font-weight: 800;
}
h2 {
  font-size: 1.18rem;
}
h3 {
  font-size: 1.02rem;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.page-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-bright);
  margin: 0 0 6px;
  display: block;
}
.page-head h1 {
  margin: 0;
}
.page-sub {
  color: var(--text-muted);
  margin: 6px 0 0;
  font-size: 0.92rem;
}

/* ==========================================================================
   App shell — sidebar (desktop) + bottom tab bar (mobile)
   ========================================================================== */

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.08rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: linear-gradient(155deg, var(--accent-bright), var(--accent-dim));
  box-shadow: 0 4px 16px -4px rgba(91, 127, 255, 0.55);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.22);
  pointer-events: none;
}
.brand-mark svg {
  width: 19px;
  height: 19px;
  color: var(--accent-ink);
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--bg-glow), var(--bg) 40%);
  border-right: 1px solid var(--border-soft);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.sidebar-header {
  padding: 0 6px;
  margin-bottom: 28px;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  position: relative;
  transition:
    background-color 0.16s var(--ease),
    color 0.16s var(--ease);
}
.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}
.nav-link:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.nav-link.is-active {
  color: var(--text);
  background: var(--accent-12);
}
.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  box-shadow: 0 0 10px 0 rgba(91, 127, 255, 0.7);
}
.nav-link.is-active svg {
  opacity: 1;
  color: var(--accent-bright);
}

.sidebar-footer {
  border-top: 1px solid var(--border-soft);
  padding-top: 14px;
  margin-top: 14px;
}
.logout-link {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.16s var(--ease), background-color 0.16s var(--ease);
}
.logout-link:hover {
  color: var(--negative);
  background: var(--negative-12);
}
.logout-link svg {
  width: 17px;
  height: 17px;
}

.topbar-mobile {
  display: none;
}

.bottom-nav {
  display: none;
}

main.container {
  max-width: 1180px;
  padding: 36px 40px 72px;
  position: relative;
  z-index: 1;
  animation: rise 0.5s var(--ease) both;
}
body.has-shell main.container {
  margin-left: var(--sidebar-w);
}

@media (max-width: 980px) {
  .sidebar {
    display: none;
  }
  body.has-shell main.container {
    margin-left: 0;
    padding: calc(var(--topbar-h) + 20px) 18px calc(var(--bottom-nav-h) + 28px);
  }

  .topbar-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-h);
    padding: 0 16px;
    background: rgba(6, 7, 10, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-soft);
    z-index: 30;
  }
  .topbar-mobile .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
  }
  .topbar-mobile .brand-mark svg {
    width: 16px;
    height: 16px;
  }
  .topbar-mobile .logout-link {
    width: auto;
    padding: 8px;
  }
  .topbar-mobile .logout-link span {
    display: none;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(9, 11, 16, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--border-soft);
    z-index: 30;
    justify-content: space-around;
    align-items: stretch;
  }
  .bottom-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-faint);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    position: relative;
    transition: color 0.16s var(--ease);
  }
  .bottom-nav-link svg {
    width: 20px;
    height: 20px;
    transition: transform 0.16s var(--ease);
  }
  .bottom-nav-link.is-active {
    color: var(--accent-bright);
  }
  .bottom-nav-link.is-active svg {
    transform: translateY(-1px);
  }
  .bottom-nav-link.is-active::after {
    content: "";
    position: absolute;
    top: 2px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px 0 rgba(91, 127, 255, 0.8);
  }
}

@media (min-width: 981px) {
  .sidebar {
    animation: slide-in-left 0.45s var(--ease) both;
  }
}

/* ==========================================================================
   Auth layout
   ========================================================================== */

.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  position: relative;
  z-index: 1;
}
.auth-container {
  width: 100%;
  max-width: 400px;
  animation: rise 0.55s var(--ease) both;
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
  text-align: center;
}
.auth-brand .brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 13px;
}
.auth-brand .brand-mark svg {
  width: 28px;
  height: 28px;
}
.auth-brand-name {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.5rem;
  letter-spacing: -0.015em;
}
.auth-brand-tag {
  font-family: var(--font-mono);
  color: var(--text-faint);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-top: -6px;
}
.auth-container .card {
  animation: none;
}
.auth-container form + p,
.auth-container p.text-muted {
  text-align: center;
  margin-top: 18px;
}

/* ==========================================================================
   Cards, grid, surfaces
   ========================================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-card);
  animation: rise 0.5s var(--ease) both;
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139, 147, 163, 0.3), transparent);
  pointer-events: none;
}
.card + .card {
  margin-top: 18px;
}

.grid {
  display: grid;
  gap: 18px;
}
.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}
.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}
.grid > .card {
  margin-top: 0;
}
.grid > * {
  animation: rise 0.5s var(--ease) both;
}
.grid > *:nth-child(1) {
  animation-delay: 0.02s;
}
.grid > *:nth-child(2) {
  animation-delay: 0.07s;
}
.grid > *:nth-child(3) {
  animation-delay: 0.12s;
}
.grid > *:nth-child(4) {
  animation-delay: 0.17s;
}

@media (max-width: 720px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  main.container {
    padding-left: 14px;
    padding-right: 14px;
  }
  .card {
    padding: 18px;
  }
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h2 {
  margin: 0;
}

.section-link {
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ==========================================================================
   Stats
   ========================================================================== */

.stat-label {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}
.stat-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 1.7rem;
  font-weight: 600;
  margin-top: 8px;
  letter-spacing: -0.01em;
}
.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: "";
  position: absolute;
  top: -30%;
  right: -20%;
  width: 60%;
  height: 140%;
  background: radial-gradient(circle, var(--accent-12), transparent 70%);
  pointer-events: none;
}

/* ==========================================================================
   Forms
   ========================================================================== */

form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input,
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  transition:
    border-color 0.16s var(--ease),
    box-shadow 0.16s var(--ease);
}
input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-12);
}
input[type="checkbox"] {
  accent-color: var(--accent);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%238b93a3' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
}

.filter-form {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.filter-form label {
  min-width: 150px;
  flex: 1 1 150px;
}
.filter-form > .btn,
.filter-form > .btn-secondary {
  flex: 0 0 auto;
}

.field-row {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.field-row input[type="checkbox"] {
  width: auto;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

button,
.btn {
  background: linear-gradient(155deg, var(--accent-bright), var(--accent));
  color: var(--accent-ink);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition:
    transform 0.15s var(--ease),
    box-shadow 0.15s var(--ease),
    filter 0.15s var(--ease);
  box-shadow: 0 6px 18px -8px rgba(91, 127, 255, 0.6);
}
button:hover,
.btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  color: var(--accent-ink);
}
button:active,
.btn:active {
  transform: translateY(0);
}
button svg,
.btn svg {
  width: 15px;
  height: 15px;
}

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: none;
  font-weight: 600;
}
.btn-secondary:hover {
  border-color: var(--text-faint);
  background: var(--surface-hover);
  color: var(--text);
}
.btn-danger {
  background: var(--negative-12);
  color: var(--negative);
  box-shadow: none;
  border: 1px solid transparent;
  font-weight: 600;
}
.btn-danger:hover {
  background: var(--negative);
  color: #1a0d0a;
  filter: none;
}
.btn-sm {
  padding: 7px 12px;
  font-size: 0.8rem;
}
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
}

.field-error {
  color: var(--negative);
  font-size: 0.8rem;
}

/* ==========================================================================
   Flash
   ========================================================================== */

.flash-stack {
  margin-bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flash {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: rise 0.35s var(--ease) both;
}
.flash svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.flash-success {
  background: var(--positive-12);
  border-color: rgba(74, 222, 154, 0.35);
  color: var(--positive);
}
.flash-error {
  background: var(--negative-12);
  border-color: rgba(255, 122, 107, 0.35);
  color: var(--negative);
}
.flash-info {
  background: var(--info-12);
  border-color: rgba(127, 212, 232, 0.35);
  color: var(--info);
}

/* ==========================================================================
   Tables — collapse to stacked cards on small screens
   ========================================================================== */

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

table {
  width: 100%;
  border-collapse: collapse;
}
th,
td {
  text-align: left;
  padding: 12px 12px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.88rem;
}
tbody tr {
  transition: background-color 0.14s var(--ease);
}
tbody tr:hover {
  background: var(--surface-hover);
}
th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.row-actions form {
  display: inline-flex;
}

td.amount,
.amount-positive,
.amount-negative {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}
.amount-positive {
  color: var(--positive);
}
.amount-negative {
  color: var(--negative);
}

@media (max-width: 720px) {
  table.stack thead {
    display: none;
  }
  table.stack,
  table.stack tbody,
  table.stack tr,
  table.stack td {
    display: block;
    width: 100%;
  }
  table.stack tr {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 4px 14px;
    margin-bottom: 10px;
    background: var(--surface-raised);
  }
  table.stack tr:hover {
    background: var(--surface-raised);
  }
  table.stack td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-soft);
    padding: 10px 0;
    text-align: right;
  }
  table.stack td:last-child {
    border-bottom: none;
  }
  table.stack td::before {
    content: attr(data-label);
    color: var(--text-faint);
    font-size: 0.68rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    text-align: left;
  }
  table.stack td:empty::before {
    content: none;
  }
}

/* ==========================================================================
   Badges / status pills
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-raised);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-active {
  background: var(--positive-12);
  color: var(--positive);
  border-color: transparent;
}
.badge-pending {
  background: var(--accent-12);
  color: var(--accent-bright);
  border-color: transparent;
}
.badge-error {
  background: var(--negative-12);
  color: var(--negative);
  border-color: transparent;
}
.badge-auto {
  border-style: dashed;
  color: var(--text-muted);
}
.category-confirm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.7rem;
  line-height: 1;
  cursor: pointer;
}
.category-confirm-btn:hover {
  color: var(--positive);
  border-color: var(--positive);
}
.category-confirm-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ==========================================================================
   Empty states
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}
.empty-state svg {
  width: 34px;
  height: 34px;
  color: var(--text-faint);
  margin-bottom: 10px;
}
.empty-state p {
  margin: 0 0 14px;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  font-size: 0.85rem;
}
.pagination a {
  font-weight: 700;
}

/* ==========================================================================
   Misc
   ========================================================================== */

.text-muted {
  color: var(--text-muted);
}
code {
  font-family: var(--font-mono);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.85em;
}

.error-page {
  text-align: center;
  padding: 100px 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.error-page .brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 15px;
  margin-bottom: 18px;
}
.error-page .brand-mark svg {
  width: 30px;
  height: 30px;
}
.error-code {
  font-family: var(--font-mono);
  color: var(--accent-bright);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.error-detail {
  white-space: pre-wrap;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  max-width: 560px;
  margin: 18px auto 0;
}

/* ==========================================================================
   Charts
   ========================================================================== */

.chart-card canvas {
  max-width: 100%;
}

/* ==========================================================================
   Page-head actions, sortable table headers, range presets
   ========================================================================== */

.page-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sort-link {
  color: inherit;
}
.sort-link:hover,
.sort-link.is-active {
  color: var(--accent-bright);
}

.range-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.range-preset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  box-shadow: none;
  padding: 6px 11px;
  font-size: 0.76rem;
  font-weight: 600;
}
.range-preset:hover {
  border-color: var(--text-faint);
  background: var(--surface-hover);
  color: var(--text);
  transform: none;
}

/* ==========================================================================
   Sidebar search
   ========================================================================== */

.sidebar-search {
  position: relative;
  margin-bottom: 18px;
  flex-direction: row;
}
.sidebar-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--text-faint);
  pointer-events: none;
}
.sidebar-search input {
  width: 100%;
  padding-left: 34px;
  font-size: 0.82rem;
}

/* ==========================================================================
   Bulk-select action bar
   ========================================================================== */

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
}
.bulk-bar select {
  max-width: 200px;
}

/* ==========================================================================
   Dashboard alerts
   ========================================================================== */

.alerts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.alert-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-12);
  border: 1px solid transparent;
  font-size: 0.86rem;
}
.alert-item a {
  color: var(--text);
}
.alert-item a:hover {
  color: var(--accent-bright);
}
.alert-item.alert-low_balance {
  background: var(--negative-12);
}
.alert-item.alert-over_budget {
  background: var(--negative-12);
}
.alert-item.alert-upcoming_bill {
  background: var(--info-12);
}

/* ==========================================================================
   Budget progress bars
   ========================================================================== */

.budget-bar {
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--surface-raised);
  overflow: hidden;
}
.budget-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 0.3s var(--ease);
}
.budget-bar-fill.is-over {
  background: var(--negative);
}

/* ==========================================================================
   Health score
   ========================================================================== */

.health-score-card {
  display: flex;
  align-items: center;
  gap: 18px;
}
.health-score-badge {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-raised);
  color: var(--text-faint);
}
.health-score-badge svg {
  width: 30px;
  height: 30px;
}
.health-score-badge.is-great,
.health-score-badge.is-good {
  background: var(--positive-12);
  color: var(--positive);
}
.health-score-badge.is-fair {
  background: var(--accent-12);
  color: var(--accent-bright);
}
.health-score-badge.is-needs_attention {
  background: var(--negative-12);
  color: var(--negative);
}
.health-score-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 6px;
}
.health-score-signal {
  font-size: 0.78rem;
  color: var(--text-faint);
}

/* ==========================================================================
   Settings hub links
   ========================================================================== */

.settings-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.settings-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background-color 0.14s var(--ease);
}
.settings-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.settings-link .text-muted {
  font-weight: 400;
  font-size: 0.82rem;
}

/* ==========================================================================
   Modal (native <dialog>)
   ========================================================================== */

dialog.modal {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 22px;
  width: min(480px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 64px));
  overflow-y: auto;
}
dialog.modal::backdrop {
  background: rgba(3, 4, 6, 0.65);
  backdrop-filter: blur(3px);
}
dialog.modal[open] {
  animation: rise 0.25s var(--ease) both;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.modal-head h2 {
  margin: 0;
}

/* ==========================================================================
   Keyframes
   ========================================================================== */

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

@keyframes slide-in-left {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
