* { margin:0; padding:0; box-sizing:border-box; }

:root {
  --bg-app: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
}

body {
  background: var(--bg-app);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
  color: var(--text-main);
  min-height: 100vh;
}

.app {
  max-width: 600px;
  margin: 0 auto;
  padding: 20px;
  padding-top: calc(env(safe-area-inset-top, 20px) + 10px); /* Weniger Padding oben für Handy */
  padding-bottom: 100px;
}

/* Header - Optimiert für Handy (nicht gequetscht) */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap; /* Erlaubt Umbruch auf sehr kleinen Screens */
  gap: 10px;
}

.header-title h1 {
  font-size: 1.2rem;
  font-weight: 700;
  white-space: nowrap;
}

.back-btn, .icon-btn {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.header-actions { display: flex; gap: 8px; }

/* Period Selector */
.period-selector {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  margin-bottom: 20px;
  font-weight: 600;
  font-size: 1rem;
  background: var(--bg-card);
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
}
.period-selector button {
  background: none; border: none; color: var(--text-main);
  font-size: 1.4rem; cursor: pointer; padding: 0 10px;
}
.period-end {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.9em;
  opacity: 0.7;
}

/* KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--bg-card);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.05);
  display: flex; flex-direction: column;
}
.kpi-label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; }
.kpi-value { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.kpi-card.income .kpi-value { color: var(--success); }
.kpi-card.expense .kpi-value { color: var(--danger); }

/* Header */
.piggy-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

/* Icon */
.piggy-icon {
  font-size: 2.4rem;
  color: #2A1D06; /* dunkler als Text für Gewicht */
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.35));
}

/* Textbereich */
.piggy-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

/* Label */
.piggy-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color:#F6E7B2;
}

/* Hauptwert */
.piggy-value {
  font-size: 1.85rem;
  font-weight: 800;
  color: #887a63;
  text-shadow: 0 1px 0 rgba(27, 25, 25, 0.22);
}

/* Details */
.piggy-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  background: rgba(0,0,0,0.16);
  padding: 8px 12px;
  border-radius: 12px;
  color: #F6E7B2;
}

/* Trend */
.piggy-trend {
  font-weight: 600;
}

/* Button im Piggy-Card */
.piggy-card .icon-btn {
  background: linear-gradient(135deg,
    rgba(255,255,255,0.3),
    rgba(255,255,255,0.12)
  );
  border: none;
  color: #1A1204;
  border-radius: 10px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.35),
    0 2px 6px rgba(0,0,0,0.22);
}


/* Budget & Ledger */
.card {
  background: var(--bg-card); border-radius: 16px;
  padding: 16px; margin-bottom: 16px;
  border: 1px solid rgba(255,255,255,0.05);
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-header h2 { font-size: 0.9rem; color: var(--text-muted); text-transform: uppercase; }
.text-btn { background: none; border: none; color: var(--primary); cursor: pointer; font-size: 0.85rem; }

.budget-list { display: flex; flex-direction: column; gap: 12px; }
.budget-item { display: flex; flex-direction: column; gap: 4px; }
.b-meta { display: flex; justify-content: space-between; font-size: 0.8rem; }
.b-track { height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.b-fill { height: 100%; border-radius: 3px; }

.ledger-list { display: flex; flex-direction: column; gap: 0; }
.ledger-date-group { margin-bottom: 12px; }
.ledger-date-header {
  font-size: 0.75rem; color: var(--text-muted); margin-bottom: 6px;
  padding-left: 4px; border-left: 3px solid var(--primary);
}
.ledger-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
}
.l-cat { font-weight: 600; font-size: 0.9rem; }
.l-note { font-size: 0.75rem; color: var(--text-muted); }
.l-amount { font-weight: 700; font-size: 0.95rem; }
.l-amount.pos { color: var(--success); }
.l-amount.neg { color: var(--text-main); }

/* FAB */
.fab {
  position: fixed; bottom: 20px; right: 20px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); border: none; color: #fff;
  font-size: 2rem; box-shadow: 0 10px 25px rgba(59, 130, 246, 0.4);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px); display: none;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal {
  width: 90%; max-width: 380px; background: var(--bg-card);
  border-radius: 16px; padding: 20px; border: 1px solid rgba(255,255,255,0.1);
}
.modal.small { max-width: 300px; }
.modal-header { display: flex; justify-content: space-between; margin-bottom: 16px; }
.close-icon { background: none; border: none; color: var(--text-muted); font-size: 1.5rem; }

.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 4px; }
.input-wrapper {
  display: flex; align-items: center; background: var(--bg-input); border-radius: 8px;
}
.input-wrapper input { background: none; border: none; color: #fff; flex: 1; padding: 10px; font-size: 1rem; }
.currency { padding-right: 10px; color: var(--text-muted); }

input, select {
  width: 100%; padding: 10px; background: var(--bg-input);
  border: 1px solid transparent; border-radius: 8px; color: #fff; font-size: 1rem;
}
.segment-control { display: flex; background: var(--bg-input); padding: 4px; border-radius: 8px; }
.seg-btn {
  flex: 1; padding: 8px; border: none; background: transparent; color: var(--text-muted);
  border-radius: 6px; font-weight: 600; cursor: pointer;
}
.seg-btn.active { background: var(--bg-card); color: var(--text-main); }

.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn { flex: 1; padding: 12px; border-radius: 8px; border: none; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.secondary { background: var(--bg-input); color: var(--text-main); }
.btn.full { width: 100%; margin-top: 10px; }

.settings-list { max-height: 200px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.set-item { display: flex; gap: 8px; }
.small-btn { padding: 6px; border-radius: 6px; background: rgba(255,255,255,0.1); border:none; color:#fff; }