@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg:           #faf7f2;
  --bg2:          #f3ede4;
  --surface:      #ffffff;
  --surface-alt:  #f7f3ec;
  --border:       #e8dfd2;
  --border-med:   #d4c9b8;
  --accent:       #2a9d8f;
  --accent-dark:  #1f8577;
  --accent-light: #e8f5f3;
  --danger:       #d9534f;
  --danger-light: #fdf0f0;
  --success:      #4a9e6b;
  --success-light:#edf7f0;
  --warning:      #d4860e;
  --warning-light:#fef6e4;
  --text:         #2c2016;
  --text-soft:    #6b5a48;
  --muted:        #a0917f;
  --shadow-sm:    0 1px 3px rgba(44,32,22,0.07), 0 1px 2px rgba(44,32,22,0.04);
  --shadow:       0 3px 12px rgba(44,32,22,0.10), 0 1px 4px rgba(44,32,22,0.06);
  --shadow-lg:    0 8px 28px rgba(44,32,22,0.13), 0 2px 8px rgba(44,32,22,0.07);
  --radius:       14px;
  --radius-sm:    9px;
  --radius-lg:    22px;
  --nav-height:   64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── App Header ─────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.25rem; height: 56px;
}

.app-brand {
  display: flex; align-items: center; gap: 0.55rem;
  font-weight: 900; font-size: 1.1rem; color: var(--text);
  letter-spacing: -0.02em; text-decoration: none;
}

.brand-icon { flex-shrink: 0; filter: drop-shadow(0 2px 5px rgba(42,157,143,0.22)); }

/* ── Tab Bar ─────────────────────────────────── */
.tab-bar {
  position: sticky; top: 56px; z-index: 90;
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  display: flex; overflow-x: auto; scrollbar-width: none; gap: 0; padding: 0 1rem;
}
.tab-bar::-webkit-scrollbar { display: none; }

.tab {
  padding: 0.875rem 1.1rem; border: none; background: none;
  color: var(--muted); font-family: 'Nunito', sans-serif;
  font-size: 0.9rem; font-weight: 700; cursor: pointer; white-space: nowrap;
  border-bottom: 2.5px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}
.tab:hover:not(.active) { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ── Tab Panels ──────────────────────────────── */
.tab-panel { display: none; max-width: 740px; margin: 0 auto; padding: 1.75rem 1.25rem 4rem; }
.tab-panel.active { display: block; }

/* ── Section Header ──────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; gap: 0.75rem; flex-wrap: wrap;
}
.section-title {
  font-size: 1.5rem; font-weight: 900; color: var(--text);
  letter-spacing: -0.03em; text-transform: none;
}

/* ── Legacy Navbar (Fallback für alte Seiten) ── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--surface); border-bottom: 1.5px solid var(--border);
  display: flex; align-items: center; height: 56px; padding: 0 1.25rem; gap: 0.5rem;
}
.nav-brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; font-weight: 900; font-size: 1.1rem; color: var(--text); letter-spacing: -0.02em; flex-shrink: 0; }
.nav-links { display: flex; gap: 0.15rem; }
.nav-link { color: var(--muted); text-decoration: none; padding: 0.45rem 0.9rem; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 700; transition: background 0.15s, color 0.15s; white-space: nowrap; }
.nav-link:hover { color: var(--text); background: var(--surface-alt); }
.nav-link.active { color: var(--accent); background: var(--accent-light); }
.nav-right { margin-left: auto; display: flex; align-items: center; }
.nav-hamburger { display: none; flex-direction: column; justify-content: center; gap: 5px; background: none; border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; padding: 0.45rem 0.5rem; }
.nav-hamburger span { display: block; width: 20px; height: 2px; background: var(--text-soft); border-radius: 2px; transition: all 0.22s; transform-origin: center; }
.navbar.nav-open .nav-hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.navbar.nav-open .nav-hamburger span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.navbar.nav-open .nav-hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Layout ──────────────────────────────────── */
.container { max-width: 740px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-header h1 { font-size: 1.8rem; font-weight: 900; letter-spacing: -0.03em; color: var(--text); }

h2 { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 2rem 0 0.75rem; }

/* ── Cards ───────────────────────────────────── */
.form-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.6rem 1.25rem; border-radius: var(--radius-sm);
  border: 1.5px solid transparent; font-family: 'Nunito', sans-serif;
  font-size: 0.9rem; font-weight: 700; cursor: pointer;
  transition: all 0.15s; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(42,157,143,0.25); }

.btn-secondary { background: var(--surface-alt); color: var(--text); border-color: var(--border-med); }
.btn-secondary:hover { background: var(--border); }

.btn-ghost { background: transparent; color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border-med); }

.btn-danger { background: var(--danger-light); color: var(--danger); border-color: rgba(217,83,79,0.22); }
.btn-danger:hover { background: rgba(217,83,79,0.14); border-color: rgba(217,83,79,0.4); }

.btn-success { background: var(--success-light); color: var(--success); border-color: rgba(74,158,107,0.3); }
.btn-success:hover { background: rgba(74,158,107,0.18); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }

/* ── Forms ───────────────────────────────────── */
.form-row { display: flex; gap: 0.75rem; align-items: flex-end; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 0.4rem; flex: 1; min-width: 120px; }
.form-group-shrink { flex: 0 0 auto; }

label { font-size: 0.78rem; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.05em; }

input[type="text"], input[type="number"], input[type="date"],
input[type="password"], select, textarea {
  width: 100%; background: var(--surface-alt);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 0.65rem 0.9rem;
  font-size: 0.92rem; font-family: 'Nunito', sans-serif;
  font-weight: 600; outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42,157,143,0.13);
  background: var(--surface);
}
input::placeholder, textarea::placeholder { color: var(--muted); font-weight: 500; }
select { cursor: pointer; }
textarea { resize: vertical; }

/* ── Stats Grid ──────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 0.875rem; margin-bottom: 0.5rem;
}
.stat-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 0.35rem; text-decoration: none; cursor: pointer;
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.18s;
  box-shadow: var(--shadow-sm);
}
.stat-card:hover { box-shadow: var(--shadow); border-color: var(--accent); transform: translateY(-2px); }
.stat-icon { font-size: 1.5rem; line-height: 1; }
.stat-value { font-size: 2.1rem; font-weight: 900; color: var(--accent); line-height: 1.1; letter-spacing: -0.04em; }
.stat-value-sm { font-size: 1.4rem !important; }
.stat-label { font-size: 0.75rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-sub { font-size: 0.72rem; font-weight: 700; color: var(--danger); background: var(--danger-light); padding: 0.15rem 0.5rem; border-radius: 20px; }

/* ── List Items ──────────────────────────────── */
.list-item {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 0.875rem 1.1rem;
  margin-bottom: 0.5rem; display: flex; align-items: center;
  gap: 0.875rem; box-shadow: var(--shadow-sm); transition: box-shadow 0.15s, border-color 0.15s;
}
.list-item:hover { box-shadow: var(--shadow); }
.list-item.erledigt { opacity: 0.5; }
.list-item.erledigt .item-name { text-decoration: line-through; }

.item-name { flex: 1; font-size: 0.95rem; font-weight: 700; color: var(--text); }
.item-meta { font-size: 0.77rem; color: var(--muted); font-weight: 600; margin-top: 0.15rem; }
.item-badge {
  font-size: 0.72rem; font-weight: 700; white-space: nowrap;
  background: var(--accent-light); color: var(--accent);
  padding: 0.2rem 0.6rem; border-radius: 20px;
}

/* ── Custom Checkbox ─────────────────────────── */
.check-wrap { flex-shrink: 0; }
.custom-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border-med); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; flex-shrink: 0;
}
.custom-check:hover { border-color: var(--accent); }
.custom-check.checked { background: var(--accent); border-color: var(--accent); }
.custom-check.checked::after {
  content: ''; width: 6px; height: 10px;
  border: 2.5px solid white; border-top: none; border-left: none;
  transform: rotate(45deg) translateY(-1px); display: block;
}

/* ── Category Headers ────────────────────────── */
.kat-gruppe-header {
  font-size: 0.75rem; font-weight: 800; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); margin: 1rem 0 0.35rem;
  display: flex; align-items: center; gap: 0.4rem; padding: 0 0.25rem;
}

/* ── Filter Tabs ─────────────────────────────── */
.filter-tabs {
  display: flex; gap: 0; margin-bottom: 1.25rem;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.25rem; width: fit-content;
  box-shadow: var(--shadow-sm);
}
.filter-btn {
  padding: 0.4rem 1.1rem; border-radius: 7px; border: none;
  background: transparent; color: var(--muted);
  font-size: 0.875rem; font-weight: 700; cursor: pointer;
  transition: all 0.15s; font-family: 'Nunito', sans-serif;
}
.filter-btn.active { background: var(--accent); color: #fff; box-shadow: var(--shadow-sm); }
.filter-btn:hover:not(.active) { color: var(--text); background: var(--surface-alt); }

/* ── Ausgaben Betrag ─────────────────────────── */
.ausgabe-betrag { font-size: 1rem; font-weight: 900; color: var(--text); letter-spacing: -0.02em; white-space: nowrap; }

/* ── Notiz Cards ─────────────────────────────── */
.notiz-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 1rem 1.1rem;
  margin-bottom: 0.5rem; cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s; box-shadow: var(--shadow-sm);
}
.notiz-card:hover { box-shadow: var(--shadow); border-color: var(--border-med); }
.notiz-card.expanded { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(42,157,143,0.1), var(--shadow); }
.notiz-titel { font-weight: 800; font-size: 0.95rem; color: var(--text); }
.notiz-vorschau { font-size: 0.83rem; color: var(--muted); margin-top: 0.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.notiz-inhalt { font-size: 0.875rem; color: var(--text-soft); margin-top: 0.45rem; white-space: pre-wrap; line-height: 1.55; font-weight: 600; }
.notiz-datum { font-size: 0.72rem; color: var(--muted); margin-top: 0.5rem; font-weight: 700; }
.notiz-edit-area { width: 100%; margin-top: 0.4rem; min-height: 80px; resize: vertical; }

/* ── States ──────────────────────────────────── */
.empty-state {
  text-align: center; color: var(--muted); padding: 3rem 1rem;
  font-size: 0.9rem; font-weight: 700; background: var(--surface);
  border: 1.5px dashed var(--border); border-radius: var(--radius);
}
.loading-state { text-align: center; color: var(--muted); padding: 3rem 1rem; font-size: 0.9rem; font-weight: 600; }

/* ── Login ───────────────────────────────────── */
body.auth-page {
  padding-top: 0; display: flex; justify-content: center;
  align-items: center; min-height: 100vh; padding: 1.5rem;
  background: var(--bg);
}
.auth-box {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.75rem 2.25rem;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; margin-bottom: 0.5rem; }
.auth-brand-text { font-size: 1.8rem; font-weight: 900; letter-spacing: -0.03em; color: var(--text); }
.auth-title { font-size: 0.95rem; font-weight: 600; text-align: center; margin-bottom: 1.75rem; color: var(--muted); }
.auth-fehler {
  background: var(--danger-light); border: 1.5px solid rgba(217,83,79,0.25);
  color: var(--danger); border-radius: var(--radius-sm); padding: 0.75rem 1rem;
  font-size: 0.85rem; font-weight: 700; margin-bottom: 1.25rem; display: none;
}

/* ── Animations ──────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.28s ease both; }

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .nav-hamburger { display: flex; margin-left: auto; }
  .nav-links {
    display: none; position: fixed; top: 56px; left: 0; right: 0;
    background: var(--surface); border-bottom: 1.5px solid var(--border);
    flex-direction: column; padding: 0.625rem 1rem 1rem; gap: 0.2rem;
    z-index: 99; box-shadow: var(--shadow);
  }
  .navbar.nav-open .nav-links { display: flex; }
  .nav-link { padding: 0.8rem 1rem; font-size: 0.95rem; }
  .nav-right { display: none; }
  .tab { padding: 0.75rem 0.9rem; font-size: 0.85rem; }
  .tab-panel { padding: 1.25rem 1rem 3rem; }
  .section-title { font-size: 1.25rem; }
  .stats-grid { gap: 0.625rem; }
  .stat-value { font-size: 1.75rem; }
  .stat-value-sm { font-size: 1.2rem !important; }
  .form-row { flex-direction: column; }
  #aus-summen { grid-template-columns: 1fr !important; }
  .auth-box { padding: 2rem 1.25rem; }
}
