/* ============================================================
   Ledger — base styles (shared across all pages)
   ============================================================ */
:root {
  --ink: #20241f;
  --paper: #fbfaf5;
  --paper-dim: #f3f1e8;
  --spine: #1f3a34;
  --spine-light: #2c4c44;
  --brass: #a9843a;
  --rust: #9c4a3d;
  --sage: #5f8267;
  --line: #ddd8c8;
  --muted: #767c6c;
  --shadow: 0 12px 32px rgba(32, 36, 31, 0.14);
  --radius: 10px;
  --radius-sm: 8px;
  --ring: 0 0 0 3px rgba(169, 132, 58, 0.22);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  margin: 0;
}

.hidden { display: none !important; }

button, input, select {
  font-family: inherit;
  font-size: inherit;
}

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.08s ease, background 0.15s ease, color 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: var(--spine);
  border-color: var(--spine);
  color: var(--paper);
}
.btn-primary:hover { background: var(--spine-light); }
.btn-ghost {
  border-color: var(--line);
  color: var(--muted);
}
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-block { width: 100%; }
.btn-danger {
  background: var(--rust);
  border-color: var(--rust);
  color: var(--paper);
}
.btn-danger:hover { background: #833d32; }
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* ============================================================
   AUTH SCREEN
   ============================================================ */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(900px 500px at 12% -10%, rgba(169, 132, 58, 0.16), transparent 60%),
    radial-gradient(800px 600px at 110% 110%, rgba(95, 130, 103, 0.18), transparent 55%),
    linear-gradient(160deg, #23423a 0%, #1f3a34 45%, #142622 100%);
  padding: 2rem;
  position: relative;
  overflow: hidden;
}
.auth-screen::after {
  content: " a7";
  position: absolute;
  right: -2rem;
  bottom: -6rem;
  font-family: 'Fraunces', serif;
  font-size: 28rem;
  color: rgba(251, 250, 245, 0.035);
  pointer-events: none;
}

.auth-card {
  background: var(--paper);
  width: 100%;
  max-width: 410px;
  padding: 2.75rem 2.5rem;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(10, 20, 17, 0.45);
  position: relative;
  z-index: 1;
}

.auth-brand {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.auth-brand .brand-mark { font-size: 2rem; }
.auth-brand .brand-name { font-size: 1.5rem; }
.brand-mark {
  font-family: 'Fraunces', serif;
  font-size: 1.8rem;
  color: var(--brass);
}
.brand-name {
  font-family: 'Fraunces', serif;
  font-size: 1.3rem;
  font-weight: 600;
}
.auth-tagline {
  color: var(--muted);
  margin: 0 0 1.75rem;
  font-size: 0.92rem;
  text-align: center;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--paper-dim);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 1.6rem;
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 999px;
  padding: 0.55rem 0;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.auth-tab:hover { color: var(--ink); }
.auth-tab.active {
  color: var(--paper);
  background: var(--spine);
}

.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}
.auth-form input {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  color: var(--ink);
  background: var(--paper);
}
.auth-form input:focus, select:focus, .modal input:focus,
.tg-form input:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: var(--ring);
}
.auth-error {
  color: var(--rust);
  font-size: 0.85rem;
  margin: 0;
  min-height: 1.2em;
}
.auth-note { color: var(--sage); font-size: 0.85rem; margin: 0; }

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--spine);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.loading-mark {
  font-family: 'Fraunces', serif;
  font-size: 3rem;
  color: var(--brass);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.94); }
  50% { opacity: 1; transform: scale(1); }
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-stack {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 200;
}
.toast {
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.88rem;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--brass);
  animation: toast-in 0.18s ease-out;
  max-width: 320px;
}
.toast-error { border-left-color: var(--rust); }
.toast-success { border-left-color: var(--sage); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(32, 36, 31, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1.5rem;
}
.modal {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.modal h2 { margin-bottom: 1.25rem; font-size: 1.3rem; }
.modal-sm { max-width: 360px; }
.confirm-message { color: var(--muted); font-size: 0.92rem; margin: -0.5rem 0 0.5rem; }
#expense-form, #income-form { display: flex; flex-direction: column; gap: 1rem; }
#expense-form label, #income-form label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}
#expense-form input, #expense-form select,
#income-form input, #income-form select {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  color: var(--ink);
  background: var(--paper);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.5rem;
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   POLISH — buttons, cards, scrollbars (appended)
   ============================================================ */
.btn {
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(32, 36, 31, 0.08);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--spine-light), var(--spine));
  box-shadow: 0 2px 8px rgba(31, 58, 52, 0.28);
}
.btn-primary:hover { filter: brightness(1.08); }

/* forgot-password text link */
.auth-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  align-self: center;
}
.auth-link:hover { color: var(--brass); }
