/* sesemi Betrieb – Farben aus design/farb-tokens-light-dark.md (gleiche Tokens wie die App) */
:root {
    --bg: #F5F8FC;
    --card: #FFFFFF;
    --surface: #F1F5FA;
    --line: #E3E9F0;
    --text: #172B4D;
    --text-2: #64748B;
    --primary: #0866FF;
    --primary-bg: #E8F0FF;
    --ok-text: #047857;
    --ok-bg: #E7F7EF;
    --warn-text: #92400E;
    --warn-bg: #FEF3C7;
    --error: #EF4444;
    --error-text: #C81E1E;
    --error-bg: #FDECEC;
    --muted-text: #475569;
    --muted-bg: #EEF2F6;
    --nav: #102A43;
    --radius: 10px;
    --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0B1622;
        --card: #13202E;
        --surface: #1B2B3C;
        --line: #1E2E40;
        --text: #E6EDF5;
        --text-2: #9AAABB;
        --primary: #3D8BFF;
        --primary-bg: #13305A;
        --ok-text: #5EE0A8;
        --ok-bg: #0F3326;
        --warn-text: #FBBF5A;
        --warn-bg: #3A2A0A;
        --error: #F05252;
        --error-text: #FF8A8A;
        --error-bg: #3D1518;
        --muted-text: #B3C0CF;
        --muted-bg: #223040;
        --nav: #07111B;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }

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

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

h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
h1:focus { outline: none; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 20px 0 8px; }

code, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.small { font-size: 12.5px; }
.muted { color: var(--text-2); }
.text-error { color: var(--error-text); }
.nowrap { white-space: nowrap; }
.hint { color: var(--text-2); font-size: 13px; border-left: 3px solid var(--line); padding-left: 10px; }

/* ---------- Rahmen ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 228px;
    flex-shrink: 0;
    background: var(--nav);
    color: #DCE6F2;
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; color: inherit; padding: 0 8px 20px; }
.brand:hover { text-decoration: none; }
.brand strong { display: block; font-size: 16px; }
.brand small { display: block; font-size: 12px; opacity: 0.7; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--primary); color: #fff;
    display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.brand-large { color: var(--text); padding: 0 0 16px; }

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { color: #C3D0DF; padding: 8px 12px; border-radius: 8px; }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }
.sidebar nav a.active { background: rgba(255, 255, 255, 0.12); color: #fff; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 0 8px; font-size: 13px; }
.who { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-quiet { color: #9FB2C8; }

.content { flex: 1; min-width: 0; padding: 24px 32px 48px; max-width: 1400px; }
.plain { min-height: 100vh; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.back { font-size: 13px; color: var(--text-2); display: inline-block; margin-bottom: 4px; }

/* ---------- Bausteine ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 16px 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.split .card { margin-bottom: 0; }
.empty { text-align: center; padding: 48px 0; color: var(--text-2); }

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid var(--primary); background: var(--primary); color: #fff;
    border-radius: 8px; padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer;
    white-space: nowrap;
}
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: default; filter: none; }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--line); font-weight: 500; }
.btn-danger { background: var(--error); border-color: var(--error); }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-login { justify-content: center; padding: 10px 16px; }
.icon-btn { border: none; background: none; color: var(--text-2); cursor: pointer; padding: 2px 6px; font-size: 14px; border-radius: 6px; }
.icon-btn:hover:not(:disabled) { background: var(--surface); color: var(--text); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 2px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.chip:hover { border-color: var(--primary); }

.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }
.badge-error { background: var(--error-bg); color: var(--error-text); }
.badge-muted { background: var(--muted-bg); color: var(--muted-text); }

.notice { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.notice-ok { background: var(--ok-bg); color: var(--ok-text); }
.notice-error { background: var(--error-bg); color: var(--error-text); }
.notice-close { border: none; background: none; color: inherit; cursor: pointer; opacity: 0.7; }
.errors { background: var(--error-bg); color: var(--error-text); border-radius: 8px; padding: 10px 14px 10px 32px; margin: 10px 0; font-family: var(--mono); font-size: 12.5px; }

/* ---------- Formulare ---------- */
input, select, textarea {
    font: inherit; color: var(--text); background: var(--card);
    border: 1px solid var(--line); border-radius: 7px; padding: 6px 9px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-bg); border-color: var(--primary); }
input:disabled, select:disabled { background: var(--surface); color: var(--text-2); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); vertical-align: middle; }
input.narrow { width: 72px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.form-grid label > input, .form-grid label > select, .form-grid label > textarea { color: var(--text); font-size: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid label.check, .check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; display: inline-flex; }
.checks { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }

textarea.code {
    width: 100%; font-family: var(--mono); font-size: 13px; line-height: 1.5;
    tab-size: 4; background: var(--surface); resize: vertical;
}
.code-block { font-family: var(--mono); font-size: 12.5px; background: var(--surface); border-radius: 8px; padding: 12px; overflow: auto; max-height: 520px; margin: 0; }

.test-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.test-row label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.test-row .grow { flex: 1; min-width: 240px; }
.samples { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.stack { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.filters input[type="search"] { flex: 1; min-width: 240px; }
.bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }

/* ---------- Tabellen ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card .table { border: none; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface); }
.table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table .num { text-align: right; }
.table .select { width: 36px; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions a { margin-left: 12px; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td, .table tbody tr:hover td { background: color-mix(in srgb, var(--primary-bg) 45%, transparent); }
.table tr.row-error td { background: var(--error-bg); }
.table-edit td { padding: 5px 6px; }
.table-edit input:not([type="checkbox"]) { width: 100%; }
.table-edit input.narrow { width: 72px; }

.facts { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.facts dt { color: var(--text-2); }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 6px; align-items: center; margin: 12px 0; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 8px; padding: 6px 14px; font: inherit; cursor: pointer; }
.tab.active { background: var(--primary-bg); border-color: var(--primary); color: var(--primary); font-weight: 600; }
.tabs input[type="search"] { margin-left: auto; min-width: 220px; }

/* ---------- Übersicht ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin: 16px 0 8px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--text); display: flex; flex-direction: column; gap: 2px; }
.tile:hover { border-color: var(--primary); text-decoration: none; }
.tile-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.tile-label { font-weight: 600; }
.tile-sub { font-size: 12.5px; color: var(--text-2); }

/* ---------- QR ---------- */
.qr-card { text-align: center; }
.qr { width: 180px; height: 180px; image-rendering: pixelated; background: #fff; border-radius: 6px; }
.qr-text { font-weight: 600; margin-top: 4px; }
.qr-card .stack { justify-content: center; }

/* ---------- Anmeldung ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login-card h1 { margin-bottom: 4px; }
.login-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

/* ---------- Etiketten ---------- */
.labels { display: flex; flex-wrap: wrap; gap: 8px; }
.label {
    width: 50mm; height: 30mm; background: #fff; color: #000;
    display: flex; align-items: center; gap: 2mm; padding: 2mm;
    border: 1px dashed #B8C4D2; overflow: hidden;
}
.label img { width: 26mm; height: 26mm; image-rendering: pixelated; flex-shrink: 0; }
.label-text { min-width: 0; display: flex; flex-direction: column; gap: 0.5mm; }
.label-brand { font-size: 7pt; letter-spacing: 0.08em; text-transform: uppercase; color: #333; }
.label-id { font-family: var(--mono); font-weight: 700; font-size: 8.5pt; overflow-wrap: anywhere; line-height: 1.15; }
.label-type { font-size: 6.5pt; color: #333; line-height: 1.2; }
.labels-a4 { gap: 0; width: 210mm; }
.labels-a4 .label { width: 70mm; height: 37mm; padding: 4mm; }
.labels-a4 .label img { width: 29mm; height: 29mm; }
.labels-a4 .label-id { font-size: 10pt; }

@media print {
    html, body { background: #fff; }
    .sidebar, .no-print, .notice, #blazor-error-ui { display: none !important; }
    .content { padding: 0; max-width: none; }
    .labels { gap: 0; }
    .label { border: none; break-inside: avoid; }
    .labels-single .label { break-after: page; }
}

/* ---------- Blazor ---------- */
#blazor-error-ui {
    display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;
    background: var(--warn-bg); color: var(--warn-text); padding: 10px 20px;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 10px; }
#blazor-error-ui .reload { margin-left: 8px; }

@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; height: auto; position: static; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-foot { margin-top: 12px; }
    .content { padding: 16px; }
    .split, .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
}
