@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f3efe6;
  --bg-strong: #ebe3d2;
  --surface: rgba(255, 250, 241, 0.86);
  --surface-strong: rgba(255, 252, 246, 0.96);
  --ink: #17202a;
  --muted: #66707b;
  --line: rgba(23, 32, 42, 0.12);
  --accent: #103b2d;
  --accent-2: #d38724;
  --accent-soft: rgba(16, 59, 45, 0.1);
  --danger: #ab2f2f;
  --success: #245640;
  --shadow: 0 22px 70px rgba(66, 47, 15, 0.12);
  --radius: 24px;
  --field-bg: rgba(255, 255, 255, 0.82);
  --hero-bg:
    radial-gradient(circle at 10% 10%, rgba(211, 135, 36, 0.22), transparent 24%),
    linear-gradient(145deg, rgba(16, 59, 45, 0.96), rgba(20, 28, 39, 0.98));
  --auth-bg:
    linear-gradient(145deg, rgba(16, 59, 45, 0.96), rgba(23, 32, 42, 0.98)),
    var(--surface);
  --overlay-grid: rgba(255,255,255,0.05);
}

:root[data-theme="dark"] {
  --bg: #0d131a;
  --bg-strong: #16202b;
  --surface: rgba(18, 27, 38, 0.82);
  --surface-strong: rgba(21, 31, 43, 0.96);
  --ink: #edf2f7;
  --muted: #98a7b8;
  --line: rgba(214, 226, 239, 0.12);
  --accent: #5bc59c;
  --accent-2: #f0b557;
  --accent-soft: rgba(91, 197, 156, 0.14);
  --danger: #ef6767;
  --success: #78d4ae;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
  --field-bg: rgba(14, 22, 31, 0.92);
  --hero-bg:
    radial-gradient(circle at 12% 12%, rgba(240, 181, 87, 0.14), transparent 24%),
    linear-gradient(145deg, rgba(12, 22, 31, 0.98), rgba(17, 29, 41, 0.98));
  --auth-bg:
    linear-gradient(145deg, rgba(12, 22, 31, 0.98), rgba(17, 29, 41, 0.98)),
    var(--surface);
  --overlay-grid: rgba(255,255,255,0.03);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Poppins", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--accent) 14%, transparent), transparent 26%),
    radial-gradient(circle at 85% 12%, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 22%),
    linear-gradient(160deg, var(--bg) 0%, var(--bg-strong) 52%, var(--bg) 100%);
  min-height: 100vh;
  transition: background .24s ease, color .24s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: linear-gradient(var(--overlay-grid) 1px, transparent 1px), linear-gradient(90deg, var(--overlay-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  opacity: 0.28;
}

button, input, select, textarea, a { font: inherit; }
button { cursor: pointer; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 14px;
  background: var(--field-bg);
  color: var(--ink);
}
textarea { resize: vertical; }
button, .button-link {
  border: none;
  border-radius: 18px;
  padding: 12px 16px;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform .16s ease, opacity .16s ease, background .16s ease;
}
button:hover, .button-link:hover { transform: translateY(-1px); }
button.secondary, .button-link.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
button.danger, .ghost-danger {
  background: var(--danger);
  color: #fff;
}
.ghost-danger {
  border: none;
  border-radius: 14px;
  padding: 8px 12px;
}
button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 20px 110px;
  position: relative;
  z-index: 1;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  align-items: center;
  gap: 28px;
  padding: 28px;
}

.auth-art,
.card,
.hero,
.panel,
.sidebar,
.install-card,
.transaction-card,
.goal-card,
.recurring-item,
.stat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.auth-art {
  min-height: 420px;
  padding: 36px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--auth-bg);
  color: #fdf8ef;
}

.auth-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: auto;
}

.auth-card { padding: 32px; max-width: 520px; width: 100%; }

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: .72rem;
  color: var(--accent-2);
}
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 4.5vw, 4.4rem); line-height: .98; margin-bottom: 16px; }
h2 { font-size: clamp(1.2rem, 2vw, 1.85rem); margin-bottom: 12px; }
.muted { color: var(--muted); }
.stack { display: grid; gap: 12px; }
.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.flash-stack {
  position: sticky;
  top: 14px;
  z-index: 30;
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}
.flash {
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
}
.flash.success { color: var(--success); }
.flash.error { color: var(--danger); }

.hero {
  padding: 28px;
  display: grid;
  gap: 24px;
  background: var(--hero-bg);
  color: #fff;
}
.hero .muted, .hero .eyebrow { color: rgba(255,255,255,0.74); }
.hero-copy { max-width: 760px; }
.hero-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.stat-card {
  background: rgba(255,255,255,0.12);
  color: #fff;
  padding: 18px;
}
.stat-card span,
.stat-card small {
  display: block;
  color: rgba(255,255,255,0.72);
}
.stat-card strong {
  display: block;
  font-size: clamp(1.5rem, 2vw, 2.2rem);
  margin: 8px 0 6px;
}

.layout {
  margin-top: 18px;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
}
.sidebar {
  position: sticky;
  top: 18px;
  padding: 18px;
  height: fit-content;
}
.brand-lockup {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), #1e624b);
  color: white;
  font-weight: 700;
}
.nav-list {
  display: grid;
  gap: 10px;
}
.nav-list button {
  justify-content: flex-start;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.nav-list button.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(16, 59, 45, 0.18);
}

.sidebar-actions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.install-card {
  margin-top: 18px;
  padding: 16px;
  display: grid;
  gap: 12px;
  background: rgba(255,255,255,0.56);
}

.content { display: grid; gap: 18px; }
.content-grid {
  display: grid;
  gap: 18px;
}
.content-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel {
  padding: 22px;
  position: relative;
  overflow: hidden;
}
.panel::after {
  content: "";
  position: absolute;
  inset: auto -20px -60px auto;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(211, 135, 36, 0.10), transparent 68%);
}
.panel > * { position: relative; z-index: 1; }
.panel-head,
.card-top,
.recurring-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.soft-box {
  border-radius: 18px;
  padding: 16px;
  background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 76%, transparent);
}
.soft-box.strong { font-size: 1.15rem; font-weight: 700; }

.metric-list,
.list-stack {
  display: grid;
  gap: 12px;
}
.metric-list > div,
.list-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255,255,255,0.56);
}
.metric-list span { display: block; color: var(--muted); margin-bottom: 6px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 12px 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.pagination-meta {
  color: var(--muted);
  font-size: .92rem;
}
.pagination-actions,
.actions,
.inline-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mobile-cards {
  display: none;
  gap: 12px;
}
.transaction-card,
.goal-card,
.recurring-item {
  padding: 16px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}
.card-money {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 8px 0 10px;
}
.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .85rem;
  background: rgba(0,0,0,0.06);
}
.pill.income { background: rgba(36, 86, 64, 0.14); color: var(--success); }
.pill.expense { background: rgba(171, 47, 47, 0.12); color: var(--danger); }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}
.calendar-cell {
  min-height: 100px;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
}
.calendar-cell.today { outline: 2px solid color-mix(in srgb, var(--accent) 34%, transparent); }
.calendar-cell.has-items {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--accent-soft) 90%, var(--surface)) ,
    color-mix(in srgb, var(--surface) 88%, transparent)
  );
}
.calendar-day { font-weight: 700; margin-bottom: 8px; }
.calendar-item, .calendar-more {
  font-size: .82rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.recurring-item.editing {
  border-color: rgba(16, 59, 45, 0.24);
  background: rgba(245, 252, 247, 0.88);
}
.inline-form { margin-top: 14px; }
.toggle-line {
  display: flex;
  gap: 10px;
  align-items: center;
}
.toggle-line input {
  width: auto;
}

.goal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.goal-card.ok { border-color: rgba(36, 86, 64, 0.18); }
.goal-card.over { border-color: rgba(171, 47, 47, 0.20); }
.goal-numbers {
  margin: 14px 0 10px;
}
.goal-numbers span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}
.progress {
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(23, 32, 42, 0.08);
}
.progress div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.feature-panel {
  min-height: 100%;
}
.chart {
  width: 100%;
  border-radius: 18px;
}
.logs {
  max-height: 320px;
  overflow: auto;
  border-radius: 18px;
  padding: 14px;
  background: #10161e;
  color: #f4eee2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .84rem;
}

.desktop-table { display: block; }
.mobile-nav {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 40;
  background: color-mix(in srgb, var(--surface-strong) 94%, transparent);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.mobile-nav button {
  padding: 10px 6px;
  background: transparent;
  color: var(--muted);
  border-radius: 18px;
}
.mobile-nav button.active {
  background: var(--accent);
  color: #fff;
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .goal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 880px) {
  .auth-shell,
  .content-grid.two-col,
  .stats-grid,
  .goal-grid,
  .split {
    grid-template-columns: 1fr;
  }
  .auth-shell { padding: 16px; }
  .hero-actions { justify-content: flex-start; }
}

@media (max-width: 760px) {
  body { padding-bottom: 82px; }
  .app-shell { padding: 14px 14px 110px; }
  .sidebar { display: none; }
  .mobile-nav { display: grid; }
  .desktop-table { display: none; }
  .mobile-cards { display: grid; }
  .calendar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel,
  .hero { padding: 18px; }
  h1 { font-size: 2.2rem; }
}
