:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e6;
  --text: #1f2328;
  --muted: #656d76;
  --accent: #0969da;
  --accent-text: #ffffff;
  --up: #1a7f37;
  --up-bg: #dafbe1;
  --degraded: #bc4c00;
  --degraded-bg: #fff1e5;
  --down: #cf222e;
  --down-bg: #ffebe9;
  --warn: #9a6700;
  --warn-bg: #fff8c5;
  --pending: #8c959f;
  --pending-bg: #eaeef2;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 8px 24px rgba(0, 0, 0, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2129;
    --border: #30363d;
    --text: #e6edf3;
    --muted: #8d96a0;
    --accent: #4493f8;
    --accent-text: #0d1117;
    --up: #3fb950;
    --up-bg: rgba(46, 160, 67, .15);
    --degraded: #f0883e;
    --degraded-bg: rgba(219, 109, 40, .15);
    --down: #f85149;
    --down-bg: rgba(248, 81, 73, .15);
    --warn: #d29922;
    --warn-bg: rgba(187, 128, 9, .15);
    --pending: #6e7681;
    --pending-bg: rgba(110, 118, 129, .15);
    --shadow: 0 8px 24px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
/* atribut hidden musí přebít display z tříd (.pill, .btn…) */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 28px 0 10px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Hlavička */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { width: 14px; height: 14px; border-radius: 50%; background: var(--up); box-shadow: 0 0 0 4px var(--up-bg); }
.summary { display: flex; gap: 8px; flex: 1; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; }
.user { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid var(--border); }

/* Přihlašovací stránka */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; padding: 0; margin: 0;
}
.login-body { padding: 28px 28px 24px; text-align: center; }
.login-body .brand { justify-content: center; }
.login-body h1 { font-size: 22px; }
.login-body > p { margin: 6px 0 20px; }
.btn.google {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  padding: 10px 14px; font-size: 15px; font-weight: 600; background: var(--surface); text-decoration: none;
}
.btn.google:hover { background: var(--surface-2); text-decoration: none; }
.login-body .small { margin: 14px 0 0; }
.notice { padding: 9px 12px; border-radius: 6px; text-align: left; }
.notice.error { color: var(--down); background: var(--down-bg); }
.notice.ok { color: var(--up); background: var(--up-bg); }
.notice.warn { color: var(--warn); background: var(--warn-bg); margin: 0; }
form.dev { padding: 16px 28px 20px; background: var(--warn-bg); border-top: 1px solid var(--border); }
form.dev p { margin: 0 0 8px; }
form.dev .row { display: flex; gap: 8px; }
.btn.dev-btn { background: var(--warn); border-color: var(--warn); color: #fff; font-weight: 600; }

main { max-width: 1400px; margin: 0 auto; padding: 16px 24px 48px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.toolbar input { max-width: 320px; }

/* Ovládací prvky */
.btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 6px; padding: 6px 12px; font: inherit; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--down); }
.btn.sm { padding: 3px 8px; font-size: 12px; }

input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 6px 9px;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }

/* Odznaky stavu */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.up { color: var(--up); background: var(--up-bg); }
.pill.degraded { color: var(--degraded); background: var(--degraded-bg); }
.pill.down { color: var(--down); background: var(--down-bg); }
.pill.pending { color: var(--pending); background: var(--pending-bg); }
.pill.warn { color: var(--warn); background: var(--warn-bg); }
.pill.off { color: var(--muted); background: var(--pending-bg); }
.pill.big { font-size: 13px; padding: 4px 12px; }

.tag {
  display: inline-block; font-size: 11px; padding: 0 6px; border-radius: 4px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); vertical-align: 1px;
}
/* Štítky webů – barva podle textu (--h = odstín) */
.label {
  display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px;
  background: hsl(var(--h, 210) 70% 92%); color: hsl(var(--h, 210) 55% 30%); border: 0; line-height: 1.6;
}
@media (prefers-color-scheme: dark) {
  .label { background: hsl(var(--h, 210) 35% 22%); color: hsl(var(--h, 210) 70% 80%); }
}
.site-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 4px; font-weight: 400; }
.tag-suggest:empty { display: none; }
button.label.add { cursor: pointer; font: inherit; font-size: 11px; font-weight: 600; opacity: .75; }
button.label.add:hover { opacity: 1; }

.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; margin: -4px 0 12px; }
.tag-filter:empty { display: none; }
.filter-chip {
  font: inherit; font-size: 12px; padding: 3px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.filter-chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.filter-chip[style] { border-color: hsl(var(--h) 50% 70%); }
.filter-chip.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.filter-chip.active .n { color: inherit; opacity: .8; }

/* Záhlaví skupiny: podklad a proužek v barvě štítku, oddělené od předchozí skupiny */
.sites tr.group-row td {
  background: hsl(var(--h, 220) 45% 94%);
  border-left: 5px solid hsl(var(--h, 220) 55% 55%);
  border-top: 10px solid var(--bg);
  border-bottom: 1px solid hsl(var(--h, 220) 40% 80%);
  padding: 12px 14px; font-size: 15px; font-weight: 700; cursor: pointer; user-select: none;
}
.sites tbody tr.group-row:first-child td { border-top: 0; }
.sites tr.group-row:hover td { background: hsl(var(--h, 220) 50% 90%); }
.sites tr.group-row.no-tag td { background: var(--surface-2); border-left-color: var(--pending); border-bottom-color: var(--border); }
.sites tr.group-row .label { font-size: 14px; padding: 3px 12px; }
.sites tr.group-row .muted { font-size: 13px; font-weight: 600; margin-left: 4px; }
.sites tr.group-row .pill { margin-left: 6px; font-size: 12px; }
.sites tr.group-row .caret { display: inline-block; width: 16px; color: hsl(var(--h, 220) 45% 40%); font-size: 13px; }
@media (prefers-color-scheme: dark) {
  .sites tr.group-row td {
    background: hsl(var(--h, 220) 30% 16%);
    border-left-color: hsl(var(--h, 220) 60% 60%);
    border-bottom-color: hsl(var(--h, 220) 30% 28%);
  }
  .sites tr.group-row:hover td { background: hsl(var(--h, 220) 32% 20%); }
  .sites tr.group-row .caret { color: hsl(var(--h, 220) 60% 75%); }
}
.toolbar label.check { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.toolbar label.check input { width: auto; }

.tag.tag-warn { color: var(--warn); background: var(--warn-bg); border-color: transparent; font-weight: 600; }

/* Tabulka webů */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
table.sites { width: 100%; border-collapse: collapse; }
.sites th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.sites th.num { text-align: right; }
.sites td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sites tr:last-child td { border-bottom: 0; }
.sites tbody tr { cursor: pointer; }
.sites tbody tr:hover { background: var(--surface-2); }
.site-name { font-weight: 600; }
.site-url { font-size: 12px; color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-msg { font-size: 12px; margin-top: 3px; max-width: 360px; }
.site-msg.down { color: var(--down); }
.site-msg.degraded { color: var(--degraded); }
.cell-actions { text-align: right; white-space: nowrap; }
.exp-warn { color: var(--warn); font-weight: 600; }
.exp-bad { color: var(--down); font-weight: 600; }
.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.spark { display: block; }
.spark rect.up { fill: var(--up); }
.spark rect.degraded { fill: var(--degraded); }
.spark rect.down { fill: var(--down); }

.empty { padding: 40px; text-align: center; color: var(--muted); }

/* Události */
.events { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.events li { display: flex; gap: 12px; align-items: baseline; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.events li:last-child { border-bottom: 0; }
.events time { color: var(--muted); font-size: 12px; white-space: nowrap; min-width: 120px; }
.events .ev-site { font-weight: 600; white-space: nowrap; }
.events .ev-msg { color: var(--muted); }
.events li.none { color: var(--muted); }

/* Dialogy */
dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow);
  width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
}
dialog.wide { width: min(920px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { margin: 0 0 14px; font-size: 17px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.grid label .muted { font-weight: 400; }
.span2 { grid-column: span 2; }
fieldset.checks { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
label.check { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
label.check input { width: auto; }
.dialog-actions { display: flex; gap: 8px; margin-top: 18px; }
.spacer { flex: 1; }
.error { color: var(--down); margin: 12px 0 0; }

/* Detail */
.detail-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.detail-head h2 { margin: 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin: 16px 0; }
.kv div { background: var(--surface-2); border-radius: 6px; padding: 8px 10px; }
.kv dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.kv dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; word-break: break-word; }
.problems { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.problems li { display: flex; gap: 10px; align-items: baseline; }
.vuln-list { font-size: 13px; margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.vuln-list a { font-weight: 600; white-space: nowrap; }
.asset-list { font-size: 12px; margin: 6px 0 0; padding-left: 18px; word-break: break-all; }
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .dot { fill: var(--accent); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.chart .area { fill: var(--accent); opacity: .08; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart .down-bar { fill: var(--down); opacity: .35; }
.chart .degraded-bar { fill: var(--degraded); opacity: .25; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); z-index: 50;
}

@media (max-width: 1100px) { .hide-md { display: none; } }
@media (max-width: 760px) {
  .hide-sm { display: none; }
  .top, main { padding-left: 16px; padding-right: 16px; }
  .grid, fieldset.checks { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .site-url, .site-msg { max-width: 200px; }
}
