/* Nova – schlankes, modernes Dashboard-Stylesheet (kein Build-Schritt). */
:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e3e6ea;
    --text: #1f2733;
    --muted: #6b7685;
    --primary: #2f6fed;
    --primary-dark: #2257c4;
    --success: #1d8a4e;
    --success-bg: #e6f5ec;
    --error: #c0362c;
    --error-bg: #fbeae8;
    --warn: #9a6700;
    --warn-bg: #fff6e0;
    --sidebar: #1b2330;
    --sidebar-text: #c3cbd6;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
    /* Abgeleitete Flächen (für Dark Mode überschreibbar). */
    --subtle: #fafbfc;     /* Tabellenkopf, Hover */
    --hover: #f4f5f7;      /* Button-/Zeilen-Hover */
    --input-bg: #ffffff;
}

[data-theme="dark"] {
    --bg: #0f141b;
    --surface: #171e27;
    --border: #2a333f;
    --text: #e4e8ee;
    --muted: #97a3b2;
    --primary: #4d8bff;
    --primary-dark: #3b73e0;
    --success: #4cc080;
    --success-bg: #14271c;
    --error: #f0635a;
    --error-bg: #2c1614;
    --warn: #e0a93b;
    --warn-bg: #2a2210;
    --sidebar: #0c1117;
    --sidebar-text: #aeb8c4;
    --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 1px 3px rgba(0, 0, 0, .35);
    --subtle: #1e2630;
    --hover: #1d2530;
    --input-bg: #0f141b;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
}
body { transition: background-color .2s ease, color .2s ease; }

/* ---- Bottom-Navigation (nur Mobil) ---- */
.bottom-nav { display: none; }

/* ---- Dark-Mode-Feinheiten ---- */
[data-theme="dark"] .badge-private,
[data-theme="dark"] .badge-draft,
[data-theme="dark"] .badge-cancelled { background: #2a333f; color: #aeb8c4; }
[data-theme="dark"] .badge-business { background: #1d2d4d; color: #9bbcff; }
[data-theme="dark"] .bar-out { opacity: .8; }
[data-theme="dark"] a { color: #ffffff; }

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

/* ---- Layout ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 230px;
    background: var(--sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 14px 10px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 21px;
    font-weight: 700;
    color: #fff;
    padding: 4px 8px 12px;
    letter-spacing: .5px;
}
.brand-mark {
    display: inline-block;
    width: 32px;
    height: 32px;
    flex: none;
    background: url('/assets/img/nova-icon.png') center / contain no-repeat;
    font-size: 0;  /* evtl. Buchstaben-Fallback ausblenden */
    line-height: 0;
}
.topbar-brand .brand-mark { width: 28px; height: 28px; }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; flex: 1; min-height: 0; overflow-y: auto; }
/* Dezente, schmale Scrollleiste – nur falls das Fenster sehr niedrig ist. */
.sidebar nav { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent; }
.sidebar nav::-webkit-scrollbar { width: 6px; }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
.sidebar nav::-webkit-scrollbar-track { background: transparent; }
.sidebar .nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 9px; }
.sidebar .nav-group-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #6b7685;
    padding: 3px 12px 2px;
}
.sidebar nav a {
    color: var(--sidebar-text);
    padding: 7px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar nav a .ico { width: 18px; text-align: center; opacity: .9; }

.sidebar .sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); padding-top: 8px; margin-top: 4px; }
/* Klar klickbares Konto-Element */
.sidebar .account-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 8px; color: var(--sidebar-text);
}
.sidebar .account-link:hover, .sidebar .account-link.active { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar .account-avatar {
    flex: none; width: 30px; height: 30px; border-radius: 50%;
    background: rgba(255,255,255,.12); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
}
.sidebar .account-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar .account-name { font-size: 13.5px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .account-sub { font-size: 11px; color: #8b95a3; }
.sidebar .account-go { flex: none; color: #8b95a3; font-size: 18px; }
.btn-link { background: none; border: none; color: var(--sidebar-text); cursor: pointer; padding: 6px 10px; font-size: 13.5px; }
.btn-link:hover { color: #fff; text-decoration: underline; }
.sidebar .version-tag { display: block; font-size: 11px; color: #6b7685; padding: 6px 10px 0; }
.sidebar .version-tag:hover { color: #9aa4b2; text-decoration: none; }
.sidebar .version-tag.update::after { content: " • Update"; color: var(--primary); font-weight: 700; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.topbar h1 { margin: 0; font-size: 20px; flex: 1; min-width: 0; }
.theme-toggle {
    margin-left: auto; flex: none;
    width: 36px; height: 36px; border-radius: 9px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    cursor: pointer; font-size: 16px; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
}
.theme-toggle:hover { background: var(--hover); }
[data-theme="light"] .theme-icon-light { display: none; }
[data-theme="dark"]  .theme-icon-dark  { display: none; }
/* Brand im Topbar nur auf Mobil sichtbar (Desktop: Sidebar genügt). */
.topbar-brand { display: none; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.topbar-brand:hover { text-decoration: none; }
.content { padding: 24px 28px; max-width: 1100px; }

/* ---- Flash ---- */
.flash { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 14px; }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error   { background: var(--error-bg); color: var(--error); }
.flash-warn    { background: var(--warn-bg); color: var(--warn); }

/* ---- Cards / Grid ---- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.card .value { font-size: 26px; font-weight: 700; }
.card .value.neg { color: var(--error); }
.card .value.pos { color: var(--success); }
.card .sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}
.panel h2 { margin: 0 0 14px; font-size: 16px; }

/* ---- Tabellen ---- */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); -webkit-overflow-scrolling: touch; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: var(--subtle); color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .3px; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--hover); }
td.num, th.num { text-align: right; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--primary); color: #fff; border: none;
    padding: 9px 16px; border-radius: 8px; font-size: 14px; cursor: pointer;
    text-decoration: none; font-weight: 500;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--hover); }
.btn-danger { background: var(--error); }
.btn-danger:hover { background: #a12c23; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .search { flex: 1; max-width: 320px; }

/* ---- Formulare ---- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 4px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
input[type=text], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=password], input[type=search], select, textarea {
    border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
    font-size: 14px; font-family: inherit; background: var(--input-bg); color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,111,237,.12); }
textarea { resize: vertical; min-height: 80px; }
.checkbox { display: flex; align-items: center; gap: 8px; }
.checkbox input { width: auto; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ---- Badges ---- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-business { background: #e8effd; color: var(--primary-dark); }
.badge-private { background: #eef0f3; color: var(--muted); }
.badge-draft { background: #eef0f3; color: var(--muted); }
.badge-sent { background: #fff6e0; color: var(--warn); }
.badge-paid { background: var(--success-bg); color: var(--success); }
.badge-overdue { background: var(--error-bg); color: var(--error); }
.badge-cancelled { background: #eef0f3; color: var(--muted); text-decoration: line-through; }

/* ---- Positions-Tabelle (Angebote/Rechnungen) ---- */
.items-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; background: transparent; }
.items-table th { background: transparent; border-bottom: 1px solid var(--border); padding: 6px 6px; }
.items-table td { padding: 4px 6px; border-bottom: none; }
.items-table input { padding: 7px 9px; }
.items-table .ta-right { text-align: right; }

.muted { color: var(--muted); }
/* ---- PWA-Install-Banner ---- */
.install-banner {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    border: 1px solid var(--primary); background: var(--success-bg);
    border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 14px;
}
[data-theme="dark"] .install-banner { background: rgba(77,139,255,.10); }
.install-banner .install-text { flex: 1; min-width: 180px; }
.install-banner .install-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 16px; padding: 2px 6px; }
.install-banner .install-close:hover { color: var(--text); }

/* ---- Einstellungen: Unter-Navigation ---- */
.subnav { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.subnav a {
    padding: 9px 14px; font-size: 14px; color: var(--muted); border-bottom: 2px solid transparent;
    margin-bottom: -1px; white-space: nowrap;
}
.subnav a:hover { color: var(--text); text-decoration: none; }
.subnav a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.disclaimer { border: 1px solid var(--border); background: var(--subtle); border-radius: var(--radius); padding: 12px 14px; font-size: 12.5px; color: var(--muted); }
.disclaimer strong { color: var(--text); }
.disclaimer p { margin: 6px 0 0; line-height: 1.5; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }

/* ---- Dashboard-Diagramm ---- */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 180px; padding: 8px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.chart-col .bars { flex: 1; display: flex; align-items: flex-end; gap: 3px; width: 100%; justify-content: center; }
.chart-col .bar { width: 42%; border-radius: 3px 3px 0 0; min-height: 1px; }
.bar-in { background: var(--success); }
.bar-out { background: var(--primary); opacity: .55; }
.chart-label { font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }
.dot-in { background: var(--success); }
.dot-out { background: var(--primary); opacity: .55; }

/* ---- Fortschrittsbalken (KU-Grenze) ---- */
.progress { background: var(--subtle); border-radius: 8px; height: 14px; overflow: hidden; }
.progress-bar { background: var(--success); height: 100%; transition: width .3s; }
.progress-bar.danger { background: var(--error); }

ul.todo { line-height: 1.9; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
dl.detail { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; }
dl.detail dt { color: var(--muted); font-size: 13px; }

/* ---- Login ---- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg); padding: 16px; }
.login-box { background: var(--surface); padding: 34px; border-radius: 14px; box-shadow: var(--shadow); width: 360px; max-width: 100%; }
.login-box h1 { margin: 0 0 6px; font-size: 24px; }
/* Empfehlungs-/Hinweis-Box (z.B. 2FA bewerben) */
.promo { display: flex; gap: 14px; align-items: flex-start; border: 1px solid var(--primary); background: var(--success-bg); border-radius: var(--radius); padding: 16px; }
[data-theme="dark"] .promo { background: rgba(77,139,255,.10); }
.promo-icon { font-size: 26px; line-height: 1; flex: none; }
.promo-body { flex: 1; }
.promo-body strong { display: block; margin-bottom: 4px; }
.promo-body p { margin: 0 0 12px; color: var(--text); font-size: 13.5px; }

.powered { text-align: center; margin: 16px 0 0; font-size: 12px; color: var(--muted); }
.powered a { color: var(--muted); }
.powered a:hover { color: var(--primary); }
.brand-title { display: flex; align-items: center; gap: 10px; }
.brand-title .brand-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 18px; }
.login-box .sub { color: var(--muted); margin-bottom: 22px; font-size: 14px; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 8px; }
.legal-footer {
    position: fixed;
    left: 20px;
    bottom: 16px;
    font-size: 13px;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 8px;
}
.legal-footer a { color: var(--muted); }
.legal-footer a:hover { color: var(--text); }
.legal-footer .sep { opacity: .5; }

/* ---- Kamera-/Upload-Button & Utility ---- */
.camera-label { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; cursor: pointer; }
.hidden { display: none; }

/* ---- Mobile-Navigation (Hamburger + Drawer) ---- */
.nav-toggle { display: none; background: none; border: none; font-size: 24px; line-height: 1; color: var(--text); cursor: pointer; padding: 0 4px; }
.nav-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }

/* ---- Mobile Layout ---- */
@media (max-width: 820px) {
    .topbar { gap: 10px; padding: 10px 14px; position: sticky; top: 0; z-index: 30; }
    .topbar h1 { display: none; } /* Titel weicht auf Mobil der Brand */
    .topbar-brand { display: flex; font-size: 17px; }
    .nav-toggle { display: block; }

    /* Feste Aktionsleiste am unteren Rand. */
    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
        background: var(--surface); border-top: 1px solid var(--border);
        padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -1px 6px rgba(0,0,0,.10);
    }
    .bottom-nav a, .bottom-nav button {
        flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
        background: none; border: none; cursor: pointer;
        color: var(--muted); font-size: 10.5px; padding: 7px 2px 5px; text-decoration: none;
        font-family: inherit;
    }
    .bottom-nav .ico { font-size: 20px; line-height: 1; }
    .bottom-nav a.active { color: var(--primary); }
    .bottom-nav a.primary .ico {
        background: var(--primary); color: #fff; width: 44px; height: 44px; border-radius: 50%;
        display: flex; align-items: center; justify-content: center; margin-top: -22px; font-size: 26px;
        box-shadow: 0 3px 10px rgba(47,111,237,.5); border: 3px solid var(--surface);
    }
    .bottom-nav a.primary { color: var(--primary); font-weight: 600; }
    /* Bottom-Padding lässt Platz für die feste Footer-Leiste (sonst verdeckt). */
    .content { padding: 16px 14px calc(84px + env(safe-area-inset-bottom, 0px)); }

    /* Sidebar wird zum Slide-in-Drawer mit vollen Labels */
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 250px;
        transform: translateX(-100%); transition: transform .25s ease; z-index: 50;
    }
    .sidebar nav a span:not(.ico), .sidebar .user-link, .sidebar .user { display: block; }
    .sidebar nav a { justify-content: flex-start; }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .nav-overlay { display: block; }

    .form-grid { grid-template-columns: 1fr; }
    dl.detail { grid-template-columns: 1fr; gap: 2px 0; }
    dl.detail dt { margin-top: 8px; font-weight: 600; }
    .toolbar { gap: 10px; }
    .toolbar .search, .toolbar form { max-width: 100%; flex: 1 1 100%; }
    .toolbar .search input, .toolbar input[type=search] { width: 100%; }
    .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
    .card .value { font-size: 21px; }
    .chart { height: 140px; }
    /* Bessere Tap-Größen */
    .btn { padding: 11px 16px; }
    input, select, textarea { font-size: 16px; } /* verhindert iOS-Zoom beim Fokus */
}

@media (max-width: 460px) {
    .cards { grid-template-columns: 1fr; }
}
