:root {
  --bg: #0f1216;
  --bg-alt: #161b22;
  --bg-soft: #1c2330;
  --border: #263041;
  --text: #e6edf3;
  --text-dim: #8b98a9;
  --accent: #4f9cf9;
  --accent-soft: rgba(79, 156, 249, 0.15);
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --purple: #a371f7;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

/* ------------------------------------------------------------------ Login */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #1b2a44 0%, var(--bg) 60%);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-dim); margin-bottom: 24px; font-size: 13px; }

/* ---------------------------------------------------------------- Formular */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
input[type=text], input[type=password], input[type=number], input[type=time], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #232c3b; border-color: #35415a; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: #6aabfa; border-color: #6aabfa; }
.btn-green { background: var(--green); border-color: var(--green); color: #052e10; font-weight: 600; }
.btn-green:hover:not(:disabled) { background: #4fcf62; }
.btn-red { background: var(--red); border-color: var(--red); color: #2b0503; font-weight: 600; }
.btn-red:hover:not(:disabled) { background: #ff6a61; }
.btn-amber { background: var(--amber); border-color: var(--amber); color: #241a00; font-weight: 600; }
.btn-sm { padding: 5px 9px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

.alert { padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: rgba(248, 81, 73, .12); border: 1px solid rgba(248, 81, 73, .4); color: #ffb4ae; }
.alert-ok { background: rgba(63, 185, 80, .12); border: 1px solid rgba(63, 185, 80, .4); color: #8ff0a0; }

/* ----------------------------------------------------------------- Layout */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { padding: 18px 20px; border-bottom: 1px solid var(--border); }
.brand h1 { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.brand span { font-size: 12px; color: var(--text-dim); }

.nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: var(--text-dim);
  font-weight: 500; margin-bottom: 2px; cursor: pointer;
}
.nav a:hover { background: var(--bg-soft); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a .ico { width: 18px; text-align: center; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-dim); }
.sidebar-foot .who { color: var(--text); font-weight: 600; margin-bottom: 8px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--border); background: var(--bg-alt);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.content { padding: 24px; flex: 1; min-width: 0; }

/* ------------------------------------------------------------------ Badge */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dot.pulse { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
.st-running { background: rgba(63,185,80,.14); color: var(--green); }
.st-stopped { background: rgba(139,152,169,.14); color: var(--text-dim); }
.st-starting, .st-stopping { background: rgba(210,153,34,.14); color: var(--amber); }
.st-crashed { background: rgba(248,81,73,.14); color: var(--red); }

/* ------------------------------------------------------------------ Cards */
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.card { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card h3 { font-size: 13px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }
.card .big { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.card .sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.meter { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.meter i.warn { background: var(--amber); }
.meter i.crit { background: var(--red); }
/* Läuft, wenn der Anteil unbekannt ist (Archiv ohne gezählte Dateien):
   ein wandernder Streifen statt einer erfundenen Prozentzahl. */
.meter i.unbestimmt {
  background: linear-gradient(90deg, var(--bg) 0%, var(--accent) 40%, var(--accent) 60%, var(--bg) 100%);
  background-size: 40% 100%;
  background-repeat: no-repeat;
  animation: meter-lauf 1.2s linear infinite;
  transition: none;
}
@keyframes meter-lauf {
  from { background-position: -40% 0; }
  to   { background-position: 140% 0; }
}

/* --------------------------------------------------------------- Tabellen */
/* Breite Tabellen scrollen innerhalb ihrer Karte, damit auf dem Handy nicht
   die komplette Seite seitlich verrutscht. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap > table { min-width: max-content; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); padding: 8px 10px; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 9px 10px; border-bottom: 1px solid rgba(38,48,65,.6); vertical-align: middle; }
tbody tr:hover { background: rgba(255,255,255,.02); }
.t-dim { color: var(--text-dim); }
.t-mono { font-family: var(--mono); font-size: 12.5px; }
.t-right { text-align: right; }
.empty { padding: 32px; text-align: center; color: var(--text-dim); }

/* --------------------------------------------------------------- Konsole */
.console-box {
  background: #0a0d11; border: 1px solid var(--border); border-radius: var(--radius);
  height: calc(100vh - 260px); min-height: 320px; overflow-y: auto;
  padding: 12px 14px; font-family: var(--mono); font-size: 12.5px; line-height: 1.65;
}
.console-line { white-space: pre-wrap; word-break: break-word; }
.console-line .ts { color: #4b5769; margin-right: 8px; user-select: none; }
.console-line.err { color: #ff9a93; }
.console-line.panel { color: var(--accent); }
.console-line.warn { color: var(--amber); }
.console-input { display: flex; gap: 8px; margin-top: 12px; }
.console-input input { font-family: var(--mono); }

/* ----------------------------------------------------------- Dateimanager */
.crumbs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; }
.crumbs a { cursor: pointer; padding: 3px 7px; border-radius: 6px; }
.crumbs a:hover { background: var(--bg-soft); }
.crumbs .sep { color: var(--text-dim); }
.file-row td:first-child { width: 28px; }
.file-name { display: flex; align-items: center; gap: 8px; cursor: pointer; min-width: 0; }
.file-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions { display: flex; gap: 4px; justify-content: flex-end; }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 14px; text-align: center; color: var(--text-dim); margin-bottom: 14px; transition: all .15s; }
.dropzone.hot { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* --------------------------------------------------------------- Modal */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--bg-alt); border: 1px solid var(--border); border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(0,0,0,.6); }
.modal.wide { max-width: 1000px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.close-x { background: none; border: none; color: var(--text-dim); font-size: 20px; cursor: pointer; line-height: 1; }
.editor { width: 100%; height: 55vh; font-family: var(--mono); font-size: 13px; background: #0a0d11; border-radius: 8px; padding: 12px; border: 1px solid var(--border); }

/* --------------------------------------------------------------- Toasts */
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--bg-soft); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 8px; padding: 11px 15px; min-width: 250px; max-width: 400px; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: slidein .2s ease; }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } }

/* --------------------------------------------------------------- Sonstiges */
.chart-wrap { position: relative; width: 100%; height: 220px; }
canvas { width: 100%; height: 100%; display: block; }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; background: var(--bg-soft); font-size: 11.5px; color: var(--text-dim); margin: 2px 3px 2px 0; }
.chip.on { background: var(--accent-soft); color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); font-weight: 600; margin: 4px 0 10px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.perm-grid label { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.perm-grid input { margin-top: 3px; }

@media (max-width: 860px) {
  th, td { padding: 8px; }
  .file-actions { flex-wrap: wrap; justify-content: flex-start; }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .topbar-actions .btn { flex: 1 1 auto; justify-content: center; }
  .modal-body { padding: 14px; }
  .card { padding: 14px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav a { flex: 1 1 auto; }
  .content { padding: 16px; }
  .console-box { height: 55vh; }
}
