:root {
  color-scheme: light;
  --bg: #f5efe8;
  --card: #fffaf5;
  --ink: #241711;
  --muted: #76675e;
  --accent: #9c4f38;
  --accent-dark: #6f3325;
  --line: #e0d2c7;
  --shadow: 0 18px 45px rgba(74, 42, 25, 0.12);
}

.theme-dark {
  color-scheme: dark;
  --bg: #0f1117;
  --card: #171a23;
  --ink: #f5efe7;
  --muted: #b7aa9f;
  --accent: #d68a64;
  --accent-dark: #f0a77e;
  --line: #2b303b;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top left, #fff7ed, var(--bg) 42%, #efe2d9);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.theme-dark {
  background: radial-gradient(circle at top left, #1d2430, var(--bg) 44%, #090b10);
}

a {
  color: inherit;
}

input, button, select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  border-bottom: 1px solid rgba(156, 79, 56, 0.18);
  background: color-mix(in srgb, var(--card) 86%, transparent);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  font-weight: 800;
  text-decoration: none;
  letter-spacing: -0.03em;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.topbar nav a, .link-button {
  color: var(--muted);
  text-decoration: none;
  font-weight: 700;
}

.user-menu {
  position: relative;
}

.user-menu summary {
  cursor: pointer;
  list-style: none;
}

.user-menu summary::-webkit-details-marker {
  display: none;
}

.user-avatar {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 950;
  box-shadow: 0 10px 24px rgba(156, 79, 56, 0.24);
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.75rem);
  z-index: 20;
  display: grid;
  gap: 0.65rem;
  width: 240px;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.user-menu-panel span {
  color: var(--muted);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.user-menu-panel a, .user-menu-panel .link-button {
  justify-self: start;
  color: var(--ink);
}

.inline-form {
  display: inline;
}

.link-button {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.page {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 3rem) 0 4rem;
}

.hero {
  min-height: 72vh;
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 2rem;
  align-items: center;
}

.hero h1, .page-heading h1, .panel h1 {
  margin: 0;
  font-size: clamp(2.5rem, 8vw, 5.7rem);
  line-height: 0.92;
  letter-spacing: -0.08em;
}

.hero p {
  max-width: 650px;
  color: var(--muted);
  font-size: 1.18rem;
  line-height: 1.6;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-card, .panel, .stat-card, .select-card, .credit-card-tile, .benefit-card {
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  gap: 1rem;
  padding: 2rem;
  transform: rotate(2deg);
}

.hero-card span {
  padding: 1rem;
  border-radius: 18px;
  background: color-mix(in srgb, var(--accent) 14%, var(--card));
  font-weight: 800;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 900;
  padding: 0.86rem 1.2rem;
  text-decoration: none;
}

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

.button.secondary {
  background: color-mix(in srgb, var(--accent) 18%, var(--card));
  color: var(--ink);
}

.button.small {
  padding: 0.55rem 0.85rem;
}

.actions, .page-heading, .year-form {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-heading {
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.page-heading h1, .panel h1 {
  font-size: clamp(2rem, 5vw, 3.6rem);
}

.panel {
  padding: clamp(1rem, 3vw, 2rem);
  margin-bottom: 1.5rem;
}

.auth-panel {
  max-width: 520px;
  margin: 3rem auto;
}

.stacked-form, .cards-form {
  display: grid;
  gap: 1rem;
}

label {
  display: grid;
  gap: 0.45rem;
  color: var(--muted);
  font-weight: 800;
}

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  padding: 0.78rem 0.9rem;
}

.alert {
  border: 1px solid #c44630;
  border-radius: 14px;
  background: #fff1ed;
  color: #8d2414;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}

.theme-dark .alert {
  background: #3b1111;
  color: #fecaca;
}

.notice {
  border: 1px solid #10b981;
  border-radius: 14px;
  background: #ecfdf5;
  color: #065f46;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}

.theme-dark .notice {
  background: #052e25;
  color: #a7f3d0;
}

.muted {
  color: var(--muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  padding: 1.4rem;
}

.stat-card span, .card-list span {
  color: var(--muted);
  display: block;
}

.stat-card strong {
  display: block;
  font-size: 2.4rem;
  margin-top: 0.35rem;
}

.value-card.positive strong {
  color: #047857;
}

.value-card.negative strong {
  color: #b91c1c;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(280px, 1.1fr);
  gap: 1rem;
  align-items: start;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.section-title h2 {
  margin: 0;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card-list article {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  background: var(--card);
}

.select-card {
  display: grid;
  grid-template-columns: 1.2fr 120px 220px 1fr;
  gap: 1rem;
  align-items: end;
  padding: 1rem;
  box-shadow: none;
}

.expanded-card-form {
  grid-template-columns: minmax(220px, 1.1fr) repeat(3, minmax(120px, 0.6fr));
}

.expanded-card-form label:last-child,
.expanded-card-form label:nth-last-child(2) {
  grid-column: span 2;
}

.reset-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
}

.checkline input {
  width: auto;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.tracker-table {
  width: 100%;
  min-width: 1360px;
  border-collapse: collapse;
}

.tracker-table th, .tracker-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 0.72rem;
  text-align: left;
  vertical-align: top;
}

.tracker-table th {
  background: color-mix(in srgb, var(--accent) 60%, var(--card));
  color: var(--ink);
  font-size: 0.78rem;
  position: sticky;
  top: 0;
  z-index: 2;
}

.tracker-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--accent) 6%, var(--card));
}

.month-cell {
  min-width: 86px;
}

.month-cell input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.note-input {
  margin-top: 0.35rem;
  padding: 0.42rem;
  font-size: 0.78rem;
}

.save-button {
  margin-top: 1rem;
}

.visual-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}

.benefits-grid {
  align-items: start;
}

.credit-card-tile {
  display: grid;
  gap: 1rem;
  padding: 1rem;
  color: inherit;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.credit-card-tile:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 60px rgba(74, 42, 25, 0.16);
}

.mock-card {
  position: relative;
  overflow: hidden;
  min-height: 184px;
  border-radius: 26px;
  padding: 1.25rem;
  color: #fff;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 0.8rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.35), 0 20px 40px rgba(40, 24, 18, 0.22);
}

.mock-card.large {
  min-height: 250px;
}

.mock-card::before, .mock-card::after {
  content: "";
  position: absolute;
  border-radius: 999px;
  background: rgba(255,255,255,0.16);
}

.mock-card::before {
  width: 180px;
  height: 180px;
  top: -70px;
  right: -40px;
}

.mock-card::after {
  width: 140px;
  height: 140px;
  bottom: -70px;
  left: 25%;
}

.mock-card strong, .mock-card small, .mock-card .network, .chip, .issuer, .contactless, .card-number {
  position: relative;
  z-index: 1;
}

.mock-card strong {
  align-self: end;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  max-width: 80%;
  text-transform: uppercase;
}

.mock-card small, .network, .card-number {
  color: rgba(255,255,255,0.82);
  font-weight: 800;
}

.card-number {
  font-size: 0.86rem;
  letter-spacing: 0.12em;
}

.issuer {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.16em;
}

.network {
  justify-self: end;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.68rem;
}

.chip {
  align-self: center;
  width: 42px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, #f8d88a, #b98c32);
  box-shadow: inset 0 0 0 1px rgba(64, 34, 8, 0.18);
}

.contactless {
  position: absolute;
  top: 4.1rem;
  left: 4.65rem;
  color: rgba(255,255,255,0.75);
  font-weight: 900;
  letter-spacing: -0.25em;
  transform: rotate(90deg);
}

.realistic-card {
  isolation: isolate;
}

.realistic-card::before {
  inset: 0;
  width: auto;
  height: auto;
  border-radius: inherit;
  background: linear-gradient(120deg, rgba(255,255,255,0.32), transparent 30%, rgba(255,255,255,0.08) 58%, transparent 72%);
  mix-blend-mode: overlay;
}

.realistic-card::after {
  width: 180px;
  height: 180px;
  right: -54px;
  bottom: -82px;
  background: rgba(255,255,255,0.12);
}

.theme-0 { background: linear-gradient(135deg, #101828, #475467); }
.theme-1 { background: linear-gradient(135deg, #44312a, #b36a55); }
.theme-2 { background: linear-gradient(135deg, #172554, #2563eb); }
.theme-3 { background: linear-gradient(135deg, #064e3b, #10b981); }
.theme-4 { background: linear-gradient(135deg, #581c87, #c084fc); }
.theme-5 { background: linear-gradient(135deg, #7c2d12, #f97316); }

.amex-platinum {
  color: #26313b;
  background:
    radial-gradient(circle at 72% 42%, rgba(255,255,255,0.82), transparent 24%),
    linear-gradient(135deg, #f8fafc 0%, #cfd6dc 32%, #f6f8f8 52%, #aeb8c0 100%);
}

.amex-platinum .issuer, .amex-platinum small, .amex-platinum .network, .amex-platinum .contactless {
  color: rgba(38, 49, 59, 0.78);
}

.amex-platinum .chip, .amex-business-gold .chip, .amex-gold .chip {
  background: linear-gradient(135deg, #fff6c7, #b5892f 48%, #f2d37a);
}

.amex-business-gold {
  color: #2e2111;
  background:
    radial-gradient(circle at 78% 35%, rgba(255,255,255,0.42), transparent 25%),
    linear-gradient(135deg, #b9822b 0%, #f4cf7a 35%, #a66a1e 70%, #f1bd52 100%);
}

.amex-business-gold .issuer, .amex-business-gold small, .amex-business-gold .network, .amex-business-gold .contactless,
.amex-gold .issuer, .amex-gold small, .amex-gold .network, .amex-gold .contactless {
  color: rgba(46, 33, 17, 0.82);
}

.amex-gold {
  color: #2b1d0f;
  background:
    radial-gradient(circle at 74% 38%, rgba(255,255,255,0.5), transparent 24%),
    linear-gradient(135deg, #d09b34 0%, #ffdf8b 38%, #bd7a23 72%, #f4c15a 100%);
}

.venture-x {
  background:
    linear-gradient(130deg, rgba(255,255,255,0.12), transparent 30%),
    linear-gradient(135deg, #09090b 0%, #1f2937 45%, #020617 100%);
}

.sapphire-preferred {
  background:
    radial-gradient(circle at 80% 30%, rgba(126, 182, 255, 0.5), transparent 24%),
    linear-gradient(135deg, #0f2a6b 0%, #1d4ed8 45%, #082f75 100%);
}

.sapphire-reserve {
  background:
    radial-gradient(circle at 80% 30%, rgba(88, 166, 255, 0.34), transparent 24%),
    linear-gradient(135deg, #030712 0%, #102452 42%, #020617 100%);
}

.citi-elite {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.1), transparent 28%),
    linear-gradient(135deg, #111827 0%, #374151 46%, #111827 100%);
}

.citi-premier {
  background:
    radial-gradient(circle at 78% 36%, rgba(255,255,255,0.24), transparent 24%),
    linear-gradient(135deg, #312e81 0%, #6366f1 48%, #1e1b4b 100%);
}

.generic-premium {
  background: linear-gradient(135deg, #44312a, #b36a55);
}

.has-card-image {
  background-size: cover;
  background-position: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
}

.has-card-image::before {
  inset: 0;
  width: auto;
  height: auto;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(0,0,0,0.48), rgba(0,0,0,0.18) 42%, rgba(0,0,0,0.68));
  mix-blend-mode: normal;
}

.has-card-image::after {
  display: none;
}

.has-card-image .issuer,
.has-card-image small,
.has-card-image .network,
.has-card-image .contactless,
.has-card-image .card-number {
  display: none;
}

.has-card-image .chip,
.has-card-image strong {
  display: none;
}

.tile-body {
  display: grid;
  gap: 0.75rem;
}

.tile-body p {
  margin: 0;
  color: var(--muted);
}

.tile-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.tile-row span, .amount-grid span {
  color: var(--muted);
  font-weight: 800;
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, var(--card));
}

.progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #df8d63);
}

.fee-meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #d7dee8;
}

.fee-meter span {
  display: block;
  height: 100%;
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #0ea5e9, #22c55e);
}

.progress.wide {
  height: 14px;
  max-width: 560px;
}

.card-hero-detail {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: clamp(1rem, 4vw, 2.5rem);
  align-items: center;
  margin-bottom: 2rem;
}

.card-summary-copy h1 {
  margin: 0 0 1rem;
  font-size: clamp(2rem, 6vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: -0.08em;
}

.summary-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.summary-pills span, .badge, .period {
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, var(--card));
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  padding: 0.45rem 0.7rem;
}

.benefit-section {
  margin-top: 2rem;
}

.benefit-section h2 {
  font-size: 1.8rem;
  letter-spacing: -0.05em;
}

.benefit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

.benefit-card {
  display: grid;
  gap: 1rem;
  padding: 1.15rem;
}

.benefit-card h3, .benefit-card p {
  margin: 0;
}

.benefit-card p {
  color: var(--muted);
  line-height: 1.5;
}

.benefit-topline {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: center;
}

.status-complete .badge {
  background: #d1fae5;
  color: #065f46;
}

.status-partial .badge {
  background: #fef3c7;
  color: #92400e;
}

.status-not-started .badge {
  background: #fee2e2;
  color: #991b1b;
}

.amount-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.amount-grid div {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  padding: 0.8rem;
}

.amount-grid strong {
  display: block;
  margin-top: 0.2rem;
}

.usage-form {
  display: grid;
  gap: 0.75rem;
}

@media (max-width: 820px) {
  .topbar, .hero, .select-card, .stats-grid, .card-hero-detail, .settings-grid, .expanded-card-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    display: grid;
  }

  .hero {
    min-height: auto;
  }

  .hero-card {
    transform: none;
  }

  .select-card {
    align-items: stretch;
  }

  .section-title, .benefit-topline {
    align-items: flex-start;
    flex-direction: column;
  }

  .amount-grid {
    grid-template-columns: 1fr;
  }

  .expanded-card-form label:last-child,
  .expanded-card-form label:nth-last-child(2) {
    grid-column: auto;
  }
}
