/* digiGate — Oberfläche im UniFi-Stil (Design-Handoff 2026-11).
   Leitsatz: ein Werkzeug, kein Dashboard. Präfix dg-, Werte nur über Token. */
:root {
    /* Farben */
    --dg-bg-app: #f4f5f6;
    --dg-bg-surface: #ffffff;
    --dg-bg-subtle: #f9fafa;
    --dg-bg-input: #f6f6f7;
    --dg-bg-hover-app: #e9eaec;
    --dg-line: #efeff0;
    --dg-line-control: #dee0e3;
    --dg-text-primary: #212327;
    --dg-text-secondary: #51565d;
    --dg-text-tertiary: #818892;
    --dg-text-disabled: #c3c6ca;
    --dg-accent: #006fff;
    --dg-accent-subtle: #e5f0ff;
    --dg-success: #38cc65;
    --dg-warning: #f29d0c;
    --dg-danger: #e5484d;
    --dg-ink-strong: #212327;

    /* Schrift */
    --dg-font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;

    /* Maße */
    --dg-topbar-height: 50px;
    --dg-rail-width: 50px;
    --dg-filter-width: 272px;
    --dg-panel-width: 400px;
    --dg-row-height: 32px;
    --dg-control-height: 32px;
    --dg-radius-sm: 4px;
    --dg-radius-md: 8px;
    --dg-shadow-panel: -4px 0 12px rgba(33, 35, 39, .06);
}

* { box-sizing: border-box; }
/* hidden gewinnt gegen eigene display-Regeln. */
[hidden] { display: none !important; }

html, body { margin: 0; }
body {
    background: var(--dg-bg-surface);
    color: var(--dg-text-secondary);
    font-family: var(--dg-font);
    font-size: 13px;
    line-height: 20px;
    font-weight: 400;
    font-feature-settings: "tnum", "zero";
    -webkit-font-smoothing: antialiased;
}
input, select, button, textarea { font: inherit; font-feature-settings: "tnum", "zero"; }
a { color: var(--dg-accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }
h1, h2, h3 { margin: 0; color: var(--dg-text-primary); font-weight: 600; }
h1 { font-size: 14px; line-height: 20px; }
h2, h3 { font-size: 12px; line-height: 16px; }
code { font: inherit; }
table { border-collapse: collapse; }

.dg-visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.dg-inline { display: inline; }
.dg-muted { color: var(--dg-text-secondary); }
.dg-hint, .dg-note { display: block; font-size: 12px; line-height: 16px; color: var(--dg-text-tertiary); }
.dg-text-primary { color: var(--dg-text-primary); }
.dg-text-tertiary { color: var(--dg-text-tertiary); }
.dg-text-warning { color: var(--dg-warning); }
.dg-text-danger { color: var(--dg-danger); }

/* Tooltip: rechts neben dem Element, Variante unterhalb (Panel-Tabs am rechten Rand). */
[data-tip] { position: relative; }
[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%);
    background: var(--dg-ink-strong); color: #fff;
    font-size: 12px; line-height: 16px; font-weight: 400;
    padding: 4px 8px; border-radius: var(--dg-radius-sm);
    white-space: nowrap; z-index: 40; pointer-events: none;
}
[data-tip].dg-tip-below:hover::after { left: 50%; top: calc(100% + 6px); transform: translateX(-50%); }

/* Statuspunkt — trägt die Information, kein Badge. */
.dg-dot { display: inline-block; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--dg-text-disabled); vertical-align: middle; }
.dg-dot-success { background: var(--dg-success); }
.dg-dot-warning { background: var(--dg-warning); }
.dg-dot-danger { background: var(--dg-danger); }
.dg-dot-disabled { background: var(--dg-text-disabled); }
.dg-state { display: inline-flex; align-items: center; gap: 8px; }

/* Logo (Platzhalter bis zum echten Logo) */
.dg-logo { width: 24px; height: 24px; border-radius: var(--dg-radius-sm); background: var(--dg-accent); display: flex; align-items: center; justify-content: center; flex: none; }
.dg-logo::before { content: ""; width: 8px; height: 8px; border: 2px solid #fff; border-radius: 2px; }

/* ---------- Gerüst ---------- */
.dg-shell { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.dg-topbar { height: var(--dg-topbar-height); flex: none; display: flex; align-items: center; background: var(--dg-bg-app); position: relative; padding: 0 16px 0 0; }
.dg-topbar-logo { width: var(--dg-rail-width); flex: none; display: flex; align-items: center; justify-content: center; }
.dg-tenant { position: relative; }
.dg-tenant-button {
    display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px;
    border: 0; border-radius: var(--dg-radius-sm); background: transparent;
    color: var(--dg-text-primary); font-weight: 600; cursor: pointer; white-space: nowrap;
}
.dg-tenant-button:hover { background: var(--dg-bg-hover-app); }
.dg-tenant-button svg { color: var(--dg-text-tertiary); }
.dg-tenant-label { display: flex; align-items: center; height: 32px; padding: 0 8px; color: var(--dg-text-primary); font-weight: 600; white-space: nowrap; }
.dg-menu {
    position: absolute; top: calc(100% + 4px); left: 0; min-width: 240px; max-height: 60vh; overflow: auto;
    background: var(--dg-bg-surface); border: 1px solid var(--dg-line-control); border-radius: var(--dg-radius-sm);
    padding: 4px; z-index: 50; display: flex; flex-direction: column;
}
.dg-menu form { margin: 0; }
.dg-menu-item {
    display: flex; align-items: center; width: 100%; height: 32px; padding: 0 8px;
    border: 0; border-radius: var(--dg-radius-sm); background: transparent; color: var(--dg-text-secondary);
    cursor: pointer; text-align: left; white-space: nowrap;
}
.dg-menu-item:hover { background: var(--dg-bg-subtle); text-decoration: none; }
.dg-menu-item.is-active { color: var(--dg-accent); font-weight: 500; }
.dg-area-title {
    position: absolute; left: 50%; top: 0; height: var(--dg-topbar-height); transform: translateX(-50%);
    display: flex; align-items: center; color: var(--dg-text-disabled); font-size: 16px; font-weight: 600;
    white-space: nowrap; pointer-events: none;
}
.dg-avatar {
    margin-left: auto; width: 28px; height: 28px; border: 0; border-radius: 50%;
    background: var(--dg-ink-strong); color: #fff; font-size: 11px; font-weight: 600; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center; flex: none;
}

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

/* Icon-Leiste */
.dg-rail {
    width: var(--dg-rail-width); flex: none; background: var(--dg-bg-surface); border-right: 1px solid var(--dg-line);
    display: flex; flex-direction: column; align-items: center; padding: 7px 0; gap: 4px; z-index: 3;
}
.dg-rail-item {
    width: 36px; height: 36px; border-radius: var(--dg-radius-sm); display: flex; align-items: center; justify-content: center;
    color: var(--dg-text-tertiary); background: transparent;
}
.dg-rail-item:hover { text-decoration: none; }
.dg-rail-item.is-active { background: var(--dg-accent-subtle); color: var(--dg-accent); }

/* Filterspalte */
.dg-filters {
    width: var(--dg-filter-width); flex: none; background: var(--dg-bg-surface); border-right: 1px solid var(--dg-line);
    overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; z-index: 2;
}
.dg-search {
    display: flex; align-items: center; gap: 8px; height: var(--dg-control-height);
    background: var(--dg-bg-input); border-radius: var(--dg-radius-sm); padding: 0 10px; color: var(--dg-text-tertiary); margin: 0;
}
.dg-search:focus-within { outline: 2px solid var(--dg-accent); outline-offset: -2px; }
.dg-search input[type="search"] {
    border: 0; background: transparent; color: var(--dg-text-secondary); width: 100%; min-width: 0;
    height: var(--dg-control-height); padding: 0; outline: none; appearance: none;
}
.dg-search input[type="search"]:focus { outline: none; }
.dg-search input::placeholder { color: var(--dg-text-disabled); }
.dg-filter-section { display: flex; flex-direction: column; gap: 8px; }
.dg-filter-title {
    display: flex; justify-content: space-between; align-items: center; width: 100%; height: 20px;
    border: 0; background: transparent; padding: 0; color: var(--dg-text-primary);
    font-size: 12px; font-weight: 600; cursor: pointer; text-align: left;
}
.dg-filter-title svg { color: var(--dg-text-tertiary); }
.dg-filter-section.is-collapsed .dg-filter-title svg { transform: rotate(-90deg); }
.dg-filter-section.is-collapsed .dg-filter-items { display: none; }
.dg-filter-items { display: flex; flex-direction: column; gap: 4px; }
.dg-check { display: flex; align-items: center; gap: 8px; height: 24px; cursor: pointer; color: var(--dg-text-secondary); min-width: 0; }
.dg-check span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dg-filter-note { font-size: 12px; line-height: 16px; color: var(--dg-text-tertiary); }

/* Inhalt */
.dg-content { flex: 1; min-width: 0; overflow: auto; background: var(--dg-bg-surface); display: flex; flex-direction: column; }
.dg-content-page { background: var(--dg-bg-subtle); padding: 16px 24px 24px; }
.dg-empty { padding: 12px; color: var(--dg-text-tertiary); }

/* Detail-Panel */
.dg-panel {
    width: var(--dg-panel-width); flex: none; background: var(--dg-bg-subtle); box-shadow: var(--dg-shadow-panel);
    display: flex; flex-direction: column; overflow: auto; position: relative; z-index: 4;
}
.dg-panel-head { height: var(--dg-topbar-height); flex: none; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 16px; }
.dg-panel-title { font-size: 14px; font-weight: 600; color: var(--dg-text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }
.dg-panel-close {
    position: absolute; right: 12px; top: 11px; width: 28px; height: 28px; border: 0; border-radius: var(--dg-radius-sm);
    background: transparent; color: var(--dg-text-tertiary); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.dg-panel-close:hover { background: var(--dg-line); }
.dg-panel-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 16px; }
.dg-panel-body form { margin: 0; }

/* ---------- Bausteine ---------- */

/* Buttons: sekundär = Outline weiß, Primär nur auf öffentlichen Seiten. */
.dg-btn {
    height: var(--dg-control-height); padding: 0 12px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: 1px solid var(--dg-line-control); border-radius: var(--dg-radius-sm); background: var(--dg-bg-surface);
    color: var(--dg-accent); font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.dg-btn:hover { background: var(--dg-bg-subtle); text-decoration: none; }
.dg-btn:disabled { color: var(--dg-text-disabled); cursor: default; background: var(--dg-bg-surface); }
.dg-btn-danger { color: var(--dg-danger); }
.dg-btn-primary { background: var(--dg-accent); border-color: var(--dg-accent); color: #fff; }
.dg-btn-primary:hover { background: var(--dg-accent); filter: brightness(.95); }
.dg-btn-block { width: 100%; }
.dg-btn-ghost, .dg-btn-sm { /* Altnamen: gleiche Optik wie .dg-btn */ }
.dg-link-button { border: 0; background: none; padding: 0; color: var(--dg-accent); cursor: pointer; text-align: left; }
.dg-link-button:hover { text-decoration: underline; }

/* Eingabefelder: ohne Rahmen, Grund bg-input. */
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="search"],
input[type="tel"], input[type="datetime-local"], input[type="date"], select, textarea {
    height: var(--dg-control-height); border: 0; border-radius: var(--dg-radius-sm); background: var(--dg-bg-input);
    color: var(--dg-text-secondary); padding: 0 10px; width: 100%; min-width: 0; font-size: 13px;
}
select:disabled, input:disabled { color: var(--dg-text-tertiary); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--dg-accent); outline-offset: -2px; }
input::placeholder { color: var(--dg-text-disabled); }
input[type="checkbox"] {
    appearance: none; width: 16px; height: 16px; margin: 0; border: 1px solid var(--dg-line-control); border-radius: var(--dg-radius-sm);
    background: var(--dg-bg-surface); display: inline-grid; place-content: center; cursor: pointer; flex: none; vertical-align: middle;
}
input[type="checkbox"]:checked { background: var(--dg-accent); border-color: var(--dg-accent); }
input[type="checkbox"]:checked::before {
    content: ""; width: 9px; height: 5px; border-left: 2px solid #fff; border-bottom: 2px solid #fff; transform: translateY(-1px) rotate(-45deg);
}
input[type="checkbox"]:disabled { cursor: default; opacity: .5; }

.dg-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; margin: 0; }
.dg-field > label, .dg-field > .dg-label { font-size: 12px; line-height: 16px; color: var(--dg-text-tertiary); }
.dg-field-check { flex-direction: row; align-items: center; gap: 8px; }
.dg-field-check > label { font-size: 13px; line-height: 20px; color: var(--dg-text-secondary); }
.dg-field-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dg-field-sm { max-width: 160px; }
.dg-readonly { height: var(--dg-control-height); line-height: var(--dg-control-height); border-radius: var(--dg-radius-sm); background: var(--dg-bg-input); color: var(--dg-text-tertiary); padding: 0 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-form { display: flex; flex-direction: column; gap: 12px; }
.dg-form-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.dg-form-row .dg-field { flex: 1 1 200px; }

/* Segment (Panel-Tabs mit Icons, Seiten-Tabs mit Text, Kautionsmodus …) */
.dg-segment, .dg-tabs { display: flex; background: var(--dg-bg-input); border-radius: var(--dg-radius-sm); padding: 2px; gap: 2px; }
.dg-segment-item, .dg-tab {
    flex: 1; height: 28px; border: 0; border-radius: 3px; background: transparent; color: var(--dg-text-tertiary);
    cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; text-decoration: none; white-space: nowrap;
}
.dg-segment-item:hover, .dg-tab:hover { text-decoration: none; }
.dg-segment-item.is-active, .dg-tab-active { background: var(--dg-bg-surface); color: var(--dg-accent); }

/* Karten */
.dg-card { background: var(--dg-bg-surface); border-radius: var(--dg-radius-md); padding: 16px; display: flex; flex-direction: column; gap: 12px; margin: 0; }
.dg-card > form:not(.dg-form-row):not(.dg-inline) { display: flex; flex-direction: column; gap: 12px; }
.dg-card > form > .dg-btn, .dg-card > .dg-btn, .dg-card > form > .dg-form-row > .dg-btn { align-self: flex-start; }
.dg-card-title { font-size: 12px; line-height: 16px; font-weight: 600; color: var(--dg-text-primary); }

/* Key/Value-Karte */
.dg-kv { background: var(--dg-bg-surface); border-radius: var(--dg-radius-md); padding: 4px 16px; }
.dg-kv-row { display: flex; justify-content: space-between; gap: 16px; min-height: 32px; align-items: center; border-bottom: 1px solid var(--dg-line); }
.dg-kv-row:last-child { border-bottom: 0; }
.dg-kv-row > :first-child { white-space: nowrap; }
.dg-kv-row > :last-child { text-align: right; overflow-wrap: anywhere; }
.dg-kv-inset { background: var(--dg-bg-input); border-radius: var(--dg-radius-sm); padding: 0 10px; }

/* Definitionsliste (Inhaltsseiten) in derselben Zeilenoptik */
.dg-dl { display: grid; grid-template-columns: max-content 1fr; column-gap: 16px; margin: 0; }
.dg-dl dt, .dg-dl dd { min-height: 32px; display: flex; align-items: center; border-bottom: 1px solid var(--dg-line); margin: 0; }
.dg-dl dt { white-space: nowrap; }
.dg-dl dd { justify-content: flex-end; text-align: right; overflow-wrap: anywhere; }
.dg-dl dt:last-of-type, .dg-dl dd:last-of-type { border-bottom: 0; }

/* Meldungen: Punkt + Text statt farbiger Fläche. */
.dg-status { display: grid; grid-template-columns: 6px 1fr; column-gap: 8px; align-items: start; margin: 0; color: var(--dg-text-secondary); }
.dg-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; margin-top: 7px; background: var(--dg-success); grid-row: 1 / span 20; }
.dg-status > * { grid-column: 2; }
.dg-status-error { color: var(--dg-danger); }
.dg-status-error::before { background: var(--dg-danger); }

/* Bestätigung destruktiver Aktionen */
.dg-confirm { background: var(--dg-bg-surface); border: 1px solid var(--dg-line-control); border-radius: var(--dg-radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.dg-confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Ausgestellter Link (einmalig sichtbar) */
.dg-issued { background: var(--dg-bg-surface); border-radius: var(--dg-radius-md); padding: 12px 16px; display: flex; flex-direction: column; gap: 4px; }
.dg-issued-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tabellen ---------- */

/* Listen-Tabelle der Screens: voll breit, ohne Außenrahmen, ohne Zebra. */
.dg-list-table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
.dg-list-table th, .dg-list-table td {
    height: var(--dg-row-height); border-bottom: 1px solid var(--dg-line); padding: 0 12px; text-align: left; vertical-align: middle;
}
.dg-list-table th { font-weight: 600; color: var(--dg-text-primary); position: sticky; top: 0; background: var(--dg-bg-surface); z-index: 1; }
.dg-list-table td { color: var(--dg-text-secondary); }
.dg-list-table .dg-col-dot { width: 32px; padding: 0; text-align: center; }
.dg-list-table .dg-col-fill { width: 100%; padding: 0; }
.dg-list-table .dg-num { text-align: right; }
.dg-list-table tbody tr { cursor: pointer; }
.dg-list-table tbody tr:hover { background: var(--dg-bg-subtle); }
.dg-list-table tbody tr.is-selected, .dg-list-table tbody tr.is-selected:hover { background: var(--dg-accent-subtle); }
.dg-list-table tbody tr:focus-visible { outline: 2px solid var(--dg-accent); outline-offset: -2px; }

/* Tabelle in Inhaltsseiten (Karten) */
.dg-table { width: 100%; border-collapse: collapse; }
.dg-table th, .dg-table td { height: var(--dg-row-height); padding: 4px 12px; border-bottom: 1px solid var(--dg-line); text-align: left; vertical-align: middle; }
.dg-table th { font-weight: 600; color: var(--dg-text-primary); }
.dg-table tr:last-child td { border-bottom: 0; }
.dg-table th:first-child, .dg-table td:first-child { padding-left: 0; }
.dg-table th:last-child, .dg-table td:last-child { padding-right: 0; }
.dg-table .dg-num { text-align: right; }
.dg-table .dg-actions { text-align: right; white-space: nowrap; }
.dg-table .dg-actions form { display: inline-flex; gap: 8px; align-items: center; }
.dg-table select { width: auto; }
.dg-table tr.dg-muted td { color: var(--dg-text-tertiary); }

/* Inhaltsseiten (Formulare, Konto, Benutzer-Details) */
.dg-page { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 720px; }
.dg-page-narrow { max-width: 480px; }
.dg-detail-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; }
.dg-breadcrumb { font-size: 12px; line-height: 16px; }

/* ---------- Öffentliche Seiten ---------- */
.dg-public { min-height: 100vh; background: var(--dg-bg-app); display: flex; justify-content: center; align-items: flex-start; padding: 48px 24px; }
.dg-public-card { width: 100%; max-width: 400px; background: var(--dg-bg-surface); border-radius: var(--dg-radius-md); padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dg-public-card > form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.dg-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--dg-text-primary); }
.dg-public-title { font-size: 16px; line-height: 24px; font-weight: 600; color: var(--dg-text-primary); }
.dg-plate-hero { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; }
.dg-plate-big { font-size: 24px; line-height: 32px; font-weight: 600; color: var(--dg-text-primary); }
.dg-public-section { border-top: 1px solid var(--dg-line); padding-top: 12px; }
.dg-public-kv .dg-kv-row > :last-child { color: var(--dg-text-secondary); }

/* Honeypot: aus dem Bild geschoben, nicht display:none — Bots erkennen das. */
.dg-hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
