:root {
  --bg: #f3f6f8;
  --bg-elevated: rgba(255, 255, 255, 0.82);
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --text: #14323b;
  --text-muted: #60747d;
  --line: rgba(19, 57, 68, 0.1);
  --brand: #0f9faa;
  --brand-deep: #0a7f88;
  --income: #15a06e;
  --income-soft: #e6f8f0;
  --expense: #f17b4f;
  --expense-soft: #fff0e9;
  --accent: #ffd66b;
  --shadow: 0 24px 50px rgba(24, 63, 72, 0.12);
  --shadow-soft: 0 14px 28px rgba(24, 63, 72, 0.08);
  --radius-xl: 30px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --max-width: 1180px;
  --transition: 180ms ease;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", "Noto Sans SC", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 159, 170, 0.18), transparent 22rem),
    radial-gradient(circle at top right, rgba(241, 123, 79, 0.15), transparent 26rem),
    linear-gradient(180deg, #f7fafb 0%, #eef3f5 100%);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.app-shell {
  padding: 24px 20px 96px;
}

.topbar,
.main-layout,
.bottom-nav {
  width: min(100%, var(--max-width));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 18px;
  font-size: 1.4rem;
  font-weight: 800;
  color: white;
  background: linear-gradient(145deg, var(--brand) 0%, var(--brand-deep) 100%);
  box-shadow: 0 16px 28px rgba(15, 159, 170, 0.25);
}

.brand h1,
.section-head h2,
.hero-copy h2,
.panel h3 {
  margin: 0;
  letter-spacing: -0.03em;
}

.eyebrow,
.section-kicker {
  margin: 0 0 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-link,
.bottom-link {
  border-radius: 999px;
  padding: 12px 18px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.7);
  transition:
    transform var(--transition),
    background var(--transition),
    color var(--transition),
    box-shadow var(--transition);
}

.nav-link:hover,
.bottom-link:hover,
.nav-link:focus-visible,
.bottom-link:focus-visible,
.button:hover,
.button:focus-visible,
.text-button:hover,
.text-button:focus-visible {
  transform: translateY(-1px);
}

.nav-link.is-active,
.bottom-link.is-active {
  color: var(--text);
  background: white;
  box-shadow: var(--shadow-soft);
}

.nav-link--accent,
.bottom-link--primary {
  color: white;
  background: linear-gradient(135deg, var(--brand) 0%, #40b7bf 100%);
}

.main-layout {
  display: grid;
  gap: 24px;
}

.view {
  display: none;
  gap: 24px;
  animation: rise-in 280ms ease;
}

.view--active {
  display: grid;
}

.surface {
  border: 1px solid rgba(255, 255, 255, 0.65);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-card {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  padding: 24px;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.hero-copy {
  display: grid;
  align-content: center;
  gap: 18px;
}

.hero-copy h2 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1.02;
}

.hero-text {
  margin: 0;
  max-width: 44ch;
  color: var(--text-muted);
  line-height: 1.75;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-highlight {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 12px 16px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.75);
  box-shadow: inset 0 0 0 1px rgba(19, 57, 68, 0.05);
}

.hero-media {
  position: relative;
  min-height: 320px;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 26px;
}

.summary-grid,
.content-grid {
  display: grid;
  gap: 20px;
}

.summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.summary-card {
  padding: 22px;
  border-radius: var(--radius-lg);
}

.summary-card__label {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.summary-card__value {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.05em;
}

.summary-card__note {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.summary-card--income .summary-card__value {
  color: var(--income);
}

.summary-card--expense .summary-card__value {
  color: var(--expense);
}

.summary-card--balance .summary-card__value[data-balance="negative"] {
  color: var(--expense);
}

.content-grid {
  grid-template-columns: 1.08fr 0.92fr;
}

.panel,
.filters-card,
.form-panel {
  padding: 22px;
  border-radius: var(--radius-lg);
}

.panel-heading,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-head {
  margin-bottom: -6px;
}

.button,
.text-button {
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    opacity var(--transition),
    background var(--transition);
}

.button {
  padding: 14px 20px;
  border-radius: 16px;
  font-weight: 700;
}

.button--primary {
  color: white;
  background: linear-gradient(135deg, var(--brand) 0%, #30b3bd 100%);
  box-shadow: 0 16px 24px rgba(15, 159, 170, 0.22);
}

.button--ghost {
  color: var(--text);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: inset 0 0 0 1px rgba(19, 57, 68, 0.08);
}

.button--danger {
  color: white;
  background: linear-gradient(135deg, #e26555 0%, #f17b4f 100%);
}

.button[disabled] {
  cursor: wait;
  opacity: 0.75;
  transform: none;
}

.text-button {
  padding: 0;
  color: var(--brand-deep);
  font-weight: 700;
  background: transparent;
}

.record-list,
.breakdown,
.stats-block {
  display: grid;
  gap: 14px;
}

.record-item,
.record-card {
  display: grid;
  gap: 10px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(19, 57, 68, 0.06);
}

.record-item__main,
.record-card__top,
.record-card__bottom,
.category-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.record-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
}

.pill--income {
  color: var(--income);
  background: var(--income-soft);
}

.pill--expense {
  color: var(--expense);
  background: var(--expense-soft);
}

.amount {
  font-weight: 800;
  letter-spacing: -0.03em;
}

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

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

.donut-layout {
  display: grid;
  gap: 18px;
  align-items: center;
  justify-items: center;
}

.donut {
  position: relative;
  width: min(220px, 54vw);
  aspect-ratio: 1;
  border-radius: 50%;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(19, 57, 68, 0.05);
}

.donut-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  z-index: 1;
}

.donut-center strong {
  font-size: 1.3rem;
  letter-spacing: -0.04em;
}

.legend-list,
.stats-list {
  display: grid;
  gap: 10px;
  width: 100%;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-name {
  font-weight: 600;
}

.legend-value {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.legend-rate {
  font-weight: 700;
}

.filters-card {
  padding-bottom: 18px;
}

.filter-grid,
.form-grid {
  display: grid;
  gap: 16px;
}

.filter-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.field,
.field-group {
  display: grid;
  gap: 8px;
}

.field--full {
  grid-column: 1 / -1;
}

.field span,
.field-label {
  font-size: 0.94rem;
  color: var(--text-muted);
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 52px;
  padding: 0 16px;
  border: 1px solid rgba(19, 57, 68, 0.1);
  border-radius: 16px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  outline: none;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
}

.field input:focus,
.field select:focus {
  border-color: rgba(15, 159, 170, 0.55);
  box-shadow: 0 0 0 4px rgba(15, 159, 170, 0.12);
}

.error-text {
  min-height: 1em;
  color: #d14d3d;
  font-size: 0.84rem;
}

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

.type-option {
  position: relative;
}

.type-option input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.type-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  min-height: 52px;
  padding: 0 16px;
  border-radius: 16px;
  font-weight: 700;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px rgba(19, 57, 68, 0.08);
  transition: all var(--transition);
}

.type-option input:checked + span {
  color: white;
  background: linear-gradient(135deg, var(--brand) 0%, #30b3bd 100%);
  box-shadow: 0 14px 24px rgba(15, 159, 170, 0.24);
}

.form-actions,
.record-actions,
.modal-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.form-actions {
  margin-top: 18px;
}

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

.records-table {
  width: 100%;
  border-collapse: collapse;
}

.records-table th,
.records-table td {
  padding: 16px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(19, 57, 68, 0.08);
  vertical-align: top;
}

.records-table th {
  color: var(--text-muted);
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.records-table td:last-child {
  width: 156px;
}

.record-actions button {
  padding: 0;
  color: var(--brand-deep);
  background: transparent;
  font-weight: 700;
}

.record-actions button:last-child {
  color: #d14d3d;
}

.records-cards {
  display: none;
  gap: 14px;
}

.empty-state {
  display: grid;
  justify-items: start;
  gap: 10px;
  padding: 28px;
  margin-top: 12px;
  border-radius: 20px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.7);
  box-shadow: inset 0 0 0 1px rgba(19, 57, 68, 0.05);
}

.empty-state h3,
.empty-state p {
  margin: 0;
}

.stats-block {
  align-items: center;
}

.stats-row {
  display: grid;
  gap: 14px;
  width: 100%;
}

.stats-row .category-row {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 0 0 1px rgba(19, 57, 68, 0.06);
}

.month-picker {
  min-width: 180px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 42, 51, 0.36);
  backdrop-filter: blur(10px);
  z-index: 30;
}

.modal {
  width: min(100%, 420px);
  padding: 24px;
  border-radius: 24px;
}

.modal h3,
.modal p {
  margin: 0;
}

.modal p {
  margin-top: 10px;
  color: var(--text-muted);
  line-height: 1.7;
}

.modal-actions {
  margin-top: 22px;
  justify-content: flex-end;
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 104px;
  display: grid;
  gap: 10px;
  z-index: 40;
}

.toast {
  min-width: 220px;
  padding: 14px 16px;
  border-radius: 16px;
  color: white;
  box-shadow: var(--shadow);
  animation:
    rise-in 220ms ease,
    fade-out 220ms ease 2.8s forwards;
}

.toast--success {
  background: linear-gradient(135deg, var(--income) 0%, #32b884 100%);
}

.toast--error {
  background: linear-gradient(135deg, #d14d3d 0%, #f17b4f 100%);
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  z-index: 25;
}

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

@keyframes fade-out {
  to {
    opacity: 0;
    transform: translateY(8px);
  }
}

@media (max-width: 1024px) {
  .hero-card,
  .content-grid,
  .summary-grid,
  .filter-grid {
    grid-template-columns: 1fr;
  }

  .hero-card {
    padding: 18px;
  }
}

@media (max-width: 768px) {
  .app-shell {
    padding: 18px 14px 104px;
  }

  .desktop-nav {
    display: none;
  }

  .bottom-nav {
    display: flex;
    width: calc(100% - 28px);
    max-width: calc(var(--max-width) - 28px);
  }

  .topbar {
    margin-bottom: 18px;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
  }

  .hero-copy h2 {
    font-size: 2.2rem;
  }

  .hero-media {
    min-height: 220px;
  }

  .panel,
  .filters-card,
  .form-panel {
    padding: 18px;
  }

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

  .records-table-wrap {
    display: none;
  }

  .records-cards {
    display: grid;
  }

  .toast-region {
    left: 14px;
    right: 14px;
    bottom: 102px;
  }

  .toast {
    min-width: 0;
  }

  .type-option span {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation: none !important;
    transition: none !important;
  }
}
