:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f5;
  --border: #e2e5ea;
  --border-strong: #cbd2da;
  --text: #14181f;
  --text-2: #5b6472;
  --text-3: #8a93a1;

  --accent: #4f46e5;
  --accent-soft: #eef0fe;
  --ok: #10914f;
  --ok-soft: #e6f5ed;
  --warn: #b45309;
  --warn-soft: #fdf2e2;
  --bad: #c02637;
  --bad-soft: #fdeaec;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px -6px rgba(16, 24, 40, .10);
  --shadow-lg: 0 8px 40px -12px rgba(16, 24, 40, .25);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1d222b;
    --border: #272d37;
    --border-strong: #3a4250;
    --text: #e8ebef;
    --text-2: #9aa4b2;
    --text-3: #6b7482;

    --accent: #818cf8;
    --accent-soft: #232445;
    --ok: #3ecf8e;
    --ok-soft: #12291f;
    --warn: #f0b357;
    --warn-soft: #2c2113;
    --bad: #f4707f;
    --bad-soft: #2e161a;

    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px -6px rgba(0, 0, 0, .5);
    --shadow-lg: 0 8px 40px -12px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: 17px; }
h2 { font-size: 20px; letter-spacing: -.018em; }
h3 { font-size: 14px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------- layout */

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px;
  padding: 0 24px; height: 60px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; margin-right: 4px; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #22d3ee));
}
.brand small { display: block; color: var(--text-3); font-size: 11px; line-height: 1.2; font-weight: 500; }

nav { display: flex; gap: 2px; margin-left: auto; }
nav button {
  padding: 7px 13px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2);
  font-weight: 550; font-size: 13px; cursor: pointer;
  transition: background .12s, color .12s;
}
nav button:hover { background: var(--surface-2); color: var(--text); }
nav button.active { background: var(--accent-soft); color: var(--accent); }
nav .count[hidden] { display: none; }
nav .count {
  display: inline-block; margin-left: 6px; padding: 0 6px;
  border-radius: 20px; background: var(--bad); color: #fff;
  font-size: 11px; font-weight: 650; line-height: 17px; vertical-align: 1px;
}

main { max-width: 1220px; margin: 0 auto; padding: 28px 24px 80px; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } }

.head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.head p { color: var(--text-2); }
.head .spacer { margin-left: auto; }

/* -------------------------------------------------------------- karty */

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px; background: var(--border); overflow: hidden;
  border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 24px;
}
.summary div { background: var(--surface); padding: 16px 18px; }
.summary .label { color: var(--text-3); font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.summary .value { font-size: 26px; font-weight: 680; letter-spacing: -.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.summary .value.ok { color: var(--ok); }
.summary .value.warn { color: var(--warn); }
.summary .value.bad { color: var(--bad); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }

.cand {
  padding: 16px; display: flex; gap: 14px; align-items: center;
  cursor: pointer; transition: border-color .12s, transform .12s;
}
.cand:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.cand .ring { flex: none; position: relative; width: 58px; height: 58px; }
.cand .ring svg { transform: rotate(-90deg); }
.cand .ring circle { fill: none; stroke-width: 6; }
.cand .ring .track { stroke: var(--border); }
.cand .ring .bar { stroke: var(--accent); transition: stroke-dasharray .5s cubic-bezier(.4,0,.2,1); }
.cand .ring.done .bar { stroke: var(--ok); }
.cand .ring .pct {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 12px; font-weight: 680; font-variant-numeric: tabular-nums;
}
.cand .info { min-width: 0; flex: 1; }
.cand .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand .role { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.cand .nums { margin-top: 5px; display: flex; gap: 9px; font-size: 12px; font-variant-numeric: tabular-nums; }
.cand .nums span { white-space: nowrap; }
.cand .nums b { font-weight: 650; }
.cand .nums .g { color: var(--ok); }
.cand .nums .a { color: var(--warn); }
.cand .nums .r { color: var(--bad); }

/* ------------------------------------------------------------- upload */

.drop {
  border: 1.5px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--surface); padding: 34px 20px; text-align: center;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop small { display: block; margin-top: 14px; color: var(--text-3); }

.drop.hero { padding: 44px 24px 34px; margin-bottom: 20px; }
.drop.hero .icon { width: 40px; height: 40px; color: var(--accent); margin-bottom: 10px; }
.drop.hero h2 { font-size: 22px; }
.drop.hero p { color: var(--text-2); margin-top: 4px; }
.drop.hero.over { border-style: solid; }

.drop-actions { display: flex; gap: 10px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.btn.lg { padding: 10px 20px; font-size: 14px; border-radius: 10px; }
.drop-cand { max-width: 300px; margin: 14px auto 0; }

/* Fotoaparát má zmysel len tam, kde naozaj je. */
#cameraBtn { display: none; }
@media (pointer: coarse) { #cameraBtn { display: inline-flex; } }

.queue-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; font-size: 13px;
}
.queue-item .name { font-weight: 600; }
.queue-item .spacer { margin-left: auto; }

.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; margin-bottom: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--accent-soft); border-radius: var(--radius);
}
.banner b { color: var(--text); }
.banner .spacer { margin-left: auto; }
.banner.warn-banner {
  border-color: color-mix(in srgb, var(--warn) 45%, var(--border));
  background: var(--warn-soft);
}

/* ------------------------------------------------------------ tabuľky */

table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 9px 12px; font-size: 11px; font-weight: 650;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody td:last-child { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.warn-text { color: var(--warn); }

.table-wrap { overflow-x: auto; border-radius: var(--radius); }

/* -------------------------------------------------------------- prvky */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.review { background: var(--warn-soft); color: var(--warn); }
.chip.invalid { background: var(--bad-soft); color: var(--bad); }
.chip.neutral { background: var(--surface-2); color: var(--text-2); }
.chip.processing { background: var(--accent-soft); color: var(--accent); }

.flags { display: inline-flex; flex-wrap: wrap; gap: 4px; vertical-align: middle; }
.flag {
  padding: 1px 7px; border-radius: 6px; font-size: 11px; font-weight: 600;
  background: var(--warn-soft); color: var(--warn); cursor: help;
}
.flag.block { background: var(--bad-soft); color: var(--bad); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  font-weight: 550; font-size: 13px; cursor: pointer;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--border)); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn.on-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.on-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input[type=text], select, textarea {
  padding: 7px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--surface); width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: -1px;
  border-color: var(--accent);
}
input.cell {
  border: 1px solid transparent; background: transparent; padding: 4px 6px;
  border-radius: 6px; width: 100%; min-width: 60px;
}
input.cell:hover { border-color: var(--border); }
input.cell.bad { background: var(--bad-soft); }

/* ------------------------------------------------------- detail hárku */

.sheet-detail { display: grid; grid-template-columns: minmax(280px, 40%) 1fr; gap: 18px; align-items: start; }
.sheet-detail > * { min-width: 0; }
@media (max-width: 1000px) { .sheet-detail { grid-template-columns: 1fr; } }
.scan { position: sticky; top: 80px; padding: 10px; overflow: hidden; }
.scan img { width: 100%; border-radius: var(--radius-sm); display: block; cursor: zoom-in; }
.scan embed, .scan iframe { width: 100%; height: 70vh; border: 0; border-radius: var(--radius-sm); }
.scan .zoom { transform-origin: top left; }

.rows-card { overflow: hidden; }
.rows-card .bar {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.rows-card .bar .spacer { margin-left: auto; }

.lightbox {
  position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.85);
  display: grid; place-items: center; padding: 20px; cursor: zoom-out;
}
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; }

/* --------------------------------------------------------- pokrytie */

.cov { font-size: 12px; }
.cov td, .cov th { padding: 6px 8px; }
.cov .cell { text-align: center; width: 30px; }
.cov .yes { color: var(--ok); font-weight: 700; }
.cov .no { color: var(--border-strong); }
.cov .rev { color: var(--warn); font-weight: 700; }
.cov th.vert { height: 110px; white-space: nowrap; }
.cov th.vert span {
  display: inline-block; transform: rotate(180deg); writing-mode: vertical-rl;
  font-weight: 600; font-size: 11px; color: var(--text-2); text-transform: none; letter-spacing: 0;
}
.cov tr.partial { background: var(--warn-soft); }

/* ------------------------------------------------------------ ostatné */

.empty { text-align: center; padding: 56px 20px; color: var(--text-3); }
.empty .icon { font-size: 34px; opacity: .5; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.hint { font-size: 12px; color: var(--text-3); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px;
  border-radius: 30px; box-shadow: var(--shadow-lg); font-weight: 550;
  z-index: 200; animation: pop .2s ease;
}
.toast.err { background: var(--bad); color: #fff; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 8px); } }

.spinner {
  width: 13px; height: 13px; border-radius: 50%; display: inline-block;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------- prihlásenie */

.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 340px; padding: 26px; }
.login .brand { margin-bottom: 22px; }
.login form { display: flex; flex-direction: column; gap: 8px; }
.login label { font-weight: 600; color: var(--text-2); }
.login .btn { justify-content: center; margin-top: 6px; padding: 9px; }
.login .err { color: var(--bad); font-size: 12px; font-weight: 600; }

details.info { margin-top: 18px; }
details.info summary { cursor: pointer; color: var(--text-2); font-weight: 550; }
details.info div { padding: 12px 0; color: var(--text-2); max-width: 70ch; }
details.info li { margin-bottom: 4px; }
