/* Uplink — Werkzeug-Layout, keine Verläufe, keine Schatten-Stapel. */

:root {
  --bg: #101114;
  --panel: #17181c;
  --panel-2: #1d1f24;
  --line: #292c33;
  --text: #e6e8eb;
  --muted: #8b9099;
  --accent: #f2f4f7;
  --ok: #4ea76a;
  --warn: #c9963f;
  --err: #c85a54;
  --radius: 6px;
  --font: -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f4f6;
    --panel: #ffffff;
    --panel-2: #f7f8f9;
    --line: #dcdfe3;
    --text: #1a1c1f;
    --muted: #6b7078;
    --accent: #101114;
    color-scheme: light;
  }
}

:root[data-theme="light"] {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #f7f8f9;
  --line: #dcdfe3;
  --text: #1a1c1f;
  --muted: #6b7078;
  --accent: #101114;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #101114;
  --panel: #17181c;
  --panel-2: #1d1f24;
  --line: #292c33;
  --text: #e6e8eb;
  --muted: #8b9099;
  --accent: #f2f4f7;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

svg { flex: none; }

.icon {
  width: 16px;
  height: 16px;
  display: inline-block;
  vertical-align: -3px;
}

.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 20px; height: 20px; }

button, input, select {
  font: inherit;
  color: inherit;
}

button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius);
  padding: 5px 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms;
}

button:hover:not(:disabled) {
  background: var(--line);
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

button.primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  opacity: .88;
}

button.ghost {
  background: transparent;
  border-color: transparent;
}

button.ghost:hover:not(:disabled) {
  background: var(--panel-2);
  border-color: var(--line);
}

button.danger:hover:not(:disabled) {
  border-color: var(--err);
  color: var(--err);
}

button.icon-btn {
  padding: 5px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

input[type="text"], input[type="password"], input[type="number"] {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 8px;
  width: 100%;
}

input[type="checkbox"] {
  accent-color: var(--accent);
}

label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.field { margin-bottom: 12px; }

.num, .tabular {
  font-variant-numeric: tabular-nums;
}

hr.rule {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

/* ---------- Login ---------- */

/* Bewusst links verankert statt mittig - das zentrierte Panel ist der
   Standardlook, den wir hier nicht wollen. Vertikal aber mittig, sonst klebt
   die Karte auf grossen Bildschirmen in der Ecke und wirkt unfertig. */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 64px 32px;
}

.login-box {
  width: 100%;
  max-width: 300px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-weight: 600;
  font-size: 14px;
}

.login-error {
  color: var(--err);
  font-size: 12px;
  margin: -4px 0 12px;
  min-height: 15px;
}

.login-box button.primary {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

/* ---------- Shell ---------- */

.shell {
  display: grid;
  grid-template-columns: 180px 1fr;
  grid-template-rows: 40px 1fr;
  grid-template-areas:
    "topbar topbar"
    "nav main";
  height: 100vh;
}

.topbar {
  grid-area: topbar;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
}

.topbar .spacer { flex: 1; }

.topbar .user-name {
  color: var(--muted);
  margin-right: 4px;
}

.nav {
  grid-area: nav;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav button {
  justify-content: flex-start;
  width: 100%;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.nav button:hover:not(:disabled) {
  background: var(--panel-2);
  color: var(--text);
}

.nav button[aria-current="page"] {
  background: var(--panel-2);
  color: var(--text);
  border-color: var(--line);
}

.main {
  grid-area: main;
  overflow: auto;
  padding: 16px;
}

.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.view-header h1 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.view-header .spacer { flex: 1; }

/* ---------- Panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel + .panel { margin-top: 12px; }

/* ---------- Drop zone ---------- */

.dropzone {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  transition: border-color 120ms, background 120ms;
}

.dropzone.drag-over {
  border-color: var(--accent);
  background: var(--panel-2);
  color: var(--text);
}

.dropzone .actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ---------- Queue summary bar ---------- */

.queue-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 12px;
  flex-wrap: wrap;
}

.queue-summary .stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 72px;
}

.queue-summary .stat .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.queue-summary .stat .value {
  font-variant-numeric: tabular-nums;
}

.queue-summary .bar-wrap {
  flex: 1 1 160px;
  min-width: 120px;
}

.queue-summary .actions {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
}

.queue-summary .concurrency {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.queue-summary select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 6px;
}

/* ---------- Progress bar ---------- */

.progress-track {
  height: 4px;
  border-radius: 2px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 120ms linear;
}

.progress-fill.ok { background: var(--ok); }
.progress-fill.err { background: var(--err); }
.progress-fill.warn { background: var(--warn); }

/* ---------- Queue table ---------- */

.qtable {
  display: flex;
  flex-direction: column;
}

.qtable .qrow {
  display: grid;
  grid-template-columns: minmax(150px, 2fr) 70px 168px 120px 120px 90px 108px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  position: relative;
}

.qtable .qrow.head {
  border-top: none;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .02em;
  padding-bottom: 8px;
}

.qrow.head > div,
.frow.head > div,
.urow.head > div,
.arow.head > div {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qtable .qrow:last-child { padding-bottom: 12px; }

.qcell { min-width: 0; }

.qcell.name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.qcell.name .fname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qcell.name .fpath {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qcell.status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.qcell.status .icon { flex: none; }
.qcell.status span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.qcell.status.ok { color: var(--ok); }
.qcell.status.err { color: var(--err); }
.qcell.status.warn { color: var(--warn); }

.qcell.actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.qrow .progress-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  border-radius: 0;
  border-left: none;
  border-right: none;
}

.qrow.empty {
  color: var(--muted);
  justify-content: center;
  display: flex;
  padding: 24px 12px;
}

/* ---------- Files table ---------- */

.ftable { display: flex; flex-direction: column; }

.ftable .frow {
  display: grid;
  grid-template-columns: minmax(160px, 2.5fr) 100px 140px 76px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.ftable.with-owner .frow {
  grid-template-columns: minmax(140px, 2fr) minmax(90px, 1fr) 100px 140px 76px;
}

.ftable .frow.head {
  border-top: none;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.ftable .frow .fname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ftable .frow .fname a {
  color: inherit;
  text-decoration: none;
}

.ftable .frow .fname a:hover {
  text-decoration: underline;
}

.files-scope {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 8px;
  margin-left: 12px;
}

/* ---------- Admin ---------- */

.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.admin-tabs button[aria-selected="true"] {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

.admin-tabs button {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.utable, .atable { display: flex; flex-direction: column; }

.utable .urow, .atable .arow {
  display: grid;
  grid-template-columns: minmax(120px, 1.4fr) minmax(100px, 1fr) 70px 70px 90px 90px 96px;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
}

.atable .arow {
  grid-template-columns: minmax(120px, 1.2fr) minmax(120px, 1.6fr) 90px 100px 90px;
}

.utable .urow.head, .atable .arow.head {
  border-top: none;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

.badge.on { color: var(--ok); border-color: var(--ok); }
.badge.off { color: var(--err); border-color: var(--err); }

.settings-form {
  padding: 12px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.settings-form .field { margin-bottom: 0; width: 180px; }

/* ---------- Dialog ---------- */

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
}

dialog::backdrop {
  background: rgba(0, 0, 0, .5);
}

.dialog-head {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.dialog-head .spacer { flex: 1; }

.dialog-body { padding: 14px; }

.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.checkbox-row label {
  margin: 0;
  color: var(--text);
}

/* ---------- Toast / aria-live ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.toast-stack {
  position: fixed;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 50;
}

.toast {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  max-width: 280px;
}

.toast.err { border-color: var(--err); color: var(--err); }
.toast.ok { border-color: var(--ok); color: var(--ok); }

/* ---------- Empty state ---------- */

.empty {
  color: var(--muted);
  padding: 24px 12px;
  text-align: center;
}

/* ---------- Responsive: stacked rows below 380px logical width ---------- */

@media (max-width: 620px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 40px auto 1fr;
    grid-template-areas:
      "topbar"
      "nav"
      "main";
  }
  .nav {
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
}

@media (max-width: 460px) {
  .qtable .qrow,
  .ftable .frow,
  .ftable.with-owner .frow,
  .utable .urow,
  .atable .arow {
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
    row-gap: 4px;
  }
  .qtable .qrow.head,
  .ftable .frow.head,
  .utable .urow.head,
  .atable .arow.head {
    display: none;
  }
  .qcell.actions, .utable .urow > .cell-actions, .atable .arow > .cell-actions {
    justify-content: flex-start;
  }
  .qcell::before, .frow > *::before, .urow > *::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .02em;
  }
  .login-screen { padding: 24px 16px; }
}
