/* Revive Control (docs/ui-redesign/server-control/DESIGN.md): UCP-Farben, Archivo, ruhige Flächen ohne Schatten.
   Desktop 232 px Seitenleiste, 80 px Kontextleiste, 32 px Inhaltsrand; schmal unter 900 px. */

@font-face {
  font-family: Archivo;
  src: url("fonts/Archivo-variable.ttf?v=1") format("truetype"); /* Schriftwechsel: v erhöhen */
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --base: #101213;
  --panel: #1b1f20;
  --input: #252b2c;
  --line: #343b3c;
  --text: #f5f5f2;
  --soft: #c3c9c6;
  --dim: #a5aeaa;
  --accent: #f29f05;
  --accent-hover: #ffb234;
  --focus: #ffd16c;
  --success: #86cfa1;
  --error: #efaca2;
  --info: #f2bd60;
  --danger: #6d3833;
  --danger-hover: #82413a;
  --on-danger: #ffe5e1;
  --surface-hover: #32393a;
  --radius: 8px;
  --radius-small: 5px;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--base);
  color: var(--text);
  font: 400 14px/22px Archivo, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, p { margin: 0; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Wortmarke */
.brand { display: flex; flex-direction: column; gap: 4px; }
.brand-mark { font-size: 27px; line-height: 32px; font-weight: 700; letter-spacing: 0.5px; }
.brand-e { color: var(--accent); }
.brand-sub { color: var(--soft); }

/* Rahmen */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--panel); display: flex; flex-direction: column; padding: 48px 16px 40px; }
.side .brand { padding: 0 16px; margin-bottom: 48px; }
.nav { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 16px; border-radius: var(--radius);
  color: var(--dim); font-weight: 600; line-height: 20px; text-decoration: none;
}
.nav-item:hover { color: var(--text); background: var(--input); }
.nav-item.is-active { background: var(--input); color: var(--text); }
.side-user { margin-top: auto; padding: 0 16px; display: flex; flex-direction: column; gap: 2px; }
.side-name { font-weight: 600; }
.side-role { color: var(--dim); font-size: 12px; line-height: 18px; }
.link { background: none; border: 0; padding: 0; margin-top: 8px; color: var(--dim); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; }
.link:hover { color: var(--text); }

.work { display: flex; flex-direction: column; min-width: 0; }
.context { height: 80px; background: var(--panel); display: flex; align-items: center; gap: 24px; padding: 0 32px; }
.context-server { font-weight: 600; }
.context-date { margin-left: auto; }
.main { padding: 32px; display: flex; flex-direction: column; gap: 24px; max-width: 1208px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
h1 { font-size: 32px; line-height: 40px; font-weight: 600; }
h2 { font-size: 18px; line-height: 26px; font-weight: 600; }
.lead { color: var(--soft); }
.login-panel .lead { margin-top: 4px; }
.soft { color: var(--soft); }
.meta { color: var(--dim); font-size: 12px; line-height: 18px; }
.notice { background: var(--panel); border-radius: var(--radius); padding: 16px 20px; color: var(--soft); }

/* Zustand: Punkt und Text */
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; line-height: 18px; min-height: 28px; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-positive { color: var(--success); }
.status-attention { color: var(--info); }
.status-error { color: var(--error); }
.status-muted { color: var(--dim); }

/* Flächen */
.panel { background: var(--panel); border-radius: var(--radius); padding: 24px; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.value { font-size: 22px; line-height: 28px; font-weight: 600; }
.section-value { font-size: 18px; line-height: 26px; font-weight: 600; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 304px; gap: 24px; }
.findings { display: flex; flex-direction: column; gap: 16px; }
.finding { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.finding-title { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.icon-info { color: var(--info); }

/* Diagramm */
.chart { width: 100%; height: auto; margin-top: 16px; display: block; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-axis { fill: var(--dim); font: 12px Archivo, Arial, sans-serif; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }

/* Tabelle */
.table { width: 100%; border-collapse: collapse; }
.table td, .table th { text-align: left; padding: 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--dim); font-weight: 400; font-size: 12px; }
.cell-time { width: 90px; font-weight: 600; color: var(--soft); }
.cell-actor { width: 180px; color: var(--soft); }

/* Bedienelemente */
.btn {
  display: inline-flex; align-items: center; justify-content: center; height: 48px; padding: 0 16px; border: 0;
  border-radius: var(--radius); font: 600 14px/20px Archivo, Arial, sans-serif; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--accent); color: var(--base); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--input); color: var(--text); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger:hover { background: var(--danger-hover); }
.form { display: flex; flex-direction: column; gap: 16px; margin-top: 24px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-weight: 600; line-height: 20px; }
.field input {
  height: 48px; padding: 0 16px; border: 0; border-radius: var(--radius); background: var(--input); color: var(--text);
  font: inherit;
}
.field-error { margin-top: 16px; color: var(--error); }

/* Anmeldung und Meldungen */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-panel { width: min(440px, 100%); background: var(--panel); border-radius: var(--radius); padding: 32px; display: flex; flex-direction: column; gap: 8px; }
.login-title { margin-top: 32px; }
.login-panel .btn-secondary { margin-top: 24px; align-self: flex-start; }

/* Schmal (Figma: mobile Übersicht 390 px) */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { padding: 20px; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; }
  .side .brand { margin: 0; padding: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .nav-item { height: 40px; }
  .side-user { margin: 0 0 0 auto; padding: 0; }
  .context { height: auto; flex-wrap: wrap; gap: 8px 16px; padding: 16px 20px; }
  .context-date { margin-left: 0; }
  .main { padding: 20px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  /* Befund vor den Kennzahlen (Figma 2902:17640) */
  .overview-grid { display: contents; }
  .findings { order: 1; }
  .kpis { order: 2; }
  .chart-panel { order: 3; }
  .main > section:last-child { order: 4; }
}

/* Stufe 2: Werkzeugleiste, Konsole, Ressourcen */
[hidden] { display: none !important; }
.toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar-end { margin-left: auto; }
.search {
  display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 16px; border-radius: var(--radius);
  background: var(--input); color: var(--soft); flex: 0 1 510px; min-width: 220px;
}
.search input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--text); font: inherit; outline: none; }
.search:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.select, .input {
  height: 48px; padding: 0 16px; border: 0; border-radius: var(--radius); background: var(--input); color: var(--text);
  font: 600 14px/20px Archivo, Arial, sans-serif;
}
.input { font-weight: 400; flex: 1; min-width: 0; }
.select { cursor: pointer; min-width: 160px; }

.console-panel { padding: 20px; }
.log {
  background: var(--base); border-radius: var(--radius-small); padding: 20px; height: 520px; overflow: auto;
  font: 400 13px/20px var(--mono); color: var(--soft);
}
.log-row { display: grid; grid-template-columns: 76px 64px 132px 1fr; gap: 0 12px; padding: 3px 0; }
.log-time, .log-channel { color: var(--dim); }
.log-channel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.log-warn .log-level { color: var(--info); }
.log-error .log-level { color: var(--error); }
.log-empty { color: var(--dim); }
.console-foot { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0 16px; border-bottom: 1px solid var(--line); }
.console-exec { display: flex; flex-direction: column; gap: 12px; padding-top: 16px; }
.exec-title { font-size: 14px; line-height: 20px; }
.exec-row { display: flex; gap: 12px; }
.exec-row .btn { width: 140px; }

.cell-strong { font-weight: 600; }
.state-ok { color: var(--success); }
.state-off { color: var(--error); }
.state-busy { color: var(--info); }
.row-link { text-decoration: none; color: var(--text); }
.row-link:hover { text-decoration: underline; }
.row-link-accent { color: var(--accent); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 16px; }
.pager-actions { display: flex; gap: 12px; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; padding: 16px 0; }
.back-link { color: var(--soft); text-decoration: none; align-self: flex-start; }
.back-link:hover { color: var(--text); }
.detail { display: flex; flex-direction: column; gap: 16px; }
.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; margin: 0; }
.facts dt { color: var(--dim); font-size: 12px; line-height: 18px; }
.facts dd { margin: 4px 0 0; font-weight: 600; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.confirm { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; padding: 20px; border-radius: var(--radius); background: var(--input); }
.confirm-title { font-weight: 600; }
.confirm .btn-secondary { background: var(--panel); }

@media (max-width: 900px) {
  .log { height: 420px; }
  .log-row { grid-template-columns: 64px 1fr; }
  .log-channel { display: none; }
  .log-text { grid-column: 1 / -1; }
  .facts { grid-template-columns: repeat(2, 1fr); }
  .exec-row { flex-direction: column; }
  .exec-row .btn { width: 100%; }
}

/* Stufe 3: Spieler, Sperren, Aktivitäten (Figma 2902:16964: Liste 744, Detail 376) */
.players-grid { display: grid; grid-template-columns: minmax(0, 1fr) 376px; gap: 24px; align-items: start; }
.search-wide { flex: 1 1 auto; }
.table-select tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.table-select tr.is-selected { background: var(--input); }
.table-select tr.is-selected td:first-child { padding-left: 12px; }
.detail-side { display: flex; flex-direction: column; gap: 12px; }
.side-facts { display: flex; flex-direction: column; gap: 16px; margin: 8px 0 0; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.side-facts dt { color: var(--dim); font-size: 12px; line-height: 18px; }
.side-facts dd { margin: 2px 0 0; }
.side-title { margin: 8px 0 0; font-size: 14px; line-height: 20px; font-weight: 600; }
.mod-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.btn-disabled { background: var(--input); color: #7e8783; cursor: not-allowed; }
.textarea {
  min-height: 72px; padding: 12px 16px; border: 0; border-radius: var(--radius); background: var(--panel); color: var(--text);
  font: inherit; resize: vertical;
}
.confirm .select { background: var(--panel); }
.form-row { flex-direction: row; align-items: flex-end; flex-wrap: wrap; margin-top: 16px; }
.field-grow { flex: 1 1 260px; }
.link-action { color: var(--accent); text-decoration: none; font-size: 14px; margin: 0; }
.link-action:hover { text-decoration: underline; color: var(--accent-hover); }

@media (max-width: 1100px) {
  .players-grid { grid-template-columns: 1fr; }
}

/* Etappe 4: Neustart planen, Team & Rechte, Mobil */
.mobile-only { display: none; }
.side-menu { display: none; }
.side-desktop { display: contents; }
.btn-block { width: 100%; }
.btn-small { height: 40px; padding: 0 14px; }
.select-small { height: 40px; min-width: 150px; }
.inline-form { display: flex; justify-content: flex-end; gap: 8px; }
.cell-actions { text-align: right; width: 1%; white-space: nowrap; }
.table td.cell-actions, .members td { vertical-align: middle; }
.table-scroll { overflow-x: auto; }
.matrix { min-width: 600px; }
.matrix th:not(:first-child), .matrix td:not(:first-child) { width: 124px; }
.finding .btn-block { margin-top: 8px; }

.scrim {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; overflow-y: auto;
  background: rgba(16, 18, 19, 0.64);
}
.dialog {
  width: min(560px, 100%); background: var(--panel); border-radius: var(--radius); padding: 32px;
  display: flex; flex-direction: column; gap: 16px; box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}
.dialog-title { font-size: 27px; line-height: 34px; }
.dialog-warning { background: var(--input); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; }
.dialog .form { margin-top: 0; }
.dialog .field-error { margin-top: 0; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.dialog-top { align-items: center; justify-content: space-between; }
.dialog-close { display: inline-flex; padding: 4px; color: var(--text); }

@media (max-width: 900px) {
  .mobile-only { display: flex; }
  .side-desktop { display: none; }
  .side { justify-content: space-between; flex-wrap: wrap; padding: 20px; background: var(--base); }
  .brand-sub { display: none; }
  .side-menu { display: block; }
  .side-menu summary { list-style: none; width: 86px; }
  .side-menu summary::-webkit-details-marker { display: none; }
  .side-menu[open] { width: 100%; order: 3; }
  .side-menu[open] summary { margin-left: auto; position: absolute; top: 20px; right: 20px; }
  .side-menu-body { display: flex; flex-direction: column; gap: 16px; padding-top: 16px; }
  .side-menu .nav { flex-direction: column; }
  .side-menu .side-user { margin: 0; padding: 16px 0 0; border-top: 1px solid var(--line); }
  .side { position: relative; }
  .context { background: var(--base); padding: 0 20px; height: auto; justify-content: space-between; }
  .context .meta { display: none; }
  .head-action { display: none; }
  .kpis { background: none; padding: 0; grid-template-columns: 1fr; gap: 12px; }
  .kpi { flex-direction: row; justify-content: space-between; align-items: baseline; }
  .kpi .meta { font-size: 14px; line-height: 22px; color: var(--soft); }
  .kpi .value { font-size: 14px; line-height: 22px; }
  .members tr { display: flex; flex-direction: column; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .members td { border: 0; padding: 0; }
  .members td.cell-actions { text-align: left; width: auto; }
  .inline-form { justify-content: flex-start; flex-wrap: wrap; }

  .scrim { padding: 0; place-items: stretch; background: var(--base); }
  .dialog { width: 100%; min-height: 100%; border-radius: 0; padding: 20px; background: var(--base); box-shadow: none; }
  .dialog-title { font-size: 30px; line-height: 38px; }
  .dialog-warning, .dialog .field input, .dialog .select { background: var(--panel); }
  .dialog-actions { grid-template-columns: 1fr; }
  .dialog-actions .btn-danger { order: -1; }
  .dialog-actions .btn-secondary { background: var(--panel); }
}

/* Etappe 5: Bedienung (Werkzeuge in der Kontextleiste, globale Suche, Hinweise) */
.context-tools { display: flex; align-items: center; gap: 8px; }
.tool-button {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 0; border-radius: var(--radius);
  background: var(--input); color: var(--soft); font: 600 13px/18px Archivo, Arial, sans-serif; text-decoration: none; cursor: pointer;
}
.tool-button:hover { background: var(--surface-hover); color: var(--text); }
.kbd { padding: 1px 6px; border-radius: var(--radius-small); background: var(--panel); color: var(--dim); font: 500 11px/16px var(--mono); }
.textarea-input { background: var(--input); min-height: 96px; }

.notice { transition: opacity 0.5s ease; }
.notice.is-leaving { opacity: 0; }

.palette {
  width: min(640px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 96px)); margin: 12vh auto auto; padding: 0; border: 0;
  border-radius: var(--radius); background: var(--panel); color: var(--text); box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  flex-direction: column; overflow: hidden;
}
.palette[open] { display: flex; }
.palette::backdrop { background: rgba(16, 18, 19, 0.64); }
/* Eingabe und Fußzeile behalten ihre Höhe; nur die Liste scrollt (sonst drückt eine lange Liste das Feld zusammen) */
.palette-input {
  flex: none; height: 64px; padding: 0 24px; border: 0; border-bottom: 1px solid var(--line); background: none; color: var(--text);
  font: 400 18px/26px Archivo, Arial, sans-serif; outline: none;
}
.palette-list { overflow-y: auto; padding: 8px; flex: 1 1 auto; min-height: 0; }
.palette-group { padding: 12px 12px 4px; }
.palette-item {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 12px; border-radius: var(--radius-small);
  color: var(--text); text-decoration: none;
}
.palette-item.is-active { background: var(--input); }
.palette-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-meta { flex-shrink: 0; }
.palette-empty { padding: 16px 12px; }
.palette-foot { flex: none; padding: 10px 24px; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .context-tools { margin-left: auto; }
  .tool-label, .kbd { display: none; }
  .tool-button { width: 40px; justify-content: center; padding: 0; }
  .palette { margin-top: 16px; max-height: calc(100vh - 32px); }
}

/* Etappe 6: Spielerakte */
.badges { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.record-grid { display: grid; grid-template-columns: minmax(0, 1fr) 376px; gap: 24px; align-items: start; }
.record-main, .record-side { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.timeline, .notes, .sessions { list-style: none; margin: 0; padding: 0; }
.timeline-item {
  display: grid; grid-template-columns: 148px minmax(0, 1fr); gap: 2px 16px; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.timeline-item .status { grid-row: span 2; align-self: start; }
.timeline-text { overflow-wrap: anywhere; }
.note-form { margin-top: 0; margin-bottom: 16px; }
.note-form .btn { align-self: flex-start; }
.note, .session { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-top: 1px solid var(--line); }
.note-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.inline-status { margin-left: 12px; min-height: 0; vertical-align: middle; }
.kpi .soft { font-size: 13px; line-height: 18px; }

@media (max-width: 1100px) {
  .record-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .kpi .soft { display: none; }
  .timeline-item { grid-template-columns: 1fr; }
  .timeline-item .status { grid-row: auto; }
}

/* Etappe 7: Betrieb & Sicherung */
.ops-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.ops-grid .panel > .soft { margin-bottom: 4px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.times { border: 0; margin: 0; padding: 0; min-width: 0; }
.time-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.input-time { flex: none; width: 100%; min-width: 0; font-variant-numeric: tabular-nums; color-scheme: dark; }
.btn-start { align-self: flex-start; }
.backup-forms { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 8px 0 16px; }
.backup-forms .form-row { margin-top: 0; }
.backup-now { display: flex; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.mono { font-family: var(--mono); font-weight: 500; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 1100px) {
  .ops-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .form-grid, .time-row { grid-template-columns: 1fr 1fr; }
  .backup-forms { align-items: stretch; }
  .backup-now .btn { width: 100%; }
}
