/* Finanzen Moser-AI — Mobile-First, LifeOS Design Language
 * Glassmorphism, Lexend, Cool-Gray + Gruener Accent (Geld-konnotation, sanft)
 * Single Source of Truth — kein Inline-CSS in index.html
 */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #16181c;
  --surface: #1a1d22;
  --surface2: #21252b;
  --surface3: #1a1d22;
  --border: #2d3139;
  --border-strong: #3a3f48;
  --text: #e0e4ea;
  --text-secondary: #8a90a0;
  --text-muted: #5a6070;
  --accent: #46a758;
  --accent-dark: #3b8f4b;
  --accent-light: rgba(70,167,88,0.14);
  --accent-bg: rgba(70,167,88,0.06);
  --warm: #f0a83a;
  --blue: #3b82f6;
  --red: #e5484d;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.15);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.12);
  --shadow: 0 2px 8px rgba(0,0,0,0.25), 0 1px 3px rgba(0,0,0,0.15);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.15);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.35), 0 4px 8px rgba(0,0,0,0.15);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  height: 100%;
  overscroll-behavior: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Lexend", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: env(safe-area-inset-bottom);
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); text-decoration: none; }

/* ── PIN Screen ── */

#pin-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999;
  padding: 20px;
}

#pin-screen.hidden { display: none; }

.pin-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  width: 100%; max-width: 380px;
  text-align: center;
  backdrop-filter: blur(20px);
}

.pin-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.5px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(70,167,88,0.4);
}

.pin-card h1 {
  font-size: 22px; font-weight: 600;
  margin-bottom: 6px;
}

.pin-card p {
  color: var(--text-muted); font-size: 13px;
  margin-bottom: 28px;
}

.pin-input {
  width: 100%;
  font-size: 28px; letter-spacing: 12px;
  text-align: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-family: inherit;
}

.pin-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.pin-error {
  color: var(--red);
  font-size: 13px;
  min-height: 20px;
  margin-bottom: 12px;
}

/* ── App Shell ── */

#app.app-hidden { display: none; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  padding-top: calc(14px + env(safe-area-inset-top));
}

.topbar-title { display: flex; align-items: center; gap: 10px; }

.topbar-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-weight: 700; font-size: 13px;
  box-shadow: 0 2px 6px rgba(70,167,88,0.35);
}

.topbar-name { font-size: 16px; font-weight: 600; }

.topbar-date { color: var(--text-muted); font-size: 12px; }

/* Tabs */

.tabs {
  display: flex; gap: 6px;
  padding: 12px;
  overflow-x: auto;
  background: var(--bg);
  position: sticky; top: 60px; z-index: 90;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  transition: all var(--transition);
}

.tab:active { transform: scale(0.97); }

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(70,167,88,0.35);
}

/* Content */

.content { padding: 16px 14px 80px; max-width: 720px; margin: 0 auto; }

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn 0.2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: 18px 0 10px;
}
.panel-title:first-child { margin-top: 4px; }

/* Stat Grid */

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 14px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
  display: flex; align-items: baseline; gap: 4px;
  word-break: break-word;
}

.stat-unit {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Coach Box (sanfter Ton) */

.coach-box {
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 14px;
  box-shadow: var(--shadow-sm);
}

#coach-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 14px;
  white-space: pre-wrap;
}

.row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Forms */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-sm);
}

.form-grid label {
  display: flex; flex-direction: column;
  gap: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  font-weight: 500;
}

.form-grid label.full { grid-column: 1 / -1; }

.form-grid input,
.form-grid textarea,
.form-grid select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  transition: border-color var(--transition);
}

.form-grid input:focus,
.form-grid textarea:focus,
.form-grid select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.form-grid textarea { resize: vertical; }

.form-actions {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.form-hint { color: var(--text-muted); font-size: 11px; }

/* Buttons */

.btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
  display: inline-block;
}

.btn:active { transform: scale(0.97); }

.btn:hover { border-color: var(--border-strong); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(70,167,88,0.35);
}

.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* Entry List */

.entry-list {
  display: flex; flex-direction: column; gap: 8px;
}

.entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-xs);
}

.entry-main { flex: 1; min-width: 0; }

.entry-line1 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}

.entry-line2 {
  font-size: 12px;
  color: var(--text-muted);
}

.entry-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.entry-amount.expense { color: var(--warm); }
.entry-amount.income { color: var(--accent); }

.entry-badge {
  display: inline-block;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.entry-badge.warm { background: rgba(240,168,58,0.15); color: var(--warm); }
.entry-badge.blue { background: rgba(59,130,246,0.15); color: var(--blue); }
.entry-badge.muted { background: var(--surface2); color: var(--text-muted); }

.entry-actions { display: flex; gap: 6px; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px; height: 30px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all var(--transition);
}

.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Filter Row */

.filter-row {
  display: flex; gap: 6px;
  margin-bottom: 14px;
  overflow-x: auto;
  scrollbar-width: none;
}
.filter-row::-webkit-scrollbar { display: none; }

.filter-btn {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Goal progress */

.goal-progress {
  height: 6px;
  background: var(--surface2);
  border-radius: 999px;
  margin-top: 8px;
  overflow: hidden;
}

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

/* Toast */

.toast {
  position: fixed;
  left: 50%; bottom: 20px;
  transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 200;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: var(--accent); color: var(--accent); }
.toast.error { border-color: var(--red); color: var(--red); }

/* Empty state */

.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 16px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* ── Mobile Tweaks ── */

@media (max-width: 380px) {
  .stat-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 20px; }
}

@media (min-width: 720px) {
  .form-grid { grid-template-columns: repeat(3, 1fr); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
}


/* FINANZEN_COACH_CSS_V1 */
.coach-intro {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
  margin-bottom: 18px;
  max-width: 640px;
}

.quick-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.quick-card {
  background: var(--surface, #1a1d22);
  border: 1px solid var(--border, #2d3139);
  border-radius: 14px;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
  text-align: left;
  color: var(--text, #e0e4ea);
  font-family: inherit;
  transition: transform 0.12s ease, border-color 0.15s ease, background 0.15s ease;
  min-height: 92px;
}

.quick-card:hover {
  border-color: var(--accent, #e5484d);
  transform: translateY(-1px);
}

.quick-card.active {
  border-color: var(--accent, #e5484d);
  background: var(--accent-bg, rgba(229,72,77,0.06));
}

.quick-icon {
  font-size: 20px;
  font-weight: 600;
  color: var(--accent, #e5484d);
  letter-spacing: 1px;
}

.quick-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
}

.quick-sub {
  font-size: 12px;
  color: var(--text-secondary, #8a90a0);
}

@media (min-width: 720px) {
  .quick-cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.ask-box {
  background: var(--surface, #1a1d22);
  border: 1px solid var(--border, #2d3139);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ask-label {
  font-size: 13px;
  color: var(--text-secondary, #8a90a0);
  font-weight: 500;
}

.ask-box textarea {
  width: 100%;
  background: var(--bg, #16181c);
  border: 1px solid var(--border, #2d3139);
  border-radius: 10px;
  color: var(--text, #e0e4ea);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.45;
  resize: vertical;
  min-height: 70px;
}

.ask-box textarea:focus {
  outline: none;
  border-color: var(--accent, #e5484d);
}

.answer-box {
  background: var(--surface2, #21252b);
  border: 1px solid var(--border, #2d3139);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 18px;
}

.answer-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.answer-tag {
  display: inline-block;
  background: var(--accent-bg, rgba(229,72,77,0.06));
  color: var(--accent, #e5484d);
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 500;
}

.answer-rag {
  font-size: 12px;
  color: var(--text-muted, #5a6070);
}

.answer-text {
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text, #e0e4ea);
}

.answer-sources {
  margin-top: 12px;
  font-size: 13px;
}

.answer-sources summary {
  cursor: pointer;
  color: var(--text-secondary, #8a90a0);
  user-select: none;
}

.source-item {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg, #16181c);
  border-radius: 8px;
  border-left: 3px solid var(--accent, #e5484d);
}

.source-file {
  font-size: 11px;
  color: var(--text-muted, #5a6070);
  margin-bottom: 4px;
  font-family: monospace;
  word-break: break-all;
}

.source-snippet {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary, #8a90a0);
  white-space: pre-wrap;
}

.qa-q {
  font-weight: 500;
  margin-bottom: 6px;
}

.qa-a {
  font-size: 13px;
  color: var(--text-secondary, #8a90a0);
  line-height: 1.5;
  white-space: pre-wrap;
}

.hidden { display: none !important; }
/* /FINANZEN_COACH_CSS_V1 */
