:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #17202e;
  --muted: #5f6b7d;
  --line: #e1e6ee;
  --primary: #1f6feb;
  --primary-hover: #185bc4;
  --primary-soft: #e8f0fe;
  --ok: #0f7b3e;
  --ok-soft: #e4f5ea;
  --bad: #b42318;
  --bad-soft: #fdecea;
  --info-soft: #eef3fb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .04);
  --focus: 0 0 0 3px rgba(31, 111, 235, .35);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141c;
    --card: #171e29;
    --text: #e6ebf2;
    --muted: #97a3b6;
    --line: #283243;
    --primary: #4c8dff;
    --primary-hover: #6aa0ff;
    --primary-soft: #1b2a45;
    --ok: #4cc27b;
    --ok-soft: #143222;
    --bad: #ff7a6e;
    --bad-soft: #3a1b1a;
    --info-soft: #18243a;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
p { margin: 0 0 12px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; color: var(--text); }
.text-bad { color: var(--bad); }
.nowrap { white-space: nowrap; }
.inline { display: inline; margin: 0; }

.wrap { width: 100%; max-width: 1320px; margin: 0 auto; padding: 0 28px; }
main.wrap { padding-top: 28px; padding-bottom: 48px; }

/* horní lišta */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand-icon { width: 22px; height: 22px; fill: var(--primary); transform: rotate(45deg); }
.brand-icon.big { width: 40px; height: 40px; }
.nav { display: flex; align-items: center; gap: 6px; }
.nav a { color: var(--muted); padding: 8px 12px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.nav a.active { color: var(--primary); background: var(--primary-soft); }

/* rozvržení */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.back { display: inline-block; font-size: 13px; margin-bottom: 6px; }
.back::before { content: "\2190  "; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack > h2 { margin: 10px 0 -2px; }
.stack > h2:first-of-type { margin-top: 0; }
@media (max-width: 1000px) {
  .grid-main, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 16px; }
  .row-2 { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
}

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-flush { padding: 0; overflow: hidden; }
.card-danger { border-color: color-mix(in srgb, var(--bad) 30%, var(--line)); }
.narrow-card { max-width: 520px; }

/* přihlášení */
.auth-page { display: flex; justify-content: center; padding-top: 10vh !important; }
.auth-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 12px; }
.auth-head { text-align: center; margin-bottom: 6px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* tlačítka */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--primary-soft); color: var(--primary); }
.btn-secondary:hover { border-color: var(--primary); }
.btn-quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-quiet:hover { color: var(--text); background: var(--bg); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-danger-outline { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.btn-danger-outline:hover { background: var(--bad-soft); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

/* formuláře */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-weight: 600; font-size: 13px; }
.field-hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12px; color: var(--bad); font-weight: 600; }
.input {
  width: 100%; height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.input:hover { border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
.has-error .input { border-color: var(--bad); }
input[type=number].input { -moz-appearance: textfield; appearance: textfield; }
input[type=number].input::-webkit-outer-spin-button,
input[type=number].input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.input-suffix { position: relative; display: block; }
.input-suffix .input { padding-right: 44px; }
.input-suffix > span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 14px; pointer-events: none; }
.form-msg { min-height: 1em; margin: 0; font-size: 13px; color: var(--muted); }

/* přepínač (stylovaný checkbox, zůstává ovladatelný klávesnicí) */
.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.switch { position: relative; flex: 0 0 auto; width: 42px; height: 24px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.slider { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; pointer-events: none; }
.slider::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::after { transform: translateX(18px); }
.switch input:focus-visible + .slider { box-shadow: var(--focus); }

/* hlášky */
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-info { background: var(--info-soft); color: var(--text); }
.alert a { font-weight: 600; margin-left: 6px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); white-space: nowrap; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }

/* tabulka */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.row-link { cursor: pointer; }
.row-link:hover td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.empty { padding: 40px; text-align: center; }

/* stav stahování nad tabulkou */
.sources { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-bottom: 20px; }
.source { padding: 14px 16px; }
.source-note { align-self: center; padding: 0 4px; }

/* seznamy */
.runs, .deals, .keys { list-style: none; margin: 0 0 12px; padding: 0; }
.runs li, .deals li, .keys li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.runs li:last-child, .deals li:last-child, .keys li:last-child { border-bottom: 0; }
.runs-head, .deal-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.deal-price { font-weight: 700; color: var(--ok); white-space: nowrap; }
.keys li { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* potvrzovací okno */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 15, 25, .45); }
.modal-card { position: relative; width: 100%; max-width: 440px; background: var(--card); border-radius: var(--radius); padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-card h2 { font-size: 18px; }
