/* TFF Hub: provozní dashboard. Jedna rodina písma, klidná neutrální škála, barva jen pro stav a primární akci. */

:root {
  color-scheme: light dark;

  /* povrchy */
  --bg: oklch(0.985 0.003 279);
  --panel: oklch(0.962 0.005 279);
  --surface: oklch(1 0 0);
  --line: oklch(0.915 0.006 279);
  --line-strong: oklch(0.84 0.01 279);

  /* text */
  --ink: oklch(0.22 0.02 279);
  --ink-2: oklch(0.46 0.02 279);

  /* akce */
  --accent: oklch(0.47 0.19 279);
  --accent-hover: oklch(0.41 0.19 279);
  --accent-ink: oklch(1 0 0);
  --focus: oklch(0.55 0.2 279);

  /* stav: text / pozadí / tečka */
  --ok: oklch(0.45 0.12 155);   --ok-bg: oklch(0.965 0.035 155);   --ok-dot: oklch(0.62 0.16 155);
  --err: oklch(0.47 0.18 25);   --err-bg: oklch(0.965 0.025 25);   --err-dot: oklch(0.58 0.21 25);
  --warn: oklch(0.45 0.1 75);   --warn-bg: oklch(0.965 0.045 90);  --warn-dot: oklch(0.72 0.15 80);
  --idle-dot: oklch(0.66 0.015 279);

  /* rozestupy (základ 4 px) */
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem; --s7: 3rem;

  --r-full: 999px; --r-xs: 4px; --r-sm: 6px; --r-md: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --side-w: 15rem;
  --z-skip: 10;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.175 0.01 279);
    --panel: oklch(0.15 0.01 279);
    --surface: oklch(0.215 0.012 279);
    --line: oklch(0.285 0.012 279);
    --line-strong: oklch(0.38 0.015 279);
    --ink: oklch(0.94 0.005 279);
    --ink-2: oklch(0.74 0.015 279);
    --accent: oklch(0.74 0.14 279);
    --accent-hover: oklch(0.8 0.12 279);
    --accent-ink: oklch(0.17 0.02 279);
    --focus: oklch(0.8 0.13 279);
    --ok: oklch(0.82 0.14 155);   --ok-bg: oklch(0.26 0.05 155);   --ok-dot: oklch(0.74 0.17 155);
    --err: oklch(0.84 0.11 25);   --err-bg: oklch(0.27 0.06 25);   --err-dot: oklch(0.7 0.19 25);
    --warn: oklch(0.86 0.12 88);  --warn-bg: oklch(0.27 0.05 88);  --warn-dot: oklch(0.8 0.15 85);
    --idle-dot: oklch(0.58 0.015 279);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); font-feature-settings: "tnum" 1; }
a { color: var(--accent); text-underline-offset: .18em; }
a:hover { color: var(--accent-hover); }
h1, h2, h3 { text-wrap: balance; margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.0625rem; line-height: 1.3; font-weight: 600; }
p { margin: 0; }
code { font-family: var(--mono); font-size: .85em; }
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }

.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip { position: absolute; left: var(--s3); top: -4rem; z-index: var(--z-skip); background: var(--accent); color: var(--accent-ink); padding: var(--s2) var(--s3); border-radius: var(--r-sm); text-decoration: none; }
.skip:focus { top: var(--s3); }

/* ---------- rozvržení aplikace ---------- */

.shell { min-height: 100dvh; display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); }

.side { overflow-y: auto; position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: var(--s5); padding: var(--s4) var(--s3); background: var(--panel); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: var(--s2); padding: var(--s1) var(--s2); color: var(--ink); font-weight: 650; text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 1.5rem; height: 1.5rem; border-radius: var(--r-sm); background: var(--ink); color: var(--bg); display: grid; place-items: center; font-size: .875rem; font-weight: 700; letter-spacing: 0; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a { display: flex; align-items: center; gap: var(--s3); min-height: 2.25rem; padding: 0 var(--s3); border-radius: var(--r-sm); color: var(--ink-2); text-decoration: none; transition: background-color .15s, color .15s; }
.nav a svg { flex: none; width: 1.125rem; height: 1.125rem; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: color-mix(in oklch, var(--ink) 8%, transparent); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }
.nav a[aria-current="page"] svg { color: var(--accent); }

.who { display: grid; gap: var(--s1); padding: var(--s3) var(--s2) 0; border-top: 1px solid var(--line); margin: 0; }
.who-name { font-weight: 600; overflow-wrap: anywhere; }

.content { min-width: 0; }
main { max-width: 84rem; margin: 0 auto; padding: var(--s6) var(--s6) var(--s7); }
.page-head { display: grid; gap: var(--s1); margin-bottom: var(--s5); }
.page-head p { color: var(--ink-2); max-width: 65ch; }

@media (max-width: 56rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); padding: var(--s3) var(--s4); border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex: 1 1 100%; order: 3; overflow-x: auto; scrollbar-width: none; }
  .nav a { flex: none; }
  .who { margin-left: auto; padding: 0; border: 0; grid-auto-flow: column; align-items: center; gap: var(--s3); }
  main { padding: var(--s5) var(--s4) var(--s6); }
}

/* ---------- ovládací prvky ---------- */

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 2.25rem; padding: 0 var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; text-decoration: none; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; }
.btn:hover { background: var(--panel); border-color: var(--ink-2); color: var(--ink); }
.btn:active { background: var(--line); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--panel); border-color: var(--line-strong); color: var(--accent-hover); }
.btn.small { min-height: 2rem; padding: 0 var(--s3); font-size: .875rem; }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: progress; pointer-events: none; }

button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; text-align: left; cursor: pointer; text-decoration: underline; text-underline-offset: .18em; }
button.link:hover { color: var(--accent-hover); }

select { min-height: 2.25rem; padding: 0 var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); font: inherit; }
select:hover { border-color: var(--ink-2); }

.flash { display: flex; gap: var(--s3); align-items: baseline; padding: var(--s3) var(--s4); margin-bottom: var(--s5); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); }

/* ---------- stav ---------- */

.state { display: inline-flex; align-items: center; gap: var(--s2); font-size: .875rem; font-weight: 600; white-space: nowrap; color: var(--ink-2); }
.state::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--idle-dot); flex: none; }
.state.ok { color: var(--ok); } .state.ok::before { background: var(--ok-dot); }
.state.error { color: var(--err); } .state.error::before { background: var(--err-dot); }
.state.skipped { color: var(--warn); } .state.skipped::before { background: var(--warn-dot); }
.state.waiting::before { background: transparent; box-shadow: inset 0 0 0 1.5px var(--idle-dot); }
.state.running { color: var(--ink); } .state.running::before { background: var(--accent); }

.summary { display: grid; grid-template-columns: auto 1fr; gap: var(--s1) var(--s4); align-items: start; padding: var(--s4) var(--s5); margin-bottom: var(--s6); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--ok-bg); }
.summary.is-error { background: var(--err-bg); }
.summary.is-warn { background: var(--warn-bg); }
.summary-dot { grid-row: span 2; margin-top: .3125rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--ok-dot); box-shadow: 0 0 0 5px color-mix(in oklch, var(--ok-dot) 22%, transparent); }
.summary.is-warn .summary-dot { background: var(--warn-dot); box-shadow: 0 0 0 5px color-mix(in oklch, var(--warn-dot) 22%, transparent); }
.summary.is-error .summary-dot { background: var(--err-dot); box-shadow: 0 0 0 5px color-mix(in oklch, var(--err-dot) 22%, transparent); }
.summary-title { margin: 0; font-size: 1.25rem; font-weight: 650; line-height: 1.3; color: var(--ok); }
.summary.is-error .summary-title { color: var(--err); }
.summary.is-warn .summary-title { color: var(--warn); }
.summary-text { color: var(--ink); }
.summary-text a { color: inherit; font-weight: 600; }

/* ---------- přehled: úlohy ---------- */

.section { margin-bottom: var(--s6); }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s4); margin-bottom: var(--s3); }
.section-head a { font-size: .875rem; }

.jobs { overflow: hidden; list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.job { display: grid; grid-template-columns: minmax(9rem, 1fr) minmax(0, 1.8fr) auto; gap: var(--s4); align-items: start; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: 0; }
.job-main, .job-state { display: grid; gap: var(--s1); justify-items: start; min-width: 0; }
.job-name { font-weight: 600; }
.job-meta { color: var(--ink-2); font-size: .875rem; overflow-wrap: anywhere; }
.job form { margin: 0; }
.job .run-form:has(.confirm) { grid-column: 1 / -1; justify-items: end; }
.job.is-error { background: color-mix(in oklch, var(--err-bg) 45%, transparent); }

/* ---------- přehled: dvě zóny (úlohy vlevo, dění a obsah vpravo) ---------- */
.board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 var(--s6); align-items: start; }
@media (min-width: 80rem) {
  .board { grid-template-columns: minmax(0, 1fr) 21rem; }
  .rail { position: sticky; top: var(--s5); }
}
.rail { min-width: 0; }

.feed { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.feed-item { display: grid; grid-template-columns: .5rem minmax(0, 1fr); gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.feed-item:last-child { border-bottom: 0; }
.feed-item.is-error { background: color-mix(in oklch, var(--err-bg) 45%, transparent); }
.feed-dot { width: .5rem; height: .5rem; margin-top: .5rem; border-radius: 50%; background: var(--idle-dot); }
.feed-dot.ok { background: var(--ok-dot); } .feed-dot.error { background: var(--err-dot); }
.feed-dot.skipped { background: var(--warn-dot); } .feed-dot.running { background: var(--accent); }
.feed-body { display: grid; gap: 2px; min-width: 0; }
.feed-body p { margin: 0; }
.feed-title { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s1) var(--s3); }
.feed-link { font-weight: 600; color: var(--ink); text-decoration: none; }
.feed-link:hover { color: var(--accent); text-decoration: underline; }
.feed-msg { font-size: .875rem; overflow-wrap: anywhere; }

.content-box { display: grid; gap: var(--s3); padding: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.content-box p { margin: 0; }
.content-box.is-warn { background: var(--warn-bg); color: var(--warn); }
.content-box.is-error { background: var(--err-bg); color: var(--err); }
.content-line { display: flex; justify-content: space-between; gap: var(--s3); }
.content-line strong { font-variant-numeric: tabular-nums; }
.meter { width: 100%; height: .5rem; border: 0; border-radius: var(--r-full); background: var(--line); appearance: none; overflow: hidden; }
.meter::-webkit-progress-bar { background: var(--line); border-radius: var(--r-full); }
.meter::-webkit-progress-value { background: var(--accent); border-radius: var(--r-full); }
.meter::-moz-progress-bar { background: var(--accent); border-radius: var(--r-full); }
.content-box.is-warn .meter::-webkit-progress-value { background: var(--warn-dot); } .content-box.is-warn .meter::-moz-progress-bar { background: var(--warn-dot); }
.content-box.is-error .meter::-webkit-progress-value { background: var(--err-dot); } .content-box.is-error .meter::-moz-progress-bar { background: var(--err-dot); }

.empty { padding: var(--s5) var(--s4); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-2); }
.empty strong { display: block; color: var(--ink); margin-bottom: var(--s1); }

/* ---------- tabulky ---------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: var(--s3) var(--s4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: var(--panel); color: var(--ink-2); font-size: .875rem; font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in oklch, var(--panel) 60%, transparent); }
td.msg { overflow-wrap: anywhere; min-width: 14rem; }
td.empty-row { color: var(--ink-2); padding: var(--s5) var(--s4); }

details summary { cursor: pointer; width: fit-content; border-radius: var(--r-sm); }
pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: var(--s2) 0 0; padding: var(--s3); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); font: .875rem/1.5 var(--mono); max-height: 16rem; overflow: auto; }

/* ---------- filtry a stránkování ---------- */

.filters { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s3) var(--s4); margin-bottom: var(--s4); }
.filters label { display: grid; gap: var(--s1); font-size: .875rem; color: var(--ink-2); font-weight: 550; }

.seg { display: flex; width: fit-content; padding: 2px; margin-bottom: var(--s4); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); }
.seg a { display: inline-flex; align-items: center; min-height: 2rem; padding: 0 var(--s4); border-radius: var(--r-xs); color: var(--ink); text-decoration: none; font-size: .875rem; font-weight: 550; opacity: .8; transition: background-color .15s, color .15s; }
.seg a:hover { opacity: 1; }
.seg a[aria-current="page"] { opacity: 1; background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }

.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--s4); margin-top: var(--s4); font-size: .875rem; color: var(--ink-2); }

/* ---------- přihlášení a chybové stránky ---------- */

.auth { min-height: 100dvh; display: grid; place-items: center; padding: var(--s5) var(--s4); }
.auth-card { width: min(26rem, 100%); display: grid; gap: var(--s4); padding: var(--s6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); }
.auth-card .brand { padding: 0; }
.auth-card form { margin: 0; }

/* ---------- stav v navigaci ---------- */
.nav-dot { width: .5rem; height: .5rem; margin-left: auto; border-radius: 50%; background: var(--warn-dot); }
.nav-dot.is-error { background: var(--err-dot); }
.nav-count { margin-left: auto; min-width: 1.25rem; padding: 0 var(--s2); border-radius: var(--r-md); background: var(--err-bg); color: var(--err); font-size: .875rem; font-weight: 650; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- hlášky ---------- */
.flash.is-ok, .job-result.is-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.flash.is-error, .job-result.is-error { background: var(--err-bg); color: var(--err); border-color: transparent; }
.flash.is-warn, .job-result.is-warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.job-result { margin: var(--s2) 0 0; padding: var(--s2) var(--s3); border-radius: var(--r-sm); font-size: .875rem; font-weight: 550; overflow-wrap: anywhere; }

/* ---------- ruční spuštění ---------- */
.run-form { display: grid; justify-items: end; gap: var(--s2); }
.confirm { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; justify-content: flex-end; max-width: 28rem; }
.confirm-text { flex: 1 1 100%; margin: 0; font-size: .875rem; text-align: right; }

/* ---------- řádky s chybou a zkrácené zprávy ---------- */
tr.is-error td, tr.is-error th { background: color-mix(in oklch, var(--err-bg) 55%, transparent); }
.clip summary { list-style: none; cursor: pointer; }
.clip summary::-webkit-details-marker { display: none; }
.clip-more, .clip-less { color: var(--accent); font-size: .875rem; white-space: nowrap; }
.clip-less, .clip[open] .clip-more { display: none; }
.clip[open] .clip-less { display: inline; }
.clip-full { margin-top: var(--s2); padding: var(--s3); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); font: .875rem/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow: auto; }

/* ---------- pás posledních 14 dní u úlohy ---------- */
.strip { display: inline-flex; gap: 3px; margin-top: var(--s1); }
.strip-day { width: .5rem; height: 1rem; border-radius: var(--r-xs); background: transparent; box-shadow: inset 0 0 0 1px var(--line-strong); }
.strip-day.ok { background: var(--ok-dot); box-shadow: none; }
.strip-day.error { background: var(--err-dot); box-shadow: none; }
.strip-day.skipped { background: var(--warn-dot); box-shadow: none; }

/* ---------- nápověda ke stavům ---------- */
.help { margin-top: var(--s3); padding: var(--s2) var(--s4); border: 1px solid var(--line); border-radius: var(--r-md); }
.help summary { font-weight: 550; color: var(--accent); }
.help dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--s2) var(--s4); margin: var(--s3) 0; }
.help dt, .help dd { margin: 0; }

/* ---------- přihlášení: rytmus karty ---------- */
.auth-card .page-head { margin-bottom: 0; gap: var(--s2); }

/* ---------- responzivita ---------- */

@media (min-width: 44.001rem) and (max-width: 64rem) {
  .job { grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--s2); }
  .job-state { grid-column: 1; grid-row: 2; }
  .run-form { grid-column: 2; grid-row: 1 / span 2; }
}

@media (max-width: 44rem) {
  .job { grid-template-columns: minmax(0, 1fr); gap: var(--s3); padding: var(--s4); }
  .job .run-form:has(.confirm) { justify-items: start; }
  .help dl { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .help dd { margin-bottom: var(--s2); }
  .pager { flex-wrap: wrap; }
  .pager .num { order: -1; flex: 1 1 100%; text-align: center; white-space: normal; }
  .pager > span:empty { display: none; }
  .pager .btn { flex: 1; }
  .filters label { flex: 1 1 9rem; }
  .filters select { width: 100%; }
}

/* dotyková zařízení a úzké obrazovky: ovládací prvky aspoň 44 px */
@media (pointer: coarse), (max-width: 44rem) {
  .btn, .btn.small, select, .nav a, .seg a { min-height: 2.75rem; }
  button.link { min-height: 2.75rem; padding-inline: var(--s2); }
  .clip summary, details summary { min-height: 2.75rem; display: inline-flex; align-items: center; }
}

/* telefon: navigace jako pětisloupcová lišta, nic se neskrývá za okrajem */
@media (max-width: 56rem) { .nav { scroll-padding-inline: var(--s4); } }
@media (max-width: 30rem) {
  .nav { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; overflow: visible; }
  .nav a { position: relative; flex-direction: column; justify-content: center; gap: 2px; min-height: 3rem; padding: var(--s1); font-size: .875rem; text-align: center; }
  .nav-dot, .nav-count { position: absolute; top: 4px; left: calc(50% + .5rem); margin: 0; }
  .summary { column-gap: var(--s3); padding: var(--s4); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
