:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #172033;
  --muted: #667085;
  --line: #d9e0ec;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --income: #047857;
  --expense: #dc2626;
  --warning: #f59e0b;
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at top left, #dbeafe 0, transparent 30rem), var(--bg);
}

button,
input,
select {
  font: inherit;
}

.hero {
  min-height: 540px;
  padding: 24px clamp(18px, 4vw, 72px) 72px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.88), rgba(37, 99, 235, 0.72)),
    url("https://images.unsplash.com/photo-1554224155-6726b3ff858f?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.topbar,
.hero__content,
.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-size: 1.2rem;
  font-weight: 800;
}

.brand__icon {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: var(--primary);
  background: #fff;
  border-radius: 12px;
}

.topbar__link {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.hero__content {
  padding-top: 96px;
}

.hero h1 {
  max-width: 820px;
  margin: 0;
  font-size: clamp(2.5rem, 7vw, 5.8rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.hero p:not(.eyebrow) {
  max-width: 720px;
  font-size: 1.2rem;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.86);
}

.eyebrow {
  margin: 0 0 10px;
  color: #60a5fa;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero__actions,
.toolbar__actions,
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button--primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.28);
}

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

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

.hero .button--ghost {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
}

.button--danger {
  color: #991b1b;
  background: #fee2e2;
}

.app-shell {
  display: grid;
  gap: 22px;
  padding: 28px clamp(16px, 4vw, 28px) 64px;
}

.panel,
.summary-card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(217, 224, 236, 0.9);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.month-manager {
  display: grid;
  gap: 18px;
  margin-top: -54px;
}

.month-tabs {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.month-tab {
  flex: 0 0 auto;
  padding: 10px 16px;
  color: var(--muted);
  background: #eef2ff;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
}

.month-tab[aria-selected="true"] {
  color: #fff;
  background: var(--primary);
}

.inline-form input,
.toolbar input,
.toolbar select,
.entry-form input,
.entry-form select,
.goal-input input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
}

.inline-form input:focus,
.toolbar input:focus,
.toolbar select:focus,
.entry-form input:focus,
.entry-form select:focus,
.goal-input input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.summary-grid,
.insights-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.summary-card {
  padding: 20px;
}

.summary-card span {
  color: var(--muted);
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.income strong {
  color: var(--income);
}

.expense strong {
  color: var(--expense);
}

.balance strong,
.saving strong {
  color: var(--primary);
}

.toolbar {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, minmax(150px, 0.7fr)) auto;
  gap: 14px;
  align-items: end;
}

.toolbar label,
.entry-form label,
.goal-input {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.section-heading {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-heading h2,
.panel h2 {
  margin: 0;
  font-size: 1.45rem;
}

.entry-form {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.entry-form__wide {
  grid-column: span 2;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  background: #f8fafc;
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #f8fbff;
}

.badge {
  display: inline-flex;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
}

.badge--income,
.badge--paid {
  color: #065f46;
  background: #d1fae5;
}

.badge--expense {
  color: #991b1b;
  background: #fee2e2;
}

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

.badge--recurring {
  color: #1e40af;
  background: #dbeafe;
}

.amount--income {
  color: var(--income);
  font-weight: 900;
}

.amount--expense {
  color: var(--expense);
  font-weight: 900;
}

.action-group {
  display: flex;
  gap: 8px;
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.empty-state,
.muted {
  color: var(--muted);
}

.empty-state {
  margin-bottom: 0;
  padding: 18px;
  text-align: center;
}

.insights-grid {
  grid-template-columns: 1.2fr 0.8fr;
}

.breakdown {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.breakdown__row {
  display: grid;
  gap: 8px;
}

.breakdown__meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 800;
}

.breakdown__bar,
.progress {
  height: 12px;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 999px;
}

.breakdown__bar span,
.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--primary), #22c55e);
  border-radius: inherit;
  transition: width 0.25s ease;
}

.goal-input {
  margin: 18px 0;
}

@media (max-width: 980px) {
  .summary-grid,
  .toolbar,
  .entry-form,
  .insights-grid {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar__actions,
  .entry-form__wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 680px) {
  .hero {
    min-height: auto;
  }

  .hero__content {
    padding-top: 64px;
  }

  .summary-grid,
  .toolbar,
  .entry-form,
  .insights-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
    min-width: 0;
  }

  thead {
    display: none;
  }

  tbody tr {
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }

  td {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    border: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 900;
  }
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  color: #065f46;
  background: #d1fae5;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
}

.sync-status[data-mode="loading"] {
  color: #1e40af;
  background: #dbeafe;
}

.sync-status[data-mode="error"] {
  color: #991b1b;
  background: #fee2e2;
}

.section-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.budget-form {
  display: grid;
  grid-template-columns: 1fr 0.8fr auto;
  gap: 10px;
  margin: 18px 0;
}

.budget-form input {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.budget-list {
  display: grid;
  gap: 14px;
}

.budget-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.over-limit {
  background: linear-gradient(90deg, #ef4444, #f59e0b) !important;
}

.link-button {
  width: fit-content;
  padding: 0;
  color: var(--primary);
  background: transparent;
  border: 0;
  cursor: pointer;
  font-weight: 900;
}

@media (min-width: 981px) {
  .insights-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .budget-form {
    grid-template-columns: 1fr;
  }

  .section-actions {
    justify-content: stretch;
  }

  .section-actions .button {
    width: 100%;
  }
}
