@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #14231C;
  --forest: #1F3B2E;
  --forest-light: #2B4F3D;
  --sand: #F2EBDD;
  --sand-dark: #E7DCC5;
  --paper: #FBF8F1;
  --gold: #C9A24B;
  --gold-dark: #A6812F;
  --rust: #B5533C;
  --rust-light: #F4E2DC;
  --line: #D8CDB2;
  --muted: #6B6355;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

  --radius: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--sand);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, .num {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: inherit; }

button {
  font-family: var(--font-body);
  cursor: pointer;
}

/* ===== Login ===== */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--forest);
  background-image: radial-gradient(circle at 20% 20%, var(--forest-light) 0%, var(--forest) 60%);
}

.login-card {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}

.login-card h1 {
  font-size: 28px;
  margin: 0 0 4px;
  color: var(--forest);
}

.login-card .subtitle {
  color: var(--muted);
  margin: 0 0 28px;
  font-size: 14px;
}

.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 16px 0 6px;
  color: var(--ink);
}

.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: var(--font-body);
  background: #fff;
}

.login-card input:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
  border-color: var(--gold);
}

.login-card button {
  width: 100%;
  margin-top: 24px;
  padding: 12px;
  background: var(--forest);
  color: var(--sand);
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 15px;
  transition: background 0.15s ease;
}
.login-card button:hover { background: var(--forest-light); }

.error-msg {
  color: var(--rust);
  font-size: 13px;
  margin-top: 14px;
  margin-bottom: 0;
}

/* ===== App Layout ===== */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--forest);
  color: var(--sand);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
}
.sidebar-user {
  font-size: 12px;
  color: rgba(242,235,221,0.6);
  margin: 0 0 28px;
}

.year-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 28px;
}

.year-tab {
  background: transparent;
  border: none;
  color: rgba(242,235,221,0.75);
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.year-tab:hover { background: rgba(242,235,221,0.08); color: var(--sand); }
.year-tab.active { background: var(--sand); color: var(--forest); font-weight: 600; }

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: auto;
}
.nav-link {
  background: transparent;
  border: none;
  color: rgba(242,235,221,0.75);
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}
.nav-link:hover { background: rgba(242,235,221,0.08); color: var(--sand); }
.nav-link.active { background: rgba(201,162,75,0.2); color: var(--gold); font-weight: 600; }

.logout-btn {
  background: transparent;
  border: 1px solid rgba(242,235,221,0.25);
  color: rgba(242,235,221,0.75);
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  margin-top: 20px;
}
.logout-btn:hover { border-color: var(--sand); color: var(--sand); }

.main {
  padding: 36px 44px;
  max-width: 980px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h2 {
  font-size: 26px;
  margin: 0;
  color: var(--forest);
}
.page-header .meta {
  color: var(--muted);
  font-size: 13px;
}

/* ===== Summary cards (ledger style, not generic rounded cards) ===== */
.summary-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}
.summary-cell {
  background: var(--paper);
  padding: 18px 20px;
}
.summary-cell .label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.summary-cell .value {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
}
.summary-cell .value.positive { color: var(--forest); }
.summary-cell .value.negative { color: var(--rust); }

/* ===== Ledger table ===== */
.ledger {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 32px;
}
.ledger-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--sand-dark);
}
.ledger-header h3 { margin: 0; font-size: 16px; color: var(--forest); }

.ledger-row {
  display: grid;
  grid-template-columns: 90px 1fr 140px 90px 40px;
  gap: 12px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.ledger-row:last-child { border-bottom: none; }
.ledger-row.head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--sand);
  font-weight: 600;
}
.ledger-row .amount { font-family: var(--font-display); font-weight: 600; text-align: right; }
.ledger-row .amount.einnahme { color: var(--forest); }
.ledger-row .amount.ausgabe { color: var(--rust); }
.ledger-row .tag {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--sand-dark);
  color: var(--muted);
}
.ledger-row .del-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
}
.ledger-row .del-btn:hover { color: var(--rust); background: var(--rust-light); }

.empty-state {
  padding: 32px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ===== Forms ===== */
.form-inline {
  display: flex;
  gap: 10px;
  padding: 16px 20px;
  background: var(--sand-dark);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  align-items: flex-end;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}
.form-field input, .form-field select {
  padding: 8px 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-body);
  background: #fff;
  min-width: 110px;
}
.form-field input:focus, .form-field select:focus {
  outline: 2px solid var(--gold);
  outline-offset: 0;
  border-color: var(--gold);
}
.form-field.grow { flex: 1; min-width: 160px; }
.form-field.grow input { width: 100%; }

.btn {
  padding: 9px 18px;
  border-radius: var(--radius);
  border: none;
  font-weight: 600;
  font-size: 14px;
}
.btn-primary { background: var(--forest); color: var(--sand); }
.btn-primary:hover { background: var(--forest-light); }
.btn-secondary { background: transparent; border: 1.5px solid var(--forest); color: var(--forest); }
.btn-secondary:hover { background: rgba(31,59,46,0.06); }

.type-toggle {
  display: flex;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.type-toggle button {
  border: none;
  background: #fff;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.type-toggle button.active.einnahme { background: var(--forest); color: var(--sand); }
.type-toggle button.active.ausgabe { background: var(--rust); color: #fff; }

/* ===== Goals ===== */
.goal-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.goal-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}
.goal-card-top h4 { margin: 0; font-size: 17px; font-family: var(--font-display); }
.goal-card-top .amounts { font-size: 13px; color: var(--muted); }
.goal-bar-track {
  height: 10px;
  background: var(--sand-dark);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 12px;
}
.goal-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 20px;
  transition: width 0.4s ease;
}
.goal-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.goal-card-actions input {
  width: 100px;
  padding: 7px 10px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
}
.goal-meta { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ===== Chart container ===== */
.chart-box {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 32px;
}
.chart-box h3 { margin: 0 0 16px; font-size: 16px; color: var(--forest); }

/* ===== Utility ===== */
.hidden { display: none !important; }
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--forest);
  color: var(--sand);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 100;
}
.toast.error { background: var(--rust); }

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; overflow-x: auto; padding: 16px; align-items: center; }
  .sidebar-brand, .sidebar-user { display: none; }
  .year-tabs { flex-direction: row; margin-bottom: 0; }
  .nav-links { flex-direction: row; margin-right: auto; }
  .main { padding: 24px 20px; }
  .summary-row { grid-template-columns: 1fr; }
  .ledger-row { grid-template-columns: 70px 1fr 100px 32px; font-size: 13px; }
  .ledger-row .tag { display: none; }
}
