@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,600;9..144,700&family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --font-sans: "Manrope", "Segoe UI", sans-serif;
  --font-display: "Fraunces", Georgia, serif;
  --bg: #f4efe6;
  --bg-soft: rgba(255, 255, 255, 0.72);
  --surface: rgba(255, 255, 255, 0.82);
  --surface-strong: #fffaf4;
  --surface-dark: #21322e;
  --border: rgba(71, 87, 82, 0.12);
  --border-strong: rgba(71, 87, 82, 0.22);
  --text: #21302d;
  --text-muted: #61716d;
  --sage: #7f9f8b;
  --sage-strong: #486658;
  --sand: #d6b796;
  --rose: #bf735d;
  --rose-strong: #994d34;
  --gold: #e5c27c;
  --ink: #1f2a28;
  --shadow: 0 24px 64px rgba(27, 44, 39, 0.08);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

html[data-theme="dark"] {
  --bg: #13201d;
  --bg-soft: rgba(20, 31, 28, 0.86);
  --surface: rgba(22, 34, 31, 0.92);
  --surface-strong: #1c2c29;
  --surface-dark: #dce8e2;
  --border: rgba(198, 213, 205, 0.08);
  --border-strong: rgba(198, 213, 205, 0.15);
  --text: #e7efe9;
  --text-muted: #a6b8b0;
  --sage: #8db59e;
  --sage-strong: #b8d2c3;
  --sand: #d9bb93;
  --rose: #cf9079;
  --rose-strong: #edb3a1;
  --gold: #f0ce8c;
  --ink: #0f1715;
  --shadow: 0 26px 64px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(229, 194, 124, 0.25), transparent 28%),
    radial-gradient(circle at right 12%, rgba(127, 159, 139, 0.18), transparent 24%),
    linear-gradient(180deg, #f8f3eb 0%, var(--bg) 54%, #ede5d8 100%);
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(229, 194, 124, 0.08), transparent 22%),
    radial-gradient(circle at right 12%, rgba(127, 159, 139, 0.16), transparent 24%),
    linear-gradient(180deg, #16231f 0%, var(--bg) 54%, #0e1715 100%);
}

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

button {
  cursor: pointer;
}

a {
  color: inherit;
}

#app {
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  height: 100vh;
}

.app-sidebar__panel,
.content-panel,
.summary-card,
.budget-card,
.auth-card,
.quick-form,
.chart-panel,
.settings-panel,
.empty-state,
.notification-drawer__panel,
.transaction-item,
.toolbar,
.hero-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.brand-block {
  padding: 1.6rem;
}

.brand-block h1,
.app-header__title,
.auth-hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2rem, 3vw, 3rem);
  line-height: 1;
}

.brand-block p,
.auth-hero p,
.section-subtitle,
.empty-state p,
.helper-text,
.field-hint {
  margin: 0.55rem 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.section-eyebrow,
.summary-card__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.65rem;
  color: var(--sage-strong);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 800;
}

.sidebar-nav,
.mobile-nav {
  display: grid;
  gap: 0.75rem;
}

.sidebar-nav button,
.mobile-nav button,
.button {
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.1rem;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.sidebar-nav button,
.mobile-nav button {
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  font-weight: 700;
}

.sidebar-nav button:hover,
.mobile-nav button:hover,
.button:hover {
  transform: translateY(-1px);
}

.sidebar-nav button.is-active,
.mobile-nav button.is-active,
.button--primary {
  background: var(--sage-strong);
  color: #f6f4ee;
}

.button--secondary {
  background: rgba(127, 159, 139, 0.14);
  color: var(--sage-strong);
}

.button--ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.button--ghost-danger {
  background: transparent;
  color: var(--rose-strong);
  border: 1px solid rgba(191, 115, 93, 0.2);
}

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

.button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.content-stage {
  padding: 1.5rem 1.5rem 6rem;
}

.content-panel {
  padding: 1.5rem;
}

.app-header,
.toolbar,
.section-header,
.form-grid,
.summary-grid,
.page-grid,
.dashboard-grid,
.settings-grid,
.chart-grid,
.auth-shell {
  display: grid;
  gap: 1rem;
}

.app-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  margin-bottom: 1.5rem;
}

.app-header__title {
  font-size: clamp(1.6rem, 2vw, 2.4rem);
}

.toolbar {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 1rem;
  margin-bottom: 1.2rem;
}

.toolbar .field {
  margin: 0;
}

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

.summary-card {
  padding: 1.35rem;
  overflow: hidden;
  position: relative;
}

.summary-card::after {
  content: "";
  position: absolute;
  inset: auto -2rem -2rem auto;
  width: 6rem;
  height: 6rem;
  border-radius: 999px;
  opacity: 0.14;
  background: currentColor;
}

.summary-card--sage {
  color: var(--sage-strong);
}

.summary-card--sand {
  color: #876545;
}

.summary-card--rose {
  color: var(--rose-strong);
}

.summary-card__title,
.summary-card__note,
.summary-card__value {
  position: relative;
  z-index: 1;
}

.summary-card__title {
  margin: 0;
  font-size: 0.95rem;
}

.summary-card__value {
  margin: 0.75rem 0 0;
  font-size: clamp(1.6rem, 2.4vw, 2.4rem);
  line-height: 1;
  color: var(--text);
}

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

.dashboard-grid {
  grid-template-columns: 1.1fr 0.9fr;
  align-items: start;
}

.chart-grid,
.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-form,
.chart-panel,
.settings-panel,
.hero-card,
.auth-card {
  padding: 1.4rem;
}

.field {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.month-pill {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.92rem 1rem;
  background: rgba(255, 255, 255, 0.55);
  color: var(--text);
}

html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .month-pill {
  background: rgba(12, 19, 17, 0.56);
}

.field textarea {
  min-height: 100px;
  resize: vertical;
}

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

.form-actions,
.header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

.text-income {
  color: #3d8a63;
}

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

.chart-list,
.transaction-list {
  display: grid;
  gap: 0.9rem;
}

.chart-list__row {
  display: grid;
  grid-template-columns: minmax(120px, 170px) minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}

.chart-list__label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.chart-list__dot,
.transaction-item__badge {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.chart-list__bar {
  height: 12px;
  border-radius: 999px;
  background: rgba(127, 159, 139, 0.12);
  overflow: hidden;
}

.chart-list__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.trend-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.9rem;
  align-items: end;
  height: 220px;
}

.trend-chart__group {
  display: grid;
  gap: 0.6rem;
  justify-items: center;
}

.trend-chart__bars {
  display: flex;
  align-items: end;
  gap: 0.4rem;
  height: 180px;
}

.trend-chart__bar {
  width: 18px;
  border-radius: 999px 999px 6px 6px;
}

.trend-chart__bar--income {
  background: linear-gradient(180deg, #9bd2b3 0%, #4c8c66 100%);
}

.trend-chart__bar--expense {
  background: linear-gradient(180deg, #f1b09a 0%, #bf735d 100%);
}

.trend-chart__label {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.transaction-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  padding: 1rem 1.1rem;
}

.transaction-item__left,
.transaction-item__right {
  display: flex;
  gap: 0.85rem;
}

.transaction-item__right {
  align-items: flex-end;
  flex-direction: column;
}

.transaction-item__left p,
.transaction-item__right span {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.transaction-item__actions {
  display: flex;
  gap: 0.6rem;
}

.budget-card {
  padding: 1rem 1.1rem;
}

.budget-card__header,
.budget-card__footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.budget-card__title {
  margin: 0;
  font-weight: 800;
}

.budget-card__meta {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.budget-card__progress {
  height: 12px;
  margin: 1rem 0 0.8rem;
  border-radius: 999px;
  background: rgba(127, 159, 139, 0.12);
  overflow: hidden;
}

.budget-card__fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.budget-card__fill--safe {
  background: linear-gradient(90deg, #8ec29e 0%, #4c8c66 100%);
}

.budget-card__fill--warning {
  background: linear-gradient(90deg, #efd094 0%, #d19a32 100%);
}

.budget-card__fill--danger {
  background: linear-gradient(90deg, #efae99 0%, #c45d40 100%);
}

.budget-card__footer {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.settings-list,
.chip-list,
.foreign-balance-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.chip,
.month-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  background: rgba(127, 159, 139, 0.1);
  color: var(--sage-strong);
  font-weight: 700;
}

.notification-drawer {
  pointer-events: none;
}

.notification-drawer__overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 21, 19, 0.42);
  opacity: 0;
  transition: opacity 180ms ease;
}

.notification-drawer__panel {
  position: fixed;
  right: 1rem;
  top: 1rem;
  bottom: 1rem;
  width: min(460px, calc(100vw - 2rem));
  transform: translateX(110%);
  transition: transform 220ms ease;
  display: grid;
  grid-template-rows: auto 1fr;
  pointer-events: auto;
}

.notification-drawer--open {
  pointer-events: auto;
}

.notification-drawer--open .notification-drawer__overlay {
  opacity: 1;
}

.notification-drawer--open .notification-drawer__panel {
  transform: translateX(0);
}

.notification-drawer__header,
.notification-item {
  padding: 1.2rem 1.3rem;
}

.notification-drawer__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

.notification-drawer__body {
  overflow: auto;
  padding: 1rem;
  display: grid;
  gap: 0.9rem;
}

.notification-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.45);
}

html[data-theme="dark"] .notification-item {
  background: rgba(12, 19, 17, 0.4);
}

.notification-item--read {
  opacity: 0.68;
}

.notification-item p,
.notification-item span {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
}

.toast-stack {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  display: grid;
  gap: 0.75rem;
  width: min(360px, calc(100vw - 2rem));
}

.toast {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

html[data-theme="dark"] .toast {
  background: rgba(18, 27, 25, 0.96);
}

.toast strong,
.toast p {
  margin: 0;
}

.toast p {
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.toast__close {
  border: 0;
  background: transparent;
  color: var(--text-muted);
}

.auth-shell {
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  padding: 1.5rem;
  align-items: stretch;
}

.auth-hero,
.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-hero {
  padding: 2rem 3rem;
}

.auth-or {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1rem 0;
  color: var(--text-muted);
}

.auth-or::before,
.auth-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-strong);
}

.hero-card {
  margin-top: 2rem;
  max-width: 520px;
}

.hero-card ul {
  margin: 1rem 0 0;
  padding-left: 1rem;
  color: var(--text-muted);
  line-height: 1.8;
}

.empty-state {
  padding: 2rem;
  text-align: center;
}

.loading-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mobile-nav {
  display: none;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-sidebar {
    display: none;
  }

  .dashboard-grid,
  .chart-grid,
  .settings-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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

  .mobile-nav {
    position: fixed;
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    padding: 0.6rem;
    background: rgba(255, 255, 255, 0.84);
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
  }

  .mobile-nav button {
    display: grid;
    place-items: center;
    min-height: 3.25rem;
    padding: 0.75rem;
    text-align: center;
  }

  .mobile-nav__icon {
    width: 1.35rem;
    height: 1.35rem;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  html[data-theme="dark"] .mobile-nav {
    background: rgba(18, 27, 25, 0.88);
  }

  .content-stage {
    padding-bottom: 7rem;
  }
}

@media (max-width: 780px) {
  .auth-shell {
    grid-template-columns: 1fr;
    padding: 1rem;
  }

  .auth-hero {
    padding: 1rem;
  }

  .toolbar,
  .inline-grid,
  .chart-list__row,
  .transaction-item,
  .budget-card__header,
  .budget-card__footer,
  .notification-drawer__header {
    grid-template-columns: 1fr;
    display: grid;
  }

  .transaction-item__right {
    align-items: flex-start;
  }

  .trend-chart {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    height: auto;
  }

  .trend-chart__bars {
    height: 120px;
  }
}
