/* aimalexpanel – ruhiges, schlichtes Layout. Styles der Erweitert-Seiten: advanced.css */

:root {
  color-scheme: dark;
  --bg: #17181a;
  --surface: #202124;
  --surface-2: #2a2b2f;
  --surface-3: #34363b;
  --term-bg: #131415;
  --line: #2c2e32;
  --line-2: #3a3c41;
  --line-3: #4b4e54;
  --text: #ececec;
  --text-2: #b6b8bc;
  --text-3: #8d9096;
  --accent: #3b74d6;
  --accent-hover: #4a82e3;
  --accent-2: #8ab4f8;
  --accent-bg: rgba(59, 116, 214, 0.14);
  --accent-line: rgba(59, 116, 214, 0.5);
  --good: #3fb950;
  --good-2: #6fd27d;
  --good-bg: rgba(63, 185, 80, 0.12);
  --good-line: rgba(63, 185, 80, 0.35);
  --warn: #d6a32a;
  --warn-2: #e8c264;
  --warn-bg: rgba(214, 163, 42, 0.12);
  --warn-line: rgba(214, 163, 42, 0.4);
  --crit: #f0524a;
  --crit-2: #ff8a83;
  --crit-bg: rgba(240, 82, 74, 0.12);
  --crit-line: rgba(240, 82, 74, 0.42);
  --off: #6b6e74;
  /* nur für die Diagramme unter „Erweitert“ */
  --series-1: #6f9fe8;
  --series-2: #d9824a;
  --spark: #4b4e54;
  --grid: #2a2c30;
  --axis: #3a3c41;
  --pop-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --radius: 12px;
}

/* ================================================================ base */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
p { margin: 0; }
code, .mono { font-family: var(--font-mono); font-size: 0.9em; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spin { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ================================================================ shell */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 24px 14px 18px; background: var(--surface);
}
.brand { display: block; padding: 0 12px 22px; color: var(--text); font-size: 18px; font-weight: 600; }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 18px 12px 6px; color: var(--text-3); font-size: 14px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px;
  border: 0; border-radius: 8px; background: none; color: var(--text-2);
  font: inherit; text-align: left; cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--surface-3); color: var(--text); font-weight: 500; }
.nav-item .dot { margin-left: auto; }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.nav-foot .nav-item { min-height: 38px; font-size: 14px; color: var(--text-3); }
.topbar { display: none; }
.main { width: 100%; max-width: 1040px; padding: 36px 40px 64px; }
.back { display: inline-block; margin-bottom: 18px; color: var(--text-2); font-size: 15px; }

/* ================================================================ status */
.dot { display: inline-block; width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--off); }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.crit { background: var(--crit); }
.dot.off, .dot.dim { background: var(--off); }
.status { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; }
.status.good { color: var(--good-2); }
.status.warn { color: var(--warn-2); }
.status.crit { color: var(--crit-2); }
.status.off { color: var(--text-2); }
.headline { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; font-size: 22px; font-weight: 600; }
.headline .dot { width: 14px; height: 14px; }
.headline.good { color: var(--good-2); }
.headline.warn { color: var(--warn-2); }
.headline.crit { color: var(--crit-2); }
.headline.off { color: var(--text-2); }

/* ================================================================ cards */
.card { position: relative; min-width: 0; background: var(--surface); border-radius: var(--radius); }
.card.pad, .box { padding: 22px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(310px, 100%), 1fr)); gap: 16px; }
.app-card { display: flex; flex-direction: column; gap: 4px; padding: 20px; }
.card-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; }
.app-card h2 { font-size: 19px; }
.app-card h2 a { color: var(--text); }
.app-card .since { color: var(--text-3); font-size: 15px; }
.app-card .btn-row { margin-top: 12px; }
.app-card .btn-row .btn { flex: 1 1 calc(50% - 4px); }
.db-list { margin: 10px 0 0; padding: 0; list-style: none; }
.db-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.db-list li span:last-child { color: var(--text-2); white-space: nowrap; }
.db-list li.more { color: var(--text-3); font-size: 14px; }
.facts-line { display: flex; flex-wrap: wrap; gap: 6px 24px; color: var(--text-2); font-size: 15px; }
.facts-line b { color: var(--text); font-weight: 600; }

.load { margin-top: 32px; padding: 18px 22px; }
.load h2 { margin-bottom: 12px; font-size: 15px; font-weight: 500; color: var(--text-2); }
.load-row { display: grid; grid-template-columns: 80px minmax(0, 1fr) 52px; align-items: center; gap: 14px; padding: 5px 0; font-size: 15px; }
.load-row span:last-child { text-align: right; color: var(--text-2); font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 4px; background: #7d8189; transition: width 0.4s; }
.bar.warn > i { background: var(--warn); }
.bar.crit > i { background: var(--crit); }

/* ================================================================ page head + tabs */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.page-head h1 { font-size: 26px; }
.page-head h1 + .status, .status-line { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.page-head .since { color: var(--text-3); font-weight: 400; }
.tabs { display: flex; gap: 6px; margin: 0 0 22px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: -1px; padding: 12px 16px;
  border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 500; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs a .i { width: 16px; height: 16px; }
.link-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 10px; }
.link-list a { display: block; padding: 16px 18px; border-radius: 10px; background: var(--surface); color: var(--text); }
.link-list a:hover { background: var(--surface-2); text-decoration: none; }

/* ================================================================ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  background: var(--surface-2); color: var(--text);
  border: 0; border-radius: 8px;
  font: 500 15px/1 var(--font-sans); white-space: nowrap; cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--surface-3); text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn.danger { color: var(--crit-2); }
.btn.danger-solid { background: var(--crit); color: #fff; }
.btn.ghost { background: transparent; color: var(--text-2); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn.icon { width: 44px; padding: 0; }
.btn.sm.icon { width: 36px; }
.btn .i { width: 17px; height: 17px; }
.actions, .btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.input, select.input {
  min-height: 42px; min-width: 0; padding: 0 12px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line-2); border-radius: 8px; font: 15px var(--font-sans);
}
.input::placeholder { color: var(--text-3); }
.input:focus { outline: none; border-color: var(--accent-2); }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 15px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.toolbar .input.search { width: min(300px, 100%); }
.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-2); font-size: 13px; white-space: nowrap;
}
.tag .i { width: 13px; height: 13px; }
.tag.warn { background: var(--warn-bg); color: var(--warn-2); }
.tag.good { background: var(--good-bg); color: var(--good-2); }
.tag.crit { background: var(--crit-bg); color: var(--crit-2); }
details > summary { cursor: pointer; color: var(--text-2); font-size: 14px; }

/* ================================================================ messages */
.empty { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 28px 16px; color: var(--text-3); text-align: center; }
.banner { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 10px; background: var(--surface-2); }
.banner > .i { margin-top: 3px; }
.banner > div { min-width: 0; flex: 1; }
.banner strong { display: block; font-weight: 600; }
.banner p { margin: 6px 0 0; color: var(--text-2); }
.banner pre { margin: 8px 0 0; white-space: pre-wrap; word-break: break-word; font: 13px/1.5 var(--font-mono); color: var(--text-2); }
.banner .actions { margin-top: 14px; }
.banner.good { background: var(--good-bg); } .banner.good > .i { color: var(--good); }
.banner.warn { background: var(--warn-bg); } .banner.warn > .i { color: var(--warn-2); }
.banner.crit { background: var(--crit-bg); } .banner.crit > .i { color: var(--crit); }
.form-error { margin-top: 16px; padding: 10px 14px; border-radius: 8px; background: var(--crit-bg); color: var(--crit-2); font-size: 15px; }

/* ================================================================ tables (Dateien) */
.tbl-box { min-width: 0; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { padding: 10px 14px; text-align: left; white-space: nowrap; font-size: 14px; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--line); }
.th-sort { display: inline-flex; align-items: center; gap: 4px; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.th-sort:hover, .th-sort.on { color: var(--text); }
.th-sort .i { width: 13px; height: 13px; }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, 0.025); }
.tbl tbody tr.link { cursor: pointer; }
.tbl .r { text-align: right; }
.tbl th.r .th-sort { margin-left: auto; }
.tbl td.r { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
.tbl .name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tbl .tbl-empty { padding: 28px 14px; text-align: center; color: var(--text-3); }
.tbl-more { padding: 10px 14px; color: var(--text-3); font-size: 14px; }

/* ================================================================ logs */
.term { position: relative; background: var(--term-bg); border-radius: var(--radius); overflow: hidden; }
.term-bar { display: flex; justify-content: space-between; gap: 10px; padding: 10px 16px; background: var(--surface); color: var(--text-3); font-size: 14px; }
.term-body { height: min(66vh, 680px); overflow: auto; padding: 10px 0; font: 13px/1.6 var(--font-mono); }
.log-line { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 14px; padding: 0 16px; }
.log-line.with-unit { grid-template-columns: 70px 150px minmax(0, 1fr); }
.log-line time { color: var(--text-3); user-select: none; }
.log-line .u { color: var(--accent-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-line span.m { white-space: pre-wrap; overflow-wrap: anywhere; color: #d4d6da; }
.log-line.err { background: rgba(240, 82, 74, 0.08); }
.log-line.err span.m { color: var(--crit-2); }
.log-line.warn span.m { color: var(--warn-2); }
.log-state { color: var(--text-3); font-size: 14px; white-space: nowrap; }
.log-state.on { color: var(--good-2); }
.jump { position: absolute; right: 16px; bottom: 14px; box-shadow: var(--pop-shadow); }

/* ================================================================ update */
.update-card { padding: 22px; }
.update-card h2 { font-size: 19px; }
.update-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.changes { margin: 0; padding: 0; list-style: none; }
.changes li { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-top: 1px solid var(--line); }
.changes li span:last-child { color: var(--text-3); font-size: 14px; white-space: nowrap; }
.history { margin-top: 14px; }
.history li { flex-wrap: wrap; }
.hist-subject { font-weight: 400; }
.history li.history-mark { padding: 14px 0 6px; border-top: 0; color: var(--accent-2); font-size: 14px; font-weight: 500; }
.files { max-height: 240px; margin: 10px 0 0; padding: 10px 12px; overflow: auto; list-style: none; background: var(--term-bg); border-radius: 8px; font: 13px/1.7 var(--font-mono); }
.files li { display: flex; gap: 12px; min-width: 0; }
.files .code { flex: none; color: var(--text-3); font-family: var(--font-sans); }
.files .path { overflow-wrap: anywhere; min-width: 0; }
.deploy-cta { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.deploy-log { padding: 14px 0; }
.step { display: flex; align-items: center; gap: 10px; padding: 5px 18px; }
.step.run .i { color: var(--accent-2); }
.step.done .i { color: var(--good); }
.step.fail .i { color: var(--crit); }
.deploy-log .banner { margin: 10px 18px 4px; }
.deploy-log details { margin: 8px 18px 0; }
.deploy-out { margin: 8px 0 0; max-height: 300px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 12.5px/1.55 var(--font-mono); color: var(--text-2); }

/* ================================================================ Dateien */
.fm-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; }
.fm-crumbs button, .fm-crumbs .cur {
  display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 8px;
  border: 0; border-radius: 6px; background: none; color: var(--text-2); font: inherit; overflow-wrap: anywhere;
}
.fm-crumbs button { cursor: pointer; }
.fm-crumbs button:hover { background: var(--surface-2); color: var(--text); }
.fm-crumbs .cur { color: var(--text); font-weight: 500; }
.fm-crumbs .sep { color: var(--text-3); }
.fm-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
  padding: 8px 10px 8px 14px; border-radius: 10px; background: var(--accent-bg); font-size: 15px;
}
.fm-strip > span { flex: 1; min-width: min(220px, 100%); display: inline-flex; align-items: center; gap: 8px; }
.fm-list.drop { outline: 2px dashed var(--accent-2); outline-offset: -2px; }
.tbl .fm-check { width: 40px; padding-right: 0; }
.fm-check input { width: 18px; height: 18px; margin: 0; vertical-align: middle; accent-color: var(--accent); cursor: pointer; }
.tbl tr.sel td { background: var(--accent-bg); }
.fm-name {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%;
  padding: 0; border: 0; background: none; color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.tbl .fm-namecol { width: 100%; max-width: 0; }
.fm-namecol .name > * { flex: none; }
.fm-namecol .name > .fm-name, .fm-namecol .name > .fm-target { flex: 0 1 auto; }
.fm-name span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fm-name:hover:not(:disabled) span { color: var(--accent-2); }
.fm-name:disabled { color: var(--text-2); cursor: default; }
.fm-ic { color: var(--text-3); }
.fm-ic.dir { color: var(--accent-2); }
.fm-target { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; color: var(--text-3); }
.tbl .fm-act { width: 52px; padding-top: 0; padding-bottom: 0; }
.fm-foot { margin-top: 10px; color: var(--text-3); font-size: 14px; }
.fm-editor { overflow: hidden; }
.fm-ed-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; padding: 10px 12px; }
.fm-ed-title { display: flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.fm-text {
  display: block; width: 100%; height: min(68vh, 760px); min-height: 260px; margin: 0; padding: 14px 16px;
  border: 0; border-radius: 0; outline: none; resize: vertical;
  background: var(--term-bg); color: #d4d6da; font: 13.5px/1.6 var(--font-mono);
  white-space: pre; overflow: auto; tab-size: 4;
}
.fm-ed-foot { padding: 8px 16px; color: var(--text-3); font-size: 14px; }

/* ================================================================ login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login { width: min(400px, 100%); padding: 32px 28px; }
.login .brand { padding: 0 0 22px; }
.login h1 { font-size: 22px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 18px; }
.field label { color: var(--text-2); font-size: 15px; }
.login .btn { width: 100%; margin-top: 24px; }

/* ================================================================ toasts, dialog, menu */
#toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: min(440px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; padding: 12px 16px; border-radius: 10px; background: var(--surface-3); box-shadow: var(--pop-shadow); }
.toast > .i { margin-top: 3px; }
.toast > div { min-width: 0; white-space: pre-line; overflow-wrap: anywhere; }
.toast.good > .i { color: var(--good); }
.toast.warn > .i { color: var(--warn-2); }
.toast.crit > .i { color: var(--crit); }
dialog {
  width: min(460px, calc(100vw - 32px)); padding: 24px;
  background: var(--surface); color: var(--text);
  border: 0; border-radius: 14px; box-shadow: var(--pop-shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 10px; font-size: 19px; }
dialog p { color: var(--text-2); }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
dialog .field { margin-top: 12px; }
.menu { position: fixed; z-index: 70; min-width: 200px; padding: 6px; background: var(--surface-2); border-radius: 10px; box-shadow: var(--pop-shadow); }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px;
  border: 0; border-radius: 6px; background: none; color: var(--text); font: 15px var(--font-sans); text-align: left; cursor: pointer;
}
.menu button .i { color: var(--text-3); }
.menu button:hover:not(:disabled), .menu button:focus-visible { background: var(--surface-3); outline: none; }
.menu button.danger, .menu button.danger .i { color: var(--crit-2); }
.menu button:disabled { opacity: 0.4; cursor: not-allowed; }
.menu hr { margin: 4px 2px; border: 0; border-top: 1px solid var(--line-2); }

/* ================================================================ Handy */
@media (max-width: 820px) {
  .shell { display: block; }
  .topbar {
    position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
    min-height: 56px; padding: 0 8px 0 16px; background: var(--surface);
  }
  .topbar .brand { padding: 0; }
  .sidebar { display: none; position: sticky; top: 56px; z-index: 29; height: auto; max-height: calc(100vh - 56px); overflow: auto; padding: 8px 12px 14px; border-top: 1px solid var(--line); }
  .shell.nav-open .sidebar { display: flex; }
  .sidebar > .brand { display: none; }
  .nav-foot { margin-top: 12px; }
  .main { padding: 20px 16px 48px; }
  .headline { font-size: 20px; margin-bottom: 18px; }
  .app-card, .update-card, .card.pad, .box { padding: 18px; }
  .page-head h1 { font-size: 22px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1; }
  .btn-row .btn { flex: 1 1 calc(50% - 4px); }
  .log-line, .log-line.with-unit { grid-template-columns: 1fr; gap: 0; padding: 3px 12px; }
  .hide-sm { display: none; }
}
