/* TronicCAD Backend – Farben nach Design-Vorlage */
:root {
    --blue: #1A6FE8;
    --blue-dark: #1459BD;
    --navy: #0B2A55;
    --navy-deep: #0A1F44;
    --yellow: #F7C21A;
    --bg: #EEF4FC;
    --card: #FFFFFF;
    --text: #0F1B2D;
    --muted: #5A6475;
    --border: #D9E3F0;
    --ok: #15803D;
    --error: #B91C1C;
    --warn: #B45309;
    --radius: 12px;
    --shadow: 0 2px 10px rgba(11, 42, 85, .07);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Inter", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); }
h1, h2 { line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.muted { color: var(--muted); }

/* Marke */
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.35rem; color: inherit; }
.brand strong { color: var(--blue); }
.brand-center { justify-content: center; margin-bottom: 1rem; }

/* Layout Backend */
.admin { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy-deep); color: #fff; padding: 20px 14px; display: flex; flex-direction: column; gap: 24px; }
.sidebar .brand strong { color: #6EA8FF; }
.sidebar ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidebar a, .sidebar .is-disabled { display: block; padding: 9px 12px; border-radius: 8px; color: #D6E2F5; text-decoration: none; }
.sidebar a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar a.is-active { background: var(--blue); color: #fff; }
.sidebar .is-disabled { opacity: .45; cursor: default; }
.sidebar small { font-size: .7rem; text-transform: uppercase; margin-left: 4px; }
.sidebar-footer { margin-top: auto; font-size: .9rem; }

.main { min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 1.3rem; margin: 0; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user form { margin: 0; }
.content { padding: 24px 28px; max-width: 1200px; }

/* Karten & Raster */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; }
.grid-2 > .card { margin-bottom: 20px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }

.table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.table th, .table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }

/* Formulare */
.form label { display: block; margin-bottom: 14px; font-weight: 500; }
.form input[type=text], .form input[type=email], .form input[type=url], .form input[type=password], .form select {
    display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-weight: 400;
    border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text);
}
.form input:focus, .form select:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.form input:disabled { background: var(--bg); color: var(--muted); }
.form .check { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.form-narrow { max-width: 560px; }
.form-actions { display: flex; justify-content: flex-end; }
.field-error { display: block; color: var(--error); font-size: .85rem; font-weight: 400; margin-top: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 20px; border: 0; border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--yellow); color: var(--navy-deep); }
.btn-primary:hover { background: #E8B40C; }
.btn-ghost { background: transparent; color: var(--blue); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--blue); }
.btn-sm { padding: 6px 14px; font-size: .875rem; }
.btn-block { width: 100%; }

/* Meldungen */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border-left: 4px solid; background: #fff; }
.alert-success { border-color: var(--ok); color: var(--ok); }
.alert-error { border-color: var(--error); color: var(--error); }
.alert-warning { border-color: var(--warn); color: var(--warn); }
.alert-info { border-color: var(--blue); color: var(--blue-dark); }

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { padding: 3px 0; }
.checklist .ok { color: var(--ok); }
.checklist .fail { color: var(--error); }

/* Einzelseiten (Login, Installer, Fehler) */
.plain { display: flex; justify-content: center; padding: 48px 16px; }
.plain-box { width: 100%; max-width: 640px; }
.plain-title { text-align: center; font-size: 1.5rem; margin: 0 0 1.25rem; }
.plain .form > .card, .plain > .plain-box > .card { margin-bottom: 18px; }

/* Listen & Werkzeugleisten */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar p { margin: 0; }
.card-flush { padding: 6px 10px; }
.card-flush .table { margin: 0; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.small { font-size: .85rem; }
.inline { display: inline; margin: 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; cursor: pointer; text-decoration: underline; }
.link-btn.danger, .danger { color: var(--error); }
.icon-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; width: 26px; height: 26px; cursor: pointer; color: var(--text); }
.icon-btn:hover { border-color: var(--blue); }
.table tr.is-child td:first-child { padding-left: 26px; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); vertical-align: middle; margin-left: 4px; }
.badge-published, .badge-ok { background: #DCF5E3; color: var(--ok); }
.badge-draft { background: #FEF3C7; color: var(--warn); }
.badge-error { background: #FDE2E2; color: var(--error); }

/* Zweispaltig: Inhalt + Seitenleiste */
.layout-sidebar { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }

/* Tabs */
.tab-list { display: flex; gap: 4px; margin-bottom: -1px; }
.tab-list button { border: 1px solid var(--border); border-bottom: 0; background: var(--bg); padding: 8px 18px; border-radius: 10px 10px 0 0; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.tab-list button[aria-selected="true"] { background: #fff; color: var(--blue); }
.tab-list button.has-error::after { content: " •"; color: var(--error); }
.tab-panel { border-top-left-radius: 0; }
.pill-tabs { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.pill-tabs a { padding: 7px 16px; border-radius: 999px; background: #fff; text-decoration: none; font-weight: 600; color: var(--muted); border: 1px solid var(--border); }
.pill-tabs a[aria-current] { background: var(--blue); color: #fff; border-color: var(--blue); }
.pill-tabs .pill-tabs-extra { margin-left: auto; border: 0; background: none; color: var(--blue); }

/* Formular-Ergänzungen */
.form textarea { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; font: inherit; font-weight: 400; border: 1px solid var(--border); border-radius: 8px; resize: vertical; }
.input-prefix { display: flex; align-items: stretch; margin-top: 5px; }
.input-prefix > span { display: flex; align-items: center; padding: 0 10px; background: var(--bg); border: 1px solid var(--border); border-right: 0; border-radius: 8px 0 0 8px; color: var(--muted); font-weight: 400; font-size: .9rem; }
.form .input-prefix input { margin-top: 0; border-radius: 0 8px 8px 0; }
.field { margin-bottom: 14px; }
.field-label { display: block; font-weight: 500; margin-bottom: 5px; }
.editor { min-height: 320px; background: #fff; font-size: 1rem; }
.ql-toolbar.ql-snow { border-radius: 8px 8px 0 0; border-color: var(--border); background: var(--bg); }
.ql-container.ql-snow { border-radius: 0 0 8px 8px; border-color: var(--border); }
.editor-source { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; }
.seo { margin-top: 8px; }
.seo summary { cursor: pointer; color: var(--blue); font-weight: 500; margin-bottom: 10px; }
.upload-form { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 30%); padding: 18px 0 8px; gap: 12px; }

.cover-preview { width: 100%; height: 140px; object-fit: cover; border-radius: 8px; margin-bottom: 12px; background: var(--bg); }
.form input[type=datetime-local], .form input[type=file] { display: block; width: 100%; margin-top: 5px; font: inherit; font-weight: 400; }
.form input[type=datetime-local] { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; }
.toolbar .pill-tabs { margin-bottom: 0; }

.mono { font-family: ui-monospace, Consolas, monospace; }
.break { word-break: break-all; }
.h-sm { font-size: .95rem; margin: 20px 0 8px; }
.editor-sm { min-height: 200px; }
.tab-panel-plain { padding-top: 0; }
.tab-panel-plain .ql-toolbar.ql-snow { border-top-left-radius: 0; }
.api-doc pre { background: var(--navy-deep); color: #E2ECFA; padding: 14px 16px; border-radius: 8px; overflow-x: auto; font-size: .82rem; line-height: 1.5; }
.api-doc table { margin-bottom: 18px; }

.center { text-align: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.error-trace { white-space: pre-wrap; font-size: .8rem; background: var(--bg); padding: 12px; border-radius: 8px; overflow-x: auto; }

/* Statistik */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: grid; gap: 2px; }
.kpi-label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.kpi-value { font-size: 1.7rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: .8rem; }
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.chart-head h2 { margin: 0; }
.chart-legend { display: flex; gap: 16px; list-style: none; margin: 0; padding: 0; font-size: .85rem; color: var(--muted); }
.chart-legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch-human { background: #1A6FE8; }
.swatch-bot { background: #D98A00; }
.chart { width: 100%; height: auto; display: block; margin-top: 12px; }
.chart-grid { stroke: #E6ECF4; stroke-width: 1; }
.chart-base { stroke: #C5D0DE; stroke-width: 1; }
.chart-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.bar-human { fill: #1A6FE8; }
.bar-bot { fill: #D98A00; }
.chart-hit { fill: transparent; }
.chart-col:hover .chart-hit { fill: rgba(26, 111, 232, .06); }
.chart-table { margin-top: 10px; }
.chart-table summary { cursor: pointer; color: var(--blue); font-size: .85rem; }
.stats-grid { gap: 0 20px; }
.stats-table td { vertical-align: top; }
.stats-label { width: 100%; }
.stats-label span { display: block; overflow-wrap: anywhere; }
.stats-bar { display: block; width: 100%; height: 4px; margin-top: 4px; }
.stats-bar rect { fill: #1A6FE8; opacity: .55; }

/* Mediathek */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.media-item { margin: 0; padding: 0; overflow: hidden; }
.media-item img { display: block; width: 100%; height: 150px; object-fit: cover; background: var(--bg); }
.media-item figcaption { padding: 10px 12px 12px; display: grid; gap: 6px; font-size: .85rem; }
.media-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-field { width: 100%; font-size: .75rem; padding: 4px 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); }

/* Startseiten-Editor */
.home-section summary { cursor: pointer; list-style: none; }
.home-section summary::-webkit-details-marker { display: none; }
.home-section summary h2 { display: inline; }
.home-section summary::after { content: "▾"; float: right; color: var(--muted); }
.home-section[open] summary { margin-bottom: 14px; }
.list-field { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px 4px; margin: 0 0 16px; }
.list-field legend { font-weight: 600; padding: 0 6px; }
.list-row { display: flex; gap: 12px; align-items: flex-start; border-bottom: 1px dashed var(--border); padding-top: 6px; }
.list-row:last-child { border-bottom: 0; }
.list-no { flex: none; width: 22px; height: 22px; margin-top: 30px; border-radius: 50%; background: var(--bg); color: var(--muted); display: grid; place-items: center; font-size: .75rem; font-weight: 700; }
.list-cell { flex: 1; min-width: 0; font-size: .85rem; }
.list-cell.list-icon { flex: 0 0 150px; }

@media (max-width: 1100px) {
    .layout-sidebar { grid-template-columns: 1fr; }
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
    .list-row { flex-wrap: wrap; }
    .list-cell.list-icon { flex-basis: 100%; }
    .admin { grid-template-columns: 1fr; }
    .sidebar { padding: 14px 16px; gap: 12px; }
    .sidebar ul { grid-auto-flow: column; overflow-x: auto; }
    .sidebar-footer { display: none; }
    .topbar, .content { padding-left: 16px; padding-right: 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
