/* PC-Inventar – Oberfläche (hell/dunkel automatisch) */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --border: #dde2ea;
  --text: #1c2330;
  --muted: #667085;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #15803d;      --ok-bg: #dcfce7;
  --warn: #b45309;    --warn-bg: #fef3c7;
  --crit: #b91c1c;    --crit-bg: #fee2e2;
  --neutral-bg: #e8ecf2;
  --bar-track: #e5e9f0;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #171e27;
    --surface-2: #1e2732;
    --border: #2b3542;
    --text: #e6eaf0;
    --muted: #94a0b1;
    --accent: #5b8def;
    --ok: #4ade80;      --ok-bg: #12301f;
    --warn: #fbbf24;    --warn-bg: #3a2c0c;
    --crit: #f87171;    --crit-bg: #3d1616;
    --neutral-bg: #263040;
    --bar-track: #263040;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; display: flex; align-items: center; gap: .5rem; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .9rem; margin: .25rem 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: .25rem 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 600; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ellipsis { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: .6rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.mainnav a { padding: .4rem .75rem; border-radius: 6px; color: var(--muted); font-weight: 500; }
.mainnav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.mainnav a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.userbox { display: flex; align-items: center; gap: .5rem; }
.userbox form { margin: 0; }

.container { max-width: 1440px; margin: 0 auto; padding: 1.25rem; }
.footer { text-align: center; padding: 1.5rem; font-size: .8rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: .5rem; }

/* ---------- Karten & Raster ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.15rem; box-shadow: var(--shadow); margin-bottom: 1rem; min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.card-head h2 { margin: 0; }
.card.empty { text-align: center; padding: 3rem 1rem; }
.grid-2, .grid-3 { display: grid; gap: 1rem; margin-bottom: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-2.tight { gap: 1.5rem; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 1rem; }
.scroll-box { max-height: 260px; overflow: auto; }

/* ---------- Kacheln ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: .15rem; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: var(--radius); padding: .8rem 1rem; cursor: pointer; color: var(--text); font: inherit;
  box-shadow: var(--shadow); transition: transform .08s ease, border-color .15s;
}
.tile:hover { transform: translateY(-1px); }
.tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tile[aria-pressed="true"] { outline: 2px solid var(--accent); }
.tile-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); font-size: .82rem; }
.tile-ok { border-left-color: var(--ok); }
.tile-warn { border-left-color: var(--warn); }
.tile-warn .tile-value { color: var(--warn); }
.tile-crit { border-left-color: var(--crit); }
.tile-crit .tile-value { color: var(--crit); }

/* ---------- Tabellen ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; white-space: nowrap; background: var(--surface); }
tbody tr:hover { background: var(--surface-2); }
table.compact th, table.compact td { padding: .35rem .5rem; }
.sortable-th { cursor: pointer; user-select: none; }
.sortable-th:hover { color: var(--text); }
.sortable-th::after { content: " ↕"; opacity: .35; }
.sortable-th[aria-sort="ascending"]::after { content: " ↑"; opacity: 1; }
.sortable-th[aria-sort="descending"]::after { content: " ↓"; opacity: 1; }
.row-deny td { background: var(--crit-bg); }
.row-inherited td { color: var(--muted); }
.row-current td { background: var(--surface-2); font-weight: 600; }
.w-bar { min-width: 150px; white-space: nowrap; }

/* ---------- Badges, Punkte, Balken ---------- */
.badge {
  display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
  background: var(--neutral-bg); color: var(--text); white-space: nowrap; margin: 0 .15rem .15rem 0;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-crit { background: var(--crit-bg); color: var(--crit); }
.chips { display: flex; flex-wrap: wrap; gap: .15rem; margin-top: .35rem; }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; flex: none; vertical-align: middle; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-crit { background: var(--crit); }

.bar { display: inline-block; width: 100px; height: 8px; border-radius: 4px; background: var(--bar-track); vertical-align: middle; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 4px; }
.bar-ok .bar-fill { background: var(--ok); }
.bar-warn .bar-fill { background: var(--warn); }
.bar-crit .bar-fill { background: var(--crit); }
.bar-label { margin-left: .5rem; font-variant-numeric: tabular-nums; font-size: .85rem; }
.disk-big .bar { width: calc(100% - 4rem); height: 14px; border-radius: 7px; }
.disk-big { margin-bottom: .75rem; }

.hbars { list-style: none; margin: 0; padding: 0; }
.hbars li { display: grid; grid-template-columns: minmax(0, 1.4fr) 1fr 2rem; align-items: center; gap: .6rem; padding: .25rem 0; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar { display: block; height: 8px; border-radius: 4px; background: var(--bar-track); overflow: hidden; }
.hbar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.hbar-value { text-align: right; font-variant-numeric: tabular-nums; }

.issue-list { list-style: none; margin: 0; padding: 0; }
.issue-list li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.issue-list li:last-child { border-bottom: 0; }

.perm-list { list-style: none; margin: 0; padding: 0; font-size: .85rem; }
.perm-list li.deny { color: var(--crit); }

/* ---------- Schlüssel/Wert ---------- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.av-item { padding-bottom: .75rem; margin-bottom: .75rem; border-bottom: 1px solid var(--border); }
.av-item:last-child { border-bottom: 0; margin-bottom: 0; }
.av-item .kv { margin-top: .5rem; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tabs a {
  padding: .55rem .9rem; color: var(--muted); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
html:not(.js) .tabpanel { margin-bottom: 2rem; }

details { border: 1px solid var(--border); border-radius: 8px; padding: .5rem .75rem; margin-bottom: .5rem; }
summary { cursor: pointer; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
details[open] summary { margin-bottom: .4rem; }

/* ---------- Formulare ---------- */
input, select, button { font: inherit; }
input[type="search"], input[type="password"], input:not([type]), select {
  padding: .45rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.search { width: min(340px, 100%); }
.btn {
  display: inline-block; padding: .45rem .9rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 500;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-ghost { background: transparent; }
.inline-form, .report-picker { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.report-picker label { display: flex; gap: .5rem; align-items: center; color: var(--muted); }

.alert { padding: .65rem .9rem; border-radius: 8px; }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-crit { background: var(--crit-bg); color: var(--crit); }

/* ---------- Login ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); padding: 2rem; }
.login-card form { display: grid; gap: .9rem; }
.login-card label { display: grid; gap: .3rem; font-weight: 500; }

/* ---------- Mobil ---------- */
@media (max-width: 700px) {
  .container { padding: 1rem 16px; }
  .topbar { padding: .6rem 16px; gap: .5rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: .4rem; }
}
.nowrap { white-space: nowrap; }
