/* ==========================================================================
   Fold UI — das Designsystem von TheFold.

   Aufbau nach dem Vorbild von shadcn/ui: semantische Tokens (Flaeche, Text,
   Rand, Akzent, Status) auf zwei Farbskalen im Stil von Radix Colors -- ein
   warmes Grau ("Sand") und das Tablegray-Orange als Akzent. Jede Komponente
   greift nur auf Tokens zu, nie auf Hex-Werte; dadurch traegt der Dark Mode
   (html[data-theme="dark"]) ohne zweite Regelkette.

   Die alten Namen (--accent, --muted, --text, --bg, --card, --border,
   --shadow) bleiben als Aliase bestehen: die Seiten-Styles in den Views
   verwenden sie und sollen ohne Umbau mitziehen.

   Gliederung: 1 Tokens · 2 Basis · 3 App-Rahmen (Sidebar, Kopfleiste)
   · 4 Komponenten · 5 Panels (Ops Chat, Jobs, Logs) · 6 Befehlspalette
   · 7 Seitenspezifisches aus dem alten Layout · 8 Responsive
   ========================================================================== */

/* 1 · Tokens ------------------------------------------------------------- */
:root {
    color-scheme: light;

    --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* Flaechen */
    --bg: #f7f6f3;
    --surface: #ffffff;
    --surface-2: #f4f2ee;
    --surface-3: #ebe8e2;
    --overlay: rgba(20, 18, 15, 0.45);

    /* Text */
    --text: #1c1b19;
    --text-2: #67625a;
    --text-3: #8f897f;

    /* Raender */
    --border: #e6e2db;
    --border-strong: #d4cdc2;

    /* Akzent (Tablegray-Orange; Fuellung so dunkel, dass weisse Schrift traegt) */
    --brand: #d68739;
    --accent: #c2621a;
    --accent-hover: #a9540f;
    --accent-fg: #ffffff;
    --accent-soft: #fbeee0;
    --accent-text: #a4500f;
    --ring: rgba(214, 135, 57, 0.35);

    /* Status: weicher Grund + lesbare Schrift */
    --ok: #2f8a4c;      --ok-soft: #e6f4ea;      --ok-text: #23663a;
    --warn: #c98612;    --warn-soft: #fcf0d9;    --warn-text: #84520e;
    --danger: #c23b32;  --danger-soft: #fbe8e6;  --danger-text: #9c2c25;
    --info: #3a72b0;    --info-soft: #e6eef9;    --info-text: #2f5d8f;
    --violet: #6a4fc7;  --violet-soft: #eee9fd;  --violet-text: #573fb0;

    /* Form */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-full: 999px;
    --shadow-xs: 0 1px 2px rgba(28, 27, 25, 0.05);
    --shadow-sm: 0 1px 3px rgba(28, 27, 25, 0.07), 0 1px 2px rgba(28, 27, 25, 0.04);
    --shadow-md: 0 8px 24px rgba(28, 27, 25, 0.10), 0 2px 6px rgba(28, 27, 25, 0.05);
    --shadow-lg: 0 24px 60px rgba(28, 27, 25, 0.18);

    --sidebar-w: 236px;
    --topbar-h: 56px;
    --content-max: 1480px;

    /* Aliase fuer bestehende Views */
    --muted: var(--text-2);
    --card: var(--surface);
    --shadow: var(--shadow-sm);
    --primary: var(--accent); /* alter Name, von einzelnen Views noch genutzt */
}

html[data-theme="dark"] {
    color-scheme: dark;

    --bg: #111110;
    --surface: #191817;
    --surface-2: #211f1d;
    --surface-3: #2a2825;
    --overlay: rgba(0, 0, 0, 0.6);

    --text: #edeae5;
    --text-2: #a8a197;
    --text-3: #7c766d;

    --border: #2d2a27;
    --border-strong: #3d3934;

    --accent: #d0701f;
    --accent-hover: #e0812f;
    --accent-fg: #ffffff;
    --accent-soft: rgba(214, 135, 57, 0.16);
    --accent-text: #f0a35e;
    --ring: rgba(240, 163, 94, 0.35);

    --ok: #46b06a;      --ok-soft: rgba(70, 176, 106, 0.15);   --ok-text: #86d9a2;
    --warn: #e0a238;    --warn-soft: rgba(224, 162, 56, 0.15); --warn-text: #f0c47a;
    --danger: #e0574d;  --danger-soft: rgba(224, 87, 77, 0.15); --danger-text: #f59990;
    --info: #5b95d6;    --info-soft: rgba(91, 149, 214, 0.16);  --info-text: #9cc2ef;
    --violet: #9a83ec;  --violet-soft: rgba(154, 131, 236, 0.16); --violet-text: #c2b3f6;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.6);
}

/* 2 · Basis -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    font-feature-settings: "cv11", "ss01";
    -webkit-font-smoothing: antialiased;
    overflow-x: clip; /* eingeklappte Panels (fixed + transform) duerfen keine Querscrollleiste erzeugen */
}
h1, h2, h3, h4 { color: var(--text); letter-spacing: -0.011em; line-height: 1.25; }
h1 { font-size: 24px; font-weight: 650; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 18px; font-weight: 650; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 8px; }
h4 { font-size: 14px; font-weight: 600; margin: 0 0 6px; }
p { margin: 0 0 12px; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }
pre { white-space: pre-wrap; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
img { max-width: 100%; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--text-2); }
.text-ok { color: var(--ok-text); }
.text-warn { color: var(--warn-text); }
.text-danger { color: var(--danger-text); }
.text-accent { color: var(--accent-text); }
.small, small { font-size: 12px; }
.mono { font-family: var(--font-mono); }
.num, td.num { font-variant-numeric: tabular-nums; }
kbd {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 20px; height: 20px; padding: 0 5px;
    border: 1px solid var(--border-strong); border-bottom-width: 2px;
    border-radius: 5px; background: var(--surface); color: var(--text-2);
    font-size: 11px; font-family: var(--font-sans); font-weight: 600; line-height: 1;
}
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
    position: absolute; left: 12px; top: -200px; z-index: 300;
    background: var(--surface); color: var(--text); padding: 8px 12px;
    border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.skip-link:focus { top: 12px; }

/* 3 · App-Rahmen --------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 90;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transition: transform .2s ease;
}
.sidebar-brand {
    height: var(--topbar-h); flex: none;
    display: flex; align-items: center; gap: 10px;
    padding: 0 16px; border-bottom: 1px solid var(--border);
    color: var(--text); text-decoration: none;
}
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { height: 22px; width: auto; }
.sidebar-brand .brand-name {
    font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
    color: var(--text-3); padding-left: 10px; border-left: 1px solid var(--border);
}
html[data-theme="dark"] .sidebar-brand img { filter: brightness(1.35); }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 10px 10px 16px; scrollbar-width: thin; }
.nav-section { margin-bottom: 14px; }
.nav-section-title {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 6px 10px 4px; margin: 0;
    background: none; border: 0; cursor: pointer;
    font: inherit; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-3);
}
.nav-section-title svg { transition: transform .15s ease; opacity: .7; }
.nav-section.collapsed .nav-section-title svg { transform: rotate(-90deg); }
.nav-section.collapsed .nav-items { display: none; }
.nav-items { display: grid; gap: 1px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    min-height: 32px; padding: 6px 10px;
    border-radius: var(--radius);
    color: var(--text-2); font-weight: 500; font-size: 13.5px;
    text-decoration: none;
}
.nav-link svg { flex: none; width: 16px; height: 16px; opacity: .85; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav-link.active svg { opacity: 1; }
.nav-link .nav-ext { margin-left: auto; width: 12px; height: 12px; opacity: .45; }

.sidebar-foot {
    flex: none; border-top: 1px solid var(--border);
    padding: 10px; display: grid; gap: 6px;
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px; padding: 4px 6px;
    font-size: 13px; color: var(--text-2); min-width: 0;
}
.sidebar-user .avatar {
    flex: none; width: 28px; height: 28px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 12px;
}
.sidebar-user .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot-row { display: flex; gap: 6px; }
.sidebar-foot-row > * { flex: 1; }
.sidebar-foot form { margin: 0; }

.app-main {
    flex: 1; min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex; flex-direction: column;
}
html.sidebar-hidden .sidebar { transform: translateX(-100%); }
html.sidebar-hidden .app-main { margin-left: 0; }

.topbar {
    position: sticky; top: 0; z-index: 70;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 20px;
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(10px);
    -webkit-backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-spacer { flex: 1; }
.search-trigger {
    display: flex; align-items: center; gap: 8px;
    width: min(420px, 100%); height: 34px; padding: 0 8px 0 10px;
    border: 1px solid var(--border); border-radius: var(--radius);
    background: var(--surface); color: var(--text-3);
    font: inherit; font-size: 13px; cursor: pointer; text-align: left;
    box-shadow: var(--shadow-xs);
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-trigger span { flex: 1; }
.search-trigger kbd { height: 18px; font-size: 10.5px; }

.icon-btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; min-width: 34px; padding: 0 10px;
    border: 1px solid transparent; border-radius: var(--radius);
    background: transparent; color: var(--text-2);
    font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn[aria-pressed="true"], .icon-btn.on { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 17px; height: 17px; flex: none; }
.icon-btn .badge-dot {
    position: absolute; top: 3px; right: 3px;
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
    background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
.icon-btn.accent { background: var(--accent); color: var(--accent-fg); }
.icon-btn.accent:hover { background: var(--accent-hover); color: var(--accent-fg); }
.topbar .menu-btn { display: none; }

main.content {
    width: 100%; max-width: var(--content-max);
    margin: 0 auto; padding: 28px 32px 64px;
}
/* Alt: main.wrap -- einige Views setzen .wrap selbst ein */
.wrap { max-width: var(--content-max); margin: 0 auto; }

/* 4 · Komponenten -------------------------------------------------------- */

/* Kopf einer Seite */
.section-header {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    margin-bottom: 20px; flex-wrap: wrap;
}
.section-header > div:first-child { min-width: 0; }
.section-header .subtitle, .subtitle { color: var(--text-2); font-size: 13.5px; margin-top: 2px; }
.section-header h2 { margin-bottom: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Buttons */
.btn, form button.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background: var(--surface); color: var(--text);
    font: inherit; font-size: 13px; font-weight: 550; line-height: 1;
    text-decoration: none; white-space: nowrap; cursor: pointer;
    box-shadow: var(--shadow-xs);
    transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled, .btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-fg); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { filter: brightness(.93); color: #fff; }
.btn.needs-run { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, transparent); color: var(--danger-text); }
.btn.small, .btn.sm { height: 28px; padding: 0 9px; font-size: 12px; border-radius: var(--radius-sm); }
.btn svg { width: 15px; height: 15px; }

/* Ein nacktes <button> in einem Formular ist die Hauptaktion des Formulars */
form button:not([class]), form button[type="submit"]:not(.btn):not(.link-danger):not(.icon-btn):not(.chip):not(.tab-btn) {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 14px;
    background: var(--accent); color: var(--accent-fg);
    border: 1px solid var(--accent); border-radius: var(--radius);
    font: inherit; font-size: 13px; font-weight: 550; cursor: pointer;
    box-shadow: var(--shadow-xs);
}
form button:not([class]):hover, form button[type="submit"]:not(.btn):not(.link-danger):not(.icon-btn):not(.chip):not(.tab-btn):hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.link-danger, .link-danger {
    background: none !important; border: 0 !important; padding: 0 !important; box-shadow: none !important;
    height: auto !important; color: var(--danger-text) !important; font: inherit; font-weight: 550; cursor: pointer;
}
button.link-danger:hover, .link-danger:hover { text-decoration: underline; }
.logout { /* alt: Abmeldeknopf */
    background: transparent; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 6px 10px; color: var(--text-2); cursor: pointer; font: inherit;
}

/* Formulare */
label { font-weight: 500; font-size: 13px; color: var(--text); }
form label { display: inline-block; margin-bottom: 4px; }
input, select, textarea { font: inherit; color: inherit; }
/* Grundform fuer Felder ausserhalb von Formularen (Filter in Panels, Suchfelder
   der Seiten). :where() haelt die Spezifitaet bei 0 -- Seitenklassen gewinnen. */
:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="color"], [type="file"], [type="hidden"], [type="submit"], [type="button"]), select, textarea) {
    min-height: 34px; padding: 6px 10px;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    background-color: var(--surface); color: var(--text);
    font: inherit; font-size: 13.5px;
}
:where(select) {
    appearance: none; -webkit-appearance: none; padding-right: 28px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238f897f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 9px center;
}
:where(select[multiple]) { background-image: none; padding-right: 10px; }
:where(input, select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
form input, form select, form textarea,
.input, .ops-form textarea {
    width: 100%;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-family: inherit; font-size: 14px;
    box-shadow: var(--shadow-xs);
    transition: border-color .12s, box-shadow .12s;
}
form select, select.input {
    appearance: none; -webkit-appearance: none;
    padding-right: 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238f897f' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center;
}
form select[multiple] { background-image: none; padding-right: 10px; }
form textarea { min-height: 96px; line-height: 1.5; resize: vertical; }
form input:hover, form select:hover, form textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-3)); }
form input:focus, form select:focus, form textarea:focus, .input:focus, .ops-form textarea:focus {
    outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring);
}
form input::placeholder, form textarea::placeholder { color: var(--text-3); }
form input:disabled, form select:disabled, form textarea:disabled { background: var(--surface-2); color: var(--text-3); }
/* Checkbox/Radio nicht auf Feldbreite ziehen (s. Push-Bestaetigung, 19.09.2026) */
form input[type="checkbox"], form input[type="radio"],
input[type="checkbox"], input[type="radio"] {
    width: 16px; height: 16px; min-height: 0; padding: 0; margin: 0;
    border: none; background: none; box-shadow: none;
    flex: 0 0 auto; accent-color: var(--accent); vertical-align: -3px;
}
form input[type="file"] { padding: 6px; }
form input[type="color"] { padding: 2px; height: 36px; }
form input[type="range"] { box-shadow: none; border: 0; padding: 0; accent-color: var(--accent); }
/* Felder in einer Aktionszeile (Filterleisten) nicht auf volle Breite */
.actions > select, .actions > input:not([type="checkbox"]):not([type="radio"]),
.filters select, .filters input:not([type="checkbox"]):not([type="radio"]) {
    width: auto; flex: 0 1 220px; min-width: 140px;
}
.actions > input[type="search"], .actions > input[type="text"] { flex-basis: 280px; }
form > div + div, form > label + input, form > label + select, form > label + textarea { margin-top: 0; }
.field { display: grid; gap: 4px; margin-bottom: 14px; }
/* Klassische Anlege-/Bearbeiten-Formulare (<form> direkt im Inhalt, Felder als
   <p><label><br><input></p>): als Karte mit lesbarer Breite statt ueber die
   ganze Seite gezogen. */
main.content > form[method="POST"]:not([class]), main.content > form.form-card {
    max-width: 820px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 22px 24px; box-shadow: var(--shadow-xs);
}
main.content > form[method="POST"]:not([class]) > p, main.content > form.form-card > p { margin: 0 0 16px; }
form p > label:first-child { display: block; margin-bottom: 5px; }
form p > label:first-child + br { display: none; }
form p > label:has(> input[type="checkbox"]), form p > label:has(> input[type="radio"]),
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) {
    display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer;
}
main.content > form[method="POST"]:not([class]) > button:last-child,
main.content > form[method="POST"]:not([class]) > .actions:last-child { margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 16px; }
.hint, .help { font-size: 12px; color: var(--text-3); }

/* Karten */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-xs);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
form.card .actions { gap: 10px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi { font-size: 26px; font-weight: 650; margin: 4px 0 2px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--text-2); font-size: 12px; font-weight: 550; text-transform: none; letter-spacing: 0; }

/* Tabellen */
table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    overflow: hidden; box-shadow: var(--shadow-xs);
    font-size: 13.5px;
}
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
    background: var(--surface-2); color: var(--text-2);
    font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0;
    white-space: nowrap;
}
tbody tr { transition: background-color .08s; }
tbody tr:hover > td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
tr:last-child td { border-bottom: none; }
td.muted { color: var(--text-2); }
.text-ok { color: var(--ok-text); }
.text-warn { color: var(--warn-text); }
.text-danger { color: var(--danger-text); }
.text-accent { color: var(--accent-text); }
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
.table-actions { white-space: nowrap; text-align: right; }
th:last-child:is(:only-child) { text-align: left; }
.table-actions a, .table-actions form, .table-actions button { display: inline-flex; vertical-align: middle; }
.table-actions a { margin-right: 10px; font-weight: 550; }
.table-actions form { margin: 0 0 0 4px !important; }
.card table, .card .table-wrap table { box-shadow: none; }

/* Pillen / Status */
.pill, .badge {
    display: inline-flex; align-items: center; gap: 4px;
    height: 22px; padding: 0 8px; border-radius: var(--radius-full);
    font-size: 11.5px; font-weight: 600; letter-spacing: .01em; text-transform: none; white-space: nowrap;
    background: var(--surface-3); color: var(--text-2);
}
.pill.status-active, .pill.status-live, .pill.status-deploy, .pill.status-operate,
.pill.status-ok, .pill.status-done, .pill.status-deployed, .pill.status-approved { background: var(--ok-soft); color: var(--ok-text); }
.pill.status-inactive, .pill.status-fail, .pill.status-failed, .pill.status-killed,
.pill.status-discarded, .pill.status-blocked, .pill.status-rejected, .pill.status-error { background: var(--danger-soft); color: var(--danger-text); }
.pill.status-building, .pill.status-code, .pill.status-processing, .pill.status-needs_input,
.pill.status-running, .pill.status-in_progress, .pill.status-pending { background: var(--warn-soft); color: var(--warn-text); }
.pill.status-planned, .pill.status-spec, .pill.status-queued { background: var(--info-soft); color: var(--info-text); }
.pill.status-idea { background: var(--violet-soft); color: var(--violet-text); }
.pill.status-test, .pill.status-missing, .pill.status-paused, .pill.status-draft { background: var(--surface-3); color: var(--text-2); }
.pill::before { content: none; }
.pill.status-live::before, .pill.status-processing::before, .pill.status-running::before, .pill.status-in_progress::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.pill.status-processing::before, .pill.status-running::before, .pill.status-in_progress::before { animation: foldPulse 1.4s ease-in-out infinite; }
@keyframes foldPulse { 50% { opacity: .3; } }
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    height: 30px; padding: 0 12px; border-radius: var(--radius-full);
    border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
    font: inherit; font-size: 12.5px; font-weight: 550; cursor: pointer; text-decoration: none;
}
.chip:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.chip.active, .chip.is-active, .chip[aria-pressed="true"], .chip.on { background: var(--text); border-color: var(--text); color: var(--bg); }

/* Meldungen */
.status, .flash {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 10px 14px; margin-bottom: 18px;
    background: var(--ok-soft); color: var(--ok-text);
    border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
    border-radius: var(--radius);
    font-weight: 500;
}
.flash svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.flash .flash-text { flex: 1; }
.flash .flash-close { background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 0 2px; font-size: 18px; line-height: 1; }
.flash .flash-close:hover { opacity: 1; }
.flash.error { background: var(--danger-soft); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.flash ul { margin: 4px 0 0; padding-left: 18px; }
.alert, .warn { padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); color: var(--warn-text); }
.empty {
    padding: 28px 20px; text-align: center;
    border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
    color: var(--text-2); background: color-mix(in srgb, var(--surface) 50%, transparent);
}

/* Aufklapper */
details > summary { cursor: pointer; }
details.card > summary, .card details > summary {
    font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px;
}
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before {
    content: ""; width: 7px; height: 7px; flex: none;
    border-right: 2px solid var(--text-3); border-bottom: 2px solid var(--text-3);
    transform: rotate(-45deg); transition: transform .15s ease; margin-right: 2px;
}
details.card[open] > summary::before { transform: rotate(45deg); }
details.card[open] > summary { margin-bottom: 14px; }

/* Reiter (Views nutzen .tab-btn/.tab-panel) */
.tabs, .tab-bar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab-btn {
    background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
    padding: 9px 12px; font: inherit; font-size: 13.5px; font-weight: 550; color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active, .tab-btn.is-active, .tab-btn[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }

/* Markdown */
.markdown-body { line-height: 1.65; }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { margin: 1em 0 0.4em; }
.markdown-body h1:first-child, .markdown-body h2:first-child { margin-top: 0; }
.markdown-body p { margin: 0 0 0.8em; }
.markdown-body ul, .markdown-body ol { margin: 0 0 0.8em; padding-left: 1.3em; }
.markdown-body code { background: var(--surface-3); border-radius: 4px; padding: 1px 5px; font-size: 0.9em; }
.markdown-body pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; }
.markdown-body pre code { background: transparent; padding: 0; }
.markdown-body table { box-shadow: none; margin-bottom: 1em; }
.markdown-body blockquote { margin: 0 0 .8em; padding: 2px 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }


/* Seitennummerierung (Laravel 'pagination::default') */
.pagination { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 16px 0 0; padding: 0; }
.pagination li > a, .pagination li > span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; padding: 0 8px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font-size: 13px; font-weight: 550;
}
.pagination li > a:hover { background: var(--surface-2); text-decoration: none; }
.pagination li.active > span { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.pagination li.disabled > span { color: var(--text-3); background: var(--surface-2); }

/* Vorformatierter Block (Logs, Antworten, Befehle) */
.pre-box {
    margin: 0; padding: 10px 12px; overflow-x: auto;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
    font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55; white-space: pre-wrap;
}
/* Unsichtbares Feld als Kopierquelle */
.copy-source { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* Raster */
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; }
.stack > * + * { margin-top: 16px; }

/* Ortsanzeige (partials/ortsanzeige) */
.ortsanzeige {
    position: relative; /* haelt das .sr-only im Kasten -- sonst entkommt es Scrollcontainern und erzeugt Querscrollen */
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: var(--radius-full);
    font-size: 11px; font-weight: 600; line-height: 1.5;
    background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.ortsanzeige-getrennt { background: var(--info-soft); color: var(--info-text); }
.ortsanzeige-warnt { background: var(--warn-soft); color: var(--warn-text); }
.ortsanzeige-zeichen { font-style: normal; margin-right: 2px; }
.ortsanzeige-name { font-variant-numeric: tabular-nums; }
.ortsanzeige-pfeil { margin: 0 4px; opacity: .7; }
.ortsanzeige-warnzeichen { margin-left: 4px; }
.ortsanzeige-ziel { white-space: nowrap; }
.ortsanzeige-legende { margin: 4px 0 18px; font-size: 12px; color: var(--text-2); }
.ortsanzeige-legende > summary { cursor: pointer; }
.ortsanzeige-legende ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 5px; }
.ortsanzeige-legende li { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }

/* 5 · Panels: Ops Chat, Jobs, Server-Logs -------------------------------- */
.backdrop {
    position: fixed; inset: 0; z-index: 85; background: var(--overlay);
    opacity: 0; pointer-events: none; transition: opacity .15s ease;
}
.backdrop.open { opacity: 1; pointer-events: auto; }

.ops-sidebar {
    position: fixed; right: 0; top: 0; z-index: 95;
    height: 100vh; height: 100dvh; width: min(420px, 100vw);
    background: var(--surface); border-left: 1px solid var(--border);
    transform: translateX(100%); transition: transform .2s ease, box-shadow .2s ease; visibility: hidden;
    display: flex; flex-direction: column;
}
.ops-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); visibility: visible; }
.ops-header {
    height: var(--topbar-h); padding: 0 12px 0 16px; flex: none;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    border-bottom: 1px solid var(--border);
}
.ops-conversations {
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    display: grid; gap: 6px; background: var(--surface-2);
    max-height: 30vh; overflow-y: auto;
}
#opsConversations { display: grid; gap: 4px; }
.ops-conversation {
    padding: 6px 10px; border-radius: var(--radius);
    border: 1px solid transparent; background: transparent;
    cursor: pointer; font-size: 13px; color: var(--text-2);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ops-conversation:hover { background: var(--surface); color: var(--text); }
.ops-conversation.active { background: var(--surface); border-color: var(--border); color: var(--text); font-weight: 550; box-shadow: var(--shadow-xs); }
.ops-log { flex: 1; padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.ops-bubble {
    max-width: 92%; padding: 9px 12px; border-radius: var(--radius-lg);
    font-size: 13.5px; line-height: 1.55;
    border: 1px solid var(--border); background: var(--surface);
}
.ops-bubble.assistant { background: var(--surface-2); border-color: var(--border); align-self: flex-start; }
.ops-bubble.user { align-self: flex-end; background: var(--accent-soft); border-color: transparent; color: var(--text); }
.ops-bubble-actions { display: flex; justify-content: flex-end; margin-top: 6px; }
.ops-copy { height: 24px !important; font-size: 11.5px !important; padding: 0 8px !important; }
.ops-form { padding: 12px 14px 14px; border-top: 1px solid var(--border); background: var(--surface); display: grid; gap: 8px; }
.ops-form textarea { min-height: 84px; }
.ops-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ops-actions label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 12.5px; }
.ops-actions .btn.primary { margin-left: auto; }

.queue-panel, .logs-panel {
    position: fixed; left: var(--sidebar-w); right: 0; bottom: 0; z-index: 80;
    height: 42vh; min-height: 260px;
    background: var(--surface); border-top: 1px solid var(--border-strong);
    visibility: hidden; transform: translateY(105%); transition: transform .2s ease;
    display: flex; flex-direction: column;
}
html.sidebar-hidden .queue-panel, html.sidebar-hidden .logs-panel { left: 0; }
.queue-panel.open, .logs-panel.open { transform: translateY(0); box-shadow: var(--shadow-lg); visibility: visible; }
.queue-header, .logs-header {
    padding: 8px 16px; min-height: 48px; flex: none;
    border-bottom: 1px solid var(--border); background: var(--surface-2);
    display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
}
.queue-header .actions, .logs-header .actions { flex-wrap: wrap; gap: 6px; }
.queue-header .actions select, .queue-header .actions input, .logs-header .actions select {
    flex: 0 0 auto; width: 130px; min-width: 0; min-height: 30px; height: 30px; padding: 3px 26px 3px 8px; font-size: 12.5px;
    border-radius: var(--radius-sm);
}
.queue-header .actions input { width: 160px; padding-right: 8px; }
.queue-header .actions input { padding-right: 8px; }
.queue-header .btn, .logs-header .btn { height: 30px; font-size: 12.5px; }
.queue-body { padding: 0; overflow-y: auto; flex: 1; }
.queue-table { border: 0; border-radius: 0; box-shadow: none; font-size: 12.5px; }
.queue-table th { position: sticky; top: 0; z-index: 1; }
.queue-table th, .queue-table td { padding: 7px 12px; }
.logs-body {
    flex: 1; padding: 12px 16px; overflow-y: auto;
    font-family: var(--font-mono); font-size: 12px; line-height: 1.55; white-space: pre-wrap;
    background: var(--surface);
}

/* 6 · Befehlspalette ----------------------------------------------------- */
.palette {
    position: fixed; inset: 0; z-index: 200;
    display: none; align-items: flex-start; justify-content: center;
    padding: 12vh 16px 16px; background: var(--overlay);
}
.palette.open { display: flex; }
.palette-box {
    width: min(640px, 100%); max-height: 70vh;
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden;
    animation: paletteIn .12s ease-out;
}
@keyframes paletteIn { from { opacity: 0; transform: translateY(-6px) scale(.99); } }
.palette-input-row { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-bottom: 1px solid var(--border); }
.palette-input-row svg { width: 18px; height: 18px; color: var(--text-3); flex: none; }
.palette-input {
    flex: 1; height: 52px; border: 0; outline: none; background: transparent;
    font: inherit; font-size: 15px; color: var(--text);
}
.palette-results { overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 10px 10px 4px; text-transform: uppercase; letter-spacing: .06em; }
.palette-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius);
    color: var(--text); text-decoration: none; font-size: 13.5px; cursor: pointer;
}
.palette-item:hover { text-decoration: none; }
.palette-item svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.palette-item .pi-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .pi-meta { font-size: 11.5px; color: var(--text-3); flex: none; }
.palette-item.active { background: var(--accent-soft); color: var(--accent-text); }
.palette-item.active svg { color: var(--accent-text); }
.palette-empty { padding: 22px 12px; text-align: center; color: var(--text-3); font-size: 13px; }
.palette-foot {
    display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border);
    background: var(--surface-2); color: var(--text-3); font-size: 11.5px;
}
.palette-foot span { display: inline-flex; align-items: center; gap: 4px; }

/* 7 · Seitenspezifisches aus dem alten Layout ---------------------------- */
.agent-map { position: relative; height: 520px; margin: 20px 0 30px; background: var(--surface-2); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); overflow: hidden; border: 1px solid var(--border); }
.agent-map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.agent-map .link { stroke: var(--border-strong); stroke-width: 2; }
.agent-map .link.active { stroke: var(--accent); stroke-width: 3; filter: drop-shadow(0 0 6px var(--ring)); }
.agent-node { position: absolute; transform: translate(-50%, -50%); background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius-lg); padding: 10px 12px; box-shadow: var(--shadow-sm); width: 200px; max-width: 200px; transition: transform 0.2s ease, border-color 0.2s ease; }
.agent-node .role { color: var(--text-2); font-size: 12px; margin-top: 4px; }
.agent-node .desc { color: var(--text-2); font-size: 11px; margin-top: 6px; }
.agent-node.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.agent-node .task { font-size: 12px; margin-top: 8px; font-weight: 600; }
.agent-node .project { font-size: 11px; color: var(--text-2); margin-top: 4px; }
.agent-node.status-running, .agent-node.status-in_progress { border-color: var(--warn); background: var(--warn-soft); }
.agent-node.status-done { border-color: var(--ok); background: var(--ok-soft); }
.agent-node.status-needs_input { border-color: var(--warn); background: var(--warn-soft); }
.agent-node.status-blocked { border-color: var(--danger); background: var(--danger-soft); }
.agent-node.status-running, .agent-node.status-in_progress { animation: agentPulse 1.6s ease-in-out infinite; }
@keyframes agentPulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.02); box-shadow: 0 0 0 6px var(--warn-soft); }
}
/* Initiativen-Kanban: alle Statusspalten gleichmaessig einpassen */
body .kanban-board { overflow-x: visible; }
body .kanban-col { flex: 1 1 0; min-width: 0; }

/* 8 · Responsive --------------------------------------------------------- */
@media (max-width: 1100px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    html.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .app-main { margin-left: 0; }
    .topbar .menu-btn { display: inline-flex; }
    .topbar .sidebar-toggle { display: none; }
    .queue-panel, .logs-panel { left: 0; }
}
@media (max-width: 900px) {
    .split { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    html, body { overflow-x: hidden; }
    main.content { padding: 18px 16px 72px; }
    .topbar { padding: 0 10px; gap: 4px; }
    .topbar .label { display: none; }
    .search-trigger kbd { display: none; }
    h1 { font-size: 21px; }
    table { font-size: 13px; }
    th, td { padding: 9px 10px; }
    /* Lieber waagrecht scrollen als Woerter Buchstabe fuer Buchstabe umbrechen */
    .table-wrap > table { min-width: 680px; }
    .table-wrap { margin-inline: -16px; padding-inline: 16px; }
    .section-header { gap: 12px; }
    .section-header .actions { width: 100%; }
    .actions .btn { flex: 1 1 auto; }
    .actions > select, .actions > input:not([type="checkbox"]):not([type="radio"]) { flex: 1 1 100%; }
    .split > div { overflow-x: auto; }
    .card-grid > .card { min-width: 0; }
    .palette { padding-top: 8vh; }
    .queue-panel, .logs-panel { height: 70vh; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
@media print {
    .sidebar, .topbar, .ops-sidebar, .queue-panel, .logs-panel, .palette { display: none !important; }
    .app-main { margin-left: 0; }
}

/* --- Anwendungen in der Kopfleiste -----------------------------------------
   Central, Forger, Studio und Nexus sind Nachbarn von TheFold, keine
   Unterseiten. Sie stehen deshalb oben als Gruppe, durch eine feine Linie vom
   uebrigen Kopf abgesetzt. */
.topbar-apps { display: flex; align-items: center; gap: 4px; }
.topbar-apps::after {
    content: ""; width: 1px; height: 20px; margin: 0 6px;
    background: var(--border);
}
.topbar-apps .icon-btn[aria-current="page"],
.topbar-apps .icon-btn.on { background: var(--accent-soft); color: var(--accent-text); }
/* Auf schmalen Geraeten tragen die Zeichen allein. */
@media (max-width: 1100px) { .topbar-apps .label { display: none; } }
@media (max-width: 560px) { .topbar-apps::after { display: none; } }

/* --- Jobs und Logs im Seitenmenue ------------------------------------------
   Es sind Schaltflaechen (sie blenden ein Panel ein), sollen aber aussehen und
   sich anfuehlen wie die uebrigen Eintraege. */
button.nav-link {
    width: 100%;
    background: none;
    border: 0;
    font: inherit;
    font-weight: 500;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}
button.nav-link[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
button.nav-link .badge-dot {
    margin-left: auto;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 999px;
    background: var(--danger, #e5484d); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 16px; text-align: center;
}
