/* =====================================================================
   patch.altmark.cloud — Oberfläche

   Aufbau:
     1. Farbtokens (dunkel als Standard, hell über [data-theme="light"])
     2. Grundgerüst und Kopfzeile
     3. Kennzahlen, Filter, gespeicherte Ansichten
     4. Tabellen (Geräte, Tickets, Updates, Protokoll)
     5. Dialoge, Meldungen, mobile Anpassungen

   Leitgedanke: Informationsdichte. Ein Techniker soll möglichst viele
   Geräte gleichzeitig überblicken, ohne zu scrollen — deshalb kleine
   Zeilenhöhen, aber klare Farbcodierung für den schnellen Zugriff.
   ===================================================================== */

/* --- 1. Tokens ------------------------------------------------------ */

:root {
    --bg:          #0f1216;
    --bg-raised:   #161a21;
    --bg-hover:    #1c222b;
    --bg-sunken:   #0b0e12;
    --border:      #262d38;
    --border-soft: #1e242d;

    --text:        #e4e8ee;
    --text-muted:  #8a94a6;
    --text-dim:    #5f6877;

    --accent:      #4a9eff;
    --accent-soft: rgba(74, 158, 255, 0.14);

    --crit:        #ff5f56;
    --crit-soft:   rgba(255, 95, 86, 0.14);
    --warn:        #ffb340;
    --warn-soft:   rgba(255, 179, 64, 0.14);
    --ok:          #3ecf8e;
    --ok-soft:     rgba(62, 207, 142, 0.14);
    --info:        #6c8cff;
    --unknown:     #6b7585;

    --radius:      6px;
    --radius-lg:   10px;
    --shadow:      0 4px 24px rgba(0, 0, 0, 0.4);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    color-scheme: dark;
}

[data-theme="light"] {
    --bg:          #f6f7f9;
    --bg-raised:   #ffffff;
    --bg-hover:    #eef1f5;
    --bg-sunken:   #e8ebf0;
    --border:      #d4dae3;
    --border-soft: #e3e8ef;

    --text:        #1a1f28;
    --text-muted:  #5d6775;
    --text-dim:    #8a93a1;

    --accent:      #0b66d0;
    --accent-soft: rgba(11, 102, 208, 0.10);

    --crit:        #d92d20;
    --crit-soft:   rgba(217, 45, 32, 0.10);
    --warn:        #b25e00;
    --warn-soft:   rgba(178, 94, 0, 0.10);
    --ok:          #027a48;
    --ok-soft:     rgba(2, 122, 72, 0.10);
    --info:        #3538cd;
    --unknown:     #79828f;

    --shadow:      0 4px 20px rgba(16, 24, 40, 0.12);

    color-scheme: light;
}

/* --- 2. Grundgerüst -------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

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

h1 { font-size: 20px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 4px; }

code {
    font-family: var(--mono);
    font-size: 0.92em;
    background: var(--bg-sunken);
    padding: 1px 5px;
    border-radius: 4px;
}

.muted     { color: var(--text-dim); }
.muted-sm  { color: var(--text-dim); font-size: 11px; display: block; }

/* Kopfzeile ---------------------------------------------------------- */

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 52px;
    padding: 0 20px;
    background: var(--bg-raised);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand-mark { color: var(--accent); font-size: 15px; }

.mainnav { display: flex; gap: 2px; flex: 1; }

.mainnav a {
    padding: 6px 13px;
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    transition: background 0.12s, color 0.12s;
}
.mainnav a:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.mainnav a.is-active { background: var(--accent-soft); color: var(--accent); }

.topbar-right { display: flex; align-items: center; gap: 10px; }

.usermenu { position: relative; }
.usermenu summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
    padding: 4px 8px;
    border-radius: var(--radius);
}
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--bg-hover); }

.avatar {
    width: 26px; height: 26px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}
.username { font-size: 13px; color: var(--text-muted); }

.usermenu-body {
    position: absolute;
    right: 0; top: calc(100% + 6px);
    min-width: 230px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 6px;
}
.usermenu-head {
    padding: 10px 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    display: flex; flex-direction: column; gap: 3px;
    margin-bottom: 6px;
}
.usermenu-head span { font-size: 12px; color: var(--text-dim); }
.usermenu-body a { display: block; padding: 8px 10px; border-radius: var(--radius); color: var(--text); }
.usermenu-body a:hover { background: var(--bg-hover); text-decoration: none; }

.page { padding: 20px; max-width: 1800px; margin: 0 auto; }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.page-sub { margin: 3px 0 0; color: var(--text-muted); font-size: 13px; }
.page-head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Abgleichstatus ------------------------------------------------------ */

.sync-state {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--border);
    color: var(--text-muted);
    white-space: nowrap;
}
.sync-ok      { border-color: var(--ok);   color: var(--ok);   background: var(--ok-soft); }
.sync-stale   { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.sync-error,
.sync-none    { border-color: var(--crit); color: var(--crit); background: var(--crit-soft); }
.sync-running { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

/* --- 3. Schaltflächen ------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-raised);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-sm      { padding: 5px 11px; font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); background: var(--accent); }
.btn-ghost   { background: transparent; }
.btn-danger  { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); background: var(--crit); }

.btn-ms {
    background: var(--bg-raised);
    width: 100%;
    justify-content: center;
    padding: 11px;
    font-size: 14px;
}

.icon-btn {
    width: 26px; height: 26px;
    display: inline-grid; place-items: center;
    border: 1px solid transparent;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
    transition: background 0.12s, color 0.12s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--border); }
.icon-btn.is-on { color: var(--ok); background: var(--ok-soft); border-color: var(--ok); }
.icon-danger:hover { color: var(--crit); border-color: var(--crit); background: var(--crit-soft); }

.ext-link { color: var(--text-dim); font-size: 14px; padding: 2px 5px; }
.ext-link:hover { color: var(--accent); text-decoration: none; }

/* Kennzahlen ---------------------------------------------------------- */

.tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.tile {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--text);
    transition: background 0.12s, transform 0.12s;
}
.tile:hover { background: var(--bg-hover); text-decoration: none; transform: translateY(-1px); }

.tile-value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.tile-crit  { border-left-color: var(--crit); }
.tile-crit  .tile-value { color: var(--crit); }
.tile-warn  { border-left-color: var(--warn); }
.tile-warn  .tile-value { color: var(--warn); }
.tile-ok    { border-left-color: var(--ok); }
.tile-ok    .tile-value { color: var(--ok); }
.tile-off   { border-left-color: var(--unknown); }
.tile-patch { border-left-color: var(--info); }
.tile-patch .tile-value { color: var(--info); }
.tile-sec   { border-left-color: var(--crit); }
.tile-sec   .tile-value { color: var(--crit); }
.tile-open  { border-left-color: var(--accent); }
.tile-open  .tile-value { color: var(--accent); }
.tile-auto  { border-left-color: var(--info); }

/* Gespeicherte Ansichten ------------------------------------------------ */

.views {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 12px;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
}
.views-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    font-weight: 600;
}
.views-list { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }

.view-chip {
    display: inline-flex;
    align-items: center;
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
}
.view-chip a {
    padding: 4px 11px;
    font-size: 12px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}
.view-chip a:hover { color: var(--text); text-decoration: none; }
.view-chip.is-active { border-color: var(--accent); background: var(--accent-soft); }
.view-chip.is-active a { color: var(--accent); }

.view-shared  { color: var(--info); font-size: 10px; }
.view-default { color: var(--warn); font-size: 10px; }

.view-del {
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    padding: 3px 8px 4px 2px;
    font-size: 14px;
    line-height: 1;
}
.view-del:hover { color: var(--crit); }

/* Filterleiste ---------------------------------------------------------- */

.filterbar {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
    padding: 12px;
    margin-bottom: 16px;
}
.views + .filterbar { border-top: 1px solid var(--border-soft); }
.filterbar:first-child { border-radius: var(--radius); }

.filterbar-main { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: flex; }
.field-search { flex: 1 1 280px; min-width: 200px; }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 7px 10px;
    font: inherit;
    font-size: 13px;
    width: 100%;
    transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
select { cursor: pointer; }

.input-sm { max-width: 110px; }
.input-xs { max-width: 70px; }

.filterbar-advanced {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}
.filterbar-advanced[hidden] { display: none; }
.filterbar-advanced.is-open { display: grid; }

.adv-group { display: flex; flex-direction: column; gap: 6px; }
.adv-group-wide { grid-column: span 2; }
.adv-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    font-weight: 600;
}

.checkrow { display: flex; gap: 14px; flex-wrap: wrap; }

.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-muted);
    user-select: none;
}
.check:hover { color: var(--text); }
.check input { width: auto; }
.check-inline { gap: 6px; }

.check-crit span { color: var(--crit); }
.check-warn span { color: var(--warn); }
.check-ok   span { color: var(--ok); }

.multiselect { min-height: 110px; padding: 4px; }
.multiselect option { padding: 3px 6px; border-radius: 3px; }

/* --- 4. Tabellen -------------------------------------------------------- */

.table-wrap {
    overflow-x: auto;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.table-flat { margin-bottom: 16px; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    text-align: left;
    padding: 9px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    /* top: 0, nicht die Höhe der Kopfzeile: .table-wrap trägt
       overflow-x und ist damit selbst der Bezugspunkt für sticky.
       Ein Versatz würde den Kopf über die erste Zeile schieben. */
    position: sticky;
    top: 0;
    z-index: 5;
}

tbody td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

/* Steuerleiste über den Kundenblöcken -------------------------------------- */

.grouptools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.grouptools-info {
    flex: 1;
    font-size: 12px;
    color: var(--text-muted);
}
.grouptools-info .muted-sm { display: inline; }

/* Kundenblöcke ----------------------------------------------------------- */

.customer {
    margin-bottom: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-raised);
}
.customer.has-crit { border-left: 3px solid var(--crit); }

.customer details > summary { list-style: none; }
.customer details > summary::-webkit-details-marker { display: none; }

.customer-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 14px;
    cursor: pointer;
    background: var(--bg-sunken);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

/* Eingeklappt braucht es keine Trennlinie nach unten. */
details:not([open]) > .customer-head { border-bottom: none; }
.customer-head:hover { background: var(--bg-hover); }

.customer-head::before {
    content: "▸";
    color: var(--text-muted);
    font-size: 15px;
    line-height: 1;
    width: 12px;
    text-align: center;
    transition: transform 0.15s, color 0.12s;
}
.customer-head:hover::before { color: var(--accent); }
details[open] > .customer-head::before { transform: rotate(90deg); }

.customer-name { font-weight: 600; font-size: 14px; }

.customer-stats { display: flex; gap: 12px; flex-wrap: wrap; flex: 1; }
.cstat { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.cstat-crit  { color: var(--crit); font-weight: 600; }
.cstat-warn  { color: var(--warn); }
.cstat-off   { color: var(--text-dim); }
.cstat-patch { color: var(--info); }
.cstat-sec   { color: var(--crit); font-weight: 600; }

.customer-only { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.customer-only:hover { color: var(--accent); }

.customer .table-wrap { border: none; border-radius: 0; }

/* Gerätetabelle ---------------------------------------------------------- */

.col-state   { width: 22px; padding-right: 0 !important; }
.col-name    { min-width: 170px; }
.col-online  { width: 100px; }
.col-os      { min-width: 160px; }
.col-patches { width: 100px; }
.col-disk    { width: 120px; }
.col-reboot  { width: 100px; white-space: nowrap; color: var(--text-muted); font-size: 12px; }
.col-issues  { min-width: 200px; }
.col-actions { width: 40px; text-align: right; }

.dot {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--unknown);
}
.dot-ok      { background: var(--ok); }
.dot-warn    { background: var(--warn); }
.dot-crit    { background: var(--crit); box-shadow: 0 0 0 3px var(--crit-soft); }
.dot-unknown { background: var(--unknown); }

.device-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 550;
    color: var(--text);
    cursor: pointer;
    text-align: left;
}
.device-link:hover { color: var(--accent); text-decoration: underline; }

.pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}
.pill-on  { background: var(--ok-soft); color: var(--ok); }
.pill-off { background: var(--bg-sunken); color: var(--text-dim); }

.os-name { display: block; font-size: 12px; }

.patch-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border-radius: 20px;
    border: 1px solid var(--info);
    background: rgba(108, 140, 255, 0.12);
    color: var(--info);
    font-size: 12px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.patch-badge:hover { filter: brightness(1.15); }
.patch-sec { color: var(--crit); font-size: 11px; }
.patch-none { color: var(--ok); font-size: 12px; }

.bar {
    position: relative;
    height: 17px;
    background: var(--bg-sunken);
    border-radius: 3px;
    overflow: hidden;
    min-width: 90px;
}
.bar-fill { position: absolute; inset: 0 auto 0 0; opacity: 0.85; border-radius: 3px; }
.bar-ok   { background: var(--ok); }
.bar-warn { background: var(--warn); }
.bar-crit { background: var(--crit); }
.bar-info { background: var(--info); }
.bar-label {
    position: relative;
    display: block;
    text-align: center;
    font-size: 11px;
    line-height: 17px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    /* Die Balkenkante läuft bei mittleren Werten genau durch die Zahl.
       Der Umriss hält sie auf beiden Untergründen lesbar. */
    text-shadow:
         0  1px 2px var(--bg-sunken),
         0 -1px 2px var(--bg-sunken),
         1px 0  2px var(--bg-sunken),
        -1px 0  2px var(--bg-sunken);
}
.bar-plain { min-width: 120px; }

.chip {
    display: inline-block;
    padding: 1px 7px;
    margin: 1px 3px 1px 0;
    border-radius: 4px;
    font-size: 11px;
    background: var(--bg-sunken);
    color: var(--text-muted);
    white-space: nowrap;
}
.chip-crit { background: var(--crit-soft); color: var(--crit); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-info { background: var(--bg-sunken); color: var(--text-dim); }
.chip-more { color: var(--text-dim); }

/* Tickettabelle ----------------------------------------------------------- */

.col-check    { width: 32px; }
.col-nr       { width: 92px; }
.col-title    { min-width: 260px; }
.col-customer { min-width: 140px; }
.col-prio     { width: 92px; }
.col-tstatus  { width: 120px; }
.col-tech     { width: 140px; }
.col-age      { width: 110px; white-space: nowrap; }
.col-tactions { width: 76px; text-align: right; white-space: nowrap; }

.ticket-row.is-seen { opacity: 0.55; }
.ticket-row.is-breached { box-shadow: inset 3px 0 0 var(--crit); }
.ticket-row.is-removing { opacity: 0.3; pointer-events: none; }

.ticket-nr { font-family: var(--mono); font-size: 12px; color: var(--text-muted); }
.ticket-title { display: block; font-weight: 500; }
.ticket-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 2px; }

.tag {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--bg-sunken);
    color: var(--text-dim);
}
.tag-auto   { background: rgba(108, 140, 255, 0.14); color: var(--info); }
.tag-breach { background: var(--crit-soft); color: var(--crit); }
.tag-admin  { background: var(--ok-soft); color: var(--ok); }
.tag-ticket-delete { background: var(--crit-soft); color: var(--crit); }

.prio { font-size: 12px; font-weight: 600; }
.prio-critical { color: var(--crit); }
.prio-high     { color: var(--warn); }
.prio-medium   { color: var(--text-muted); }
.prio-low      { color: var(--text-dim); }

.status-select {
    padding: 4px 6px;
    font-size: 12px;
    border-radius: var(--radius);
}
.status-select.st-open     { border-color: var(--accent); color: var(--accent); }
.status-select.st-pending  { border-color: var(--warn);   color: var(--warn); }
.status-select.st-resolved { border-color: var(--ok);     color: var(--ok); }
.status-select.st-closed   { color: var(--text-dim); }
.status-select.is-saving   { opacity: 0.5; }

.age-warn {
    font-size: 10px;
    color: var(--warn);
    background: var(--warn-soft);
    padding: 0 5px;
    border-radius: 3px;
}

.bulkbar {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    flex-wrap: wrap;
}
.bulkbar[hidden] { display: none; }
.bulk-count { font-size: 13px; }
.bulk-field { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.bulk-field select { width: auto; }

/* Updatetabelle ------------------------------------------------------------ */

.col-pname  { min-width: 320px; }
.col-pclass { width: 160px; color: var(--text-muted); font-size: 12px; }
.col-pkb    { width: 100px; font-family: var(--mono); font-size: 12px; }
.col-pcount { width: 160px; }
.col-pcust  { width: 80px; font-variant-numeric: tabular-nums; }
.col-pact   { width: 40px; text-align: right; }

.patches tr.is-security .col-pname { color: var(--crit); }
.sec-mark { color: var(--crit); margin-right: 4px; }

/* Betriebssystemübersicht ---------------------------------------------------- */

.section-title {
    font-size: 16px;
    font-weight: 600;
    margin: 26px 0 6px;
}
.section-note {
    color: var(--text-muted);
    font-size: 13px;
    margin: 0 0 12px;
}
.section-note em { color: var(--text); font-style: normal; font-weight: 500; }

.tiles-sm { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); margin-bottom: 12px; }
.tiles-sm .tile-value { font-size: 18px; }

.col-osname   { min-width: 210px; }
.col-osed     { min-width: 150px; }
.col-oscount  { width: 90px; font-variant-numeric: tabular-nums; }
.col-oseol    { width: 140px; white-space: nowrap; }
.col-osstate  { width: 150px; }
.col-ostarget { min-width: 160px; }
.col-osact    { width: 40px; text-align: right; }

.os-family  { font-weight: 600; }
.os-version { color: var(--text-muted); margin-left: 5px; }
.os-target  { color: var(--accent); font-size: 12px; }

/* Farbige Kante je Supportzustand — dieselbe Sprache wie die Geräteampel. */
.os-row.os-crit    { box-shadow: inset 3px 0 0 var(--crit); }
.os-row.os-warn    { box-shadow: inset 3px 0 0 var(--warn); }
.os-row.os-ok      { box-shadow: inset 3px 0 0 var(--ok); }
.os-row.os-unknown { box-shadow: inset 3px 0 0 var(--unknown); }

.osstate {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.osstate-crit    { background: var(--crit-soft); color: var(--crit); }
.osstate-warn    { background: var(--warn-soft); color: var(--warn); }
.osstate-ok      { background: var(--ok-soft);   color: var(--ok); }
.osstate-unknown { background: var(--bg-sunken); color: var(--text-dim); }

.col-oscur   { min-width: 130px; }
.col-cpu     { min-width: 230px; }
.col-ram     { width: 90px; white-space: nowrap; }
.col-verdict { width: 140px; }
.col-why     { min-width: 220px; }

.cpu-name { font-size: 12px; }

/* Protokolltabelle ---------------------------------------------------------- */

.col-ts     { width: 140px; white-space: nowrap; font-size: 12px; color: var(--text-muted); }
.col-actor  { width: 190px; }
.col-action { width: 200px; }
.col-target { width: 150px; font-family: var(--mono); font-size: 12px; }
.col-detail { font-size: 12px; color: var(--text-muted); }
.col-ip     { width: 120px; font-family: var(--mono); font-size: 11px; color: var(--text-dim); }

.actor-name { font-weight: 500; }
.audit tr.is-failed { background: var(--crit-soft); }

/* --- 5. Dialoge und Meldungen ---------------------------------------------- */

.dialog {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-raised);
    color: var(--text);
    padding: 22px;
    max-width: 480px;
    width: calc(100vw - 40px);
    box-shadow: var(--shadow);
}
.dialog-wide { max-width: 820px; }
.dialog::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(2px); }

.dialog-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 16px; }
.danger-title { color: var(--crit); }

.form-row { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: 13px; }
.form-row > span { color: var(--text-muted); }
.form-check { flex-direction: row; align-items: center; gap: 9px; }
.form-check input { width: auto; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.delete-summary {
    background: var(--bg-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 14px;
    font-size: 13px;
}
.delete-summary dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; }
.delete-summary dt { color: var(--text-dim); font-size: 12px; }
.delete-summary dd { margin: 0; }

.alert {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 11px 13px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 14px;
    border: 1px solid;
}
.alert-error { background: var(--crit-soft); border-color: var(--crit); color: var(--crit); }
.alert-warn  { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert span  { color: var(--text-muted); }

/* Gerätedetails ------------------------------------------------------------- */

.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.detail-title { display: flex; align-items: center; gap: 10px; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.detail-item { background: var(--bg-sunken); border-radius: var(--radius); padding: 9px 11px; }
.detail-item dt { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin-bottom: 2px; }
.detail-item dd { margin: 0; font-size: 13px; word-break: break-word; }

.detail-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    font-weight: 600;
    margin: 18px 0 8px;
}

.patch-list { max-height: 320px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.patch-list table { font-size: 12px; }

/* Sonstiges ------------------------------------------------------------------ */

.empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    background: var(--bg-raised);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty p { margin: 0 0 5px; }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 14px; }
.pager-info { font-size: 12px; color: var(--text-muted); }

.toast {
    position: fixed;
    bottom: 22px; left: 50%;
    transform: translate(-50%, 100px);
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 11px 18px;
    font-size: 13px;
    box-shadow: var(--shadow);
    opacity: 0;
    transition: transform 0.22s ease, opacity 0.22s ease;
    pointer-events: none;
    z-index: 200;
    max-width: min(560px, calc(100vw - 40px));
}
.toast.is-visible { transform: translate(-50%, 0); opacity: 1; }
.toast.is-error   { border-color: var(--crit); color: var(--crit); }
.toast.is-success { border-color: var(--ok);   color: var(--ok); }

/* Warnband bei abgeschalteter Anmeldung ------------------------------------ */

.devbanner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 7px 20px;
    background: var(--crit);
    color: #fff;
    font-size: 12.5px;
    /* Nicht wegscrollbar: die Warnung muss dauerhaft sichtbar bleiben. */
    position: sticky;
    top: 0;
    z-index: 100;
}
.devbanner-mark { font-size: 14px; }
.devbanner strong { font-weight: 650; }
.devbanner span { opacity: 0.92; }
.devbanner-fix { margin-left: auto; opacity: 0.8 !important; }
.devbanner code {
    background: rgba(0, 0, 0, 0.22);
    color: #fff;
    padding: 1px 5px;
}

/* Die Kopfzeile klebt unter dem Warnband, nicht darüber. */
.devbanner ~ .topbar { top: 32px; }

/* Anmeldung --------------------------------------------------------------- */

.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: var(--shadow);
}
.login-mark { font-size: 30px; color: var(--accent); margin-bottom: 10px; }
.login-sub { color: var(--text-muted); font-size: 13px; margin: 6px 0 26px; }
.login-foot { color: var(--text-dim); font-size: 12px; margin: 20px 0 0; }
.login-card .alert { text-align: left; }

.error-wrap { max-width: 620px; margin: 80px auto; text-align: center; }
.error-message {
    color: var(--text-muted);
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin: 18px 0 22px;
    text-align: left;
    font-family: var(--mono);
    font-size: 12px;
    word-break: break-word;
}
.error-actions { display: flex; gap: 10px; justify-content: center; }

/* Mobil --------------------------------------------------------------------- */

@media (max-width: 900px) {
    .page { padding: 12px; }
    .topbar { gap: 12px; padding: 0 12px; overflow-x: auto; }
    .brand-text, .username { display: none; }
    thead th { position: static; }
    .col-os, .col-reboot, .col-issues, .col-tech { display: none; }
    .adv-group-wide { grid-column: span 1; }
    .tiles { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
    .tile-value { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
