/* ==========================================================================
   nexhub audit - Operator-Interface
   Dunkle Flaeche, Tiefe statt Rahmen, Typografie traegt die Hierarchie.
   Genau ein Akzent. Aktionsfarben sind Datenkodierung, keine Dekoration.
   ========================================================================== */

:root {
  /* Flaechen: kuehl-neutral, leicht blaustichig statt totem Grau */
  --bg:        #0a0b0e;
  --surface:   #101218;
  --raised:    #161922;
  --raised-2:  #1c2029;
  --hairline:  #21252f;
  --hairline-soft: #191c24;

  --text:      #eceef2;
  --text-2:    #a2a9b8;
  --text-3:    #6d7583;

  --accent:      #f0b429;
  --accent-soft: rgba(240, 180, 41, .13);
  --accent-line: rgba(240, 180, 41, .32);

  --create: #4ec97f;
  --modify: #5aa2f5;
  --delete: #f2685e;
  --rename: #e0a63c;
  --attr:   #8891a1;

  --r-sm: 7px;
  --r:    11px;
  --r-lg: 15px;

  /* Abstandsskala - jeder Abstand im Layout stammt aus dieser Liste */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 44px;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text",
          "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code",
          "Roboto Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.015em; }

::selection { background: var(--accent-soft); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ---------------------------------------------------------------- Geruest */

.shell { display: flex; min-height: 100dvh; }

.side {
  width: 244px;
  flex: 0 0 244px;
  padding: 20px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  /* Kein harter Rahmen: die Trennung entsteht durch den Flaechenwechsel */
  background: var(--surface);
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 2px; }
.brand .logo { color: var(--accent); flex: none; }
.brand-name { font-size: 14.5px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-3); font-family: var(--mono); letter-spacing: -.01em; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-3);
  padding: 14px 10px 5px;
}
.nav a {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13.5px;
  transition: background .16s var(--ease), color .16s var(--ease);
}
.nav a:hover { background: var(--raised); color: var(--text); }
.nav a.active { background: var(--raised-2); color: var(--text); font-weight: 500; }
.nav a.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 17px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav .count {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
  padding: 1px 7px; border-radius: 20px;
}

.side-foot { margin-top: auto; }
.me {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r);
  background: var(--raised);
}
.me img, .me .avatar-fallback {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: var(--raised-2); display: grid; place-items: center;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.me-name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-role { font-size: 11.5px; color: var(--text-3); }
.side-foot form { margin-top: 7px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s5);
  padding: var(--s5) var(--s6) var(--s4);
}
.topbar h1 { font-size: 19px; letter-spacing: -.025em; }
.topbar .meta {
  font-family: var(--mono); font-size: 11.5px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46ch;
}

.content { padding: 0 var(--s6) var(--s7); flex: 1; }

/* ------------------------------------------------------------- Steuerzeile */

/* Filterleiste: eine zusammenhaengende Zeile, kein Umbruch am Desktop.
   Die Felder teilen sich den Platz, statt jeweils eine Mindestbreite zu
   erzwingen und dadurch in die naechste Zeile zu rutschen. */
.filterbar {
  display: flex; align-items: flex-end; gap: var(--s3);
  background: var(--surface);
  border-radius: var(--r);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .03);
}
.filterbar .field { flex: 1 1 0; min-width: 0; }
.filterbar .field input,
.filterbar .field select { width: 100%; min-width: 0; }
.filterbar .field-narrow { flex: 0 1 148px; }
.filterbar .actions { display: flex; gap: var(--s2); flex: none; padding-bottom: 1px; }

/* Reine Button-Zeile, z. B. "zurueck zur Uebersicht" */
.bar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }

.field { display: flex; flex-direction: column; gap: var(--s1); }
.field label {
  font-size: 11px; font-weight: 500; color: var(--text-3);
  letter-spacing: .01em; padding-left: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

input[type=text], input[type=date], select {
  appearance: none;
  background: var(--raised);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 8px 11px;
  font-size: 13px;
  font-family: inherit;
  transition: background .16s var(--ease), border-color .16s var(--ease);
}
select {
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
                    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 11px) 52%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
select[multiple] { background-image: none; padding-right: 11px; }
input:hover, select:hover { background: var(--raised-2); }
input:focus, select:focus {
  outline: none; background: var(--raised-2);
  border-color: var(--accent-line);
}
input::placeholder { color: var(--text-3); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--hairline);
  background: var(--raised);
  color: var(--text);
  padding: 8px 14px; border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: background .16s var(--ease), transform .1s var(--ease);
}
.btn:hover { background: var(--raised-2); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent); border-color: var(--accent);
  color: #17130a; font-weight: 600;
}
.btn-primary:hover { background: #f7c246; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--raised); color: var(--text); }
.btn-danger { color: var(--delete); border-color: transparent; background: transparent; }
.btn-danger:hover { background: rgba(242, 104, 94, .11); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* ------------------------------------------------------------------ Karten */

.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  /* Tiefe statt Rahmen: obere Lichtkante plus weicher Schatten */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .035),
    0 1px 2px rgba(0, 0, 0, .35),
    0 8px 26px -14px rgba(0, 0, 0, .7);
  overflow: hidden;
}
.card + .card { margin-top: var(--s5); }

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: var(--s4) var(--s5);
}
.card-head h2 { font-size: 14px; letter-spacing: -.01em; }
.card-head .hint { font-size: 12.5px; color: var(--text-3); font-family: var(--mono); }
/* Kopf plus Inhalt: der Kopf bringt seinen Abstand bereits mit */
.card-head + .card-body { padding-top: 0; }
.card-body { padding: var(--s5); }

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

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3);
  padding: var(--s2) var(--s5);
  white-space: nowrap;
  border-bottom: 1px solid var(--hairline-soft);
}
thead th a { color: var(--text-3); transition: color .14s var(--ease); }
thead th a:hover { color: var(--text-2); }
thead th a.sorted { color: var(--accent); }

tbody td {
  padding: var(--s3) var(--s5);
  vertical-align: middle;
  font-size: 13px;
  border-bottom: 1px solid var(--hairline-soft);
}
/* Zellen mit Formularen brauchen etwas mehr Luft, sonst kleben die Felder */
tbody td:has(form) { padding-top: var(--s2); padding-bottom: var(--s2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .13s var(--ease); }
tbody tr:hover { background: var(--raised); }

.mono { font-family: var(--mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.dim { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }

.filecell { font-family: var(--mono); font-size: 12.5px; max-width: 520px; }
.filecell .dirpart { color: var(--text-3); }
.filecell .filepart { color: var(--text); }

/* Aktion: Punkt plus Wort statt schwerer Pille */
.act { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; white-space: nowrap; }
.act::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.act-create { color: var(--create); }
.act-modify { color: var(--modify); }
.act-delete { color: var(--delete); }
.act-rename { color: var(--rename); }
.act-attr   { color: var(--attr); }
.act-unknown { color: var(--text-3); }

.state { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.state-ok      { color: var(--create); }
.state-wait    { color: var(--rename); }
.state-blocked { color: var(--delete); }
.state-off     { color: var(--text-3); }

/* ------------------------------------------------------------ Leerzustand */

.empty { padding: var(--s7) var(--s5); text-align: center; }
.empty .glyph {
  width: 46px; height: 46px; margin: 0 auto var(--s4);
  border-radius: var(--r); display: grid; place-items: center;
  background: var(--raised); color: var(--text-3);
}
.empty h3 { font-size: 15.5px; margin-bottom: var(--s2); }
.empty p { margin: 0 auto; max-width: 56ch; font-size: 13.5px; color: var(--text-2); }
.empty .note {
  display: inline-block; margin-top: var(--s5); text-align: left;
  font-family: var(--mono); font-size: 12px; color: var(--text-3);
  background: var(--bg); border-radius: var(--r-sm); padding: var(--s3) var(--s4);
  line-height: 1.7;
}

/* -------------------------------------------------------------------- Diff */

.diff { font-family: var(--mono); font-size: 12.5px; line-height: 1.7; overflow-x: auto; }
.diff-row { display: flex; white-space: pre; }
.diff-ln {
  flex: 0 0 54px; text-align: right; padding: 0 12px 0 8px;
  color: var(--text-3); user-select: none;
  position: sticky; left: 0; background: var(--surface);
  font-variant-numeric: tabular-nums;
}
.diff-txt { padding: 0 16px; flex: 1; }
.diff-add { background: rgba(78, 201, 127, .09); }
.diff-add .diff-txt { color: #8fe0ab; }
.diff-add .diff-ln  { background: rgba(78, 201, 127, .06); }
.diff-del { background: rgba(242, 104, 94, .09); }
.diff-del .diff-txt { color: #ff9d95; }
.diff-del .diff-ln  { background: rgba(242, 104, 94, .06); }
.diff-hunk { background: var(--raised); }
.diff-hunk .diff-txt, .diff-hunk .diff-ln { color: var(--text-3); }

/* Kennzahlen ueber dem Diff */
.stats { display: flex; gap: 16px; align-items: baseline; font-family: var(--mono); font-size: 12.5px; }
.stats .plus { color: var(--create); }
.stats .minus { color: var(--delete); }

/* ------------------------------------------------------------ Detailliste */

.kv { display: grid; grid-template-columns: 172px 1fr; gap: 0; }
.kv dt {
  font-size: 12.5px; color: var(--text-3);
  padding: var(--s3) var(--s4) var(--s3) 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.kv dd {
  margin: 0; font-family: var(--mono); font-size: 12.5px; word-break: break-all;
  padding: var(--s3) 0; border-bottom: 1px solid var(--hairline-soft);
}
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: none; padding-bottom: 0; }
.kv dt:first-of-type, .kv dd:first-of-type { padding-top: 0; }

/* --------------------------------------------------------------- Seitenlauf */

.pager { display: flex; align-items: center; justify-content: space-between; margin-top: var(--s4); }
.pager .info { font-size: 12px; color: var(--text-3); font-family: var(--mono); }
.pager .grp { display: flex; gap: var(--s2); }

/* --------------------------------------------------------------- Meldungen */

.flash {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); border-radius: var(--r); margin-bottom: var(--s5);
  font-size: 13px; background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.03);
}
.flash::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.flash-ok  { color: var(--create); }
.flash-err { color: var(--delete); }
.flash span { color: var(--text); }

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

.gate {
  min-height: 100dvh; display: grid; place-items: center; padding: 26px;
  background:
    radial-gradient(1100px 620px at 50% -20%, rgba(240,180,41,.055), transparent 62%),
    var(--bg);
}
.gate-card {
  width: 100%; max-width: 428px;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 34px 32px 30px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.045),
    0 20px 60px -30px rgba(0,0,0,.9);
}
.gate .logo { color: var(--accent); }
.gate h1 { font-size: 22px; margin: 20px 0 9px; letter-spacing: -.03em; }
.gate p { color: var(--text-2); margin: 0 0 26px; font-size: 13.5px; max-width: 42ch; }
.gate .btn { width: 100%; justify-content: center; padding: 11px; }
.gate-note {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--hairline-soft);
  font-size: 12px; color: var(--text-3); line-height: 1.65;
}

.steps { display: flex; flex-direction: column; gap: 0; margin: 4px 0 6px; }
.step { display: flex; gap: 13px; padding-bottom: 18px; position: relative; }
.step:last-child { padding-bottom: 0; }
.step:not(:last-child)::after {
  content: ""; position: absolute; left: 10px; top: 23px; bottom: 4px;
  width: 1.5px; background: var(--hairline);
}
.step-dot {
  flex: none; width: 21px; height: 21px; border-radius: 50%;
  display: grid; place-items: center; font-size: 10.5px; font-weight: 600;
  background: var(--raised); color: var(--text-3); z-index: 1;
}
.step-done .step-dot { background: rgba(78,201,127,.16); color: var(--create); }
.step-active .step-dot { background: var(--accent-soft); color: var(--accent); }
.step-active .step-dot::after {
  content: ""; position: absolute; width: 21px; height: 21px; border-radius: 50%;
  border: 1.5px solid var(--accent-line);
  animation: ring 2.4s var(--ease) infinite;
}
@keyframes ring {
  0%   { transform: scale(1);   opacity: .85; }
  70%  { transform: scale(1.7); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}
.step-title { font-size: 13.5px; font-weight: 500; }
.step-desc { font-size: 12px; color: var(--text-3); }

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

/* Zwischenbreiten: lieber sauber in zwei Zeilen umbrechen, als fuenf Felder
   auf je 60 px zusammenzuquetschen. */
@media (max-width: 1240px) {
  .filterbar { flex-wrap: wrap; }
  .filterbar .field { flex: 1 1 172px; }
  .filterbar .field-narrow { flex: 0 1 148px; }
  .filterbar .actions { margin-left: auto; }
}

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

@media (max-width: 940px) {
  .shell { flex-direction: column; }
  .side {
    width: auto; flex: none; flex-direction: row; align-items: center;
    gap: 16px; padding: 11px 16px; overflow-x: auto;
  }
  .side-foot { margin-top: 0; margin-left: auto; }
  .side-foot form { display: none; }
  .me { background: transparent; padding: 0; }
  .me-role { display: none; }
  .nav { flex-direction: row; gap: 3px; }
  .nav-label { display: none; }
  .nav a.active::before { display: none; }
  .topbar { padding: var(--s4) var(--s4) var(--s3); }
  .topbar .meta { display: none; }
  .content { padding: 0 var(--s4) var(--s6); }
  .card { border-radius: var(--r); }
  .card-head, .card-body, thead th, tbody td { padding-left: var(--s4); padding-right: var(--s4); }
  /* Filter untereinander, sobald nebeneinander nicht mehr lesbar ist */
  .filterbar { flex-wrap: wrap; padding: var(--s3); }
  .filterbar .field { flex: 1 1 150px; }
  .filterbar .field-narrow { flex: 1 1 130px; }
  .filterbar .actions { flex: 1 1 100%; }
  .filterbar .actions .btn { flex: 1; justify-content: center; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { padding-bottom: 0; border: none; }
  .kv dd { padding-top: 2px; }
  .card { overflow-x: auto; }
}
