:root {
  color-scheme: light;
  --ink: #3f3651;
  --muted: #746d83;
  --paper: #fff8f5;
  --panel: #fffefd;
  --line: #f1dde7;
  --soft: #fff0f4;
  --teal: #8bd3c7;
  --teal-dark: #2f7d73;
  --amber: #ffd166;
  --rose: #ff8fab;
  --blue: #8ec5ff;
  --violet: #cdb4db;
  --green: #9bd7a7;
  --wash-a: rgba(255, 214, 232, 0.56);
  --wash-b: rgba(205, 239, 253, 0.46);
  --shadow: 0 16px 40px rgba(111, 86, 112, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

[data-theme="mint"] {
  --ink: #24433d;
  --muted: #5f7771;
  --paper: #f5fff9;
  --panel: #ffffff;
  --line: #d8efe6;
  --soft: #eafff3;
  --teal: #75d6b5;
  --teal-dark: #277864;
  --amber: #f8d77a;
  --rose: #ff9fb2;
  --blue: #92d7ff;
  --violet: #c6c6ff;
  --green: #8ee2a4;
  --wash-a: rgba(183, 247, 211, 0.52);
  --wash-b: rgba(214, 245, 255, 0.48);
  --shadow: 0 16px 40px rgba(53, 107, 91, 0.11);
}

[data-theme="peach"] {
  --ink: #4d3a35;
  --muted: #7b6a63;
  --paper: #fff8f0;
  --panel: #ffffff;
  --line: #f0dfd2;
  --soft: #fff0e3;
  --teal: #92d8c0;
  --teal-dark: #2c796b;
  --amber: #ffd36e;
  --rose: #ff9a8b;
  --blue: #9fcfff;
  --violet: #d6b7ee;
  --green: #a7d99a;
  --wash-a: rgba(255, 209, 189, 0.52);
  --wash-b: rgba(255, 232, 163, 0.42);
  --shadow: 0 16px 40px rgba(123, 84, 59, 0.12);
}

[data-theme="berry"] {
  --ink: #42324f;
  --muted: #756980;
  --paper: #fbf7ff;
  --panel: #ffffff;
  --line: #eadcf4;
  --soft: #f7ecff;
  --teal: #91d6d1;
  --teal-dark: #2d7674;
  --amber: #ffd166;
  --rose: #ff8fab;
  --blue: #9ad0ff;
  --violet: #c7a4e8;
  --green: #a6d9a7;
  --wash-a: rgba(231, 198, 255, 0.5);
  --wash-b: rgba(189, 224, 254, 0.44);
  --shadow: 0 16px 40px rgba(85, 64, 105, 0.12);
}

[data-theme="sky"] {
  --ink: #263d54;
  --muted: #62778b;
  --paper: #f5fbff;
  --panel: #ffffff;
  --line: #d9eaf6;
  --soft: #eaf7ff;
  --teal: #8adbd3;
  --teal-dark: #287a82;
  --amber: #ffe082;
  --rose: #ff9fb5;
  --blue: #7ec8ff;
  --violet: #bfc4ff;
  --green: #99dfb0;
  --wash-a: rgba(189, 224, 254, 0.58);
  --wash-b: rgba(255, 241, 168, 0.42);
  --shadow: 0 16px 40px rgba(63, 102, 134, 0.11);
}

[data-theme="lavender"] {
  --ink: #443757;
  --muted: #746987;
  --paper: #fcf8ff;
  --panel: #ffffff;
  --line: #eadff5;
  --soft: #f8efff;
  --teal: #94ddd3;
  --teal-dark: #347a78;
  --amber: #f8d98a;
  --rose: #ff9fca;
  --blue: #a7d4ff;
  --violet: #bba4ee;
  --green: #a9dfb4;
  --wash-a: rgba(217, 199, 255, 0.52);
  --wash-b: rgba(200, 247, 220, 0.38);
  --shadow: 0 16px 40px rgba(86, 64, 116, 0.12);
}

[data-theme="matcha"] {
  --ink: #344833;
  --muted: #6a7d68;
  --paper: #fbfff6;
  --panel: #ffffff;
  --line: #dfecd7;
  --soft: #f1fae9;
  --teal: #9bd7c3;
  --teal-dark: #407a5c;
  --amber: #e7d978;
  --rose: #ffa9b7;
  --blue: #9fd6ef;
  --violet: #c9b8ee;
  --green: #92d59b;
  --wash-a: rgba(205, 234, 192, 0.56);
  --wash-b: rgba(246, 247, 196, 0.42);
  --shadow: 0 16px 40px rgba(76, 103, 61, 0.11);
}

[data-theme="candy"] {
  --ink: #46364a;
  --muted: #796d82;
  --paper: #fff8fb;
  --panel: #ffffff;
  --line: #f0dfe8;
  --soft: #fff0f6;
  --teal: #98ded0;
  --teal-dark: #2f7e78;
  --amber: #ffe08a;
  --rose: #ff8fab;
  --blue: #96d4ff;
  --violet: #c7b5ff;
  --green: #a9e4a0;
  --wash-a: rgba(255, 202, 212, 0.56);
  --wash-b: rgba(189, 224, 254, 0.42);
  --shadow: 0 16px 40px rgba(119, 76, 105, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 12% -8%, var(--wash-a), transparent 340px),
    radial-gradient(circle at 92% 4%, var(--wash-b), transparent 300px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.34), transparent 300px),
    var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(217, 226, 236, 0.9);
  background: rgba(246, 247, 242, 0.9);
  backdrop-filter: blur(18px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1240px;
  margin: 0 auto;
  padding: calc(14px + var(--safe-top)) 20px 14px;
}

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

.brand-mark {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--ink), var(--teal-dark));
  color: white;
  box-shadow: 0 10px 24px rgba(111, 86, 112, 0.2);
}

.brand-title {
  margin: 0;
  font-size: 20px;
  line-height: 1.05;
  letter-spacing: 0;
}

.brand-subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 20px;
  max-width: 1240px;
  margin: 0 auto;
  padding: calc(18px + var(--safe-top)) 20px 40px;
}

.app-layout {
  min-height: 100dvh;
  padding: calc(16px + var(--safe-top)) 20px calc(104px + var(--safe-bottom));
}

.app-content {
  max-width: 980px;
  margin: 0 auto;
}

.screen-stack {
  display: grid;
  gap: 16px;
}

.screen-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 2px 2px;
}

.screen-title span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.screen-title h2 {
  margin: 4px 0 0;
  font-size: 28px;
  line-height: 1.08;
}

.screen-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.notification-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(151, 181, 173, 0.45);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--teal-dark);
  box-shadow: 0 10px 24px rgba(16, 42, 67, 0.08);
}

.notification-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.notification-dot {
  position: absolute;
  right: -5px;
  top: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border: 2px solid white;
  border-radius: 999px;
  background: var(--rose);
  color: white;
  font-size: 10px;
  font-weight: 900;
  line-height: 14px;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  width: min(560px, calc(100vw - 24px));
  padding: 8px;
  border: 1px solid rgba(217, 226, 236, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 16px 42px rgba(16, 42, 67, 0.16);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.bottom-tab {
  display: grid;
  min-width: 0;
  min-height: 58px;
  place-items: center;
  gap: 3px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.bottom-tab[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.bottom-tab-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: rgba(20, 184, 166, 0.12);
  color: var(--teal-dark);
  font-size: 13px;
}

.bottom-tab[aria-pressed="true"] .bottom-tab-icon {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.auth-layout {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(480px, 100%);
}

.auth-switch {
  width: 100%;
  margin-bottom: 16px;
}

.auth-switch .segment {
  flex: 1;
}

.sidebar,
.main {
  display: grid;
  gap: 16px;
  align-content: start;
}

.admin-layout {
  grid-template-columns: minmax(0, 1fr);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.panel-header > div:first-child {
  min-width: 0;
}

.panel-title {
  margin: 0;
  font-size: 16px;
}

.panel-kicker {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.panel-body {
  padding: 16px 18px 18px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: 16px;
}

.stats-summary {
  display: grid;
  gap: 12px;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(255, 246, 250, 0.72)),
    var(--panel);
}

.metric-label {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  display: block;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 800;
  font-size: 30px;
  line-height: 1;
}

.metric-foot {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
}

.badge.is-live {
  border-color: rgba(20, 184, 166, 0.3);
  background: rgba(20, 184, 166, 0.12);
  color: var(--teal-dark);
}

.badge.is-warn {
  border-color: rgba(245, 158, 11, 0.32);
  background: rgba(245, 158, 11, 0.13);
  color: #8a5700;
}

.badge.is-danger {
  border-color: rgba(225, 29, 72, 0.25);
  background: rgba(225, 29, 72, 0.1);
  color: #9f1239;
}

.segmented,
.compact-control {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.segment {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 32px;
  padding: 6px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  white-space: nowrap;
}

.segment[aria-pressed="true"] {
  background: linear-gradient(145deg, var(--ink), var(--teal-dark));
  color: white;
}

.entry-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(56px, 1fr));
  min-width: 128px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(16, 42, 67, 0.13);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
  box-shadow: none;
}

.button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.button.ghost {
  min-height: 34px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.button.danger {
  background: var(--rose);
}

.button.teal {
  background: var(--teal-dark);
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.notification-list,
.notification-admin-list {
  display: grid;
  gap: 12px;
}

.notification-card,
.admin-notification-card {
  padding: 14px;
  border: 1px solid rgba(217, 226, 236, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.notification-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.notification-card h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.notification-card-head span {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.notification-card p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-hint {
  align-self: flex-end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.verification-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.draft-list {
  display: grid;
  gap: 12px;
}

.draft-item {
  padding: 12px;
  border: 1px solid rgba(217, 226, 236, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field.span-2 {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.field input,
.field select {
  height: 40px;
  padding: 0 11px;
}

.field textarea {
  min-height: 84px;
  resize: vertical;
  padding: 10px 11px;
  line-height: 1.5;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.14);
}

.voice-pad {
  display: grid;
  gap: 12px;
}

.voice-button {
  display: grid;
  width: 100%;
  min-height: 116px;
  place-items: center;
  border: 1px solid rgba(20, 184, 166, 0.3);
  border-radius: 8px;
  background:
    radial-gradient(circle at center, rgba(255, 143, 171, 0.18), transparent 42%),
    radial-gradient(circle at 70% 20%, rgba(142, 197, 255, 0.2), transparent 46%),
    #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.voice-button .mic {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 50%;
  background: var(--teal-dark);
  color: white;
}

.voice-button .mic svg {
  width: 31px;
  height: 31px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice-button.is-recording .mic {
  animation: pulse 1.2s infinite;
  background: var(--rose);
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.35);
  }

  70% {
    box-shadow: 0 0 0 18px rgba(225, 29, 72, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(225, 29, 72, 0);
  }
}

.voice-status {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.inline-note {
  margin: -4px 0 0;
  padding: 9px 11px;
  border: 1px solid rgba(20, 184, 166, 0.18);
  border-radius: 8px;
  background: rgba(20, 184, 166, 0.08);
  color: var(--teal-dark);
  font-size: 12px;
  line-height: 1.45;
}

.draft-preview {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.06);
}

.draft-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chart-wrap {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 16px;
  align-items: center;
}

.stats-block {
  display: grid;
  gap: 12px;
}

.stats-block + .stats-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.donut {
  position: relative;
  width: min(190px, 100%);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: conic-gradient(var(--line) 0 100%);
}

.donut::after {
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: #fff;
  content: "";
}

.donut-center {
  position: absolute;
  inset: 28px;
  z-index: 1;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.45;
}

.legend-list,
.record-list,
.budget-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.legend-item,
.record-item,
.budget-item {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.legend-main,
.record-main,
.budget-main,
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.legend-name,
.record-note,
.budget-name {
  overflow: hidden;
  min-width: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 800;
}

.category-icon {
  display: inline-grid;
  flex: 0 0 30px;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--category-color) 28%, white);
  border-radius: 8px;
  background: color-mix(in srgb, var(--category-color) 16%, white);
  font-size: 16px;
  line-height: 1;
  vertical-align: middle;
}

.record-title-wrap,
.category-budget-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.legend-meta,
.record-meta,
.budget-meta {
  color: var(--muted);
  font-size: 12px;
}

.swatch {
  display: inline-block;
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
}

.bar-track {
  overflow: hidden;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--soft);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

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

.bar-fill.danger {
  background: var(--rose);
}

.trend-chart {
  width: 100%;
  min-height: 220px;
  color: var(--teal-dark);
}

.empty-state {
  display: grid;
  gap: 10px;
  place-items: start;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
}

.empty-state.compact {
  padding: 14px;
}

.record-amount {
  flex: 0 0 auto;
  font-weight: 900;
}

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

.record-amount.expense {
  color: var(--rose);
}

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.month-input {
  max-width: 170px;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 40px));
  padding: 12px 14px;
  border: 1px solid rgba(16, 42, 67, 0.12);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
}

.editor-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 42, 67, 0.45);
}

.editor {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border-radius: 8px;
  background: white;
  box-shadow: 0 22px 70px rgba(16, 42, 67, 0.28);
}

.fine-print {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.budget-category-section {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.category-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-chip,
.theme-choice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.category-chip[aria-pressed="true"],
.theme-choice[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--teal-dark) 36%, white);
  background: color-mix(in srgb, var(--teal) 22%, white);
  color: var(--teal-dark);
}

.category-budget-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.category-budget-row input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  outline: none;
  text-align: right;
}

.category-budget-meta {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.category-budget-row .bar-track {
  grid-column: 1 / -1;
}

.budget-alerts {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(255, 143, 171, 0.42);
  border-radius: 8px;
  background: rgba(255, 143, 171, 0.12);
  color: #8d2850;
  font-size: 12px;
  line-height: 1.45;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.theme-choice {
  justify-content: flex-start;
  width: 100%;
}

.theme-swatches {
  display: inline-flex;
  gap: 3px;
}

.theme-swatches i {
  display: block;
  width: 16px;
  height: 16px;
  border: 1px solid rgba(63, 54, 81, 0.08);
  border-radius: 50%;
}

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

.code-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.code-search-form {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(160px, 220px) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

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

.admin-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 13px;
}

.code-table {
  min-width: 980px;
}

.admin-table th,
.admin-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-table hr {
  margin: 7px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.admin-table th {
  color: var(--muted);
  font-size: 12px;
}

.admin-table select {
  min-width: 96px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  background: #fff;
}

.code-box {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf8;
}

.code-box pre {
  overflow-x: auto;
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
}

.category-budget-row input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.14);
}

.account-panel .panel-body {
  padding-top: 10px;
}

.account-grid {
  display: grid;
  gap: 10px;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 42px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.account-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.account-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.account-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
}

.account-actions .button:only-child {
  grid-column: 1 / -1;
}

.footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px 32px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .layout,
  .admin-layout,
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    align-items: center;
    padding: calc(10px + var(--safe-top)) 12px 10px;
  }

  .header-actions {
    flex: 0 0 auto;
    width: auto;
    gap: 6px;
    justify-content: flex-end;
  }

  .brand-title {
    font-size: 17px;
  }

  .brand-subtitle {
    display: none;
  }

  .brand-mark {
    flex-basis: 36px;
    width: 36px;
    height: 36px;
  }

  .header-actions .badge:nth-of-type(2),
  .header-actions .segmented {
    display: none;
  }

  .layout {
    padding: calc(12px + var(--safe-top)) 12px 30px;
  }

  .app-layout {
    padding: calc(12px + var(--safe-top)) 12px calc(104px + var(--safe-bottom));
  }

  .screen-title h2 {
    font-size: 24px;
  }

  .stat-row,
  .form-grid,
  .chart-wrap,
  .category-grid,
  .theme-grid,
  .code-summary-grid,
  .code-search-form {
    grid-template-columns: 1fr;
  }

  .code-export-actions {
    justify-content: flex-start;
  }

  .field.span-2 {
    grid-column: auto;
  }

  .panel-header,
  .panel-body {
    padding-right: 14px;
    padding-left: 14px;
  }

  .donut {
    width: min(210px, 72vw);
    margin: 0 auto;
  }

  .category-budget-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .category-budget-row input {
    text-align: left;
  }

  .metric-value {
    font-size: 26px;
  }

  .bottom-nav {
    bottom: calc(10px + var(--safe-bottom));
    width: calc(100vw - 16px);
    padding: 6px;
    border-radius: 14px;
  }

  .bottom-tab {
    min-height: 54px;
    font-size: 11px;
  }

  .account-actions {
    grid-template-columns: 1fr;
  }
}
