/* ============================================================
   Familienplaner – Theme im Stil von "Invictus"
   Dunkle Anthrazit-Flächen, Invictus-Rot (#bd343e) als Akzent,
   PT Sans. Die Tailwind-Farbskalen (slate/blue/…) werden in
   finanzplaner.html per tailwind.config auf dunkle Werte gemappt;
   hier stehen die eigenen Komponenten + die wenigen Overrides,
   die sich über die Palette allein nicht lösen lassen.
   Overrides nutzen ":root .klasse", damit sie unabhängig von der
   Reihenfolge gegen die zur Laufzeit erzeugten Tailwind-Styles gewinnen.
   ============================================================ */

:root {
    color-scheme: dark;
    --primary: #bd343e;
    --primary-hover: #a02e36;
    --primary-text: #ec6f78;
    --page: #141416;
    --frame: #1c1c1e;
    --surface: #282b30;
    --surface-2: #2e3137;
    --inset: #1c1c1e;
    --line: #34373d;
    --text: #e4e5e8;
    --muted: #9a9fa7;
}

html { background-color: var(--page); }

body {
    font-family: 'PT Sans', Arial, Helvetica, sans-serif;
    background-color: var(--page);
    color: var(--text);
    -webkit-tap-highlight-color: transparent;
}

.app-overlay {
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(1200px 500px at 50% -200px, rgba(189, 52, 62, 0.16), transparent 70%),
        var(--page);
}

/* ---------- Karten (Invictus .card) ---------- */
.card {
    background: var(--surface);
    border: 2px solid var(--frame);
    border-radius: 8px;
    box-shadow: 0 8px 24px -12px rgba(0, 0, 0, 0.6);
    color: var(--text);
}

/* Innenabstand je Padding-Klasse merken, damit die Kopfzeile bündig an den Kartenrand kommt */
.card.p-3 { --cp: 0.75rem; }
.card.p-4 { --cp: 1rem; }
.card.p-5 { --cp: 1.25rem; }
.card.p-6 { --cp: 1.5rem; }
.card.p-8 { --cp: 2rem; }
@media (min-width: 768px) {
    .card.md\:p-5 { --cp: 1.25rem; }
    .card.md\:p-6 { --cp: 1.5rem; }
}

/* Invictus-Kartenkopf: roter Balken mit Icon + Titel.
   Greift für Karten, deren erstes Kind die Überschrift ist (oder eine
   Zeile aus Überschrift + Aktionsbuttons). */
.card > h2:first-child,
.card > div.justify-between:first-child:has(> h2) {
    margin: calc(var(--cp, 1rem) * -1) calc(var(--cp, 1rem) * -1) 1rem;
    padding: 0.7rem var(--cp, 1rem);
    background: linear-gradient(180deg, #c43a44 0%, var(--primary) 100%);
    border-bottom: 2px solid var(--frame);
    border-radius: 6px 6px 0 0;
    color: #fff;
}
.card > h2:first-child,
.card > div.justify-between:first-child > h2 {
    font-size: 1.05rem;
    letter-spacing: 0.01em;
    color: #fff;
}
.card > h2:first-child i,
.card > div.justify-between:first-child > h2 i { color: #fff !important; }
.card > div.justify-between:first-child:has(> h2) > h2 { margin-bottom: 0; }
/* Buttons im roten Kopf: dunkel-transparent statt rot-auf-rot */
.card > div.justify-between:first-child:has(> h2) button,
.card > div.justify-between:first-child:has(> h2) select {
    background: rgba(0, 0, 0, 0.25) !important;
    border-color: rgba(0, 0, 0, 0.15) !important;
    color: #fff !important;
    box-shadow: none !important;
}
.card > div.justify-between:first-child:has(> h2) button:hover { background: rgba(0, 0, 0, 0.4) !important; }
.card > div.justify-between:first-child:has(> h2) .text-slate-500,
.card > div.justify-between:first-child:has(> h2) .text-slate-600 { color: rgba(255, 255, 255, 0.8) !important; }

/* ---------- Formulare ---------- */
.input-std,
:root select.input-std {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    background-color: var(--inset);
    color: #d0d1d4;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input-std::placeholder { color: #6f747c; opacity: 1; }
.input-std:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(189, 52, 62, 0.22);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); }
textarea, select { color: inherit; }
option { background: var(--surface); color: var(--text); }

.val-input { text-align: right; font-weight: 600; }
input.day-input-fixkosten {
    padding: 8px 2px;
    text-align: center;
    -moz-appearance: textfield;
}
.day-input-fixkosten::-webkit-outer-spin-button,
.day-input-fixkosten::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ---------- Buttons ---------- */
.btn-add-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--primary-text);
    background: rgba(189, 52, 62, 0.08);
    border: 1px dashed rgba(189, 52, 62, 0.55);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s;
}
.btn-add-row:hover { background: rgba(189, 52, 62, 0.16); border-color: var(--primary); }
.btn-del,
.btn-edit {
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.btn-del { color: #f47c84; background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.22); }
.btn-del:hover { background: rgba(239, 68, 68, 0.22); color: #fff; }
.btn-edit { color: #c9ccd1; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); }
.btn-edit:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* ---------- KFZ-Kennzeichen (bleibt bewusst hell wie ein echtes Schild) ---------- */
.euro-plate {
    display: inline-flex;
    align-items: stretch;
    height: 24px;
    border: 2px solid #1a1a1a;
    border-radius: 4px;
    background: #ffffff;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    vertical-align: middle;
}
.euro-plate-eu {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 15px;
    background: #003399;
    line-height: 1;
}
.euro-plate-eu .euro-plate-stars { font-size: 5px; color: #ffcc00; letter-spacing: -1px; }
.euro-plate-eu .euro-plate-d { font-size: 8px; font-weight: 700; color: #ffffff; }
.euro-plate-text {
    display: flex;
    align-items: center;
    padding: 0 6px;
    font-family: 'Arial Narrow', 'Helvetica Neue', Arial, sans-serif;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1px;
    color: #0a0a0a;
    white-space: nowrap;
}

/* ---------- Monats-Chips ---------- */
.month-chip {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--inset);
    color: var(--muted);
    user-select: none;
    transition: background 0.15s, color 0.15s;
}
.month-chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.month-chip.current-month { box-shadow: 0 0 0 2px #f59e0b; }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--frame);
    color: #fff;
    padding: 12px 22px;
    border-radius: 6px;
    border-left: 4px solid var(--primary);
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    z-index: 60;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    padding: 4px 8px;
}
td { padding: 4px 8px; background: #24272c; }
td:first-child { border-radius: 6px 0 0 6px; }
td:last-child { border-radius: 0 6px 6px 0; }
#fixkosten-tbl { table-layout: fixed; }
#fixkosten-tbl th, #fixkosten-tbl td { box-sizing: border-box; }
.th-fk-symbol { width: 68px; }
.th-fk-betrag { width: 100px; }
.th-fk-tag { width: 46px; }
.th-fk-abgebucht { width: 70px; }
.th-fk-del { width: 40px; }
#fixkosten-tbl td:last-child { padding: 4px 2px; }
#fixkosten-tbl .btn-del { padding: 5px 6px; }
.cb-styled { width: 18px; height: 18px; accent-color: #10b981; cursor: pointer; }

/* ---------- App-Kopf ---------- */
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(28, 28, 30, 0.96);
    border-bottom: 2px solid var(--primary);
    box-shadow: 0 6px 20px -8px rgba(0, 0, 0, 0.7);
    padding-top: env(safe-area-inset-top);
}
.app-logo { width: 42px; height: 42px; flex-shrink: 0; border-radius: 10px; box-shadow: 0 4px 14px rgba(189, 52, 62, 0.35); }
.topbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 36px;
    min-width: 36px;
    padding: 0 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #d0d1d4;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.topbar-btn:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.topbar-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.topbar-btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
@media (max-width: 767px) { .topbar-btn { padding: 0; width: 36px; } }

/* ---------- Navigation ---------- */
.nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 6px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    line-height: 1.15;
    color: #a3a7ae;
    text-align: center;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
    white-space: normal;
    min-width: 0;
    overflow-wrap: break-word;
}
.nav-btn span { min-width: 0; overflow-wrap: break-word; }
.nav-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
.nav-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 14px rgba(189, 52, 62, 0.35);
}
.nav-btn.hidden, .nav-dropdown-item.hidden { display: none !important; }
.nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    background: var(--surface);
    border: 2px solid var(--frame);
    border-radius: 8px;
    padding: 5px;
}
@media (min-width: 900px) { .nav-grid { grid-template-columns: repeat(8, 1fr); } }
.nav-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 12px 16px;
    font-weight: 700;
    font-size: 0.92rem;
    color: #c9ccd1;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background 0.15s;
}
.nav-dropdown-item:hover { background: rgba(255, 255, 255, 0.05); }
.nav-dropdown-item.active-item {
    background: rgba(189, 52, 62, 0.14);
    border-left-color: var(--primary);
    color: #fff;
}
#nav-dropdown-chevron { transition: transform 0.2s; }
#nav-dropdown-chevron.rotate-180 { transform: rotate(180deg); }

.app-footer {
    text-align: center;
    font-size: 0.72rem;
    color: #6f747c;
    padding: 18px 0 calc(10px + env(safe-area-inset-bottom));
}


/* ---------- Scrollbar wie bei Invictus ---------- */
* { scrollbar-width: thin; scrollbar-color: var(--primary) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 3px; }

::selection { background: rgba(189, 52, 62, 0.55); color: #fff; }

/* ============================================================
   Overrides für Tailwind-Klassen, die doppelt belegt sind
   (z. B. "white" als Text- UND als Flächenfarbe)
   ============================================================ */
:root .bg-white { background-color: var(--surface-2); }
:root .bg-white\/80 { background-color: rgba(46, 49, 55, 0.85); }
:root .hover\:bg-white:hover { background-color: #363a41; }
:root .text-slate-100 { color: #f1f2f4; }
:root .text-slate-200 { color: #e4e5e8; }
:root .text-slate-300 { color: #6f747c; }
:root .bg-slate-900 .text-slate-300 { color: #c9ccd1; }
:root .text-black { color: #e4e5e8; }

/* Akzent-Text (blau -> Invictus-Rot) auf dunklem Grund lesbar halten */
:root .text-blue-500 { color: #e2646d; }
:root .text-blue-600, :root .hover\:text-blue-600:hover { color: var(--primary-text); }
:root .text-blue-700, :root .hover\:text-blue-700:hover, :root .text-blue-800 { color: #f08a91; }

/* Farbige Texte (600/700) auf dunklem Grund aufhellen – generiert */
:root .text-emerald-600, :root .hover\:text-emerald-600:hover { color: #34d399; }
:root .text-emerald-700, :root .hover\:text-emerald-700:hover { color: #6ee7b7; }
:root .text-amber-600, :root .hover\:text-amber-600:hover { color: #fbbf24; }
:root .text-amber-700, :root .hover\:text-amber-700:hover { color: #fcd34d; }
:root .text-rose-600, :root .hover\:text-rose-600:hover { color: #fb7185; }
:root .text-rose-700, :root .hover\:text-rose-700:hover { color: #fda4af; }
:root .text-red-600, :root .hover\:text-red-600:hover { color: #f87171; }
:root .text-red-700, :root .hover\:text-red-700:hover { color: #fca5a5; }
:root .text-purple-600, :root .hover\:text-purple-600:hover { color: #c084fc; }
:root .text-purple-700, :root .hover\:text-purple-700:hover { color: #d8b4fe; }
:root .text-indigo-600, :root .hover\:text-indigo-600:hover { color: #818cf8; }
:root .text-indigo-700, :root .hover\:text-indigo-700:hover { color: #a5b4fc; }
:root .text-green-600, :root .hover\:text-green-600:hover { color: #4ade80; }
:root .text-green-700, :root .hover\:text-green-700:hover { color: #86efac; }
:root .text-yellow-600, :root .hover\:text-yellow-600:hover { color: #facc15; }
:root .text-yellow-700, :root .hover\:text-yellow-700:hover { color: #fde047; }
:root .text-orange-600, :root .hover\:text-orange-600:hover { color: #fb923c; }
:root .text-orange-700, :root .hover\:text-orange-700:hover { color: #fdba74; }
:root .text-sky-600, :root .hover\:text-sky-600:hover { color: #38bdf8; }
:root .text-sky-700, :root .hover\:text-sky-700:hover { color: #7dd3fc; }
:root .text-cyan-600, :root .hover\:text-cyan-600:hover { color: #22d3ee; }
:root .text-cyan-700, :root .hover\:text-cyan-700:hover { color: #67e8f9; }
:root .text-teal-600, :root .hover\:text-teal-600:hover { color: #2dd4bf; }
:root .text-teal-700, :root .hover\:text-teal-700:hover { color: #5eead4; }
:root .text-pink-600, :root .hover\:text-pink-600:hover { color: #f472b6; }
:root .text-pink-700, :root .hover\:text-pink-700:hover { color: #f9a8d4; }
:root .text-lime-600, :root .hover\:text-lime-600:hover { color: #a3e635; }
:root .text-lime-700, :root .hover\:text-lime-700:hover { color: #bef264; }
:root .text-violet-600, :root .hover\:text-violet-600:hover { color: #a78bfa; }
:root .text-violet-700, :root .hover\:text-violet-700:hover { color: #c4b5fd; }
:root .text-fuchsia-600, :root .hover\:text-fuchsia-600:hover { color: #e879f9; }
:root .text-fuchsia-700, :root .hover\:text-fuchsia-700:hover { color: #f0abfc; }

/* ---------- Marke / Login ---------- */
.brand-wordmark {
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #fff;
    font-size: 1.6rem;
}
.brand-wordmark span { color: var(--primary-text); }
.app-topbar .brand-wordmark { font-size: 1.1rem; }
@media (min-width: 768px) { .app-topbar .brand-wordmark { font-size: 1.25rem; } }
.login-logo { width: 76px; height: 76px; border-radius: 18px; }
.login-screen {
    background:
        radial-gradient(900px 420px at 50% -120px, rgba(189, 52, 62, 0.28), transparent 70%),
        var(--page);
}
/* Expliziter Kartenkopf (Login) – gleiche Optik wie die automatischen Kartenköpfe */
.card-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0.85rem 1.25rem;
    background: linear-gradient(180deg, #c43a44 0%, var(--primary) 100%);
    border-bottom: 2px solid var(--frame);
    color: #fff;
}
.card-head-icon { font-size: 1.6rem; width: 2rem; text-align: center; }
#nav-dropdown-trigger {
    background: var(--surface);
    border: 2px solid var(--frame);
    border-radius: 8px;
    color: #fff;
}
#nav-dropdown-panel { background: var(--surface-2); border: 2px solid var(--frame); border-radius: 8px; }

/* Farbige Oberkanten (border-t-4 …) entfallen bei Karten mit rotem Kopf */
.card:has(> h2:first-child)[class*="border-t-"],
.card:has(> div.justify-between:first-child > h2)[class*="border-t-"] { border-top: 2px solid var(--frame); }

/* ---------- Smartphone ---------- */
@media (max-width: 640px) {
    #save-status { display: none !important; }
    th { font-size: 0.66rem; padding: 3px 4px; }
    td { padding: 3px 4px; }
    .input-std { padding: 7px 8px; font-size: 0.85rem; }
    .btn-del { padding: 5px 8px; }
    .btn-del i { font-size: 0.8rem; }
    .th-fk-symbol { width: 46px; }
    .th-fk-betrag { width: 62px; }
    .th-fk-tag { width: 30px; }
    .th-fk-abgebucht { width: 34px; }
    .th-fk-del { width: 30px; }
    #fixkosten-tbl .input-std { padding: 6px 3px; font-size: 0.78rem; }
    #fixkosten-tbl .icon-select-abbuchung { padding: 6px 0 !important; font-size: 1.25rem !important; }
    #fixkosten-tbl .day-input-fixkosten { text-align: center; }
    #fixkosten-tbl td:last-child { padding: 3px 1px; }
    #fixkosten-tbl .btn-del { padding: 4px 5px; }
    #fixkosten-tbl .btn-del i { font-size: 0.72rem; }
}
