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

:root {
    /* Warme "Katzenmensch"-Palette: cremiger Hintergrund, Ingwerkatzen-Orange als Akzent */
    --bg: #fbf3ea;
    --panel: #fffdfa;
    --text: #3a2e28;
    --muted: #8a7668;
    --border: #ecdfd0;
    --primary: #e2703a;
    --primary-dark: #c85a28;
    --primary-soft: #fce8d8;
    --accent: #a9779c;
    --danger: #d1495b;
    --success: #6a9955;
    --input-bg: #ffffff;
    --radius: 18px;
    --radius-sm: 12px;
}

html[data-theme="dunkel"] {
    --bg: #241c17;
    --panel: #2f2620;
    --text: #f3e9df;
    --muted: #b3a196;
    --border: #453a31;
    --primary: #f0925a;
    --primary-dark: #f7b184;
    --primary-soft: #4a3626;
    --accent: #c79bb9;
    --danger: #f0808f;
    --success: #91c47a;
    --input-bg: #3a2f28;
}

html[data-theme="dunkel"] body { background: var(--bg); }
html[data-theme="dunkel"] input,
html[data-theme="dunkel"] select,
html[data-theme="dunkel"] textarea { background: var(--input-bg); color: var(--text); }
html[data-theme="dunkel"] .btn-secondary { background: #453a31; color: var(--primary-dark); }
html[data-theme="dunkel"] .flash-success { background: #2c3f22; color: #cdeab8; }
html[data-theme="dunkel"] .flash-error { background: #4a2228; color: #f8c9d0; }
html[data-theme="dunkel"] .suggestion-chip { background: #453a31; color: var(--primary-dark); }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    background-image:
        radial-gradient(circle at 92% 4%, var(--primary-soft) 0%, transparent 45%),
        radial-gradient(circle at 4% 96%, var(--primary-soft) 0%, transparent 40%);
    background-attachment: fixed;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

h1, h2 { font-family: 'Quicksand', 'Nunito', sans-serif; font-weight: 700; }
h1 { font-size: 1.75rem; margin: 0 0 20px; }
h2 { font-size: 1.18rem; margin: 0 0 14px; }

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

/* Topbar */
.topbar { background: var(--panel); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner {
    max-width: 1100px; margin: 0 auto; padding: 12px 20px;
    display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.brand { font-family: 'Quicksand', sans-serif; font-weight: 700; color: var(--text); font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.topbar nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); font-weight: 600; padding: 6px 0; border-bottom: 2px solid transparent; }
.topbar nav a.active, .topbar nav a:hover { color: var(--primary-dark); text-decoration: none; border-bottom-color: var(--primary); }
.user-menu { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 0.9rem; }

/* "Mehr"-Dropdown in der Navigation */
.nav-dropdown { position: relative; display: inline-block; }
.nav-dropdown summary {
    list-style: none; cursor: pointer; color: var(--muted); font-weight: 600; padding: 6px 0;
    border-bottom: 2px solid transparent; user-select: none;
}
.nav-dropdown summary::-webkit-details-marker { display: none; }
.nav-dropdown summary:hover, .nav-dropdown summary.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.nav-dropdown-menu {
    position: absolute; top: calc(100% + 10px); left: 0; background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: 0 8px 24px rgba(180,120,80,0.15); padding: 8px; z-index: 20;
    display: flex; flex-direction: column; min-width: 170px;
}
.nav-dropdown-menu a { color: var(--text); font-weight: 600; padding: 8px 10px; border-radius: 8px; font-size: 0.9rem; }
.nav-dropdown-menu a:hover, .nav-dropdown-menu a.active { background: var(--primary-soft); color: var(--primary-dark); text-decoration: none; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px;
    box-shadow: 0 2px 10px rgba(180, 120, 80, 0.06);
    position: relative; overflow: hidden;
}
.card::before {
    content: ''; position: absolute; top: -14px; right: 14px; width: 26px; height: 26px;
    background: var(--primary-soft); border-radius: 40% 60% 55% 45%; opacity: 0.7;
}
.card-label { color: var(--muted); font-size: 0.85rem; margin-bottom: 6px; }
.card-value { font-size: 1.6rem; font-weight: 800; font-family: 'Quicksand', sans-serif; }
.card-sub { color: var(--muted); font-size: 0.8rem; margin-top: 4px; }

/* Panels */
.panel {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
    margin-bottom: 20px; box-shadow: 0 2px 10px rgba(180, 120, 80, 0.05);
}
.panel-actions { display: flex; gap: 10px; margin: 16px 0 24px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

.geek-box {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white; border-radius: var(--radius); padding: 20px; margin-bottom: 24px;
    position: relative; overflow: hidden;
}
.geek-box::after {
    content: '🐾'; position: absolute; right: 16px; bottom: 8px; font-size: 3rem; opacity: 0.18;
    transform: rotate(-12deg);
}
.geek-box h2 { color: white; }
.geek-list { margin: 0; padding-left: 20px; line-height: 1.7; list-style: none; }
.geek-list li { position: relative; padding-left: 4px; margin-bottom: 4px; }
.geek-list li::before { content: '🐾'; position: absolute; left: -22px; font-size: 0.85em; opacity: 0.85; }
.geek-list strong { font-weight: 800; }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.table th { color: var(--muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.table tr:hover td { background: rgba(226, 112, 58, 0.04); }
.details-table th { text-transform: none; font-size: 0.88rem; width: 40%; color: var(--text); font-weight: 700; }

.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; color: white; font-size: 0.78rem; font-weight: 700; }

/* Forms */
form label { display: block; margin-bottom: 14px; font-size: 0.88rem; font-weight: 700; color: var(--text); }
input, select, textarea {
    display: block; width: 100%; margin-top: 6px; padding: 10px 13px;
    border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 0.95rem; font-family: inherit;
    background: var(--input-bg); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(226, 112, 58, 0.15); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 4px 20px; }
.form-actions { display: flex; gap: 10px; margin-top: 10px; }

button, .btn-secondary, .btn-danger, .btn-danger-outline {
    display: inline-block; padding: 10px 20px; border-radius: 999px; font-size: 0.92rem; font-weight: 700;
    border: 1.5px solid transparent; cursor: pointer; text-align: center; font-family: inherit;
}
button, button[type="submit"] { background: var(--primary); color: white; }
button:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: var(--primary-soft); color: var(--primary-dark); }
.btn-secondary:hover { background: #f6d5b8; text-decoration: none; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger-outline { background: transparent; color: var(--danger); border-color: var(--danger); }

/* Filter bar */
.filter-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filter-bar input, .filter-bar select { width: auto; margin-top: 0; min-width: 160px; }

/* Auth */
.auth-box {
    max-width: 400px; margin: 60px auto; background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 32px; box-shadow: 0 8px 30px rgba(180, 120, 80, 0.1);
    text-align: center;
}
.auth-box h1 { font-size: 1.4rem; }
.auth-box::before {
    content: '🐱'; display: block; font-size: 2.4rem; margin-bottom: 6px;
}
.auth-box form, .auth-box p { text-align: left; }

/* Flash */
.flash { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.9rem; }
.flash-success { background: #e3f0dc; color: #3d5c2e; }
.flash-error { background: #fbe2e5; color: #832634; }

/* Detail */
.detail-header { display: flex; align-items: center; gap: 14px; }
.farb-dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--panel); box-shadow: 0 0 0 1px var(--border); }
.doc-list { list-style: none; padding: 0; margin: 0 0 14px; }
.doc-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.doc-list li form { margin: 0; }
.doc-list li button.remove-feld { padding: 4px 10px; }

.anbieter-link-chip {
    display: inline-flex; align-items: center; gap: 4px; background: var(--primary-soft); color: var(--primary-dark);
    padding: 5px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 700; margin: 6px 0 16px;
}
.anbieter-link-chip:hover { background: #f6d5b8; text-decoration: none; }

/* Tags */
.tag-list { margin: 4px 0 16px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag-chip { display: inline-block; padding: 3px 12px; border-radius: 999px; color: white; font-size: 0.78rem; font-weight: 700; }
.tag-chip.small { padding: 2px 9px; font-size: 0.72rem; margin: 1px; }

/* Budget-Ampel */
.budget-box { border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; border: 1px solid var(--border); }
.budget-box.budget-ok { background: rgba(106,153,85,0.1); }
.budget-box.budget-warnung { background: rgba(224,153,51,0.12); }
.budget-box.budget-ueberschritten { background: rgba(209,73,91,0.1); }
.budget-info { margin-bottom: 8px; font-size: 0.92rem; }
.budget-bar { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.budget-bar-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.3s; }
.budget-box.budget-warnung .budget-bar-fill { background: #d9971f; }
.budget-box.budget-ueberschritten .budget-bar-fill { background: var(--danger); }

/* Aktivitätsprotokoll */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-list li { display: flex; align-items: baseline; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.activity-icon { font-size: 1rem; }
.activity-text { flex: 1; min-width: 200px; }
.activity-meta { white-space: nowrap; }

/* Copy-Feld (API-Key, Kalender-Link) */
.copy-field input { font-family: monospace; font-size: 0.82rem; background: var(--bg); cursor: pointer; }

/* Theme-Toggle */
.theme-toggle { background: transparent; border: 1.5px solid var(--border); padding: 6px 12px; font-size: 1rem; line-height: 1; border-radius: 999px; }
.theme-toggle:hover { background: var(--primary-soft); }

/* Prognose-Regler (stats.php) */
.prognose-controls { display: flex; gap: 24px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.prognose-controls label { font-size: 0.85rem; min-width: 220px; }
.prognose-controls input[type="range"] { width: 100%; margin-top: 8px; accent-color: var(--primary); }
.prognose-value { font-weight: 700; color: var(--primary-dark); }

/* Freigaben */
.checkbox-label { display: flex; align-items: center; font-weight: 600; margin-bottom: 16px; }
details { margin: 10px 0; }
details summary { cursor: pointer; color: var(--primary-dark); font-weight: 700; font-size: 0.88rem; }
details[open] summary { margin-bottom: 8px; }

.umfang-radio { display: flex; gap: 20px; margin-bottom: 10px; }
.contract-checklist {
    background: var(--bg); border: 1px dashed var(--border); border-radius: var(--radius-sm);
    padding: 12px 16px; margin-bottom: 14px; max-height: 220px; overflow-y: auto;
}
.contract-checklist .checkbox-label { margin-bottom: 8px; font-weight: 500; }

/* Zusatzfelder (Formular) */
.zusatzfelder-block { margin: 20px 0; padding: 16px; background: var(--bg); border-radius: var(--radius-sm); border: 1px dashed var(--border); }
.zusatzfeld-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; margin-bottom: 8px; align-items: center; }
.zusatzfeld-row input { margin-top: 0; }
.remove-feld {
    background: transparent; border: none; color: var(--danger); font-size: 1.1rem; cursor: pointer;
    padding: 4px 8px; border-radius: 999px;
}
.remove-feld:hover { background: rgba(209,73,91,0.12); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.suggestion-chip {
    background: var(--primary-soft); color: var(--primary-dark); border: none; border-radius: 999px;
    padding: 5px 14px; font-size: 0.8rem; font-weight: 700; cursor: pointer; font-family: inherit;
}
.suggestion-chip:hover { background: #f6d5b8; }
#feld-hinzufuegen { margin-top: 4px; }

/* Sterne-Bewertung (reines CSS, keine JS-Logik nötig für die Anzeige) */
.star-rating-block { margin: 20px 0; }
.star-rating { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; font-size: 1.7rem; }
.star-rating input { display: none; }
.star-rating label { color: var(--border); cursor: pointer; margin: 0; padding: 0; transition: color 0.15s; }
.star-rating input:checked ~ label,
.star-rating label:hover,
.star-rating label:hover ~ label { color: #f0a83c; }
.small-btn { padding: 5px 14px; font-size: 0.8rem; margin-top: 6px; }
.stars-readonly { color: #f0a83c; letter-spacing: 1px; }
.stars-readonly .stern-leer { color: var(--border); }

/* Sparpotenzial / Alternativangebot */
.sparpotenzial-block { margin: 20px 0; padding: 16px; background: var(--bg); border-radius: var(--radius-sm); border: 1px dashed var(--border); }
.sparpotenzial-card {
    background: linear-gradient(135deg, #fef3e2, #fde3d0); border: 1px solid #f6d5b8; border-radius: var(--radius);
    padding: 18px; margin-bottom: 20px;
}
html[data-theme="dunkel"] .sparpotenzial-card { background: linear-gradient(135deg, #3a2e1c, #3f2a1c); border-color: #5a4530; }
.sparpotenzial-card h2 { color: var(--primary-dark); }
.sparpotenzial-highlight { font-size: 1.5rem; font-weight: 800; color: var(--primary-dark); font-family: 'Quicksand', sans-serif; }

/* Kündigungsschreiben */
.letter-paper {
    background: #fffefb; color: #1a1a1a; border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 40px 48px; max-width: 700px; margin: 0 auto 20px; box-shadow: 0 4px 18px rgba(0,0,0,0.06);
    font-family: 'Georgia', 'Times New Roman', serif; line-height: 1.6; min-height: 500px;
}
#letter-text { outline: none; white-space: pre-wrap; }
#letter-text:focus { background: rgba(226,112,58,0.03); }

@media print {
    .topbar, .no-print, h1, .flash { display: none !important; }
    body { background: white !important; }
    .container { padding: 0; max-width: none; }
    .letter-paper { box-shadow: none; border: none; margin: 0; max-width: none; }
}
