/* HagenCloud Leitstand – Stahlgrau, Schiefer-Tinte, Signalgelb */
:root {
    --steel: #E9ECEB;
    --panel: #F7F8F7;
    --line: #C9D0D0;
    --ink: #1C2A35;
    --ink-soft: #5A6B76;
    --signal: #E3A700;
    --signal-ink: #3A2C00;
    --online: #2E8B57;
    --starting: #D98E04;
    --stopping: #C0392B;
    --idle: #9AA6AD;
    --console-bg: #1C2A35;
    --console-fg: #DDE5E8;

    --font-ui: "Barlow", system-ui, sans-serif;
    --font-head: "Barlow Semi Condensed", "Barlow", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;

    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--steel);
    color: var(--ink);
    font: 16px/1.5 var(--font-ui);
    -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-head); font-weight: 600; line-height: 1.15; margin: 0; }
h1 { font-size: 2rem; letter-spacing: -0.01em; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.0625rem; }
p { margin: 0; }
.muted { color: var(--ink-soft); }
.error { color: var(--stopping); min-height: 1.5em; }
code, pre, .mono { font-family: var(--font-mono); font-size: 0.875rem; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }

/* ---------------------------------------------------------------- Buttons & Formulare */
.btn {
    font: 600 0.9375rem var(--font-head);
    border: 1px solid var(--ink);
    background: transparent;
    color: var(--ink);
    padding: var(--s2) var(--s4);
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { background: var(--ink); color: var(--panel); }
.btn.primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn.primary:hover { background: #C99400; border-color: #C99400; color: var(--signal-ink); }
.btn.danger { border-color: var(--stopping); color: var(--stopping); }
.btn.danger:hover { background: var(--stopping); color: #fff; }
.btn.small { padding: 2px var(--s3); font-size: 0.875rem; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

label { display: grid; gap: var(--s1); font-weight: 500; font-size: 0.9375rem; }
label.check { display: flex; align-items: center; gap: var(--s2); font-weight: 400; }
input, select, textarea {
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: var(--s2) var(--s3);
    width: 100%;
}
input[type=checkbox] { width: auto; }
textarea { min-height: 6em; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(227, 167, 0, .35); }
.hint { font-weight: 400; font-size: 0.8125rem; color: var(--ink-soft); }

/* ---------------------------------------------------------------- Anmeldung */
.login { min-height: 100%; display: grid; place-items: center; padding: var(--s5); }
.login-card {
    width: min(400px, 100%);
    display: grid;
    gap: var(--s4);
    background: var(--panel);
    padding: var(--s6);
    border-top: 6px solid var(--signal);
}
.login-card .brand { font-size: 2.25rem; }

/* ---------------------------------------------------------------- Rahmen */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: 100%; }
.app > * { min-width: 0; }
.sidebar {
    background: var(--ink);
    color: var(--console-fg);
    display: flex;
    flex-direction: column;
    padding: var(--s5) 0;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .brand {
    font: 700 1.5rem var(--font-head);
    padding: 0 var(--s5) var(--s5);
    color: var(--signal);
}
.sidebar nav { display: grid; }
.sidebar nav a {
    padding: var(--s2) var(--s5);
    text-decoration: none;
    font-family: var(--font-head);
    font-weight: 500;
    font-size: 1.0625rem;
    border-left: 4px solid transparent;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); }
.sidebar nav a.active { border-left-color: var(--signal); background: rgba(255, 255, 255, .08); color: #fff; }
.sidebar-foot { margin-top: auto; padding: 0 var(--s5); display: grid; gap: var(--s2); justify-items: start; font-size: 0.9375rem; }

.view { padding: var(--s6) var(--s7); max-width: 1400px; width: 100%; outline: none; }
.view-head { display: flex; align-items: end; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s5); flex-wrap: wrap; }
.view-head p { margin-top: var(--s1); }
.toolbar { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; }
.section { margin-top: var(--s6); }
.section > h2 { margin-bottom: var(--s3); }

/* ---------------------------------------------------------------- Übersicht: Kennzahlen */
.figures { display: flex; gap: var(--s6); flex-wrap: wrap; margin-bottom: var(--s6); }
.figure b { display: block; font: 600 2.5rem/1 var(--font-head); }
.figure span { color: var(--ink-soft); }

.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s4); }
.node { background: var(--panel); padding: var(--s4); border-left: 4px solid var(--ink); }
.node.head { border-left-color: var(--signal); }
.node h3 { display: flex; justify-content: space-between; }
.node .meter { height: 8px; background: var(--steel); margin: var(--s2) 0 var(--s1); }
.node .meter i { display: block; height: 100%; background: var(--ink); }

/* ---------------------------------------------------------------- Stellwerk (Tasks als Strecken) */
.board { background: var(--panel); padding: var(--s2) 0; }
.track {
    display: grid;
    grid-template-columns: 180px 1fr;
    align-items: center;
    padding: var(--s3) var(--s5);
    border-bottom: 1px solid var(--line);
}
.track:last-child { border-bottom: 0; }
.track-name { font: 600 1.0625rem var(--font-head); }
.track-name small { display: block; font: 400 0.8125rem var(--font-ui); color: var(--ink-soft); }
.rail {
    position: relative;
    display: flex;
    gap: var(--s3);
    flex-wrap: wrap;
    min-height: 56px;
    align-items: center;
    padding-left: var(--s2);
}
.rail::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 50%;
    border-top: 2px dashed var(--line);
    z-index: 0;
}
.block {
    position: relative;
    z-index: 1;
    min-width: 124px;
    background: #fff;
    border: 2px solid var(--idle);
    padding: var(--s1) var(--s2) var(--s2);
    text-align: left;
    font: inherit;
    color: inherit;
    cursor: pointer;
    border-radius: 2px;
}
.block:hover { border-color: var(--ink); }
.block .lamp { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--idle); margin-right: var(--s1); }
.block b { font: 600 0.9375rem var(--font-head); white-space: nowrap; display: block; }
.block .fill { height: 5px; background: var(--steel); margin-top: var(--s1); }
.block .fill i { display: block; height: 100%; background: var(--ink); }
.block small { display: block; font-size: 0.75rem; color: var(--ink-soft); }
.block.ONLINE { border-color: var(--online); }
.block.ONLINE .lamp { background: var(--online); }
.block.STARTING, .block.PREPARING { border-color: var(--starting); }
.block.STARTING .lamp, .block.PREPARING .lamp { background: var(--starting); animation: blink 1.2s steps(2) infinite; }
.block.STOPPING .lamp { background: var(--stopping); }
.block.STOPPING { border-color: var(--stopping); }
.track .empty { color: var(--ink-soft); font-size: 0.875rem; position: relative; z-index: 1; background: var(--panel); padding-right: var(--s2); }
@keyframes blink { 50% { opacity: .25; } }

/* ---------------------------------------------------------------- Tabellen */
.table-wrap { overflow-x: auto; background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: var(--s2) var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font: 600 0.875rem var(--font-head); color: var(--ink-soft); background: var(--steel); }
tr:last-child td { border-bottom: 0; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn { margin-left: var(--s1); }
.state { display: inline-flex; align-items: center; gap: var(--s1); font-weight: 500; }
.state::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--idle); }
.state.ONLINE::before { background: var(--online); }
.state.STARTING::before, .state.PREPARING::before { background: var(--starting); }
.state.STOPPING::before { background: var(--stopping); }
.tag { display: inline-block; font-size: 0.8125rem; padding: 0 var(--s2); border: 1px solid var(--line); border-radius: 2px; margin: 1px 2px 1px 0; background: #fff; }
.empty-state { padding: var(--s6) var(--s5); text-align: center; color: var(--ink-soft); background: var(--panel); }

/* ---------------------------------------------------------------- Konsole */
.console {
    background: var(--console-bg);
    color: var(--console-fg);
    font: 0.8125rem/1.55 var(--font-mono);
    padding: var(--s3) var(--s4);
    height: 60vh;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.console .warn { color: #F2C14E; }
.console .err { color: #FF8A7A; }
.console .me { color: var(--signal); }
.console-input { display: flex; gap: var(--s2); margin-top: var(--s2); }
.console-input input { font-family: var(--font-mono); }

/* ---------------------------------------------------------------- Seitenpanel */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(28, 42, 53, .45); z-index: 20; }
.drawer {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: min(760px, 100%);
    background: var(--steel);
    z-index: 21;
    overflow-y: auto;
    padding: var(--s5) var(--s6);
    box-shadow: -8px 0 24px rgba(28, 42, 53, .25);
}
.drawer-head { display: flex; justify-content: space-between; align-items: start; gap: var(--s4); margin-bottom: var(--s4); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s1) var(--s4); margin: var(--s3) 0 var(--s4); font-size: 0.9375rem; }
.facts dt { color: var(--ink-soft); }
.facts dd { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s4); align-items: end; }
.form-actions { display: flex; gap: var(--s2); margin-top: var(--s5); }
fieldset { border: 1px solid var(--line); padding: var(--s4); margin: var(--s4) 0 0; }
legend { font: 600 1rem var(--font-head); padding: 0 var(--s1); }

/* ---------------------------------------------------------------- Dateibrowser */
.crumbs { display: flex; gap: var(--s1); flex-wrap: wrap; align-items: center; margin-bottom: var(--s3); }
.crumbs button { background: none; border: 0; font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer; padding: 0; }
.crumbs span { color: var(--ink-soft); }
.file-name { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.file-name:hover { text-decoration: underline; }
.file-name.dir { font-weight: 600; }
.editor { font: 0.8125rem/1.55 var(--font-mono); min-height: 55vh; white-space: pre; tab-size: 4; }

/* ---------------------------------------------------------------- Meldungen */
.toast {
    position: fixed;
    bottom: var(--s5); left: 50%;
    transform: translate(-50%, 150%);
    background: var(--ink);
    color: #fff;
    padding: var(--s3) var(--s5);
    border-left: 4px solid var(--signal);
    transition: transform .2s ease, visibility 0s linear .2s;
    visibility: hidden;
    z-index: 30;
    max-width: min(560px, 90vw);
}
.toast.show { transform: translate(-50%, 0); visibility: visible; transition: transform .2s ease; }
.toast.bad { border-left-color: var(--stopping); }

/* ---------------------------------------------------------------- Mobil */
@media (max-width: 860px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .sidebar { position: static; height: auto; padding: var(--s3) 0; }
    .sidebar nav { display: flex; overflow-x: auto; }
    .sidebar nav a { border-left: 0; border-bottom: 3px solid transparent; white-space: nowrap; }
    .sidebar nav a.active { border-bottom-color: var(--signal); }
    .sidebar .brand { padding-bottom: var(--s2); }
    .sidebar-foot { flex-direction: row; display: flex; gap: var(--s4); padding-top: var(--s2); }
    .view { padding: var(--s5) var(--s4); }
    .track { grid-template-columns: 1fr; gap: var(--s2); }
    .drawer { padding: var(--s4); }
}
@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
