/* Server-OS – Oberfläche (dunkel als Standard, helles Design umschaltbar) */
:root {
  --bg: #0e1116; --bg2: #141922; --card: #181e28; --card2: #1e2532; --line: #2a3242;
  --text: #e6e9ef; --muted: #8b95a7; --dim: #5d6779;
  --accent: #22c55e; --accent2: #16a34a; --accent-soft: rgba(34,197,94,.12);
  --blue: #60a5fa; --warn: #f59e0b; --warn-soft: rgba(245,158,11,.13); --bad: #ef4444; --bad-soft: rgba(239,68,68,.13);
  --radius: 12px; --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  --shadow: 0 8px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f5f8; --bg2: #ffffff; --card: #ffffff; --card2: #f5f7fa; --line: #dfe4ec;
  --text: #161b24; --muted: #5d6779; --dim: #8b95a7;
  --accent: #16a34a; --accent2: #15803d; --accent-soft: rgba(22,163,74,.1);
  --shadow: 0 8px 30px rgba(20,30,50,.12);
  color-scheme: light;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .92em; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 14px; }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; flex: none; }
.brand .logo svg { width: 18px; height: 18px; }
.brand b { font-size: 15px; display: block; line-height: 1.2; }
.brand small { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a:hover { background: var(--card2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav a .badge { margin-left: auto; }
.side-foot { margin-top: auto; padding: 12px 8px 0; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.side-foot .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { display: none; }
.page { padding: 26px 30px 60px; max-width: 1400px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Bausteine ---------- */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2 { font-size: 14px; }
.card-head .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 14px 16px 0; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.metric .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.metric .value { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.2; margin: 4px 0 2px; }
.metric .value small { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.metric .foot { color: var(--muted); font-size: 12px; font-family: var(--mono); }
.metric canvas { width: 100%; height: 44px; display: block; margin-top: 8px; }

.bar { height: 6px; background: var(--card2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }
.bar.warn > i { background: var(--warn); } .bar.bad > i { background: var(--bad); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 600; background: var(--card2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.blue { background: rgba(96,165,250,.13); color: var(--blue); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); display: inline-block; flex: none; }
.dot.ok { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--card2); cursor: pointer; font-weight: 550; font-size: 13px; white-space: nowrap; }
.btn:hover { border-color: var(--dim); }
.btn svg { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06130a; }
.btn.primary:hover { background: var(--accent2); }
.btn.danger { color: var(--bad); } .btn.danger:hover { border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--card2); }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.icon { padding: 6px; }
.btn:disabled { opacity: .5; cursor: default; }
.btns { display: inline-flex; gap: 4px; flex-wrap: wrap; }

input[type=text], input[type=password], input[type=number], input:not([type]), select, textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 13px; resize: vertical; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
label.field > small { display: block; color: var(--dim); font-size: 12px; margin-top: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 12px; color: var(--muted); cursor: pointer; font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

/* Tabellen werden auf dem Handy zu Karten */
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr:hover { background: var(--card2); }
table.t td.num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
table.t td.act { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.show-m { display: none !important; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }

pre.log { background: #0a0d12; color: #cfd6e2; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font: 12px/1.55 var(--mono); max-height: 60vh; overflow: auto; white-space: pre-wrap; word-break: break-all; margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 34px 16px; }
.empty svg { width: 34px; height: 34px; color: var(--dim); display: block; margin: 0 auto 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 10px; border: 1px solid; margin-bottom: 14px; font-size: 13.5px; }
.alert.warn { background: var(--warn-soft); border-color: rgba(245,158,11,.35); }
.alert.bad { background: var(--bad-soft); border-color: rgba(239,68,68,.35); }
.alert.ok { background: var(--accent-soft); border-color: rgba(34,197,94,.3); }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }

/* Status-Streifen auf dem Dashboard */
.status-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.status-tile { display: flex; align-items: center; gap: 11px; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; min-width: 0; }
.status-tile:hover { border-color: var(--dim); }
.status-tile .ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--card2); color: var(--muted); flex: none; }
.status-tile .ico svg { width: 18px; height: 18px; }
.status-tile.ok .ico { background: var(--accent-soft); color: var(--accent); }
.status-tile.warn .ico { background: var(--warn-soft); color: var(--warn); }
.status-tile.bad .ico { background: var(--bad-soft); color: var(--bad); }
.status-tile b { display: block; font-size: 14px; }
.status-tile span { color: var(--muted); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 4px; margin-top: 10px; }
.cores i { height: 26px; border-radius: 4px; background: var(--card2); position: relative; overflow: hidden; }
.cores i b { position: absolute; left: 0; right: 0; bottom: 0; background: var(--accent); opacity: .85; transition: height .4s; }

/* Apps / eigene Dienste */
.apps { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.app-tile { display: flex; align-items: center; gap: 11px; padding: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); position: relative; min-width: 0; }
.app-tile:hover { border-color: var(--accent); }
.app-tile .emo { font-size: 22px; width: 38px; height: 38px; display: grid; place-items: center; background: var(--card2); border-radius: 9px; flex: none; }
.app-tile b { display: block; font-size: 13.5px; } .app-tile small { color: var(--muted); font-size: 11.5px; font-family: var(--mono); }
.app-tile .dot { position: absolute; top: 10px; right: 10px; }

/* Dateimanager */
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-family: var(--mono); font-size: 13px; }
.crumbs a { color: var(--muted); padding: 2px 6px; border-radius: 6px; } .crumbs a:hover { background: var(--card2); color: var(--text); }
.crumbs span { color: var(--dim); }
.file-name { display: flex; align-items: center; gap: 9px; cursor: pointer; min-width: 0; }
.file-name svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.file-name.dir svg { color: var(--blue); }
.drop { outline: 2px dashed var(--accent); outline-offset: -6px; }

/* Terminal */
.term-wrap { background: #0a0d12; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; height: calc(100vh - 170px); min-height: 320px; }
.term-wrap .xterm { height: 100%; }
.term-keys { display: none; gap: 6px; margin-top: 8px; overflow-x: auto; }

/* Modal, Toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(5,8,12,.6); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { background: var(--bg2); border: 1px solid var(--line); border-radius: 14px; width: min(560px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal.wide { width: min(1000px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-body { padding: 18px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow); max-width: 360px; animation: up .2s; font-size: 13.5px; }
.toast.bad { border-left-color: var(--bad); }
@keyframes fade { from { opacity: 0 } } @keyframes up { from { transform: translateY(8px); opacity: 0 } }

/* Login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background:
  radial-gradient(600px 300px at 50% 0%, var(--accent-soft), transparent), var(--bg); }
.auth .card { width: min(380px, 100%); padding: 26px; box-shadow: var(--shadow); }
.auth .brand { justify-content: center; padding-bottom: 6px; }
.auth p { color: var(--muted); text-align: center; margin: 0 0 20px; font-size: 13.5px; }
.auth .err { color: var(--bad); font-size: 13px; margin: -4px 0 10px; min-height: 18px; }

.spin { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg) } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- Tablet ---------- */
@media (max-width: 1150px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- Smartphone ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .shell.nav-open .side { transform: none; }
  .shell.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; }
  .top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--bg2); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  .top b { flex: 1; font-size: 15px; }
  .page { padding: 16px 14px calc(84px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 19px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .g4.keep2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span2 { grid-column: auto; }
  .status-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric .value { font-size: 23px; }
  .bottom-nav { display: flex !important; }
  .term-wrap { height: calc(100vh - 230px); }
  .term-keys { display: flex; }
  #toasts { left: 14px; right: 14px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .toast { max-width: none; }
  /* Tabellen als Karten */
  table.t.cards thead { display: none; }
  table.t.cards, table.t.cards tbody, table.t.cards tr, table.t.cards td { display: block; width: 100%; }
  table.t.cards tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  table.t.cards td { border: 0; padding: 2px 0; }
  table.t.cards td[data-l]::before { content: attr(data-l) ": "; color: var(--dim); font-size: 12px; font-family: var(--sans); }
  table.t.cards td.act { text-align: left; padding-top: 8px; }
  .hide-m { display: none !important; }
  .show-m { display: inline-flex !important; }
  /* Dateiliste auf dem Handy: eine Zeile pro Eintrag */
  table.t.cards.files tr { display: flex; align-items: center; gap: 8px; padding: 6px 14px; }
  table.t.cards.files td { width: auto; }
  table.t.cards.files td:first-child { flex: 1; min-width: 0; }
  table.t.cards.files td[data-l] { display: none; }
  table.t.cards.files td.act { padding: 0; }
  table.t.cards.files .file-name { padding: 6px 0; }
  .modal-bg { place-items: end center; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; width: 100%; }
}
.bottom-nav { display: none; position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg2); border-top: 1px solid var(--line); z-index: 25; padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; color: var(--muted); font-size: 10.5px; font-weight: 550; }
.bottom-nav a svg { width: 21px; height: 21px; }
.bottom-nav a.on { color: var(--accent); }
