/* =========================================================================
   Strážce OPS — scraper console v3
   Design systém podle Claude Design předloh (Downloads/1C…15).
   Tokeny = CSS custom properties; komponenty sdílené všemi stránkami.
   Fonty: Nunito (text), Poppins (nadpisy), JetBrains Mono (čísla/kód) —
   self-hostované ve /static/fonts/ (viz fonts.css, extrahováno z předloh).
   ========================================================================= */

@import url("/static/fonts/fonts.css");

:root {
  /* petrolejové jádro (sidebar) */
  --sidebar-bg: #0e3a47;
  --sidebar-bg2: #0b303b;
  --sidebar-muted: #2c5764;
  --sidebar-text: #cfe3e9;
  --sidebar-dim: #7fa3ae;

  /* teal akcent */
  --accent: #00acc1;
  --accent-strong: #0094a8;
  --accent-deep: #00788a;
  --accent-soft: #e6f7f9;
  --accent-tint: #cdf0f4;
  --accent-chip: #a8e4ec;

  /* teplý akcent / alerty */
  --warm: #ff7a45;
  --warm-deep: #f15f25;
  --danger: #e0533d;
  --danger-soft: #fdeeea;
  --warn: #f5a623;
  --warn-soft: #fdf3e0;
  --warm-soft: #fff1ea;
  --warm-tint: #fff8f3;

  /* neutrály */
  --bg: #f4fafb;
  --surface: #ffffff;
  --border: #e3eef1;
  --border-strong: #d6e6ea;
  --text: #2e2c26;
  --muted: #5a7e89;
  --muted-2: #8ba7b0;

  /* stavové */
  --ok: #2ec27e;
  --ok-deep: #128a4d;
  --ok-soft: #e7f8f0;

  /* portálové barvy */
  --p-sreality: #2ec27e;
  --p-idnes: #e0533d;
  --p-realitymix: #8b5cf6;
  --p-bezrealitky: #0aa88a;
  --p-bazos: #ff7a45;
  --p-reality_cz: #3b82f6;
  --p-exdrazby: #f5a623;
  --p-portal_drazeb: #5a7e89;
  --p-drazby_online: #c2569b;
  --p-remax: #d0021b;
  --p-ulovdomov: #7c3aed;
  --p-century21: #b8860b;

  --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --font-head: 'Poppins', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Mono', Consolas, monospace;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(14, 58, 71, 0.05), 0 4px 14px rgba(14, 58, 71, 0.05);
  --sidebar-w: 224px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; color: var(--text); }
.mono, code { font-family: var(--font-mono); }

/* ---------- app shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.page-content { padding: 18px 22px 40px; width: 100%; }

/* ---------- sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-muted) transparent;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar-logo {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: var(--accent);
  color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-brand b { font-family: var(--font-head); font-size: 14px; font-weight: 700; color: #fff; display: block; line-height: 1.2; }
.sidebar-brand small { font-family: var(--font-mono); font-size: 10px; color: var(--sidebar-dim); }

.nav-section { padding: 14px 10px 2px; }
.nav-section-label {
  font-size: 10px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--sidebar-dim); padding: 0 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; margin: 1px 0;
  border-radius: 8px;
  color: var(--sidebar-text); font-size: 13px; font-weight: 600;
  border-left: 3px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; color: #fff; }
.nav-item.active {
  background: rgba(0, 172, 193, 0.16);
  border-left-color: var(--accent);
  color: #fff;
}
.nav-badge {
  margin-left: auto;
  background: var(--warm);
  color: #fff; font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  border-radius: 999px; padding: 1px 6px; line-height: 1.5;
}
.sidebar-foot {
  margin-top: auto;
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-family: var(--font-mono); font-size: 10px; color: var(--sidebar-dim);
}
.sidebar-foot .logout-link { color: var(--sidebar-dim); cursor: pointer; }
.sidebar-foot .logout-link:hover { color: #fff; text-decoration: none; }

/* mobil: sidebar jako drawer */
.drawer-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    height: 100dvh;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,0.4); }
  .drawer-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--muted); cursor: pointer; font-size: 17px;
  }
  .drawer-backdrop {
    display: none; position: fixed; inset: 0; z-index: 55; background: rgba(14, 58, 71, 0.45);
  }
  .drawer-backdrop.open { display: block; }
}

/* ---------- page header ---------- */
.page-header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 40;
}
.page-header h1 { font-size: 19px; font-weight: 700; }
.page-subtitle { margin: 1px 0 0; font-size: 12px; color: var(--muted); }
.page-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- karty ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-title { font-family: var(--font-head); font-size: 15px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--muted); }
.card-meta { margin-left: auto; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.card.warm { background: var(--warm-tint); border-color: #f8dcc8; }

.section-label {
  font-size: 10px; font-weight: 800; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted-2); margin-bottom: 6px;
}

/* ---------- staty ---------- */
.stat-value {
  font-family: var(--font-mono); font-weight: 700; font-size: 22px; line-height: 1.15;
  color: var(--accent-deep);
}
.stat-value.warm { color: var(--warm-deep); }
.stat-value.danger { color: var(--danger); }
.stat-value.ok { color: var(--ok-deep); }
.stat-value.plain { color: var(--text); }
.stat-label { font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); }
.stat-sub { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }

/* ---------- chips / badges / dots ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.04em;
  border-radius: 999px; padding: 2px 8px;
  background: var(--accent-soft); color: var(--accent-deep);
  text-transform: lowercase;
}
.badge.ok { background: var(--ok-soft); color: var(--ok-deep); }
.badge.warn { background: var(--warn-soft); color: #a86a06; }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.muted { background: #eef4f6; color: var(--muted); }
.badge.warm { background: var(--warm-soft); color: var(--warm-deep); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted-2); flex-shrink: 0; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }
.dot.accent { background: var(--accent); }
.dot.pulse { animation: dot-pulse 1.6s infinite; }
@keyframes dot-pulse {
  0% { box-shadow: 0 0 0 0 rgba(46, 194, 126, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(46, 194, 126, 0); }
  100% { box-shadow: 0 0 0 0 rgba(46, 194, 126, 0); }
}

.chip {
  display: inline-block; font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  border-radius: 6px; padding: 2px 7px;
  background: var(--accent-soft); color: var(--accent-deep);
}
.chip[data-portal="sreality"] { background: #e6f8ef; color: #148a52; }
.chip[data-portal="idnes"] { background: #fceceb; color: var(--p-idnes); }
.chip[data-portal="realitymix"] { background: #f1ecfd; color: #6d3fd6; }
.chip[data-portal="bezrealitky"] { background: #e4f6f2; color: #0a8a72; }
.chip[data-portal="bazos"] { background: var(--warm-soft); color: var(--warm-deep); }
.chip[data-portal="reality_cz"] { background: #e9f1fe; color: #2563cf; }
.chip[data-portal="exdrazby"] { background: var(--warn-soft); color: #a86a06; }
.chip[data-portal="portal_drazeb"] { background: #edf2f4; color: var(--muted); }

/* číslované step-chipy (pipeline) */
.step-chip {
  width: 22px; height: 22px; border-radius: 7px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: #fff;
  background: var(--accent);
}

/* ---------- tlačítka ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-body); font-size: 12.5px; font-weight: 700;
  border-radius: 8px; padding: 7px 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-deep); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn.warm { background: var(--warm); border-color: var(--warm); color: #fff; }
.btn.warm:hover { background: var(--warm-deep); border-color: var(--warm-deep); }
.btn.danger-ghost { border-color: #f3c4bb; color: var(--danger); background: var(--surface); }
.btn.danger-ghost:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 11.5px; border-radius: 7px; }

/* ---------- taby / pill přepínače ---------- */
.tabs {
  display: inline-flex; gap: 2px;
  background: #eaf2f4; border-radius: 8px; padding: 2px;
}
.tabs button, .tabs a {
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--font-body); font-size: 12px; font-weight: 700;
  color: var(--muted); border-radius: 7px; padding: 4px 12px;
}
.tabs button:hover, .tabs a:hover { color: var(--text); text-decoration: none; }
.tabs button.active, .tabs a.active { background: var(--surface); color: var(--accent-deep); box-shadow: 0 1px 3px rgba(14,58,71,0.12); }

/* filter chip row */
.filter-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent-deep);
  border: 1px solid var(--accent-tint); border-radius: 999px; padding: 2px 10px;
}
.filter-chip .x { cursor: pointer; opacity: 0.6; font-weight: 800; }
.filter-chip .x:hover { opacity: 1; }

/* ---------- formulářové prvky ---------- */
.input, .select, textarea.input {
  font-family: var(--font-body); font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px; padding: 7px 10px;
  outline: none;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--muted-2); }
label.lbl { display: block; font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted-2); margin-bottom: 4px; }

/* toggle switch */
.switch { position: relative; width: 34px; height: 19px; display: inline-block; flex-shrink: 0; }
.switch input { display: none; }
.switch i {
  position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong);
  transition: background 0.15s; cursor: pointer;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
  transition: transform 0.15s;
}
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(15px); }

/* ---------- tabulky ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted-2);
  padding: 6px 10px; border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}
.table td { padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: var(--bg); }
.table td.num, .table th.num { text-align: right; font-family: var(--font-mono); }
.table .mono { font-size: 11.5px; }

/* ---------- progress bary ---------- */
.bar { height: 4px; border-radius: 999px; background: #e8f1f3; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.4s; }
.bar > i.ok { background: var(--ok); }
.bar > i.warn { background: var(--warn); }
.bar > i.danger { background: var(--danger); }
.bar > i.warm { background: var(--warm); }
.bar.lg { height: 8px; }

/* ---------- grafy (Chart.js) + KPI řádek + ranking ---------- */
.chart-wrap { position: relative; height: 220px; }
.chart-wrap.sm { height: 130px; }
.chart-wrap.lg { height: 280px; }
.chart-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--muted-2); font-size: 12px; text-align: center; padding: 0 16px; pointer-events: none;
}
.kpi-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 2px 0 12px; }
.kpi { background: var(--bg); border-radius: var(--radius-sm); padding: 8px 12px; min-width: 0; }
.kpi .stat-value { font-size: 18px; }
.kpi .stat-label { margin-bottom: 2px; }
.delta { font-family: var(--font-mono); font-size: 11px; }
.delta.up { color: var(--danger); }      /* spotřeba roste = dražší */
.delta.down { color: var(--ok-deep); }
.rank-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.rank-row { display: grid; grid-template-columns: 12px minmax(120px, 170px) 1fr 76px 86px 44px; gap: 8px; align-items: center; }
.rank-row .bar { height: 6px; }
.rank-row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .num { text-align: right; }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 3px; }
@media (max-width: 720px) {
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rank-row { grid-template-columns: 12px minmax(90px, 1fr) 76px 44px; }
  .rank-row .bar, .rank-row .req { display: none; }
}

/* ---------- callouty ---------- */
.callout {
  border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12px;
  background: var(--accent-soft); color: var(--accent-deep); border: 1px solid var(--accent-tint);
}
.callout.warm { background: var(--warm-soft); color: #9c4a1d; border-color: #f8dcc8; }
.callout.danger { background: var(--danger-soft); color: var(--danger); border-color: #f3c4bb; }
.callout.warn { background: var(--warn-soft); color: #8a5a08; border-color: #f3e0b5; }

/* ---------- gridy ---------- */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main-side { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-content { padding: 12px 12px 32px; }
}

/* ---------- AI batche (analýza fotek, audit inzerátů) — static/js/ai_runs.js ---------- */
.ai-live { border: 1px solid var(--accent-tint); background: var(--accent-soft); border-radius: 12px;
           padding: 12px 14px; margin-bottom: 12px; display: flex; flex-direction: column; gap: 10px; }
.ai-live-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.ai-live .bar { height: 10px; }
.ai-eta { font-variant-numeric: tabular-nums; font-weight: 700; }
.ai-runs td.num { white-space: nowrap; }
.bar.indet { overflow: hidden; }
.bar.indet i { width: 35% !important; animation: ai-indet 1.2s ease-in-out infinite; }
@keyframes ai-indet { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.ai-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px 14px; }
.ai-form label { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.ai-checks { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; color: var(--text); font-weight: 500; }
.ai-checks label { flex-direction: row; align-items: center; gap: 4px; color: var(--text); font-weight: 500; }
.ai-est { background: var(--accent-soft); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.ai-est b.big { font-size: 20px; }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80; display: none;
  background: rgba(14, 58, 71, 0.5);
  align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(14, 58, 71, 0.35);
  width: 100%; max-width: 860px; padding: 20px;
}

/* ---------- toast ---------- */
#toast-host { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--sidebar-bg); color: #fff; font-size: 12.5px; font-weight: 600;
  border-radius: 9px; padding: 10px 14px; box-shadow: 0 8px 24px rgba(14,58,71,0.35);
  animation: toast-in 0.2s ease;
  max-width: 340px;
}
.toast.danger { background: var(--danger); }
.toast.ok { background: var(--ok-deep); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- drobnosti ---------- */
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.small { font-size: 11.5px; }
.tiny { font-size: 10.5px; }
.num { font-family: var(--font-mono); }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.right { margin-left: auto; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.skeleton { color: var(--muted-2); }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
