:root {
  --bg: #0b0d12;
  --panel: #12151b;
  --panel-2: #1a1f28;
  --panel-3: #222836;
  --border: #262c38;
  --border-soft: #1c212b;
  --text: #eef1f6;
  --muted: #8f99ab;
  --muted-2: #6b7486;
  --accent: #5b8cff;
  --accent-hover: #7aa0ff;
  --accent-soft: rgba(91, 140, 255, 0.14);
  --good: #3ecf8e;
  --good-soft: rgba(62, 207, 142, 0.14);
  --bad: #f0615f;
  --bad-soft: rgba(240, 97, 95, 0.14);
  --warn: #e8b339;
  --warn-soft: rgba(232, 179, 57, 0.14);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.28);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image: radial-gradient(circle at 15% 0%, rgba(91, 140, 255, 0.06), transparent 45%);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

a { color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------- App shell: left sidebar + content, responsive ---------- */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--panel), var(--bg) 130%);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  padding: 4px 10px 24px;
}

.sidebar-brand::before {
  content: '';
  width: 20px;
  height: 20px;
  border-radius: 6px;
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #8a5bff);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.06) inset, 0 4px 10px rgba(91,140,255,0.35);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s var(--ease), background 0.15s var(--ease);
}

.sidebar-nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.15s var(--ease);
}

.sidebar-nav a:hover { color: var(--text); background: var(--panel-2); }
.sidebar-nav a:hover svg { opacity: 1; }

.sidebar-nav a.active {
  color: var(--text);
  background: var(--accent-soft);
  font-weight: 600;
}

.sidebar-nav a.active svg { opacity: 1; }

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.sidebar-logout { margin-top: auto; padding-top: 12px; }

.app-content {
  flex: 1;
  min-width: 0;
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 28px 60px;
  width: 100%;
}

/* Mobile top bar + hamburger - hidden on desktop */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  z-index: 30;
}

.hamburger {
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s var(--ease);
}

.hamburger:hover { background: var(--panel-2); }

.mobile-brand { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  z-index: 40;
}

@media (max-width: 860px) {
  .mobile-topbar { display: flex; }

  .app-shell { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s var(--ease);
    z-index: 50;
    box-shadow: var(--shadow-md);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop.open { display: block; }

  .app-content { padding: 20px 16px 80px; }

  .sidebar-nav a.active::before { left: -8px; }
}

/* ---------- Login page ---------- */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
  background-image:
    radial-gradient(circle at 20% 20%, rgba(91, 140, 255, 0.14), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(138, 91, 255, 0.1), transparent 40%);
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
}

.login-brand {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.login-card h1 { font-size: 22px; margin-bottom: 22px; letter-spacing: -0.01em; }

.login-error {
  background: var(--bad-soft);
  border: 1px solid rgba(240, 97, 95, 0.35);
  color: var(--bad);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
}

h1 { font-size: 23px; margin: 0 0 20px; letter-spacing: -0.015em; font-weight: 650; }
h2 { font-size: 15px; margin: 0 0 14px; color: var(--text); font-weight: 600; letter-spacing: -0.005em; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  transition: border-color 0.15s var(--ease), transform 0.15s var(--ease);
}

.card:hover { border-color: #333b4a; transform: translateY(-1px); }

.card .label {
  font-size: 11.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  margin-bottom: 8px;
}

.card .value {
  font-size: 25px;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.value.good { color: var(--good); }
.value.bad { color: var(--bad); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 22px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr { transition: background 0.12s var(--ease); }
tbody tr:hover { background: var(--panel-2); }

tr:last-child td { border-bottom: none; }

form.inline { display: inline; }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

input, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

input:hover, select:hover { border-color: var(--muted-2); }

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

label {
  font-size: 11.5px;
  color: var(--muted);
  display: block;
  margin-bottom: 5px;
  font-weight: 500;
}

.field { display: flex; flex-direction: column; }

button, .btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 550;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background 0.15s var(--ease), transform 0.1s var(--ease), box-shadow 0.15s var(--ease);
}

button:hover, .btn:hover { background: var(--accent-hover); }
button:active, .btn:active { transform: translateY(1px); }

button.secondary, .btn.secondary {
  background: var(--panel-3);
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover, .btn.secondary:hover { background: #2a3140; border-color: var(--muted-2); }

button.danger {
  background: transparent;
  color: var(--bad);
  border: 1px solid rgba(240, 97, 95, 0.4);
  padding: 5px 11px;
  font-size: 12px;
  font-weight: 500;
}

button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }

.pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.pill.over { background: var(--bad-soft); color: var(--bad); }
.pill.under { background: var(--good-soft); color: var(--good); }

.progress-bar {
  background: var(--panel-3);
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
  margin-top: 7px;
}

.progress-bar .fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.3s var(--ease);
}

.progress-bar .fill.over { background: linear-gradient(90deg, var(--bad), #ff8a87); }

.empty-state {
  color: var(--muted);
  font-size: 13.5px;
  padding: 28px 16px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.chart-wrap {
  position: relative;
  height: 260px;
}

.help-text {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 16px;
}

/* ---------- Monthly Ledger summary panel (dashboard) ---------- */

.ledger-panel { padding: 22px 24px; }

.ledger-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.period-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.period-toggle input { display: none; }

.period-toggle .switch {
  position: relative;
  width: 36px;
  height: 20px;
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background 0.15s var(--ease);
}

.period-toggle .switch::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}

.period-toggle input:checked + .switch { background: var(--accent-soft); border-color: var(--accent); }
.period-toggle input:checked + .switch::before { transform: translateX(16px); background: var(--accent); }

.ledger-body {
  display: flex;
  align-items: center;
  gap: 32px;
  flex-wrap: wrap;
}

.ledger-ring {
  flex-shrink: 0;
  text-align: center;
}

.ledger-stats {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ledger-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  color: var(--muted);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}

.ledger-stat:last-child { border-bottom: none; padding-bottom: 0; }

.ledger-stat strong { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }

.ledger-stat-total strong { font-size: 18px; }

/* ---------- Ledger page (bigger hero version, /ledger) ---------- */

.ledger-hero {
  padding: 34px 38px;
  background: linear-gradient(155deg, var(--panel-2), var(--panel) 60%);
  position: relative;
  overflow: hidden;
}

.ledger-hero::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(91,140,255,0.16), transparent 70%);
  pointer-events: none;
}

.ledger-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}

.ledger-title { font-size: 29px; margin: 0; letter-spacing: -0.02em; }

.ledger-header-actions {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.currency-form {
  display: flex;
  align-items: center;
  gap: 8px;
}

.currency-form input {
  width: 64px;
  text-align: center;
}

.ledger-body-lg { gap: 48px; position: relative; }

.ledger-ring-lg { padding: 4px 0; }

.ledger-stats-lg { gap: 16px; }

.ledger-stats-lg .ledger-stat { font-size: 15px; padding-bottom: 12px; }
.ledger-stats-lg .ledger-stat strong { font-size: 18px; }
.ledger-stats-lg .ledger-stat-total strong { font-size: 23px; }

.section-heading {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 12px;
  font-weight: 650;
  color: var(--muted);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .ledger-hero { padding: 22px; }
  .ledger-body-lg { gap: 24px; }
  .ledger-title { font-size: 22px; }
}
