/* EQS Harvest – provozní administrace. Jeden soubor, bez závislostí. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --accent-text: #ffffff;

  --blue: #2563eb;   --blue-soft: #eff4ff;   --blue-text: #1e40af;
  --green: #16a34a;  --green-soft: #ecfdf3;  --green-text: #166534;
  --amber: #d97706;  --amber-soft: #fffbeb;  --amber-text: #92400e;
  --red: #dc2626;    --red-soft: #fef2f2;    --red-text: #991b1b;
  --gray-soft: #f3f4f6; --gray-text: #374151;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-pop: 0 8px 24px rgba(16, 24, 40, .08);
  --sidebar: 232px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10;
    --surface: #14171c;
    --surface-2: #181c22;
    --text: #e5e7eb;
    --text-2: #c2c7d0;
    --muted: #8b93a1;
    --border: #252a32;
    --border-strong: #333a44;
    --accent: #4f8cff;
    --accent-hover: #6b9dff;
    --accent-soft: #15213a;
    --accent-text: #0b0d10;
    --blue: #4f8cff;   --blue-soft: #15213a;   --blue-text: #9dbcff;
    --green: #34c26b;  --green-soft: #10261a;  --green-text: #7fdca2;
    --amber: #f0a43a;  --amber-soft: #2a1f0c;  --amber-text: #f6c77d;
    --red: #f26b6b;    --red-soft: #2c1415;    --red-text: #f7a3a3;
    --gray-soft: #1e232a; --gray-text: #c2c7d0;
    --shadow: none;
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14px/1.5 var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 14px; font-weight: 600; }
p { margin: 0 0 8px; }
code { font: 12px var(--mono); background: var(--gray-soft); padding: 1px 5px; border-radius: 4px; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

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

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--text); font-weight: 650; font-size: 15px; }
.brand:hover { text-decoration: none; color: var(--text); }
.brand-mark {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  background: var(--accent); color: var(--accent-text); font-size: 13px; font-weight: 700;
}
.nav-group { margin-top: 10px; padding: 0 10px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--gray-soft); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.active .icon { stroke: var(--accent); }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.sync {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-2);
}
.sync:hover { text-decoration: none; color: var(--text); border-color: var(--border-strong); }
.sync small { display: block; color: var(--muted); }
.user { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 10px; font-size: 13px; color: var(--text-2); }
.user form { margin: 0; }

.main { padding: 28px 32px 48px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }

/* ------------------------------------------------------------------ stavové tečky a štítky */

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--muted); }
.dot-ok { background: var(--green); }
.dot-warn { background: var(--amber); }
.dot-err { background: var(--red); }
.dot-run { background: var(--blue); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot-run { animation: none; } }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap;
  background: var(--gray-soft); color: var(--gray-text);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-open, .badge-running { background: var(--blue-soft); color: var(--blue-text); }
.badge-final, .badge-done { background: var(--green-soft); color: var(--green-text); }
.badge-draft, .badge-abandoned { background: var(--amber-soft); color: var(--amber-text); }
.badge-failed { background: var(--red-soft); color: var(--red-text); }
.badge-plain::before { display: none; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--gray-soft); color: var(--text-2); font-size: 12px; white-space: nowrap; }
.tag-ok { background: var(--green-soft); color: var(--green-text); }
.tag-warn { background: var(--amber-soft); color: var(--amber-text); }

/* ------------------------------------------------------------------ karty a dlaždice */

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head a { font-size: 13px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush .card-head { padding: 16px 20px 0; }
.card.highlight { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 16px; align-items: start; }
.grid2 > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 16px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; color: var(--text);
}
a.tile:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.accent .tile-value { color: var(--accent); }

.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--muted); font-size: 13px; }
.meta b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.bar { height: 6px; border-radius: 3px; background: var(--gray-soft); overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

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

.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 220px);
}
.table-wrap.auto { max-height: none; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 600; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.nowrap, th.nowrap { white-space: nowrap; }
td.strong { font-weight: 600; }
td.wrap { min-width: 220px; }
td.col-name { min-width: 170px; }
.num { text-align: right; white-space: nowrap; }
.row-done td { color: var(--muted); }
.row-done td a { color: var(--muted); }
tr.empty td { padding: 40px 12px; text-align: center; color: var(--muted); }
.thumb { display: block; width: 36px; height: 36px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--gray-soft); }

/* tabulky uvnitř karet (přehled) */
.list { width: 100%; }
.list td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.list td + td { padding-left: 12px; }
.list tr:last-child td { border-bottom: 0; }
.list tbody tr:hover td { background: none; }

/* ------------------------------------------------------------------ formuláře a tlačítka */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 500 13px var(--font); cursor: pointer; white-space: nowrap;
}
.btn:hover { text-decoration: none; background: var(--surface-2); color: var(--text); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: var(--red); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: none; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--muted); cursor: pointer; }
button.link:hover { color: var(--text); text-decoration: underline; }

input, select, textarea {
  font: 14px var(--font); color: var(--text);
  height: 34px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface);
}
select[multiple], textarea { height: auto; padding: 6px 10px; }
input[type=checkbox], input[type=radio] { height: auto; width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
input::placeholder { color: var(--muted); }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .count { margin-right: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
.section-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 10px; flex-wrap: wrap; }

.filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.filters input[type=search] { flex: 1 1 240px; min-width: 200px; }
.filters select { max-width: 220px; }
.filters .field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.filters .spacer { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }

.form label.field { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.form label.field input, .form label.field select, .form label.field textarea { display: block; width: 100%; margin-top: 6px; font-weight: 400; }
.form label.field small { display: block; margin-top: 4px; font-weight: 400; color: var(--muted); }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.form .options { display: flex; flex-wrap: wrap; gap: 10px 20px; margin-bottom: 14px; }
.form .columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px 16px; }
.form-section { padding: 18px 0; border-top: 1px solid var(--border); }
.form-section:first-of-type { border-top: 0; padding-top: 4px; }
.form-section h2 { margin-bottom: 4px; }
.form-section > .hint { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.form-actions { display: flex; gap: 8px; padding-top: 18px; border-top: 1px solid var(--border); }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form label.field { flex: 1 1 260px; margin: 0; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.actions form { margin: 0; }
input.copy { width: 100%; font: 12px var(--mono); background: var(--surface-2); }
input.copy.big { font-size: 14px; height: 42px; }

/* ------------------------------------------------------------------ hlášky, stránkování, detail */

.flash {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; margin-bottom: 16px; border-radius: var(--radius-sm);
  background: var(--green-soft); color: var(--green-text); border: 1px solid transparent;
}
.flash-error { background: var(--red-soft); color: var(--red-text); }
.flash-warn { background: var(--amber-soft); color: var(--amber-text); }
.flash a { color: inherit; text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.warn { color: var(--red); }
.nowrap { white-space: nowrap; }

.pager { display: flex; gap: 4px; align-items: center; justify-content: flex-end; margin: 14px 0 0; }
.pager a, .pager b, .pager span {
  min-width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0 8px;
  border-radius: var(--radius-sm); font-variant-numeric: tabular-nums;
}
.pager a { color: var(--text-2); border: 1px solid var(--border); background: var(--surface); }
.pager a:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
.pager b { background: var(--accent); color: var(--accent-text); }
.pager span { color: var(--muted); }

dl.props { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 0; margin: 0; }
dl.props dt, dl.props dd { padding: 8px 0; border-bottom: 1px solid var(--border); margin: 0; }
dl.props dt { color: var(--muted); }
dl.props dt:last-of-type, dl.props dd:last-of-type { border-bottom: 0; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:first-child::before { background: var(--accent); }
.timeline li:last-child::after { display: none; }
.timeline time { display: block; font-size: 12px; color: var(--muted); }

.notes { font-size: 12px; color: var(--text-2); }
.notes div + div { margin-top: 2px; }

.empty-state { text-align: center; padding: 32px 16px; color: var(--muted); }
.empty-state h2 { color: var(--text); margin-bottom: 6px; }

/* ------------------------------------------------------------------ přihlášení */

.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 380px; padding: 28px; }
.login .brand { padding: 0 0 20px; }
.login .btn { width: 100%; height: 38px; }

/* ------------------------------------------------------------------ mobil */

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; z-index: 10; height: auto;
    flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .brand { padding: 0 8px 0 0; }
  .brand span:last-child, .nav-group, .sidebar-foot .user span { display: none; }
  .nav { display: flex; gap: 2px; }
  .nav a { white-space: nowrap; padding: 6px 8px; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; flex-direction: row; align-items: center; }
  .sync small { display: none; }
  .main { padding: 18px 16px 40px; }
  .table-wrap { max-height: none; }
  dl.props { grid-template-columns: 1fr; }
  dl.props dt { border-bottom: 0; padding-bottom: 0; }
}
