/* ==========================================================================
   Haushaltsbuch PWA - Ultra-Smooth Dark Organic Glassmorphism System
   ========================================================================== */

:root, [data-theme="pastel-lavender"] {
  /* Theme 1 (DEFAULT): Light Pastel Soft Lavender & Sky Blue */
  --bg-main: #f1f5f9;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-card-border: rgba(203, 213, 225, 0.6);
  --bg-input: #ffffff;
  --bg-header: rgba(241, 245, 249, 0.9);
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-success: #10b981;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;
  --accent-info: #0284c7;
  
  --radius-sm: 14px;
  --radius-md: 22px;
  --radius-lg: 32px;
  --radius-pill: 9999px;
  
  --shadow-sm: 0 4px 14px rgba(148, 163, 184, 0.2);
  --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.2);
  --shadow-lg: 0 20px 40px rgba(148, 163, 184, 0.35);

  /* Abgesetzte Flächen (Listeneinträge, Karten, eingeblendete Formulare) und
     Overlays. Diese Werte waren zuvor fest auf Dunkelblau verdrahtet und
     blieben deshalb in allen hellen Themes schwarz. */
  --bg-elevated: rgba(255, 255, 255, 0.72);
  --bg-elevated-strong: rgba(255, 255, 255, 0.94);
  --overlay-backdrop: rgba(100, 116, 139, 0.45);
  --overlay-border: rgba(15, 23, 42, 0.12);
  --container-shadow: 0 0 60px rgba(148, 163, 184, 0.35);

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --nav-height: 70px;
}

[data-theme="pastel-peach"] {
  /* Theme 2: Light Pastel Warm Peach & Sunset Rose */
  --bg-main: #fff7ed;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-border: rgba(254, 215, 170, 0.6);
  --bg-input: #ffffff;
  --bg-header: rgba(255, 247, 237, 0.9);
  
  --text-primary: #431407;
  --text-secondary: #7c2d12;
  --text-muted: #9a3412;
  
  --accent-primary: #ea580c;
  --accent-purple: #c026d3;
  --accent-pink: #e11d48;
  --accent-success: #16a34a;
  --accent-danger: #dc2626;
  --accent-warning: #d97706;
  --accent-info: #0284c7;
  
  --shadow-sm: 0 4px 14px rgba(251, 146, 60, 0.15);
  --shadow-glow: 0 0 25px rgba(249, 115, 22, 0.2);
  --shadow-lg: 0 20px 40px rgba(251, 146, 60, 0.25);
}

[data-theme="pastel-mint"] {
  /* Theme 3: Light Pastel Botanical Mint & Sage Green */
  --bg-main: #f0fdf4;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-border: rgba(187, 247, 208, 0.6);
  --bg-input: #ffffff;
  --bg-header: rgba(240, 253, 244, 0.9);
  
  --text-primary: #052e16;
  --text-secondary: #14532d;
  --text-muted: #166534;
  
  --accent-primary: #059669;
  --accent-purple: #7c3aed;
  --accent-pink: #db2777;
  --accent-success: #16a34a;
  --accent-danger: #dc2626;
  --accent-warning: #d97706;
  --accent-info: #0891b2;
  
  --shadow-sm: 0 4px 14px rgba(74, 222, 128, 0.15);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.2);
  --shadow-lg: 0 20px 40px rgba(74, 222, 128, 0.25);
}

[data-theme="cyber-midnight"] {
  /* Theme 4: Cyber-Glassmorphism Neon Midnight */
  --bg-main: #080c15;
  --bg-card: rgba(16, 23, 38, 0.68);
  --bg-card-border: rgba(255, 255, 255, 0.09);
  --bg-input: rgba(10, 15, 26, 0.75);
  --bg-header: rgba(8, 12, 21, 0.85);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --accent-primary: #6366f1;
  --accent-purple: #8b5cf6;
  --accent-pink: #ec4899;
  --accent-success: #10b981;
  --accent-danger: #ef4444;
  --accent-warning: #f59e0b;
  --accent-info: #06b6d4;
  
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.4);
  --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.7);

  --bg-elevated: rgba(10, 15, 26, 0.6);
  --bg-elevated-strong: rgba(16, 23, 38, 0.95);
  --overlay-backdrop: rgba(8, 12, 21, 0.92);
  --overlay-border: rgba(255, 255, 255, 0.15);
  --container-shadow: 0 0 60px rgba(0, 0, 0, 0.85);
}

[data-theme="obsidian-gold"] {
  /* Theme 5: Obsidian & Champagner Gold */
  --bg-main: #050508;
  --bg-card: rgba(18, 18, 24, 0.85);
  --bg-card-border: rgba(234, 179, 8, 0.25);
  --bg-input: rgba(10, 10, 14, 0.9);
  --bg-header: rgba(5, 5, 8, 0.9);
  
  --text-primary: #fef08a;
  --text-secondary: #eab308;
  --text-muted: #a1a1aa;
  
  --accent-primary: #eab308;
  --accent-purple: #d946ef;
  --accent-pink: #f43f5e;
  --accent-success: #10b981;
  --accent-danger: #f87171;
  --accent-warning: #fbbf24;
  --accent-info: #38bdf8;
  
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(234, 179, 8, 0.35);
  --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.9);

  --bg-elevated: rgba(18, 18, 24, 0.7);
  --bg-elevated-strong: rgba(24, 24, 32, 0.96);
  --overlay-backdrop: rgba(5, 5, 8, 0.93);
  --overlay-border: rgba(234, 179, 8, 0.25);
  --container-shadow: 0 0 60px rgba(0, 0, 0, 0.9);
}

[data-theme="pastel-purple"] {
  /* Theme 6: Light Pastel Purple Velvet & Soft Orchid */
  --bg-main: #faf5ff;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-border: rgba(233, 213, 255, 0.7);
  --bg-input: #ffffff;
  --bg-header: rgba(250, 245, 255, 0.9);
  
  --text-primary: #3b0764;
  --text-secondary: #6b21a8;
  --text-muted: #7e22ce;
  
  --accent-primary: #9333ea;
  --accent-purple: #c084fc;
  --accent-pink: #f43f5e;
  --accent-success: #16a34a;
  --accent-danger: #dc2626;
  --accent-warning: #d97706;
  --accent-info: #0284c7;
  
  --shadow-sm: 0 4px 14px rgba(192, 132, 252, 0.2);
  --shadow-glow: 0 0 25px rgba(147, 51, 234, 0.3);
  --shadow-lg: 0 20px 40px rgba(192, 132, 252, 0.3);
}

[data-theme="dark-purple"] {
  /* Theme 7: Dark Cyber Neon Purple & Amethyst Glass */
  --bg-main: #0f051d;
  --bg-card: rgba(26, 12, 46, 0.78);
  --bg-card-border: rgba(192, 132, 252, 0.25);
  --bg-input: rgba(18, 8, 33, 0.9);
  --bg-header: rgba(15, 5, 29, 0.9);
  
  --text-primary: #f3e8ff;
  --text-secondary: #d8b4fe;
  --text-muted: #a855f7;
  
  --accent-primary: #c084fc;
  --accent-purple: #e879f9;
  --accent-pink: #f43f5e;
  --accent-success: #34d399;
  --accent-danger: #f87171;
  --accent-warning: #fbbf24;
  --accent-info: #38bdf8;
  
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(192, 132, 252, 0.4);
  --shadow-lg: 0 25px 60px rgba(0, 0, 0, 0.85);

  --bg-elevated: rgba(18, 8, 33, 0.65);
  --bg-elevated-strong: rgba(26, 12, 46, 0.96);
  --overlay-backdrop: rgba(15, 5, 29, 0.93);
  --overlay-border: rgba(192, 132, 252, 0.25);
  --container-shadow: 0 0 60px rgba(0, 0, 0, 0.85);
}

[data-theme="pastel-mint-fresh"] {
  /* Theme 8: Light Pastel Fresh Mint */
  --bg-main: #f0fdf4;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-border: rgba(187, 247, 208, 0.7);
  --bg-input: #ffffff;
  --bg-header: rgba(240, 253, 244, 0.9);
  
  --text-primary: #064e3b;
  --text-secondary: #047857;
  --text-muted: #059669;
  
  --accent-primary: #10b981;
  --accent-purple: #34d399;
  --accent-pink: #f43f5e;
  --accent-success: #16a34a;
  --accent-danger: #dc2626;
  --accent-warning: #d97706;
  --accent-info: #059669;
  
  --shadow-sm: 0 4px 14px rgba(52, 211, 153, 0.2);
  --shadow-glow: 0 0 25px rgba(16, 185, 129, 0.3);
  --shadow-lg: 0 20px 40px rgba(52, 211, 153, 0.25);
}

[data-theme="pastel-turquoise"] {
  /* Theme 9: Light Pastel Ocean Turquoise */
  --bg-main: #ecfeff;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-border: rgba(165, 243, 252, 0.7);
  --bg-input: #ffffff;
  --bg-header: rgba(236, 254, 255, 0.9);
  
  --text-primary: #083344;
  --text-secondary: #0e7490;
  --text-muted: #06b6d4;
  
  --accent-primary: #06b6d4;
  --accent-purple: #22d3ee;
  --accent-pink: #f43f5e;
  --accent-success: #10b981;
  --accent-danger: #dc2626;
  --accent-warning: #d97706;
  --accent-info: #0891b2;
  
  --shadow-sm: 0 4px 14px rgba(34, 211, 238, 0.2);
  --shadow-glow: 0 0 25px rgba(6, 182, 212, 0.3);
  --shadow-lg: 0 20px 40px rgba(34, 211, 238, 0.25);
}

[data-theme="pastel-mint-turquoise"] {
  /* Theme 10: Light Pastel Tropical Mint & Turquoise Lagoon */
  --bg-main: #f0fdfa;
  --bg-card: rgba(255, 255, 255, 0.88);
  --bg-card-border: rgba(153, 246, 228, 0.7);
  --bg-input: #ffffff;
  --bg-header: rgba(240, 253, 250, 0.9);
  
  --text-primary: #042f2e;
  --text-secondary: #0f766e;
  --text-muted: #0d9488;
  
  --accent-primary: #14b8a6;
  --accent-purple: #2dd4bf;
  --accent-pink: #f43f5e;
  --accent-success: #10b981;
  --accent-danger: #dc2626;
  --accent-warning: #d97706;
  --accent-info: #06b6d4;
  
  --shadow-sm: 0 4px 14px rgba(45, 212, 191, 0.2);
  --shadow-glow: 0 0 25px rgba(20, 184, 166, 0.3);
  --shadow-lg: 0 20px 40px rgba(45, 212, 191, 0.25);
}

/* Reset & Base Styles */
* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

* {
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main);
  position: relative;
  box-shadow: var(--container-shadow);
  /* env(): Platz für den Home-Indikator moderner Smartphones. Das viewport-fit=cover
     im HTML lässt die Seite bis in die Geräteecken laufen - ohne diese Abstände
     verschwindet der untere Rand hinter der Systemleiste. */
  padding-bottom: calc(var(--nav-height) + 15px + env(safe-area-inset-bottom, 0px));
}

/* Unauthenticated State */
.app-container.not-authenticated {
  padding-bottom: 0;
}

.app-container.not-authenticated .app-header,
.app-container.not-authenticated .app-nav {
  display: none !important;
}

/* Header Styles - Curved Glass */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--bg-card-border);
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
  /* Oberer Abstand für Notch / Statusleiste bei viewport-fit=cover */
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 14px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.header-content h1 {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, #a5b4fc, #818cf8, #c084fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.user-sub-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.user-badge {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.sync-badge {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}

.sync-status-online {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.sync-status-offline {
  background: rgba(245, 158, 11, 0.18);
  color: var(--accent-warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.month-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--bg-card-border);
}

.month-selector button {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
}

.month-selector span {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

/* Main Content & Screens */
.app-main {
  flex: 1;
  padding: 16px;
}

.tab-screen {
  display: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-screen.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Ultra-Smooth Organic Card Component */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);

  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

.card-description {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Hero Budget Card - Organic Curved Gradient */
.hero-budget-card {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.22), rgba(139, 92, 246, 0.18), rgba(16, 185, 129, 0.12));
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-lg);
  text-align: center;
  padding: 28px 20px;
  box-shadow: 0 15px 35px rgba(99, 102, 241, 0.25);
}

.hero-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
}

.hero-amount {
  font-size: 2.4rem;
  font-weight: 800;
  color: #ffffff;
  margin: 8px 0;
  letter-spacing: -0.5px;
}

.hero-subtext {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-bottom: 14px;
}

.hero-subtext strong {
  color: var(--accent-success);
}

/* Zeitraum der Budgetperiode - nur sichtbar, wenn der Gehaltstag nicht der
   1. ist. Wird in updatePeriodHints zusaetzlich per display gesteuert. */
.hero-period {
  font-size: 0.78rem;
  color: var(--text-secondary);
  opacity: 0.85;
  margin-bottom: 10px;
}

/* "X pro Tag bis zum Gehalt" unter der Budgetleiste. */
.hero-daily {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 10px;
  /* Lange Betraege duerfen die Karte auf dem Handy nicht sprengen. */
  min-width: 0;
  overflow-wrap: anywhere;
}

.form-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.78rem;
  line-height: 1.4;
  color: var(--text-secondary);
  opacity: 0.85;
}

.progress-bar-container {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-success), var(--accent-primary));
  border-radius: var(--radius-pill);
  transition: width 0.4s ease;
}

/* Calculation Flow & Smooth Summary Cards */
.calculation-flow {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calc-summary-card {
  background: rgba(255, 255, 255, 0.03);
  border-left: 5px solid var(--accent-warning);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}

.calc-summary-card.highlight-blue {
  border-left-color: var(--accent-info);
  background: rgba(6, 182, 212, 0.07);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.92rem;
}

.summary-row strong {
  font-size: 1.15rem;
  color: var(--text-primary);
}

/* Smooth Pill Badges */
.badge {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-success { background: rgba(16, 185, 129, 0.18); color: var(--accent-success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-danger  { background: rgba(239, 68, 68, 0.18);  color: var(--accent-danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.18); color: var(--accent-warning); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-info    { background: rgba(6, 182, 212, 0.18);  color: var(--accent-info); border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-secondary{ background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); border: 1px solid rgba(148, 163, 184, 0.2); }

/* Form Controls & Inputs - Ultra Smooth Pill/Squircle Shapes */
.input-group-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.input-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Entscheidend gegen den Überlauf auf schmalen Displays:
   Flex-Elemente haben min-width:auto und schrumpfen deshalb nie unter ihre
   Mindestbreite. Ein <input> bringt über das size-Attribut rund 20 Zeichen
   Grundbreite mit - zwei davon plus Löschen-Schaltfläche passen auf einem
   Handy nicht nebeneinander, und die Zeile lief aus dem Rahmen. */
.input-row > * {
  min-width: 0;
}

.input-row label {
  font-size: 0.88rem;
  color: var(--text-secondary);
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Eingabefelder teilen sich den verfügbaren Platz, statt ihre Grundbreite
   durchzusetzen. Knapperer Innenabstand, damit auf 360 px Text sichtbar bleibt. */
.input-row input {
  flex: 1 1 0;
  width: auto;
  padding-left: 12px;
  padding-right: 12px;
}

/* Bezeichnung bekommt mehr Platz als der Betrag */
.input-row input[data-type$="-name"] { flex: 3 1 0; }
.input-row input[data-type$="-amount"] { flex: 2 1 0; }

.input-row .expense-delete-btn {
  flex: 0 0 auto;
  margin-left: 0;
}

/* Strikte & vollständige Ausblendung aller Browser-Spin-Pfeile in ALLEN Browsern */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  margin: 0 !important;
  opacity: 0 !important;
  display: none !important;
  pointer-events: none !important;
}

input[type="number"] {
  -webkit-appearance: textfield !important;
  -moz-appearance: textfield !important;
  appearance: textfield !important;
}

input[type="number"],
input[type="text"],
input[type="password"],
input[type="date"],
select {
  background: var(--bg-input);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.98rem;
  outline: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  min-height: 46px;
}

input[type="number"]:not(.input-row input),
input[type="text"]:not(.input-row input),
input[type="password"]:not(.input-row input),
select:not(.input-row select) {
  width: 100%;
}

input:focus, select:focus {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
  background: var(--bg-input);
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Zweispaltiges Formularraster, das auf schmalen Displays selbsttätig umbricht.
   Vorher stand hier ein festes 1fr 1fr. Grid-Elemente haben aber - genau wie
   Flex-Elemente - min-width:auto und schrumpfen nicht unter ihre Mindestbreite.
   Ein <input type="date"> bringt rund 170 px mit; die deklarierten gleichen
   Spalten lösten deshalb zu 134/170 auf, und das Betragsfeld wurde erdrückt.
   Auf iOS sind Datumsfelder noch breiter - dort lief die Zeile aus der Karte. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 12px;
}

.form-grid > * {
  min-width: 0;
}

.form-grid input,
.form-grid select {
  width: 100%;
  min-width: 0;
}

/* Input With Icon */
.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 16px;
  font-size: 1.15rem;
  pointer-events: none;
  opacity: 0.7;
}

.input-with-icon input {
  padding-left: 48px !important;
  border-radius: var(--radius-sm);
}

/* Buttons - Ultra Smooth Pill Shapes */
.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
  color: #ffffff;
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-primary:hover, .btn-primary:active {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.6);
}

.btn-lg {
  padding: 15px 24px;
  font-size: 1rem;
  border-radius: var(--radius-pill);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--bg-card-border);
  color: var(--text-secondary);
}

.btn-outline:active {
  background: rgba(255, 255, 255, 0.08);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.18);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.78rem;
  border-radius: var(--radius-pill);
}

.btn-block {
  width: 100%;
}

/* Expense List */
.expense-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.expense-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-card-border);
}

.expense-info h4 {
  font-size: 0.92rem;
  color: var(--text-primary);
}

.expense-info span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.expense-amount {
  font-weight: 700;
  color: var(--accent-danger);
  font-size: 0.98rem;
}

.expense-delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  margin-left: 10px;
  font-size: 1.1rem;
}

/* Sinking Funds & Spartöpfe Grids */
.sinking-funds-grid, .spartoepfe-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.pot-card {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

/* Ein-/ausblendbare Formulare (Rücklage, Spartopf).
   Vorher als Inline-Style mit fester Dunkelfarbe im HTML. */
.inline-form {
  display: none;
  background: var(--bg-elevated);
  padding: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  border: 1px solid var(--bg-card-border);
}

.inline-form.is-open { display: block; }

/* Aktionsleiste unterhalb einer Karte (z. B. Position hinzufügen / übertragen) */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.card-actions .btn { flex: 1 1 auto; }

/* Vollbild-Overlay der Live-Kamera */
.modal-overlay.is-open { display: flex; }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--overlay-backdrop);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  text-align: center;
  background: var(--bg-elevated-strong);
  border: 1px solid var(--overlay-border);
  box-shadow: var(--shadow-lg);
}

.modal-video-frame {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  margin: 12px 0;
  aspect-ratio: 4/3;
  border: 1px solid var(--bg-card-border);
}

.pot-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
}

.pot-header h4 {
  font-size: 0.92rem;
}

.pot-balance {
  font-weight: 700;
  color: var(--accent-success);
}

/* Bottom Navigation - Smooth Curved Bar */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  /* Leiste wächst um die Safe Area, damit die Schaltflächen nicht unter dem
     Home-Indikator liegen. */
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--bg-card-border);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 1000;
}

.nav-item {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.25s ease;
  padding: 6px 14px;
}

.nav-item .nav-icon {
  font-size: 1.35rem;
  margin-bottom: 2px;
}

.nav-item.active {
  color: var(--accent-primary);
}

.nav-item.active .nav-icon {
  transform: scale(1.15);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* OCR Camera Styles */
.ocr-preview {
  margin-top: 14px;
  text-align: center;
}

#ocr-canvas {
  max-width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--bg-card-border);
}

.ocr-status {
  font-size: 0.82rem;
  color: var(--accent-info);
  margin-top: 8px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  cursor: pointer;
}

/* Profile Card */
.profile-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.profile-info-row strong {
  color: var(--text-primary);
}

/* ==========================================================================
   ULTRA-SMOOTH CYBER-GLASSMORPHISM AUTH SCREEN & GLOWING AURA
   ========================================================================== */

.auth-wrapper {
  position: relative;
  min-height: 85vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 12px;
}

/* Ambient Glowing Orbs */
.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.6;
  pointer-events: none;
  animation: floatGlow 8s infinite alternate ease-in-out;
}

.auth-orb-1 {
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, var(--accent-primary), var(--accent-purple));
  top: 8%;
  left: 5%;
}

.auth-orb-2 {
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, var(--accent-info), var(--accent-success));
  bottom: 10%;
  right: 5%;
  animation-delay: -4s;
}

@keyframes floatGlow {
  0% {
    transform: translate(0, 0) scale(1);
  }
  100% {
    transform: translate(35px, -30px) scale(1.2);
  }
}

/* Auth Fullscreen Card - Super Smooth Squircle Shape */
.auth-fullscreen-card {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-lg);
  padding: 36px 28px;
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);

  animation: authCardScaleIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes authCardScaleIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(12px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.auth-brand-header {
  text-align: center;
  margin-bottom: 26px;
}

.auth-logo-badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 68px;
  height: 68px;
  border-radius: 24px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
  border: 1px solid var(--bg-card-border);
  box-shadow: var(--shadow-glow);
  margin-bottom: 14px;
  animation: logoFloat 4s infinite ease-in-out;
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

.auth-logo-icon {
  font-size: 2.3rem;
}

.auth-brand-header h2 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--accent-primary);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.auth-brand-header p {
  font-size: 0.86rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Smooth Pill Auth Tabs */
.auth-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-input);
  padding: 5px;
  border-radius: var(--radius-pill);
  margin-bottom: 24px;
  border: 1px solid var(--bg-card-border);
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 11px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-tab.active {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-purple));
  color: #ffffff;
  box-shadow: 0 4px 18px rgba(99, 102, 241, 0.45);
}

.auth-submit-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.btn-arrow {
  font-size: 1.2rem;
  transition: transform 0.2s ease;
}

.auth-submit-btn:hover .btn-arrow {
  transform: translateX(4px);
}

.auth-error {
  background: color-mix(in srgb, var(--accent-danger) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent-danger) 45%, transparent);
  color: var(--accent-danger);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  margin-bottom: 18px;
  text-align: center;
}

/* Hinweis statt Fehler (z. B. die Abmeldung nach Inaktivität).
   Die Textfarbe ist bewusst --text-primary und nicht die Warnfarbe: Zuvor
   standen hier fest verdrahtete Werte (#fef08a auf hellem Gelb), die im
   dunklen Theme funktionierten und in den hellen Themes nahezu unlesbar
   waren. Rahmen und Fläche tragen die Warnfarbe, der Text bleibt in jedem
   Theme kontrastreich. */
.auth-error.auth-notice {
  background: color-mix(in srgb, var(--accent-warning) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent-warning) 50%, transparent);
  color: var(--text-primary);
  font-weight: 500;
}

.auth-error.auth-erfolg {
  background: color-mix(in srgb, var(--accent-success) 16%, transparent);
  border-color: color-mix(in srgb, var(--accent-success) 50%, transparent);
  color: var(--text-primary);
  font-weight: 500;
}

.auth-footer-note {
  margin-top: 22px;
  font-size: 0.74rem;
  color: var(--text-muted);
  text-align: center;
}

/* ==========================================================================
   Anleitung (Setup-Tab)

   Bewusst auf <details>/<summary> aufgebaut: klappt ohne JavaScript, ist
   standardmässig zu und bleibt selbst dann bedienbar, wenn diese Datei aus
   einem alten Cache kommt - dann sieht es schlichter aus, funktioniert aber.
   ========================================================================== */
.help-item {
  border-top: 1px solid var(--bg-card-border);
}

.help-item:first-of-type {
  margin-top: 10px;
}

.help-item > summary {
  /* list-style entfernt den Standard-Pfeil; ::-webkit-details-marker für Safari */
  list-style: none;
  cursor: pointer;
  padding: 13px 28px 13px 2px;   /* rechts Platz für das Chevron */
  position: relative;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  min-height: 44px;              /* komfortable Tippfläche */
  display: flex;
  align-items: center;
}

.help-item > summary::-webkit-details-marker { display: none; }

.help-item > summary::after {
  content: '⌄';
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-60%);
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.help-item[open] > summary::after {
  transform: translateY(-30%) rotate(180deg);
}

.help-item[open] > summary {
  color: var(--accent-primary);
}

.help-item > *:not(summary) {
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.help-item p { margin: 0 0 9px; }
.help-item > *:last-child { margin-bottom: 13px; }

.help-item ol,
.help-item ul {
  margin: 0 0 9px;
  padding-left: 20px;
}

.help-item li { margin-bottom: 5px; }

.help-item strong { color: var(--text-primary); }

/* Rechenkette - abgesetzt, damit die Struktur sofort erkennbar ist */
.help-formula {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 10px;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.help-formula .help-result {
  color: var(--accent-primary);
  font-weight: 700;
}

/* Einschränkungen ehrlich benennen, ohne zu dominieren */
.help-note {
  border-left: 3px solid var(--accent-warning);
  padding-left: 10px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Rücklage, die im angezeigten Monat noch nicht gilt */
.pot-card-inaktiv {
  opacity: 0.55;
  border-style: dashed;
}

/* Erklärender Hinweis unter einem Eingabefeld */
.field-hint {
  display: block;
  margin-top: 5px;
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--text-muted);
}

/* Versionsnummer am Fuss der Einstellungen */
.app-version {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--bg-card-border);
  text-align: center;
  font-size: 0.76rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Spartopf-Badge in der Ausgabenliste & Aktions-Buttons */
.badge-pot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.pot-action-btn {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  color: var(--accent-primary);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pot-action-btn:hover {
  background: rgba(99, 102, 241, 0.25);
}


/* Uebersichtskarte fuer den Gesamt-Sparbestand ueber allen Toepfen. */
.spartoepfe-hero-card {
  background: var(--bg-elevated);
  border: 1.5px solid var(--accent-primary);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  margin-bottom: 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.spartoepfe-hero-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.spartoepfe-hero-amount {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-primary);
  line-height: 1.2;
  /* Lange Betraege duerfen die Karte auf dem Handy nicht sprengen. */
  overflow-wrap: anywhere;
}

.spartoepfe-hero-subtext {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ==========================================================================
   Offene Rechnungen & Smart Due Banner Styles
   ========================================================================== */

/* Dringendes Fälligkeits-Banner ganz oben im Dashboard */
.due-invoices-banner {
  background: rgba(239, 68, 68, 0.12);
  border: 1.5px solid var(--accent-danger);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  animation: fadeIn 0.3s ease;
}

.due-invoices-banner .banner-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.due-invoices-banner .banner-text {
  flex: 1;
}

.due-invoices-banner strong {
  color: var(--accent-danger);
}

/* Liste der Rechnungen */
.invoice-list-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Einzelne Rechnungs-Karte */
.invoice-card {
  background: var(--bg-elevated);
  border: 1px solid var(--bg-card-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.invoice-card:hover {
  border-color: rgba(99, 102, 241, 0.4);
}

.invoice-card-paid {
  opacity: 0.72;
  border-style: dashed;
  background: rgba(16, 185, 129, 0.05);
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.invoice-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.invoice-title {
  margin: 0;
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-word;
}

.invoice-category-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Fälligkeits-Ampel Badges */
.badge-due {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.badge-due-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.badge-due-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-due-ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-due-paid {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
  border: 1px solid rgba(100, 116, 139, 0.3);
}

/* Untere Zeile: Betrag & Aktions-Buttons */
.invoice-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.invoice-amount {
  font-size: 1.12rem;
  font-weight: 700;
  color: var(--text-primary);
}

.invoice-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Touch-optimierte Aktionsbuttons */
.invoice-pay-btn {
  background: linear-gradient(135deg, var(--accent-success), #059669);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 6px 12px;
  min-height: 38px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
  transition: transform 0.1s ease, filter 0.15s ease;
}

.invoice-pay-btn:active {
  transform: scale(0.96);
}

.invoice-cal-btn {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.28);
  color: var(--accent-primary);
  border-radius: var(--radius-pill);
  padding: 6px 10px;
  min-height: 38px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.invoice-cal-btn:active {
  background: rgba(99, 102, 241, 0.25);
  transform: scale(0.96);
}

.invoice-icon-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  min-height: 38px;
  min-width: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
  transition: opacity 0.15s ease;
}

.invoice-icon-btn:hover {
  opacity: 1;
}

.invoice-icon-btn.invoice-delete-btn {
  color: var(--accent-danger);
  font-size: 1.25rem;
}

.invoice-payment-options {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.invoice-payment-options summary {
  cursor: pointer;
}

.invoice-payment-options input {
  max-width: 100%;
  margin-top: 6px;
}
