:root {
  --bg: #f4f6fb;
  --bg-strong: #eaf0fa;
  --panel: rgba(255, 255, 255, 0.74);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --panel-2: rgba(248, 250, 255, 0.9);
  --border: rgba(15, 23, 42, 0.06);
  --border-strong: rgba(15, 23, 42, 0.12);
  --text: #111827;
  --muted: #5f6b7a;
  --primary: #4f7cff;
  --primary-soft: rgba(79, 124, 255, 0.12);
  --green: #2bb673;
  --teal: #1ca5c2;
  --orange: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --shadow: 0 28px 60px rgba(15, 23, 42, 0.08);
  --sidebar-bg: rgba(255, 255, 255, 0.48);
  --input-bg: rgba(255, 255, 255, 0.8);
  --button-text: #ffffff;
}

body.dark-theme {
  --bg: #0b1020;
  --bg-strong: #121b2f;
  --panel: rgba(17, 24, 39, 0.88);
  --panel-strong: rgba(15, 23, 42, 0.96);
  --panel-2: rgba(21, 31, 52, 0.9);
  --border: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.2);
  --text: #e5eefb;
  --muted: #a7b6cf;
  --primary: #7aa2ff;
  --primary-soft: rgba(122, 162, 255, 0.16);
  --green: #44d899;
  --teal: #4ac7dc;
  --orange: #fbbf24;
  --red: #f87171;
  --purple: #b18cff;
  --shadow: 0 30px 70px rgba(2, 6, 23, 0.45);
  --sidebar-bg: rgba(15, 23, 42, 0.78);
  --input-bg: rgba(15, 23, 42, 0.9);
  --button-text: #08111e;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(79, 124, 255, 0.12), transparent 24%),
    radial-gradient(circle at bottom right, rgba(139, 92, 246, 0.10), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-strong) 100%);
  color: var(--text);
  transition: background 0.25s ease, color 0.25s ease;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  padding: 28px 20px 18px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed 90%);
  color: white;
  font-weight: 800;
  box-shadow: 0 16px 35px rgba(79, 124, 255, 0.25);
}

.eyebrow,
.mini-label {
  margin: 0 0 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}

.nav-item {
  color: var(--muted);
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 14px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  font-weight: 500;
}

.nav-item.active,
.nav-item:hover {
  color: var(--text);
  background: rgba(79, 124, 255, 0.08);
  border-color: rgba(79, 124, 255, 0.12);
}

.sidebar-card {
  margin-top: auto;
  background: linear-gradient(135deg, rgba(79, 124, 255, 0.10), rgba(139, 92, 246, 0.08));
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px 16px;
  box-shadow: var(--shadow);
}

.sidebar-card h3 {
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.sidebar-card p:last-child {
  color: var(--muted);
  line-height: 1.6;
}

.logout-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--muted);
  text-decoration: none;
}

.theme-toggle {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(79, 124, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  padding: 0;
}

.content {
  padding: 30px 32px 32px;
}

.topbar,
.section-header,
.section-header-split {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.date-pill {
  background: rgba(79, 124, 255, 0.08);
  border: 1px solid rgba(79, 124, 255, 0.12);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
}

.soft-button {
  background: rgba(17, 24, 39, 0.03);
  color: var(--text);
  border: 1px solid var(--border-strong);
}

.hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 26px 30px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, rgba(79, 124, 255, 0.09), rgba(255, 255, 255, 0.82));
}

.hero-copy {
  flex: 1;
}

.status-badge {
  display: inline-block;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(43, 182, 115, 0.10);
  border: 1px solid rgba(43, 182, 115, 0.18);
  color: #1c8f5d;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.hero-copy h3 {
  font-size: clamp(1.4rem, 2vw, 2.2rem);
  margin-bottom: 8px;
}

.hero-copy p {
  color: var(--muted);
  line-height: 1.6;
}

.hero-metrics {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.hero-metrics > div {
  min-width: 170px;
  background: rgba(255, 255, 255, 0.70);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 18px;
}

.hero-metrics span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
  font-size: 12px;
}

.hero-metrics strong {
  font-size: 1.1rem;
}

.stats-grid,
.form-grid,
.details-grid {
  display: grid;
  gap: 20px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  margin-bottom: 24px;
}

.stat-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-header,
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.card-header span,
.panel-header h3,
.panel-header span,
.stat-card small {
  color: var(--muted);
}

.stat-card strong {
  font-size: clamp(1.6rem, 2vw, 2.2rem);
  letter-spacing: -0.04em;
  color: var(--text);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: 0 0 12px currentColor;
}

.dot.expense { color: var(--red); background: var(--red); }
.dot.investment { color: var(--green); background: var(--green); }
.dot.budget { color: var(--primary); background: var(--primary); }
.dot.event { color: var(--orange); background: var(--orange); }

.highlight {
  background: linear-gradient(135deg, rgba(79, 124, 255, 0.12), rgba(255, 255, 255, 0.82));
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr 1.2fr;
  gap: 20px;
  margin-bottom: 24px;
}

.analytics-card {
  min-height: 240px;
}

.full-width-panel {
  grid-column: 1 / -1;
}

.bar-chart {
  height: 180px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding-top: 10px;
}

.bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  height: 100%;
}

.bar-wrap {
  width: 100%;
  height: 150px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(17, 24, 39, 0.03);
  border-radius: 12px 12px 8px 8px;
  overflow: hidden;
}

.bar {
  width: 100%;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(180deg, #7c9cff 0%, #4ade80 100%);
  min-height: 12px;
}

.bar-group span {
  color: var(--muted);
  font-size: 12px;
}

.budget-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.budget-ring-wrap {
  display: flex;
  justify-content: center;
  margin: 14px 0 10px;
}

.budget-ring {
  --progress: 0;
  position: relative;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: conic-gradient(var(--primary) calc(var(--progress) * 1%), rgba(15, 23, 42, 0.07) 0);
  display: grid;
  place-items: center;
}

.budget-ring::before {
  content: "";
  position: absolute;
  inset: 15px;
  background: rgba(255, 255, 255, 0.98);
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.budget-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.budget-inner strong {
  font-size: 1.6rem;
}

.budget-inner span,
.ring-label {
  color: var(--muted);
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 10px;
}

.category-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(17, 24, 39, 0.02);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.category-meta,
.category-values {
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-values {
  flex-direction: column;
  align-items: flex-end;
}

.category-values small {
  color: var(--muted);
}

.legend {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.panel {
  padding: 20px;
}

.budget-editor {
  margin-bottom: 24px;
}

.budget-form-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) minmax(150px, 0.8fr) auto;
  align-items: end;
  gap: 14px;
  margin-top: 18px;
}

.budget-form-row label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.budget-actions {
  display: flex;
  align-items: end;
  gap: 12px;
}

.budget-form-row select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: var(--input-bg);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.budget-form-row select:focus {
  outline: none;
  border-color: rgba(79, 124, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.10);
}

.form-panel form {
  margin-top: 16px;
}

.panel-header {
  margin-bottom: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid transparent;
}

.pill.neutral {
  background: rgba(15, 23, 42, 0.03);
  border-color: rgba(15, 23, 42, 0.08);
  color: var(--muted);
}

.pill.positive {
  background: rgba(43, 182, 115, 0.08);
  border-color: rgba(43, 182, 115, 0.2);
  color: #1b8f63;
}

.pill.warn {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.2);
  color: #b76a00;
}

section.single-column-form-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 20px;
  align-items: start;
}

form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: rgba(79, 124, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(79, 124, 255, 0.10);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
}

textarea {
  resize: vertical;
  min-height: 84px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, #5e7cff 100%);
  color: var(--button-text);
  font-weight: 600;
  transition: transform 0.2s ease, opacity 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 16px 28px rgba(79, 124, 255, 0.22);
}

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

button.reset-button {
  background: rgba(239, 68, 68, 0.12);
  color: var(--red);
  box-shadow: none;
}

button.delete {
  background: rgba(239, 68, 68, 0.10);
  color: var(--red);
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: none;
}

.calendar-panel {
  margin-bottom: 24px;
}

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

.calendar-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: rgba(17, 24, 39, 0.03);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.calendar-header-cell {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.calendar-day {
  min-height: 110px;
  padding: 8px 8px 10px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 12px;
}

.calendar-day.muted {
  opacity: 0.5;
}

.calendar-day.today {
  border-color: rgba(79, 124, 255, 0.42);
  box-shadow: inset 0 0 0 1px rgba(79, 124, 255, 0.12);
}

.day-number {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 8px;
}

.calendar-tag {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 4px 6px;
  border-radius: 8px;
  font-size: 10px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-tag {
  background: rgba(245, 158, 11, 0.10);
  color: #b76a00;
}

.expense-tag {
  background: rgba(239, 68, 68, 0.07);
  color: #c53a3a;
}

.item-list,
.note-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-list li,
.note-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(15, 23, 42, 0.05);
}

.item-list li > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.item-actions span,
.item-actions small {
  color: var(--muted);
}

.gain {
  color: var(--green) !important;
}

.empty {
  color: var(--muted);
  justify-content: center;
}

.note-list li {
  justify-content: space-between;
}

.note-list li span {
  color: var(--text);
  line-height: 1.5;
}

.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(90vw, 460px);
}

.auth-card {
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.auth-brand {
  margin-bottom: 12px;
}

.auth-card h2 {
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--muted);
  margin-bottom: 18px;
}

.auth-error {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.14);
  color: #b91c1c;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--muted);
}

.auth-form button {
  margin-top: 6px;
}

.auth-switch {
  text-align: center;
  color: var(--muted);
  margin-top: 18px;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
}

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 20px 18px 28px;
  }

  .topbar,
  .hero-panel,
  .section-header,
  .section-header-split {
    flex-direction: column;
    align-items: flex-start;
  }

  .analytics-grid,
  .stats-grid,
  .form-grid,
  .details-grid,
  section.single-column-form-layout {
    grid-template-columns: 1fr;
  }

  .calendar-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}
