/* DKonnect Rechnungen: mobil zuerst. Dunkles Design, große Tippflächen, keine externen Schriften. */
:root {
    --bg: #0b1120;
    --bg-2: #0f172a;
    --card: #1e293b;
    --card-2: #243247;
    --border: #334155;
    --text: #f8fafc;
    --muted: #94a3b8;
    --primary: #0ea5e9;
    --primary-hover: #38bdf8;
    --ok: #22c55e;
    --warn: #f59e0b;
    --danger: #ef4444;
    --radius: 14px;
    --nav-h: 64px;
    --side-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 16px;
    min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
h1 { font-size: 1.5rem; line-height: 1.25; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 8px; }
.mb { margin-bottom: 16px; }

/* Layout: Seitenleiste ab Tablet, untere Navigation auf dem Handy */
.shell { display: block; }
.side-nav { display: none; }
.content { padding: 16px 16px calc(var(--nav-h) + 28px); max-width: 1100px; margin: 0 auto; }

.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(15, 23, 42, .96); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    color: var(--muted); font-size: .72rem; font-weight: 600;
}
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.fab span.fab-icon {
    display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%;
    background: var(--primary); color: #04202e; margin-top: -18px; box-shadow: 0 6px 18px rgba(14, 165, 233, .45);
}
.bottom-nav a.fab { color: var(--text); }

@media (min-width: 900px) {
    .shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
    .side-nav {
        display: flex; flex-direction: column; gap: 4px; padding: 20px 14px;
        background: var(--bg-2); border-right: 1px solid var(--border);
        position: sticky; top: 0; height: 100vh; overflow-y: auto;
    }
    .side-nav .brand { padding: 4px 10px 16px; }
    .side-nav .brand img { max-height: 40px; max-width: 100%; }
    .side-nav a {
        display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
        color: var(--muted); font-weight: 600;
    }
    .side-nav a svg { width: 20px; height: 20px; flex: none; }
    .side-nav a:hover { background: var(--card); color: var(--text); }
    .side-nav a.active { background: rgba(14, 165, 233, .14); color: var(--primary); }
    .side-nav .spacer { flex: 1; }
    .bottom-nav { display: none; }
    .content { padding: 28px 32px 60px; }
}

/* Kopfbereich einer Seite */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-block; margin-bottom: 8px; font-size: .9rem; color: var(--muted); }

/* Karten, Raster, Kennzahlen */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.card > h2 { margin-bottom: 12px; }
.card.accent { border-left: 4px solid var(--primary); }
.card.warn { border-left: 4px solid var(--warn); }
.card.danger { border-left: 4px solid var(--danger); }
.grid { display: grid; gap: 12px; }
.grid > *, .content > *, .card, .row .main { min-width: 0; }
.g2 { grid-template-columns: 1fr; }
.g3 { grid-template-columns: 1fr; }
.g4 { grid-template-columns: 1fr 1fr; }
@media (min-width: 700px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.stat .label { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: 2px; word-break: break-word; }
.stat .hint { color: var(--muted); font-size: .8rem; }
.stat.good .value { color: var(--ok); }
.stat.bad .value { color: var(--danger); }

/* Listen: auf dem Handy als Karten, kein horizontales Scrollen nötig */
.rows { display: flex; flex-direction: column; }
.row {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 4px; border-bottom: 1px solid var(--border); color: var(--text);
}
.row:last-child { border-bottom: 0; }
a.row:hover { background: rgba(255, 255, 255, .03); color: var(--text); }
.row .main { min-width: 0; flex: 1; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .side { text-align: right; flex: none; max-width: 48%; }
.row .side .badge { margin-top: 2px; }
.row .amount { font-weight: 700; }

/* Status-Badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700; background: var(--card-2); color: var(--muted); }
.badge.bezahlt { background: rgba(34, 197, 94, .16); color: var(--ok); }
.badge.offen { background: rgba(14, 165, 233, .16); color: var(--primary); }
.badge.teilbezahlt { background: rgba(245, 158, 11, .16); color: var(--warn); }
.badge.ueberfaellig { background: rgba(239, 68, 68, .18); color: var(--danger); }
.badge.storniert, .badge.storno { background: rgba(148, 163, 184, .18); color: var(--muted); }
.badge.angebot { background: rgba(168, 85, 247, .18); color: #c4b5fd; }
.badge.unklar { background: rgba(245, 158, 11, .16); color: var(--warn); }
.badge.review { background: rgba(245, 158, 11, .2); color: var(--warn); }

/* Formulare */
label { display: block; font-size: .85rem; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
    width: 100%; background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 10px; padding: 12px; font: inherit; font-size: 16px; min-height: 46px;
}
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--primary); }
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
.field { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.check label { margin: 0; color: var(--text); font-weight: 500; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 46px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--border);
    background: var(--card-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { border-color: var(--primary); color: var(--text); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #04202e; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: rgba(239, 68, 68, .12); }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .9rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: wait; }

/* Positionen im Beleg-Formular */
.item { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 10px; display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.item .desc { grid-column: 1 / -1; }
.item .note { grid-column: 1 / -1; }
.item .remove { grid-column: 1 / -1; justify-self: end; }
@media (min-width: 700px) {
    .item { grid-template-columns: 3fr 90px 130px auto; align-items: end; }
    .item .desc { grid-column: auto; }
    .item .note { grid-column: 1 / 4; }
    .item .remove { grid-column: auto; }
}
.sum-bar { display: flex; justify-content: space-between; align-items: center; padding: 12px 4px; font-weight: 700; font-size: 1.1rem; }

/* Meldungen */
.flashes { margin-bottom: 16px; display: grid; gap: 8px; }
.flash { padding: 12px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--card); }
.flash.success { border-color: var(--ok); }
.flash.error { border-color: var(--danger); background: rgba(239, 68, 68, .1); }
.notice { padding: 12px 14px; border-radius: 10px; background: rgba(245, 158, 11, .12); border: 1px solid rgba(245, 158, 11, .5); margin-bottom: 14px; }

/* Fortschrittsbalken, Diagramm */
.progress { height: 10px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress.warn > span { background: var(--warn); }
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; align-items: end; height: 150px; margin-top: 8px; }
.chart .col { display: flex; gap: 2px; align-items: end; height: 100%; justify-content: center; }
.chart .bar { width: 42%; border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar.in { background: var(--ok); }
.chart .bar.out { background: var(--danger); opacity: .8; }
.chart-labels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; text-align: center; font-size: .65rem; color: var(--muted); margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }

/* Tabellen (nur Auswertungen) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; min-width: 520px; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--border); text-align: left; font-size: .92rem; }
th { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; white-space: nowrap; }
tfoot td { font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: .9rem; }
.chip.active { background: rgba(14, 165, 233, .15); border-color: var(--primary); color: var(--primary); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card img { max-height: 70px; margin: 0 auto 18px; display: block; }

kbd, code { background: var(--bg-2); padding: 1px 6px; border-radius: 6px; font-size: .85em; }
details summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.kv { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; min-width: 96px; padding-top: 2px; }
.kv > span:last-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }

@media print { .side-nav, .bottom-nav, .actions { display: none !important; } body { background: #fff; color: #000; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
