/* ==========================================================================
   ML Serwer – style.
   Zwykły CSS bez narzędzi do budowania: zmieniasz plik, odświeżasz stronę.
   Kolory są zdefiniowane raz jako zmienne (tokeny) – osobno dla trybu
   jasnego i ciemnego.
   ========================================================================== */

/* ---------- Tokeny: tryb jasny ---------- */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e1e4ea;
  --text: #1a1d23;
  --muted: #5f6673;
  --primary: #2563eb;
  --primary-hover: #1d4fd8;
  --primary-soft: #e8efff;
  --focus: #2563eb66;

  /* kolory statusów: tekst + tło znacznika */
  --queued: #8a5a00;   --queued-bg: #fff3d6;
  --running: #1d4fd8;  --running-bg: #e3ecff;
  --done: #157a3b;     --done-bg: #ddf5e5;
  --failed: #b42318;   --failed-bg: #fde4e1;
  --cancelled: #5f6673; --cancelled-bg: #eceef2;

  --log-bg: #0f1419;
  --log-text: #d7dde5;
  --shadow: 0 1px 2px rgb(16 24 40 / .06), 0 1px 3px rgb(16 24 40 / .08);
  --radius: 14px;
  color-scheme: light;
}

/* ---------- Tokeny: tryb ciemny (systemowy lub wybrany ręcznie) ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --border: #2a2f3a;
    --text: #e8eaef; --muted: #9aa3b2;
    --primary: #5b8cff; --primary-hover: #77a0ff; --primary-soft: #1c2740; --focus: #5b8cff66;
    --queued: #f4c25b; --queued-bg: #3a2e12;
    --running: #8db0ff; --running-bg: #1c2a4a;
    --done: #5fd38a; --done-bg: #14301f;
    --failed: #ff8a7f; --failed-bg: #3d1a17;
    --cancelled: #a3abb8; --cancelled-bg: #262a33;
    --log-bg: #0a0c10; --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a21; --surface-2: #1f232c; --border: #2a2f3a;
  --text: #e8eaef; --muted: #9aa3b2;
  --primary: #5b8cff; --primary-hover: #77a0ff; --primary-soft: #1c2740; --focus: #5b8cff66;
  --queued: #f4c25b; --queued-bg: #3a2e12;
  --running: #8db0ff; --running-bg: #1c2a4a;
  --done: #5fd38a; --done-bg: #14301f;
  --failed: #ff8a7f; --failed-bg: #3d1a17;
  --cancelled: #a3abb8; --cancelled-bg: #262a33;
  --log-bg: #0a0c10; --shadow: none;
  color-scheme: dark;
}

/* ---------- Podstawy ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
h1, h2, h3 { line-height: 1.25; margin: 0; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
a { color: var(--primary); }
code {
  font: .88em/1.4 ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", monospace;
  background: var(--surface-2); padding: .1em .35em; border-radius: 5px;
}
.muted { color: var(--muted); }
.small { font-size: .875rem; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.spin { transform-origin: 12px 12px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

.container { max-width: 880px; margin: 0 auto; padding: 20px 16px 48px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

/* ---------- Przyciski ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  min-height: 42px; padding: 0 16px; border-radius: 10px;
  border: 1px solid transparent; background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--border); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger-ghost { background: transparent; border-color: var(--border); color: var(--failed); }
.btn-danger-ghost:hover { background: var(--failed-bg); }
.btn-lg { min-height: 50px; padding: 0 26px; font-size: 1.05rem; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .9rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .ic { width: 20px; height: 20px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Formularze ---------- */
label { display: block; font-weight: 600; font-size: .95rem; }
input:not([type="checkbox"]), select {
  display: block; width: 100%; margin-top: 6px; min-height: 44px; padding: 0 12px;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
}
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary); margin: 2px 0 0; flex: none; }

/* ---------- Komunikaty ---------- */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: 10px; font-size: .95rem;
}
.alert .ic { margin-top: 2px; }
.alert-error { background: var(--failed-bg); color: var(--failed); }
.alert-info { background: var(--queued-bg); color: var(--queued); }
.alert-success { background: var(--done-bg); color: var(--done); }
.alert .muted { color: inherit; opacity: .8; display: block; }

/* ---------- Znaczniki statusu ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 4px 11px 4px 9px; border-radius: 999px; font-weight: 700; font-size: .875rem;
}
.st-queued { color: var(--queued); background: var(--queued-bg); }
.st-running { color: var(--running); background: var(--running-bg); }
.st-done { color: var(--done); background: var(--done-bg); }
.st-failed { color: var(--failed); background: var(--failed-bg); }
.st-cancelled { color: var(--cancelled); background: var(--cancelled-bg); }
.tag {
  display: inline-block; padding: 0 6px; margin-right: 2px; border-radius: 5px;
  font-size: .75rem; font-weight: 700; letter-spacing: .03em;
  background: var(--primary-soft); color: var(--primary);
}

/* ---------- Nagłówek i pasek stanu ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; color: var(--text); text-decoration: none; white-space: nowrap;
}
.brand-lg { font-size: 1.4rem; }
.logo {
  width: 26px; height: 26px; border-radius: 7px; background: var(--primary); flex: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 15l3.5-3.5 3 3L18 9' stroke='white' stroke-width='2.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.status-bar {
  flex: 1; min-width: 0; display: flex; flex-wrap: wrap; gap: 6px 8px;
  justify-content: center; font-size: .85rem;
}
.stat {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  padding: 3px 10px; border-radius: 999px; background: var(--surface-2);
  font-variant-numeric: tabular-nums;
}
.stat-label { color: var(--muted); font-weight: 600; }
.stat .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ai-ok { color: var(--done); }
.ai-slow { color: var(--queued); background: var(--queued-bg); font-weight: 600; }
.ai-off { color: var(--muted); }
.user-menu { display: flex; align-items: center; gap: 2px; }
.user-menu form { margin: 0; }
.user-name { font-weight: 600; font-size: .9rem; margin: 0 6px; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* przełącznik motywu: pokazujemy księżyc w jasnym, słońce w ciemnym */
.only-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .only-dark { display: contents; }
  :root:not([data-theme="light"]) .only-light { display: none; }
}
:root[data-theme="dark"] .only-dark { display: contents; }
:root[data-theme="dark"] .only-light { display: none; }

/* ---------- Pole wysyłania ---------- */
.upload {
  border: 2px dashed var(--border); padding: 28px 24px; margin-bottom: 32px;
  transition: border-color .15s, background .15s;
}
.upload.dragover { border-color: var(--primary); background: var(--primary-soft); }
.drop-empty { text-align: center; cursor: pointer; }
.drop-icon {
  width: 56px; height: 56px; margin: 0 auto 12px; display: grid; place-items: center;
  border-radius: 50%; background: var(--primary-soft); color: var(--primary);
}
.drop-icon .ic { width: 28px; height: 28px; }
.drop-title { font-size: 1.2rem; font-weight: 700; margin: 0; }
.drop-or { color: var(--muted); margin: 6px 0 10px; }
.drop-hint { max-width: 520px; margin: 16px auto 0; }
.drop-ready { display: grid; gap: 16px; }

.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 12px; border-radius: 10px; background: var(--surface-2);
}
.file-item .ic { color: var(--muted); }
.file-item.is-script .ic { color: var(--primary); }
.file-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-role { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.file-size { font-size: .8rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.file-remove { width: 32px; height: 32px; }

.check {
  display: flex; gap: 12px; align-items: flex-start; font-weight: 400; cursor: pointer;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
}
.check > span { display: grid; }
.check.disabled { opacity: .6; cursor: not-allowed; }

.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

/* ---------- Lista zadań ---------- */
.jobs h2 { margin-bottom: 12px; }
.job-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.job-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding-right: 12px;
  border-left: 4px solid var(--border);
}
.job-row.status-queued { border-left-color: var(--queued); }
.job-row.status-running { border-left-color: var(--running); }
.job-row.status-done { border-left-color: var(--done); }
.job-row.status-failed, .job-row.status-timeout { border-left-color: var(--failed); }
.job-open {
  flex: 1; min-width: 0; display: flex; gap: 14px; align-items: flex-start;
  padding: 14px 4px 14px 14px; border: 0; background: none; color: inherit;
  font: inherit; text-align: left; cursor: pointer; border-radius: var(--radius);
}
.job-badge { width: 128px; flex: none; }
.job-main { min-width: 0; display: grid; gap: 2px; }
.job-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-meta { font-size: .85rem; color: var(--muted); }
.job-info { font-size: .92rem; }
.job-error { color: var(--failed); }
.job-dl { flex: none; }

.empty {
  text-align: center; padding: 40px 20px; border: 1px dashed var(--border);
  border-radius: var(--radius); color: var(--text);
}
.empty-icon { color: var(--muted); }
.empty-icon .ic { width: 36px; height: 36px; }
.empty-title { font-weight: 700; font-size: 1.1rem; margin: 8px 0 4px; }

/* ---------- Panel szczegółów ---------- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / .4); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(760px, 100%);
  background: var(--bg); overflow-y: auto; box-shadow: -8px 0 30px rgb(0 0 0 / .2);
  animation: slide-in .18s ease-out;
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } }
.detail-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.detail-title { flex: 1; min-width: 0; }
.detail-title h2 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-body { padding: 18px 16px 40px; display: grid; gap: 18px; }
.facts {
  margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px;
}
.facts > div { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.facts .facts-wide { grid-column: 1 / -1; }
.facts dt { font-size: .8rem; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.log-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: -8px; }
.log-head label { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.live {
  margin-left: 6px; padding: 1px 8px; border-radius: 99px; font-size: .75rem;
  background: var(--running-bg); color: var(--running);
}
.log {
  margin: 0; min-height: 160px; max-height: 60vh; overflow: auto;
  padding: 14px; border-radius: 10px; background: var(--log-bg); color: var(--log-text);
  font: 13px/1.5 ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", monospace;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.log .srv { color: #7cc4ff; }

/* ---------- Logowanie ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(400px, 100%); padding: 28px; display: grid; gap: 16px; }
.login p { margin: 0; }

/* ---------- Nawigacja ---------- */
.nav-link {
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem;
  padding: 8px 10px; border-radius: 10px;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { color: var(--primary); background: var(--primary-soft); }
.user-name.nav-link { margin: 0; max-width: 16ch; }

/* ---------- Podstrony (Konto, Admin) ---------- */
.container.narrow { max-width: 760px; }
.container.wide { max-width: 1100px; }
.back-link {
  display: inline-flex; align-items: center; gap: 4px; margin-bottom: 8px;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: .9rem;
}
.back-link:hover { color: var(--text); }
.page-title { font-size: 1.6rem; margin-bottom: 18px; }
.section { padding: 22px; margin-bottom: 20px; display: grid; gap: 14px; }
.section > p { margin: 0; }
.sub { margin-top: 10px; }
.hint { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); margin-top: 4px; }

.perm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.perm-list li { display: flex; gap: 8px; align-items: center; }
.perm-list .yes .ic { color: var(--done); }
.perm-list .no { color: var(--muted); }
.perm-list .no .ic { color: var(--failed); }

.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 14px; }
.steps li::marker { font-weight: 700; color: var(--primary); }
.cmd {
  margin: 6px 0 0; padding: 10px 12px; border-radius: 10px; overflow-x: auto;
  background: var(--log-bg); color: var(--log-text);
  font: 13px/1.6 ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", monospace;
}
.kv { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.kv > span { font-size: .875rem; color: var(--muted); min-width: 110px; }
.kv code { overflow-wrap: anywhere; }

.form-grid { display: grid; gap: 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); align-items: start; }
.form-actions { grid-column: 1 / -1; }
.check.inline { padding: 10px 12px; align-items: center; }
.check-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; }

/* tabele */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
  text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.nowrap { white-space: nowrap; }
.row-off td { opacity: .55; }
.row-msg { font-size: .8rem; margin-top: 4px; }
.row-msg.err { color: var(--failed); }
.row-msg.ok { color: var(--done); }
.inline-form { display: flex; gap: 6px; }
.inline-form input { margin: 0; min-height: 36px; width: 140px; }

/* przełącznik on/off */
.switch {
  position: relative; width: 44px; height: 26px; border-radius: 99px; border: 0; padding: 0;
  background: var(--border); cursor: pointer; transition: background .15s;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .3); transition: transform .15s;
}
.switch.on { background: var(--done); }
.switch.on .knob { transform: translateX(18px); }
.switch:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Asystent AI ---------- */
:root { --ai: #7c3aed; --ai-bg: #f3edff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --ai: #b794ff; --ai-bg: #261c3d; } }
:root[data-theme="dark"] { --ai: #b794ff; --ai-bg: #261c3d; }

.btn-ai { background: var(--ai-bg); color: var(--ai); }
.btn-ai:hover { border-color: var(--ai); }
.ai-box {
  display: grid; gap: 12px; padding: 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
}
.ai-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ai-head h3 { display: flex; align-items: center; gap: 6px; color: var(--ai); }
.ai-note { font-size: .8rem; color: var(--muted); }
.ai-note.ai-slow { color: var(--queued); background: var(--queued-bg); padding: 2px 10px; border-radius: 99px; font-weight: 600; }
.ai-thread { display: grid; gap: 10px; }
.ai-thread:empty { display: none; }
.ai-answer {
  border-left: 3px solid var(--ai); background: var(--ai-bg);
  border-radius: 0 10px 10px 0; padding: 10px 14px;
}
.ai-label {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: .75rem; font-weight: 700; color: var(--ai); margin-bottom: 6px;
}
.ai-mode.slow { color: var(--queued); }
.ai-text { font-size: .95rem; overflow-wrap: anywhere; }
.ai-text p { margin: 0 0 8px; }
.ai-text ul, .ai-text ol { margin: 0 0 8px; padding-left: 1.3em; }
.ai-text li { margin-bottom: 3px; }
.ai-code {
  margin: 0 0 8px; padding: 10px 12px; border-radius: 8px; overflow-x: auto;
  background: var(--log-bg); color: var(--log-text);
  font: 12.5px/1.5 ui-monospace, "JetBrains Mono", "DejaVu Sans Mono", monospace;
}
.ai-code code { background: none; padding: 0; color: inherit; }
.ai-typing { color: var(--muted); font-style: italic; }
.ai-error { color: var(--failed); font-weight: 600; font-size: .9rem; }
.cursor {
  display: inline-block; width: 7px; height: 1em; margin-left: 2px; vertical-align: -2px;
  background: var(--ai); animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }
.ai-question {
  justify-self: end; max-width: 85%; padding: 8px 12px; border-radius: 12px 12px 2px 12px;
  background: var(--primary); color: #fff; font-size: .95rem; overflow-wrap: anywhere;
}
.ai-chat { display: flex; gap: 8px; }
.ai-chat input { margin: 0; }
.ai-foot { margin: 0; }
#precheck-out .ai-answer { margin-top: 2px; }

/* ---------- Okno "Serwer przygotuje przed startem" ---------- */
.prep {
  display: grid; gap: 10px; padding: 14px 16px; border-radius: 12px;
  background: var(--primary-soft); border: 1px solid var(--primary);
}
.prep-title { margin: 0; font-weight: 700; }
.prep-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.prep-item {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px;
  padding: 8px 12px; border-radius: 10px; background: var(--surface);
}
.prep-check { display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; }
.prep-name { overflow-wrap: anywhere; }
.prep-detail { font-size: .85rem; color: var(--muted); }
.prep-item.bad .prep-detail { color: var(--failed); }
.prep-item.bad .prep-name { text-decoration: line-through; opacity: .7; }
.prep-note { margin: 0; }

/* ---------- Serwis ---------- */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.title-row .page-title { margin: 0; }
.svc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; }
.svc { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 600; }
.svc .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.svc.ok .dot { background: var(--done); }
.svc.bad { background: var(--failed-bg); color: var(--failed); }
.svc.bad .dot { background: var(--failed); }
.svc .muted { margin-left: auto; }
.diag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.diag {
  display: grid; grid-template-columns: 24px minmax(160px, 1fr) 2fr auto; align-items: center; gap: 4px 10px;
  padding: 8px 12px; border-radius: 10px; background: var(--surface-2);
}
.diag.bad { background: var(--failed-bg); }
.diag-mark { font-weight: 800; }
.diag.ok .diag-mark { color: var(--done); }
.diag.bad .diag-mark, .diag.bad .diag-name { color: var(--failed); }
.diag-name { font-weight: 600; }
.diag-detail { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.diag-manual { grid-column: 2 / -1; font-size: .85rem; }
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 100; max-width: min(420px, calc(100% - 32px));
  padding: 12px 16px; border-radius: 10px; background: var(--done-bg); color: var(--done);
  box-shadow: 0 4px 20px rgb(0 0 0 / .2); font-weight: 600;
}
.toast.bad { background: var(--failed-bg); color: var(--failed); }
#service select { width: auto; min-height: 36px; margin: 0; }
@media (max-width: 640px) { .diag { grid-template-columns: 24px 1fr; } .diag-detail, .diag .btn { grid-column: 2; } }

/* ---------- Telefon ---------- */
.show-sm { display: none; }
@media (max-width: 640px) {
  .hide-sm { display: none !important; }
  .show-sm { display: inline; }
  .topbar-inner { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; }
  .brand span:last-child { display: none; }
  .status-bar { order: 3; flex-basis: 100%; justify-content: flex-start; gap: 6px; }
  .user-menu { margin-left: auto; }
  .container { padding: 16px 12px 40px; }
  .upload { padding: 22px 16px; }
  .drop-title { font-size: 1.05rem; }
  .actions .btn-lg { flex: 1 1 100%; }
  .job-open { flex-direction: column; gap: 8px; }
  .job-badge { width: auto; }
  .job-dl { align-self: flex-start; margin-top: 14px; }
  .drawer-panel { width: 100%; }
  .nav-link { padding: 8px 6px; }
  .user-name.nav-link { max-width: 10ch; }
  .section { padding: 16px; }
}

/* --- Podgląd zadania na żywo (partials/job_live.html) --- */
.live-panel { display: grid; gap: 14px; margin: 4px 0 18px; }
.live-panel:empty { display: none; }
.live-progress, .live-meters { display: grid; gap: 8px; }
.live-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bar { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar > div { height: 100%; background: var(--primary); border-radius: inherit; transition: width .6s ease; }
.bar-warn > div { background: var(--queued); }
.meter { display: grid; grid-template-columns: 130px 1fr 120px; gap: 10px; align-items: center; }
.meter .small { text-align: right; }
@media (max-width: 560px) { .meter { grid-template-columns: 1fr 90px; } .meter .bar { grid-column: 1 / -1; grid-row: 2; } }
.live-section h3 { margin: 0 0 8px; font-size: 1rem; }
.metrics-chart { width: 100%; height: 180px; display: block; }
.metrics-chart .chart-bg { fill: var(--surface-2, var(--bg)); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; font-size: .875rem; }
.legend-item i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.thumbs a { display: grid; gap: 4px; color: inherit; text-decoration: none; }
.thumbs img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; }
.thumbs span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.file-list li { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.file-list a { display: inline-flex; gap: 6px; align-items: center; min-width: 0; }
.file-list code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
