:root {
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --bg-input: #f9fafb;
    --text-main: #111827;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --info-bg: #eff6ff;
    --info-text: #1e40af;
    
    --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    --radius: 12px;
}

body.dark-mode {
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text-main: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    
    --primary: #60a5fa;
    --primary-hover: #3b82f6;
    --success: #34d399;
    --danger: #f87171;
    --danger-bg: #450a0a;
    --info-bg: #1e293b;
    --info-text: #93c5fd;
}

/* SCROLLBARS VERSTECKEN */
* { scrollbar-width: none; -ms-overflow-style: none; -webkit-tap-highlight-color: transparent; }
*::-webkit-scrollbar { display: none; }

html, body { height: 100%; margin: 0; padding: 0; overflow: hidden; }
body { font-family: 'Inter', sans-serif; background: var(--bg-body); color: var(--text-main); display: flex; flex-direction: column; }
#app { display: flex; flex-direction: column; height: 100%; }

/* --- HEADER & NAV --- */
.top-nav {
    flex-shrink: 0; background: var(--bg-card); border-bottom: 1px solid var(--border);
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
    padding: 12px 16px; box-shadow: var(--shadow-sm); z-index: 100; gap: 10px;
}
.nav-brand { display: flex; align-items: center; gap: 15px; flex: 1; }
.logo { font-weight: 800; font-size: 1.2rem; color: var(--primary); white-space: nowrap; }
.view-switch { display: flex; background: var(--bg-input); padding: 4px; border-radius: 8px; border: 1px solid var(--border); }
.nav-pill {
    background: transparent; border: none; padding: 6px 12px; border-radius: 6px; font-weight: 600; 
    font-size: 0.85rem; color: var(--text-secondary); transition: all 0.2s; white-space: nowrap; cursor: pointer;
}
.nav-pill.active { background: var(--bg-card); color: var(--text-main); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

.nav-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-group { display: flex; align-items: center; gap: 6px; background: var(--bg-card); padding: 4px; border-radius: 8px; }

/* --- LAYOUT & GRID --- */
.content-area { flex: 1; overflow-y: auto; padding: 16px; width: 100%; box-sizing: border-box; max-width: 1600px; margin: 0 auto; -webkit-overflow-scrolling: touch; }
/* Grid wechselt auf Mobile zu 1 Spalte */
.grid-layout { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 20px; padding-bottom: 80px; }
.col-left, .col-right { display: flex; flex-direction: column; gap: 20px; }

/* --- CARDS & LISTS --- */
.card { background: var(--bg-card); border-radius: var(--radius); box-shadow: var(--shadow-md); border: 1px solid var(--border); overflow: hidden; display: flex; flex-direction: column; }
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.card-header h3 { margin: 0; font-size: 1rem; font-weight: 700; white-space: nowrap; }

.list-container { flex: 1; min-height: 50px; }

.list-item { 
    padding: 14px 16px; 
    border-bottom: 1px solid var(--border); 
    display: flex; flex-direction: column; gap: 10px;
    border-left: 4px solid transparent; transition: background 0.2s;
    /* Touch Optimierung */
    cursor: pointer;
}
.list-item:active { background: var(--bg-input); } /* Feedback beim Antippen */

.list-item.paid-entry { border-left-color: var(--success); background: rgba(16, 185, 129, 0.05); }
.list-item.income-row, .list-item.settings-item { flex-direction: row; align-items: center; justify-content: space-between; }

/* Header & Body in List Items */
.item-header { display: flex; justify-content: space-between; align-items: center; width: 100%; }
.item-header > div:first-child { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-right: 10px; overflow: hidden; }
/* Größere Checkbox für Touch */
.item-header input[type="checkbox"] { width: 24px; height: 24px; cursor: pointer; margin: 0; flex-shrink: 0; border-radius: 4px; }

.item-body { display: flex; justify-content: space-between; align-items: center; width: 100%; gap: 15px; }
.item-body-info { flex: 1; min-width: 0; }

.list-footer { padding: 14px 16px; background: var(--bg-input); border-top: 1px solid var(--border); font-weight: 600; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }

.info-banner { font-size: 0.85rem; color: var(--info-text); background: var(--info-bg); padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* --- CONTROLS & INPUTS --- */
.progress-container { height: 6px; width: 100%; background: var(--bg-input); border-radius: 3px; overflow: hidden; border: 1px solid var(--border); margin-top: 4px; }
.progress-fill { height: 100%; background: var(--primary); transition: width 0.3s; }
.progress-fill.full { background: var(--success); }

/* Größere Touch-Ziele für Inputs */
.distribute-group { display: flex; align-items: center; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--bg-card); height: 40px; flex-shrink: 0; }
.distribute-group input { border: none; background: transparent; padding: 0 8px; text-align: center; width: 70px; font-weight: bold; height: 100%; border-radius: 0; font-size: 16px; }
.distribute-group button { border: none; border-left: 1px solid var(--border); height: 100%; padding: 0 16px; border-radius: 0; background: transparent; color: var(--primary); font-size: 1.2rem; }

.action-bar { margin-bottom: 20px; }
/* Buttons höher für Touch */
.btn { padding: 12px 20px; border-radius: 10px; font-weight: 600; border: none; font-size: 0.95rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; min-height: 32px; } /* Kleine Buttons bleiben klein */
.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-main); }
.full-width { width: 100%; }

.icon-btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 8px; font-size: 1.2rem; color: var(--text-secondary); border: 1px solid transparent; }

/* Schriftgröße 16px verhindert iOS Zoom */
input, select { background: var(--bg-input); border: 1px solid var(--border); color: var(--text-main); padding: 12px; border-radius: 8px; width: 100%; box-sizing: border-box; outline: none; font-size: 16px; }

/* --- SUMMARY & POCKETS --- */
.summary-card { background: var(--bg-card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-md); border: 1px solid var(--border); display: flex; flex-wrap: wrap; justify-content: space-around; margin-bottom: 20px; gap: 15px; }
.summary-item { min-width: 90px; text-align: center; }
.summary-item .label { font-size: 0.7rem; color: var(--text-secondary); display: block; margin-bottom: 4px; }
.summary-item .value { font-size: 1.4rem; font-weight: 700; }
.value.success { color: var(--success); }
.value.danger { color: var(--danger); }
.summary-divider { width: 1px; height: 40px; background: var(--border); }

.pockets-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; padding: 16px; }
.pocket-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: 12px; padding: 16px; text-align: center; }
.pocket-bal { font-size: 1.2rem; font-weight: 700; color: var(--text-main); margin-top: 6px; }

/* Helpers */
.badge { font-size: 0.7rem; padding: 3px 8px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; color: var(--text-secondary); white-space: nowrap; }
.badge-purple { background: rgba(187, 134, 252, 0.1); color: #bb86fc; border-color: #bb86fc; }
.badge-income { background: rgba(59, 130, 246, 0.1); color: var(--primary); border-color: var(--primary); }
.status-missing { color: var(--danger); font-weight: 600; font-size: 0.85rem; }
.status-ok { color: var(--success); font-weight: 600; font-size: 0.85rem; }

/* --- MOBILE SPECIFIC MEDIA QUERY --- */
@media (max-width: 900px) {
    .grid-layout { grid-template-columns: 1fr; } /* Alles untereinander */
    .top-nav { flex-direction: column; align-items: stretch; gap: 15px; padding: 15px; }
    .nav-brand { justify-content: space-between; width: 100%; }
    .nav-toolbar { justify-content: space-between; width: 100%; }
    .toolbar-group { flex: 1; justify-content: center; }
    .desktop-only { display: none; }
    
    .modal-box { width: 95%; max-width: none; bottom: 20px; border-radius: 20px; }
    
    .summary-item .value { font-size: 1.2rem; }
    .list-item { padding: 16px; } /* Mehr Platz für Finger */
}

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 3000; justify-content: center; align-items: center; display: flex; backdrop-filter: blur(3px); }
.modal-box { background: var(--bg-card); padding: 24px; border-radius: 16px; width: 420px; max-width: 90%; box-shadow: var(--shadow-md); border: 1px solid var(--border); }
.modal-body { display: flex; flex-direction: column; gap: 15px; margin: 20px 0; max-height: 60vh; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; }
.modal-footer button { flex: 1; } /* Auf Mobile Buttons breiter machen */

/* Login */
.login-wrapper { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-body); z-index: 2000; justify-content: center; align-items: center; padding: 20px; box-sizing: border-box; }
.login-box { width: 100%; max-width: 350px; text-align: center; }

#context-menu { position: absolute; background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-md); display: none; overflow: hidden; z-index: 4000; }
#context-menu div { padding: 12px 20px; cursor: pointer; font-size: 1rem; }