:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f0f1f6;
  --border: #e1e3ec;
  --text: #1d2030;
  --muted: #6b7085;
  --accent: #6c55f0;
  --accent-soft: #ece9ff;
  --ok: #18a058;
  --ok-soft: #e3f6ec;
  --warn: #d08700;
  --warn-soft: #fdf2dc;
  --bad: #d63b3b;
  --bad-soft: #fde6e6;
  --info: #2f7fe0;
  --info-soft: #e2eefc;
  --shadow: 0 1px 2px rgba(20, 22, 40, .06), 0 2px 8px rgba(20, 22, 40, .04);
  --radius: 10px;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #12131a;
  --surface: #1b1c25;
  --surface-2: #23242f;
  --border: #2e3040;
  --text: #e6e7ef;
  --muted: #9095ab;
  --accent: #8b78ff;
  --accent-soft: #2a2550;
  --ok: #3ccf7f;
  --ok-soft: #173326;
  --warn: #f0b43c;
  --warn-soft: #3a2e14;
  --bad: #ff6b6b;
  --bad-soft: #3d1d20;
  --info: #5aa2ff;
  --info-soft: #1a2a40;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 15px; }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.view { max-width: 1320px; margin: 0 auto; padding: 24px 20px 60px; }

/* Layout helpers */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
@media (max-width: 1000px) {
  .grid-2, .grid-3, .editor-layout { grid-template-columns: 1fr; }
}
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); min-width: 0;
}
.card + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.stack > * + * { margin-top: 16px; }
.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.section-title h2 { margin: 0; }
.section-title .right { margin-left: auto; display: flex; gap: 6px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 500; cursor: pointer;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 4px 10px; font-size: 12.5px; }

/* Forms */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=number], input[type=password], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { font-family: var(--mono); font-size: 12.5px; resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Code editor */
.CodeMirror { height: 560px; border-radius: 8px; font-family: var(--mono); font-size: 13px; border: 1px solid var(--border); }

/* Tables */
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover { background: var(--surface-2); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.passed { background: var(--ok-soft); color: var(--ok); }
.badge.failed { background: var(--bad-soft); color: var(--bad); }
.badge.error { background: var(--bad-soft); color: var(--bad); }
.badge.running { background: var(--info-soft); color: var(--info); }
.badge.running::before { animation: pulse 1.2s infinite; }
.badge.queued { background: var(--warn-soft); color: var(--warn); }
.badge.stopped { background: var(--surface-2); color: var(--muted); }
@keyframes pulse { 50% { opacity: .25; } }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .value .unit { font-size: 13px; color: var(--muted); font-weight: 500; margin-left: 2px; }
.kpi .delta { font-size: 12px; margin-top: 2px; }
.delta.better { color: var(--ok); }
.delta.worse { color: var(--bad); }
.kpi.bad .value { color: var(--bad); }
.kpi.good .value { color: var(--ok); }

.chart-box { position: relative; height: 260px; }

/* Log */
.log {
  background: #0f1017; color: #d6d8e4; border-radius: 8px; padding: 12px; margin: 0;
  height: 380px; overflow: auto; white-space: pre-wrap; word-break: break-all;
}

/* Alerts */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert.error { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--info-soft); color: var(--info); }
.alert pre { white-space: pre-wrap; margin: 6px 0 0; }

/* Empty */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 6px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs button {
  background: none; border: 0; padding: 9px 14px; font: inherit; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Template cards */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.tpl { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; cursor: pointer; background: var(--surface); }
.tpl:hover { border-color: var(--accent); }
.tpl h3 { margin-bottom: 4px; }
.tpl p { margin: 0; font-size: 12.5px; color: var(--muted); }

/* Key/value rows */
.kv-row { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 6px; margin-bottom: 6px; }
.req-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; background: var(--surface-2); }
.req-row .top { display: grid; grid-template-columns: 110px 1fr 90px auto; gap: 6px; }

/* Login */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login { width: 340px; }
.login .brand { justify-content: center; margin-bottom: 18px; font-size: 18px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 10, 20, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow: auto; }
.modal { background: var(--surface); border-radius: 12px; padding: 20px; width: 100%; max-width: 820px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* Toast */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; padding: 10px 16px; border-radius: 8px;
  background: var(--text); color: var(--bg); box-shadow: 0 6px 24px rgba(0, 0, 0, .2); max-width: 420px;
}
.toast.error { background: var(--bad); color: #fff; }

.file-list { list-style: none; margin: 0; padding: 0; }
.file-list li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.file-list li:last-child { border-bottom: 0; }
.file-list .name { font-family: var(--mono); font-size: 12.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; }

.check-ok { color: var(--ok); font-weight: 600; }
.check-bad { color: var(--bad); font-weight: 600; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); }

/* Sekce & stránky */
.ep-tbl th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.ep-tbl th.sortable:hover { color: var(--text); }
.ep-tbl td, .ep-tbl th { padding: 7px 8px; }
.ep-name { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-bar { position: relative; min-width: 90px; }
.ep-bar::before { content: ""; position: absolute; right: 4px; top: 6px; bottom: 6px; width: calc((100% - 8px) * var(--w) / 100); background: var(--accent-soft); border-radius: 3px; }
.ep-bar > span { position: relative; font-weight: 600; }
