:root {
    --brand: #1f4e79;
    --brand-2: #2e75b6;
    --bg: #f3f5f8;
    --panel: #ffffff;
    --line: #dde3ea;
    --text: #1d2733;
    --muted: #6b7785;
    /* Statusfarben */
    --st-blau: #dcecfb;
    --st-blau-line: #7fb2e5;
    --st-gruen: #d9f2df;
    --st-gruen-line: #4caf6a;
    --st-gelb: #fff4c2;
    --st-gelb-line: #e0b400;
    --st-orange: #ffe1c4;
    --st-orange-line: #f08a24;
    --st-rot: #fbd5d5;
    --st-rot-line: #d64545;
}

html, body {
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100%;
}

a, .btn-link { color: var(--brand-2); }
.btn-primary { background-color: var(--brand); border-color: var(--brand); }
.btn-primary:hover { background-color: #173c5e; border-color: #173c5e; }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background-color: var(--brand); border-color: var(--brand); }
h1:focus { outline: none; }

/* Shell */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-top {
    display: flex; align-items: center; gap: 1.5rem; padding: 0 1rem; height: 52px;
    background: linear-gradient(90deg, var(--brand) 0%, var(--brand-2) 100%); color: #fff; flex-shrink: 0;
}
.app-brand { color: #fff !important; font-weight: 700; font-size: 1.15rem; text-decoration: none; letter-spacing: .02em; }
.app-nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.app-nav a { color: rgba(255,255,255,.85); text-decoration: none; padding: .35rem .75rem; border-radius: 6px; white-space: nowrap; }
.app-nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.app-nav a.active { background: rgba(255,255,255,.22); color: #fff; }
.app-user { display: flex; align-items: center; gap: .75rem; font-size: .9rem; white-space: nowrap; }
.app-main { flex: 1; padding: 1rem; min-height: 0; display: flex; flex-direction: column; }

.app-dialog { border: none; border-radius: 10px; padding: 1.25rem; max-width: 460px; width: calc(100% - 32px); box-shadow: 0 10px 40px rgba(0,0,0,.25); color: var(--text); }
.app-dialog::backdrop { background: rgba(10, 20, 30, .45); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin-bottom: 1rem; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: #fff; padding: .35rem .8rem; border-radius: 6px; font-size: .9rem; }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.modal-backdrop-lite { position: fixed; inset: 0; background: rgba(10,20,30,.4); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-lite { width: 100%; max-width: 420px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%); }
.login-card { background: #fff; border-radius: 14px; padding: 2rem; width: 100%; max-width: 400px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.brand-mark { font-size: 1.8rem; font-weight: 700; color: var(--brand); }

/* Start */
.start-wrap { max-width: 900px; margin: 2rem auto; width: 100%; }
.start-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.start-tile { display: flex; flex-direction: column; gap: .35rem; padding: 1.5rem; background: #fff; border: 1px solid var(--line);
    border-radius: 12px; text-decoration: none; color: var(--text); transition: box-shadow .15s, transform .15s; }
.start-tile:hover { box-shadow: 0 8px 24px rgba(31,78,121,.15); transform: translateY(-2px); color: var(--text); }
.start-icon { font-size: 2rem; color: var(--brand-2); }
.start-title { font-size: 1.2rem; font-weight: 600; }
.start-text { color: var(--muted); font-size: .9rem; }

.table code { word-break: break-all; font-size: .8rem; }
.table td input.form-control { min-width: 9rem; }

/* Konfiguration */
.attr-card { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .75rem; margin-bottom: .5rem; background: #fafbfc; }
.cols-box { margin-top: .5rem; padding: .5rem; border-left: 3px solid var(--brand-2); background: #fff; border-radius: 4px; }

/* Erfassung */
.capture { display: flex; flex-direction: column; flex: 1; min-height: calc(100vh - 52px - 2rem); gap: .75rem; }
.capture-toolbar { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap;
    background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .6rem .75rem; }
.export-panel { background: #f1faf3; border: 1px solid #bfe3c8; border-radius: 10px; padding: .75rem; }
.capture-body { display: grid; grid-template-columns: minmax(230px, 300px) minmax(320px, 1fr) minmax(320px, 1.2fr); gap: .75rem; flex: 1; min-height: 0; }
.capture-body > section { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .75rem; min-height: 0; overflow: auto; }
.col-files { display: flex; flex-direction: column; }
.col-preview { padding: 0 !important; overflow: hidden !important; display: flex; }
.col-preview iframe { border: 0; width: 100%; height: 100%; min-height: 60vh; border-radius: 10px; }
.img-wrap { overflow: auto; width: 100%; height: 100%; padding: .5rem; text-align: center; }
.img-wrap img { max-width: 100%; height: auto; }
.empty-hint { color: var(--muted); display: flex; align-items: center; justify-content: center; text-align: center; width: 100%; min-height: 160px; padding: 1rem; }

.dropzone { position: relative; border: 2px dashed #a9bccf; border-radius: 10px; background: #f7fafd; min-height: 92px;
    display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: .9rem; }
.dropzone:hover { border-color: var(--brand-2); background: #eef5fc; }
.dropzone.busy { opacity: .7; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dz-text { pointer-events: none; padding: .5rem; }

.file-list-head { display: flex; gap: .5rem; align-items: center; margin: .6rem 0 .3rem; padding: 0 .25rem; }
.file-list { list-style: none; padding: 0; margin: 0; flex: 1; overflow: auto; }
.file-item { display: flex; gap: .5rem; align-items: flex-start; padding: .45rem .5rem; border-radius: 6px; cursor: pointer;
    border: 1px solid transparent; border-left: 4px solid transparent; margin-bottom: 3px; }
.file-item:hover { border-color: var(--line); }
.file-item.current { outline: 2px solid var(--brand-2); outline-offset: -2px; }
.file-meta { min-width: 0; flex: 1; }
.file-name { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-sub { font-size: .75rem; color: var(--muted); }

.st-neu { background: #fff; }
.file-item.st-neu { border-left-color: #d0d6dd; }
.st-blau { background: var(--st-blau); }
.file-item.st-blau { border-left-color: var(--st-blau-line); }
.st-gruen { background: var(--st-gruen); }
.file-item.st-gruen { border-left-color: var(--st-gruen-line); }
.st-gelb { background: var(--st-gelb); }
.file-item.st-gelb { border-left-color: var(--st-gelb-line); }
.st-orange { background: var(--st-orange); }
.file-item.st-orange { border-left-color: var(--st-orange-line); }
.st-rot { background: var(--st-rot); }
.file-item.st-rot { border-left-color: var(--st-rot-line); }
.st-fehler { background: repeating-linear-gradient(45deg, #fff, #fff 6px, #f3e3e3 6px, #f3e3e3 12px); }
.file-item.st-fehler { border-left-color: #8a2c2c; }
.st-sel { background: #fff; border: 2px solid var(--brand-2); }
.st-badge { color: var(--text); font-weight: 500; border: 1px solid var(--line); }

.dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 50%; border: 1px solid #b8c2cc; vertical-align: -1px; }
.legend { display: flex; flex-wrap: wrap; gap: .25rem .75rem; margin-top: .5rem; color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .75rem; margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; }
.attr-table th { width: 38%; font-weight: 500; color: var(--muted); font-size: .85rem; }
.attr-table td { font-size: .9rem; word-break: break-word; }
.attr-table th[colspan] { width: auto; border-bottom: 0; padding-bottom: 0; }
.attr-table table { word-break: normal; }
.attr-table table th { width: auto; font-size: .75rem; white-space: nowrap; }
.attr-table tr.missing th, .attr-table tr.missing td { background: #fdecec; }
.history { padding-left: 1rem; margin-top: .4rem; }
.history li { margin-bottom: .3rem; }

.statusbar { display: grid; grid-template-columns: 4rem 220px 1fr; align-items: center; gap: .75rem; background: #fff;
    border: 1px solid var(--line); border-radius: 10px; padding: .5rem .75rem; font-size: .9rem; }
.statusbar.running { border-color: var(--brand-2); }
.status-pct { font-weight: 700; color: var(--brand); text-align: right; }
.status-bar { height: 10px; background: #e7ecf1; border-radius: 6px; overflow: hidden; }
.status-fill { height: 100%; background: linear-gradient(90deg, var(--brand-2), var(--brand)); transition: width .4s; }
.statusbar.running .status-fill { background-size: 30px 30px;
    background-image: linear-gradient(45deg, rgba(255,255,255,.25) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.25) 50%, rgba(255,255,255,.25) 75%, transparent 75%), linear-gradient(90deg, var(--brand-2), var(--brand));
    animation: stripes 1s linear infinite; }
@keyframes stripes { from { background-position: 0 0, 0 0; } to { background-position: 30px 0, 0 0; } }
.status-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1100px) {
    .capture-body { grid-template-columns: 1fr 1fr; }
    .col-preview { grid-column: 1 / -1; min-height: 60vh; }
}
@media (max-width: 700px) {
    .app-main { padding: .5rem 16px; }
    .app-top { gap: .75rem; }
    .app-user span { display: none; }
    .capture-body { grid-template-columns: 1fr; }
    .statusbar { grid-template-columns: 3rem 1fr; }
    .status-text { grid-column: 1 / -1; white-space: normal; }
}

/* Blazor-Standard */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }
#blazor-error-ui {
    background: lightyellow; bottom: 0; box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); box-sizing: border-box;
    display: none; left: 0; padding: 0.6rem 1.25rem 0.7rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }
.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; }
.blazor-error-boundary::after { content: "Es ist ein Fehler aufgetreten."; }
