:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --sidebar: #1f2937;
    --sidebar-hover: #374151;
    --sidebar-active: #2563eb;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --ok: #16a34a;
    --warn: #d97706;
    --shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

/* ---- Ladebalken (Seiten-Navigation) ---- */
#page-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0;
    background: var(--primary); box-shadow: 0 0 6px rgba(37, 99, 235, .5);
    z-index: 9999; opacity: 0; transition: width .2s ease;
}
#page-progress.active { opacity: 1; }
#page-progress.done { transition: width .3s ease, opacity .4s ease .2s; opacity: 0; }
/* Inhalt waehrend der Navigation leicht abdunkeln (mit Delay -> kein Flackern bei schnellen Wechseln) */
.app-content { transition: opacity .2s ease; }
.nav-loading .app-content { opacity: .55; pointer-events: none; transition: opacity .2s ease .15s; }

html, body {
    margin: 0;
    font-family: "Segoe UI", Roboto, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
h1:focus { outline: none; }

/* ---- Shell (VDO-Fleet-Stil: Topbar oben, Sidebar+Content darunter) ---- */
.app-root { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
    height: 60px; flex-shrink: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 22px;
}
.topbar-brand { display: flex; align-items: center; gap: 14px; }
.topbar-logo { height: 26px; display: block; }
.topbar-title {
    font-size: 15px; font-weight: 600; color: var(--text-muted);
    padding-left: 14px; border-left: 1px solid var(--border); letter-spacing: .02em;
}
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.topbar-build { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.app-body { display: flex; flex: 1; min-height: 0; }

.app-nav {
    width: 240px;
    background: var(--sidebar);
    color: #e5e7eb;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}

.nav-scroll { padding: 12px 0; overflow-y: auto; }
.nav-group {
    padding: 14px 18px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #9ca3af;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    color: #d1d5db;
    font-size: 14px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-icon { width: 20px; text-align: center; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.app-header {
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}
.user-greeting { font-size: 14px; }
.user-name { color: var(--text-muted); margin-left: 6px; font-size: 13px; }
.app-header-actions { display: flex; align-items: center; gap: 16px; }
.lang-switch { display: flex; gap: 4px; align-items: center; font-size: 13px; }
.lang-switch a { color: var(--text-muted); padding: 3px 7px; border-radius: 6px; }
.lang-switch a:hover { background: #f1f5f9; color: var(--text); }
.lang-switch .lang-current { padding: 3px 7px; font-weight: 700; color: var(--primary); }

/* ---- Pager ---- */
.pager { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin: 10px 0; }
.pager-top { margin-bottom: 14px; }
.pager-info { font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.pager-nav { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.pager-num {
    min-width: 30px; height: 30px; padding: 0 8px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: 7px;
    font-size: 13px; color: var(--text); background: var(--surface);
}
.pager-num:hover { background: #f1f5f9; }
.pager-num.disabled { opacity: .4; pointer-events: none; }
.pager-num.pager-current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.pager-gap { padding: 0 4px; color: var(--text-muted); }
.pager-size { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }
.pager-size a { padding: 2px 7px; border-radius: 6px; }
.pager-size a:hover { background: #f1f5f9; }
.pager-size .size-current { padding: 2px 7px; font-weight: 700; color: var(--primary); }

.app-content { flex: 1; min-height: 0; min-width: 0; padding: 24px; overflow: auto; }

/* ---- Page ---- */
.page { max-width: 1400px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.page h1 { font-size: 22px; margin: 0 0 4px; }
.page-lead { color: var(--text-muted); margin-top: 0; }
.hint { color: var(--text-muted); font-size: 13px; margin-top: 12px; }
.notice { background: #fef9c3; border: 1px solid #fde047; padding: 12px 16px; border-radius: 8px; }

.badge {
    background: #e0e7ff; color: #3730a3;
    border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600;
}

/* ---- Buttons ---- */
.btn {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    padding: 7px 14px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 14px;
}
.btn:hover { background: #f1f5f9; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; }
.logout-form { margin: 0; }

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}
.filter-bar label, .report-toolbar label {
    display: flex; flex-direction: column; gap: 4px;
    font-size: 12px; color: var(--text-muted);
}
.filter-bar input, .filter-bar select {
    padding: 7px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; color: var(--text);
    background: #fff;
}

/* ---- Grid ---- */
.table-scroll { max-width: 100%; overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid thead th {
    text-align: left; padding: 10px 12px; background: #f8fafc;
    border-bottom: 1px solid var(--border); font-weight: 600; white-space: nowrap;
    position: sticky; top: 0;
}
.grid tbody td { padding: 8px 12px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.grid tbody tr:hover { background: #f8fafc; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid th.sortable { padding: 0; }
.grid th.sortable > a { display: block; padding: 10px 12px; color: inherit; white-space: nowrap; }
.grid th.sortable > a:hover { background: #eef2f7; color: var(--primary); }
.grid th.sortable.num > a { text-align: right; }
.sort-arrow { color: var(--primary); font-size: 10px; }
.grid .mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
.grid .empty { text-align: center; color: var(--text-muted); padding: 24px; }
.row-error { background: #fef2f2; }
.row-error:hover { background: #fee2e2; }
.row-ok td:first-child { border-left: 3px solid var(--ok); }
.row-warn td:first-child { border-left: 3px solid var(--warn); }
.row-muted { color: var(--text-muted); }
.grand-total td { background: #f8fafc; border-top: 2px solid var(--border); padding: 13px 12px; font-size: 14px; white-space: nowrap; }

/* ---- Tiles (Home) ---- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; margin-top: 20px; }
.tile {
    display: block; background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 20px; box-shadow: var(--shadow); color: var(--text);
    transition: transform .08s ease, box-shadow .08s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.1); }
.tile-icon { font-size: 26px; }
.tile-title { font-weight: 700; margin: 10px 0 4px; }
.tile-desc { color: var(--text-muted); font-size: 13px; }

/* ---- Login ---- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: var(--sidebar); }
.login-card { background: #fff; padding: 36px 32px; border-radius: 14px; width: 340px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-logo { display: block; height: 40px; margin: 0 auto 18px; }
.login-title { margin: 0; font-size: 22px; text-align: center; }
.login-subtitle { margin: 4px 0 22px; text-align: center; color: var(--text-muted); }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--text-muted); }
.login-form input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 15px; }
.login-form .btn-primary { margin-top: 8px; padding: 11px; font-size: 15px; }
.login-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); padding: 10px 12px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

/* ---- Buttons/Extras ---- */
.btn-sm { padding: 4px 10px; font-size: 12px; }
.col-action { width: 44px; text-align: center; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 7px; font-size: 15px; line-height: 1;
    text-decoration: none;
}
.icon-btn:hover { background: #e0e7ff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }

/* ---- Forms ---- */
.page-narrow { max-width: 720px; }
.form-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 16px; }
.form-wide { max-width: 900px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: 13px; color: var(--text-muted); }
.field > span { font-weight: 500; }
.field input, .field select, .field textarea {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; color: var(--text); background: #fff; font-family: inherit;
}
.field textarea { resize: vertical; }
.field textarea.mono, .sql-editor { font-family: "Cascadia Code", Consolas, monospace; font-size: 13px; }
.field-sm { max-width: 160px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 180px; }
.field-check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 14px; align-self: flex-end; padding-bottom: 8px; }
.field-check input { width: 18px; height: 18px; }
.field-readonly { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; color: var(--text-muted); }
.form-actions { display: flex; gap: 10px; margin-top: 10px; }
.form-side-actions { display: flex; gap: 10px; }
.inline-form { margin: 0; }
.danger-zone { border-color: #fecaca; }
.danger-zone p { margin: 0 0 10px; color: var(--text-muted); font-size: 13px; }

/* ---- Chips / Presets ---- */
.preset-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.chip { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; font-size: 12px; color: var(--text); }
.chip:hover { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---- Chart ---- */
.chart-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.chart-wrap { width: 100%; }
.report-chart { width: 100%; height: auto; max-height: 420px; display: block; }
.chart-grid { stroke: #eef2f7; stroke-width: 1; }
.chart-axisline { stroke: #cbd5e1; stroke-width: 1; }
.chart-axis { fill: var(--text-muted); font-size: 11px; }
.chart-empty { padding: 24px; text-align: center; color: var(--text-muted); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; justify-content: center; }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text); }
.chart-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ---- Detail list ---- */
.detail-list { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; }
.dl-row { display: grid; grid-template-columns: 200px 1fr; gap: 16px; padding: 10px 16px; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.dl-row:last-child { border-bottom: none; }
.dl-key { color: var(--text-muted); font-weight: 500; }
.dl-val { word-break: break-word; white-space: pre-wrap; }
.dl-val.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }

/* ---- Tabs (CSS-only, ohne JS) ---- */
.report-tabs { position: relative; }
.tab-radio { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
.tab-bar { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab {
    padding: 9px 18px; cursor: pointer; color: var(--text-muted); font-weight: 500;
    border: 2px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0; margin-bottom: -2px;
    user-select: none;
}
.tab:hover { color: var(--text); }
.tab-content { display: none; }
#rvtab-data:checked ~ .tab-content-data { display: block; }
#rvtab-chart:checked ~ .tab-content-chart { display: block; }
#rvtab-data:checked ~ .tab-bar label[for="rvtab-data"],
#rvtab-chart:checked ~ .tab-bar label[for="rvtab-chart"] {
    color: var(--primary); background: var(--surface);
    border-color: var(--border); border-bottom-color: var(--surface);
}
