:root {
  --bg: #070b14;
  --bg-soft: #0f172a;
  --surface: rgba(15, 23, 42, 0.78);
  --surface-2: rgba(30, 41, 59, 0.7);
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: rgba(148, 163, 184, 0.24);
  --brand: #8b5cf6;
  --brand-2: #22d3ee;
  --danger: #ef4444;
  --ok: #10b981;
  --shadow: 0 20px 55px rgba(2, 6, 23, 0.38);
}

* {
  box-sizing: border-box;
}

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

.skip-link {
  position: absolute;
  left: 0.75rem;
  top: -80px;
  z-index: 100;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f172a;
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 0.75rem;
}

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

body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -5%, rgba(34, 211, 238, 0.18), transparent 50%),
    radial-gradient(1200px 600px at 100% -15%, rgba(139, 92, 246, 0.2), transparent 45%),
    var(--bg);
}

.shell {
  width: min(1160px, 100% - 1.25rem);
  margin-inline: auto;
}

.page-header {
  margin-top: 1rem;
  margin-bottom: 0.9rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 1rem;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 24px rgba(139, 92, 246, 0.35);
}

.brand-kicker {
  margin: 0 0 0.2rem;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  font-weight: 700;
  color: var(--brand-2);
}

.page-header h1 {
  margin: 0;
  font-size: clamp(1.1rem, 2.3vw, 1.75rem);
  font-weight: 800;
}

.page-nav {
  display: inline-flex;
  gap: 0.45rem;
  padding: 0.3rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.75);
  width: 100%;
  overflow-x: auto;
}

.nav-link {
  text-decoration: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.48rem 0.9rem;
  border-radius: 999px;
  white-space: nowrap;
  text-align: center;
  flex: 1 1 auto;
}

.nav-link-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.nav-link.active,
.nav-link:hover {
  color: #fff;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(34, 211, 238, 0.2));
}

.container {
  margin-bottom: 2.5rem;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: clamp(0.9rem, 2.8vw, 1.2rem);
}

h2 {
  margin: 0;
  font-size: 1.03rem;
}

h3 {
  margin: 0;
  font-size: 0.95rem;
}

.section-subtitle {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.dashboard-head,
.transactions-head,
.chart-side-panel {
  display: flex;
}

.dashboard-head,
.transactions-head {
  display: flex;
  justify-content: space-between;
  gap: 0.85rem;
  align-items: flex-start;
  flex-wrap: wrap;
}

.transactions-head {
  margin-bottom: 0.9rem;
}

.inline-expense-form {
  margin-bottom: 0.9rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.6rem;
  align-items: end;
}

.inline-submit-btn {
  white-space: nowrap;
  justify-self: start;
}

.time-controls {
  display: grid;
  gap: 0.6rem;
}

.custom-range {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.dashboard-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

.stats-column {
  display: grid;
  gap: 0.7rem;
}

.stat-card,
.chart-card,
.budget-item {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.stat-card {
  padding: 1rem;
}

.metric-card .big-number {
  font-size: clamp(1.3rem, 2.6vw, 1.85rem);
}

.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.big-number {
  margin: 0.45rem 0;
  font-size: clamp(1.75rem, 3.6vw, 2.2rem);
  font-weight: 800;
}

.muted-text {
  margin: 0;
  color: var(--muted);
}

.chart-card {
  padding: 0.95rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
  align-items: start;
}

.chart-side-panel {
  flex-direction: column;
  gap: 0.7rem;
}

.chart-wrap {
  position: relative;
  width: 100%;
  max-width: 250px;
  margin-inline: auto;
}

.chart-center-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  pointer-events: none;
  padding: 1rem;
}

.chart-center-label {
  margin: 0;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.chart-center-percent {
  margin: 0.15rem 0 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: #f8fafc;
}

.chart-center-amount {
  margin: 0.1rem 0 0;
  font-size: 0.72rem;
  color: #cbd5e1;
}

.chart-legend {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.4rem;
}

.chart-legend li {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.86rem;
}

.legend-left {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.budget-sheet-wrap h3 {
  margin: 0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #cbd5e1;
}

.budget-sheet {
  min-width: 520px;
  border-collapse: collapse;
}

.budget-sheet thead th {
  font-size: 0.72rem;
  background: rgba(51, 65, 85, 0.55);
}

.budget-sheet tbody td {
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.45);
}

.budget-sheet tbody tr:nth-child(even) td {
  background: rgba(30, 41, 59, 0.45);
}

.budget-sheet-input {
  min-width: 102px;
  max-width: 120px;
  padding: 0.36rem 0.45rem;
  border-radius: 6px;
  font-size: 0.8rem;
}

.budget-category-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
}

.budget-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.8);
}

#budget-sheet-body .over-limit {
  color: #fda4af;
  font-weight: 700;
}

.over-limit {
  color: #fda4af !important;
}

.paycheck-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}

.paycheck-inputs {
  display: grid;
  gap: 0.65rem;
}

.paycheck-table tbody td {
  font-size: 0.88rem;
}

.transactions-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  align-items: end;
}

label {
  display: grid;
  gap: 0.32rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.required-asterisk {
  color: #f87171;
  font-weight: 700;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  border: 1px solid var(--line);
  color: #e2e8f0;
  border-radius: 10px;
  padding: 0.62rem 0.68rem;
  background: rgba(15, 23, 42, 0.7);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(34, 211, 238, 0.75);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

input.is-invalid,
select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  appearance: textfield;
}

.btn {
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  padding: 0.58rem 0.88rem;
  font-weight: 600;
}

.btn:focus-visible,
.floating-add-btn:focus-visible,
a:focus-visible {
  outline: 2px solid #22d3ee;
  outline-offset: 2px;
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
}

.btn-secondary {
  background: #334155;
}

.btn-danger {
  background: #b91c1c;
}

.btn-edit,
.btn-delete {
  font-size: 0.81rem;
  padding: 0.45rem 0.66rem;
}

.row-actions {
  display: inline-flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

thead th {
  color: #cbd5e1;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.72rem;
  border-bottom: 1px solid var(--line);
}

tbody td {
  padding: 0.74rem;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

tbody tr:hover {
  background: rgba(148, 163, 184, 0.08);
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 1.2rem;
}

.floating-add-btn {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 999px;
  font-size: 1.9rem;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  box-shadow: 0 20px 30px rgba(12, 74, 110, 0.42);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 30;
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.86);
}

.auth-card {
  width: min(460px, 100%);
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #0f172a;
  box-shadow: var(--shadow);
}

.auth-form {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.7rem;
}

.auth-error {
  margin: 0.65rem 0 0;
  color: #fca5a5;
  font-size: 0.84rem;
}

.auth-success {
  margin: 0.65rem 0 0;
  color: #86efac;
  font-size: 0.84rem;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1rem 0;
}

.auth-page-wrap {
  width: min(520px, 100% - 1.25rem);
}

.auth-page-card h1 {
  margin: 0;
  font-size: clamp(1.4rem, 3.8vw, 1.9rem);
}

.login-layout {
  width: min(940px, 100% - 1.25rem);
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
  align-items: center;
  justify-items: center;
}

.auth-logo-panel {
  display: grid;
  gap: 0.42rem;
  padding: 0.2rem;
  text-align: center;
}

.budget-logo-icon {
  width: 124px;
  height: 124px;
  position: relative;
  margin-inline: auto;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 25%, rgba(34, 211, 238, 0.28), rgba(15, 23, 42, 0.08) 55%),
    linear-gradient(135deg, rgba(139, 92, 246, 0.28), rgba(34, 211, 238, 0.24));
  box-shadow:
    inset 0 0 0 1px rgba(148, 163, 184, 0.26),
    0 16px 30px rgba(34, 211, 238, 0.2);
}

.logo-bar {
  position: absolute;
  bottom: 30px;
  width: 13px;
  border-radius: 999px;
  background: linear-gradient(180deg, #22d3ee, #8b5cf6);
}

.logo-bar-1 {
  left: 32px;
  height: 26px;
}

.logo-bar-2 {
  left: 52px;
  height: 40px;
}

.logo-bar-3 {
  left: 72px;
  height: 54px;
}

.logo-trend-line {
  position: absolute;
  left: 30px;
  right: 28px;
  top: 48px;
  height: 0;
  border-top: 3px solid rgba(186, 230, 253, 0.95);
  transform: rotate(-18deg);
  transform-origin: left center;
}

.logo-trend-line::after {
  content: "";
  position: absolute;
  right: -3px;
  top: -5px;
  width: 9px;
  height: 9px;
  border-top: 3px solid rgba(186, 230, 253, 0.95);
  border-right: 3px solid rgba(186, 230, 253, 0.95);
  transform: rotate(45deg);
}

.logo-coin {
  position: absolute;
  top: 16px;
  right: 14px;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b);
  box-shadow: inset 0 0 0 2px rgba(180, 83, 9, 0.32);
}

.auth-logo-title,
.auth-logo-subtitle {
  margin: 0;
  letter-spacing: 0.14em;
  font-weight: 800;
}

.auth-logo-title {
  margin-top: 0.5rem;
  color: #c4b5fd;
  font-size: 1.02rem;
}

.auth-logo-subtitle {
  color: #67e8f9;
  font-size: 0.78rem;
}

.auth-footer {
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-footer a {
  color: #c4b5fd;
}

.password-rules {
  margin: 0.7rem 0 0;
  padding-left: 1.2rem;
  color: #dbeafe;
  font-size: 0.85rem;
  display: grid;
  gap: 0.3rem;
}

.modal-card {
  width: min(640px, 100%);
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #0f172a;
  box-shadow: var(--shadow);
  padding: 1.15rem;
}

.form-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.72rem;
}

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

.modal-actions {
  margin-top: 0.95rem;
  display: flex;
  justify-content: end;
  gap: 0.52rem;
}

.hidden {
  display: none !important;
}

.insights-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.72rem;
}

.insight-card {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.9rem;
}

.insight-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.insight-card strong {
  margin-top: 0.3rem;
  display: block;
  font-size: 1.15rem;
}

.analysis-chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.82rem;
}

.chart-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.85rem;
  background: var(--surface-2);
}

.trend-list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.45rem;
  color: #dbeafe;
}

@media (min-width: 640px) {
  .shell {
    width: min(1160px, 94%);
  }

  .custom-range,
  .form-grid,
  .inline-expense-form {
    grid-template-columns: repeat(2, minmax(170px, 1fr));
  }

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

@media (min-width: 900px) {
  .page-header {
    margin-top: 1.4rem;
    margin-bottom: 1.15rem;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .page-nav {
    width: auto;
    overflow: visible;
  }

  .nav-link {
    flex: 0 0 auto;
  }

  .dashboard-grid {
    grid-template-columns: minmax(210px, 290px) 1fr;
  }

  .chart-card {
    grid-template-columns: minmax(220px, 280px) 1fr;
  }

  .paycheck-grid,
  .analysis-chart-grid {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }

  .insights-grid {
    grid-template-columns: repeat(3, minmax(190px, 1fr));
  }

  .inline-expense-form {
    grid-template-columns: 120px 170px 170px minmax(220px, 1fr) auto;
  }

  .inline-submit-btn {
    justify-self: auto;
  }

  .login-layout {
    grid-template-columns: minmax(340px, 460px) 180px;
    width: min(820px, 100% - 1.25rem);
    margin-inline: auto;
    justify-content: center;
    align-items: center;
    gap: 1.4rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
