:root {
  --brand: #054B90;
  --brand-dark: #03396d;
  --brand-soft: #e8f0f9;
  --accent: #f5b800;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #6b7686;
  --line: #e2e7ee;
  --ok: #1f8a4c;
  --ok-soft: #e6f5ec;
  --warn: #b26a00;
  --warn-soft: #fff4dc;
  --err: #c0392b;
  --err-soft: #fdecea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: 'IBM Plex Mono', ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: 'Montserrat', system-ui, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}
[hidden] { display: none !important; }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- Horná lišta ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px; height: 60px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--brand); flex-shrink: 0; }
.brand img { height: 26px; }
.brand span { font-weight: 600; font-size: 13px; padding-left: 12px; border-left: 1px solid var(--line); white-space: nowrap; }
#nav { display: flex; gap: 2px; flex: 1; }
#nav a {
  padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap;
}
#nav a:hover { background: var(--bg); color: var(--text); }
#nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; white-space: nowrap; }
.who .role { font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 0; font-size: 22px; color: var(--brand); cursor: pointer; }

@media (max-width: 960px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .nav-toggle { display: block; }
  #nav, .who { display: none; width: 100%; }
  .topbar.open #nav { display: flex; flex-direction: column; }
  .topbar.open .who { display: flex; justify-content: space-between; padding-top: 8px; border-top: 1px solid var(--line); }
  .brand span { display: none; }
}

/* ---------- Obsah ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 60px; }
@media (max-width: 600px) { main { padding: 16px; } }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.loading { color: var(--muted); padding: 40px 0; text-align: center; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 700; color: var(--brand); margin-top: 4px; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- Tabuľky ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.toolbar input[type=search] { flex: 1; min-width: 200px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: #fafbfc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--brand-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 30px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }
.badge.info { background: var(--brand-soft); color: var(--brand); }
.badge.off { background: #eef0f3; color: var(--muted); }

/* ---------- Formuláre ---------- */
input, select, textarea, button { font: inherit; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfd6df; border-radius: 8px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); font-weight: 500; }
.check input { width: auto; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: #fff; color: var(--brand); border-color: #cfd6df; }
.btn.secondary:hover { background: var(--brand-soft); }
.btn.ghost { background: none; color: var(--muted); padding: 6px 10px; }
.btn.ghost:hover { color: var(--text); background: var(--bg); }
.btn.danger { background: var(--err); }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

.alert { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert.err { background: var(--err-soft); color: var(--err); }
.alert.warn { background: var(--warn-soft); color: #7a4a00; }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.info { background: var(--brand-soft); color: var(--brand-dark); }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Prihlásenie ---------- */
.auth-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .logo { display: block; width: 220px; max-width: 80%; margin: 0 auto 6px; }
.auth-card .subtitle { text-align: center; color: var(--muted); margin-bottom: 22px; font-weight: 500; }
.auth-card .btn { width: 100%; justify-content: center; }

/* ---------- Modálne okno ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto;
}
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 620px; padding: 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.modal-head h2 { margin: 0; font-size: 18px; }
.modal-head .x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }

.dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; margin: 0 0 16px; }
.dl dt { color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 1px; }
.dl dd { margin: 0; word-break: break-word; }
@media (max-width: 600px) { .dl { grid-template-columns: 1fr; } .dl dd { margin-bottom: 6px; } }
.section-title { font-size: 13px; font-weight: 700; color: var(--brand); text-transform: uppercase; letter-spacing: .04em; margin: 18px 0 10px; }

.secret { font-family: var(--mono); font-size: 18px; background: var(--brand-soft); color: var(--brand-dark); padding: 12px; border-radius: 8px; text-align: center; letter-spacing: .05em; user-select: all; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); font-weight: 500;
}
.toast.err { background: var(--err); }

.picker-results { display: flex; flex-direction: column; margin: 6px 0 14px; border-radius: 8px; overflow: hidden; }
.picker-results:not(:empty) { border: 1px solid var(--line); }
.picker-results button { text-align: left; background: #fff; border: 0; border-bottom: 1px solid var(--line); padding: 9px 12px; cursor: pointer; }
.picker-results button:last-child { border-bottom: 0; }
.picker-results button:hover { background: var(--brand-soft); }
.picked { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px; background: var(--brand-soft); margin-bottom: 14px; }

.verify { margin-bottom: 16px; }
.verify label { font-size: 14px; color: var(--text); margin-bottom: 8px; }
.verify-row { display: flex; gap: 10px; margin-bottom: 6px; }
.verify-row input { font-family: var(--mono); font-size: 18px; letter-spacing: .06em; text-transform: uppercase; }
.status-banner { padding: 14px 16px; border-radius: 8px; font-size: 16px; font-weight: 700; margin-bottom: 16px; text-align: center; }
.status-banner.ok { background: var(--ok-soft); color: var(--ok); }
.status-banner.info { background: var(--brand-soft); color: var(--brand); }
.status-banner.warn { background: var(--warn-soft); color: var(--warn); }
.status-banner.err { background: var(--err-soft); color: var(--err); }

.dropzone {
  border: 2px dashed #cfd6df; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; background: #fafbfc;
}
.dropzone.drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
