:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --surface: #ffffff;
  --surface-soft: #f7fafb;
  --ink: #102a2e;
  --muted: #74878b;
  --line: #e7edef;
  --navy: #0c2d32;
  --teal: #0f766e;
  --teal-strong: #0b5f59;
  --teal-soft: #e8f7f4;
  --blue: #2563eb;
  --blue-soft: #eef4ff;
  --green: #15803d;
  --green-soft: #edf9f0;
  --orange: #d97706;
  --orange-soft: #fff7e8;
  --red: #dc2626;
  --red-soft: #fff0f0;
  --shadow: 0 12px 32px rgba(21, 57, 63, 0.08);
  --shadow-soft: 0 6px 18px rgba(21, 57, 63, 0.06);
  font-family: Inter, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: #e8eef0;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 430px);
  min-height: 100vh;
  margin: 0 auto;
  padding-bottom: 30px;
  overflow: hidden;
  background: var(--bg);
  box-shadow: 0 0 50px rgba(15, 43, 48, 0.08);
}

.hero,
.manage-hero {
  position: relative;
  min-height: 270px;
  padding: 30px 20px 52px;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(circle at 92% 0%, rgba(62, 207, 184, 0.26), transparent 36%),
    radial-gradient(circle at -10% 90%, rgba(37, 99, 235, 0.18), transparent 42%),
    linear-gradient(145deg, #082b31 0%, #0c3e43 58%, #0f5554 100%);
}

.hero::after,
.manage-hero::after {
  content: "";
  position: absolute;
  right: -55px;
  bottom: -85px;
  width: 190px;
  height: 190px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  box-shadow:
    0 0 0 28px rgba(255, 255, 255, 0.025),
    0 0 0 56px rgba(255, 255, 255, 0.018);
  pointer-events: none;
}

.manage-hero {
  min-height: 184px;
  padding-bottom: 28px;
}

.topbar,
.section-title,
.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
}

.topbar,
.section-title.inline,
.dialog-head,
.dialog-actions {
  justify-content: space-between;
}

.topbar {
  position: relative;
  z-index: 1;
}

.month-label,
.hero p,
h1,
h2 {
  margin: 0;
}

.month-label {
  color: rgba(255, 255, 255, 0.68);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

h1 {
  margin-top: 10px;
  font-size: 28px;
  line-height: 1.12;
  letter-spacing: -0.04em;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

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

.pill-button,
.icon-button {
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(10px);
  transition: transform 0.18s ease, background 0.18s ease;
}

.pill-button:active,
.icon-button:active,
.add-button:active,
.primary-button:active,
.secondary-button:active {
  transform: scale(0.96);
}

.pill-button {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  font-size: 22px;
  line-height: 1;
}

.manage-button {
  font-size: 17px;
}

.hero-balance-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 34px;
}

.hero-balance-item {
  min-width: 0;
  padding: 17px 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
}

.hero-balance-item.future {
  background: rgba(255, 255, 255, 0.13);
}

.hero-balance-item span {
  display: block;
  color: rgba(255, 255, 255, 0.66);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.hero-balance-item strong {
  display: block;
  margin-top: 11px;
  color: #baf4dc;
  font-size: 27px;
  line-height: 1.08;
  letter-spacing: -0.035em;
  white-space: nowrap;
}

.hero-balance-item.future strong {
  color: #fff;
}

.hero-note {
  position: relative;
  z-index: 1;
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  font-weight: 600;
}

.card {
  position: relative;
  margin: 16px 16px 0;
  padding: 20px;
  border: 1px solid rgba(223, 232, 234, 0.85);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

#appContent .summary-card {
  margin-top: -30px;
}

.auth-card {
  margin-top: 28px;
  padding: 24px;
}

.auth-card h2 {
  font-size: 23px;
}

.section-title {
  min-height: 24px;
}

.section-title h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 16px;
  margin-right: 9px;
  border-radius: 2px;
  vertical-align: -2px;
  background: linear-gradient(180deg, #20b8a5, #0f766e);
}

.section-title.inline span,
.text-button {
  color: var(--teal);
  font-size: 13px;
  font-weight: 700;
}

.text-button {
  border: 0;
  padding: 4px 0;
  background: transparent;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 18px;
}

.summary-item {
  min-width: 0;
  padding: 15px 13px;
  border: 1px solid #edf2f3;
  border-radius: 16px;
  background: var(--surface-soft);
}

.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-item strong {
  display: block;
  margin-top: 9px;
  font-size: 20px;
  line-height: 1;
  letter-spacing: -0.025em;
}

.summary-item.success {
  border-color: #d7efe2;
  background: linear-gradient(145deg, #effbf4, #e8f7f0);
}

.summary-item.success span,
.summary-item.success strong {
  color: #107044;
}

.subtle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.budget-list,
.fixed-list,
.record-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.budget-item {
  min-height: 142px;
  padding: 16px;
  border: 1px solid #e2eeee;
  border-radius: 18px;
  background: linear-gradient(145deg, #f7fbfb, #eff8f7);
}

.budget-item.over {
  border-color: #f8d9d9;
  background: linear-gradient(145deg, #fff9f9, #fff0f0);
}

.budget-item.default-budget {
  border-color: #e7edef;
  background: #f7f9fa;
}

.budget-head,
.budget-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.budget-item h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.budget-status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
  border-radius: 12px;
  color: var(--green);
  background: #dcf7e6;
  font-size: 11px;
  font-weight: 700;
}

.budget-item.over .budget-status {
  color: var(--red);
  background: #fee2e2;
}

.budget-item.default-budget .budget-status {
  color: #526569;
  background: #e7edef;
}

.budget-metrics {
  margin-top: 17px;
}

.budget-metric {
  min-width: 0;
}

.budget-metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.budget-metric strong {
  display: block;
  margin-top: 5px;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.budget-metric.remaining strong {
  color: var(--green);
}

.budget-item.over .budget-metric.remaining strong {
  color: var(--red);
}

.budget-progress,
.annual-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce9e8;
}

.budget-progress {
  margin-top: 15px;
}

.budget-item.over .budget-progress {
  background: #f7dede;
}

.budget-progress span {
  display: block;
  height: 100%;
  width: 0;
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6, #0f766e);
}

.budget-item.over .budget-progress span {
  background: linear-gradient(90deg, #fb7185, #dc2626);
}

.add-button,
.primary-button {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, #0f8f83, #0b6a64);
  box-shadow: 0 6px 14px rgba(15, 118, 110, 0.2);
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.add-button {
  width: 52px;
  height: 34px;
  border-radius: 12px;
  font-size: 13px;
}

.annual-total {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  margin-top: 20px;
}

.annual-total strong {
  font-size: 38px;
  line-height: 1;
  letter-spacing: -0.045em;
}

.annual-total span {
  color: var(--muted);
  font-size: 13px;
}

.annual-progress-track {
  position: relative;
  margin-top: 16px;
  overflow: visible;
}

.annual-actual {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #14b8a6, #0f766e);
}

.annual-actual.ahead {
  background: linear-gradient(90deg, #fbbf24, #d97706);
}

.annual-actual.over {
  background: linear-gradient(90deg, #fb7185, #dc2626);
}

.annual-baseline-marker {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 0;
  border-left: 2px dashed #173c42;
}

.record-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid #e8eff0;
  border-radius: 16px;
  background: #fbfcfc;
}

.record-row.system-record {
  background: #f5f8f8;
}

.record-content {
  min-width: 0;
}

.record-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.record-type,
.record-system-tag {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #0f766e;
  background: #dff5f1;
  font-size: 11px;
  font-weight: 700;
}

.record-system-tag {
  color: #607478;
  background: #e7edef;
}

.record-row h3 {
  margin: 9px 0 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.record-row p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.record-amount {
  color: var(--red);
  font-size: 17px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.fixed-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 2px;
  border-top: 1px solid var(--line);
  color: #40575b;
  font-size: 14px;
}

.fixed-row:first-child,
.manage-row:first-child {
  border-top: 0;
}

.fixed-row strong {
  color: var(--ink);
  font-size: 15px;
}

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

.manage-grid.compact {
  padding-top: 0;
  border-top: 0;
}

.manage-list {
  display: grid;
  gap: 0;
  margin-top: 18px;
}

.manage-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  padding: 11px 2px;
  border-top: 1px solid var(--line);
}

.manage-row span {
  min-width: 0;
  color: #40575b;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.manage-row strong {
  color: var(--ink);
  font-size: 15px;
}

.delete-record {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 11px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 18px;
  line-height: 1;
}

.empty-state {
  padding: 22px 18px;
  border: 1px dashed #d6e1e3;
  border-radius: 16px;
  color: var(--muted);
  background: #fafcfc;
  font-size: 13px;
  text-align: center;
}

.full-button {
  width: 100%;
}

label {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  color: #40575b;
  font-size: 13px;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid #dbe5e7;
  border-radius: 13px;
  padding: 12px 14px;
  outline: none;
  color: var(--ink);
  background: #fbfdfd;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

input:focus {
  border-color: #38a89b;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
}

dialog {
  width: min(360px, calc(100vw - 32px));
  border: 0;
  border-radius: 24px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(15, 43, 48, 0.26);
}

dialog::backdrop {
  background: rgba(6, 35, 40, 0.5);
  backdrop-filter: blur(2px);
}

.expense-form {
  padding: 22px;
}

.dialog-head {
  margin-bottom: 20px;
}

.dialog-head p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-color: #e2eaec;
  border-radius: 11px;
  color: #527074;
  background: #f4f8f8;
  font-size: 22px;
}

.dialog-actions {
  gap: 12px;
  margin: 20px 0 0;
  padding: 0;
}

.secondary-button,
.primary-button {
  flex: 1;
  height: 44px;
  border-radius: 13px;
}

.secondary-button {
  border: 1px solid #dbe5e7;
  color: #40575b;
  background: #fff;
  font-weight: 700;
}

@media (max-width: 360px) {
  .hero,
  .manage-hero {
    padding-left: 16px;
    padding-right: 16px;
  }

  .card {
    margin-left: 12px;
    margin-right: 12px;
    padding: 18px;
  }

  .hero-balance-grid {
    gap: 8px;
  }

  .hero-balance-item {
    padding-left: 12px;
    padding-right: 12px;
  }

  .hero-balance-item strong {
    font-size: 23px;
  }

  .summary-grid {
    gap: 8px;
  }

  .summary-item {
    padding-left: 10px;
    padding-right: 10px;
  }

  .summary-item strong {
    font-size: 18px;
  }
}
