/* Sistemske pisave (brez zunanjih fontov), svetla in temna tema po nastavitvi sistema. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5f6672;
  --border: #e2e5ea;
  --accent: #2563eb;
  --up: #15803d;
  --up-bg: #dcfce7;
  --down: #b91c1c;
  --down-bg: #fee2e2;
  --unknown: #6b7280;
  --unknown-bg: #eceef1;
  --paused: #a16207;
  --paused-bg: #fef3c7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #181b21;
    --text: #e8eaee;
    --muted: #9aa1ad;
    --border: #2a2f38;
    --accent: #60a5fa;
    --up: #4ade80;
    --up-bg: #12301f;
    --down: #f87171;
    --down-bg: #3a1717;
    --unknown: #a1a8b3;
    --unknown-bg: #262a31;
    --paused: #facc15;
    --paused-bg: #3a3214;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
}
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 0.8rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
[hidden] { display: none !important; }

/* ---------- zgornja vrstica ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { white-space: nowrap; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.brand:hover { text-decoration: none; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--up);
  box-shadow: 0 0 0 4px var(--up-bg); }
nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
nav a { color: var(--muted); font-weight: 500; }
nav a.active { color: var(--text); }
.me { font-size: 0.85rem; }

.container { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1rem; }

/* ---------- kartice in gumbi ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  font: inherit; font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--down); }
.btn.danger:hover { border-color: var(--down); }
.btn.ghost { background: transparent; }
.btn.small { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
.linkbtn { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }

/* ---------- obrazci ---------- */
label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; font-weight: 500; }
input, select {
  font: inherit; font-weight: 400;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.hint { color: var(--muted); font-weight: 400; font-size: 0.8rem; }
.error {
  color: var(--down); background: var(--down-bg);
  border-radius: 8px; padding: 0.55rem 0.8rem; margin: 0.6rem 0; font-size: 0.9rem;
}

.auth { max-width: 380px; margin: 3rem auto; display: flex; flex-direction: column; gap: 0.9rem; padding: 2rem; }
.auth p { margin: 0; }
.auth .btn.primary { margin-top: 0.3rem; }

.grid-form { display: grid; grid-template-columns: 1fr 2fr 1fr; gap: 0.8rem; }
.add-form details { margin: 0.8rem 0 0; }
.add-form summary { cursor: pointer; color: var(--muted); font-size: 0.85rem; margin-bottom: 0.6rem; }
.add-form > .btn { margin-top: 0.9rem; }

/* ---------- statistika ---------- */
.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.8rem; margin-bottom: 1rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.9rem 1.1rem; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.85rem; }
.stat.up .stat-value { color: var(--up); }
.stat.down .stat-value { color: var(--down); }
.stat.unknown .stat-value { color: var(--unknown); }

/* ---------- značke stanja ---------- */
.badge {
  display: inline-block; min-width: 4.2rem; text-align: center;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 0.25rem 0.6rem; border-radius: 999px;
}
.badge.up { color: var(--up); background: var(--up-bg); }
.badge.down { color: var(--down); background: var(--down-bg); }
.badge.unknown { color: var(--unknown); background: var(--unknown-bg); }
.badge.paused { color: var(--paused); background: var(--paused-bg); }

/* ---------- seznam monitorjev ---------- */
.monitor { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr) auto; gap: 1rem; align-items: center;
  border-left: 4px solid var(--unknown); }
.monitor.up { border-left-color: var(--up); }
.monitor.down { border-left-color: var(--down); }
.monitor.paused { border-left-color: var(--paused); opacity: 0.85; }
.monitor-head { display: flex; gap: 0.8rem; align-items: center; min-width: 0; }
.monitor-title { display: flex; flex-direction: column; min-width: 0; }
.monitor-name { font-weight: 600; color: var(--text); }
.monitor-url { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.monitor-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin: 0; }
.monitor-stats dt { color: var(--muted); font-size: 0.75rem; }
.monitor-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.monitor-actions { display: flex; gap: 0.4rem; }
.empty { text-align: center; padding: 2rem; }
.empty p { margin: 0.2rem 0; }

/* ---------- podrobnosti ---------- */
.page-head .back { width: 100%; font-size: 0.9rem; }
.detail-title { display: flex; align-items: center; gap: 0.8rem; }
.detail-url { width: 100%; word-break: break-all; font-size: 0.9rem; }
.chart-wrap { width: 100%; }
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.chart-dot { fill: var(--accent); }
.chart-fail { fill: var(--down); opacity: 0.35; }
.chart-empty { fill: var(--muted); font-size: 14px; }
.legend { font-size: 0.8rem; display: flex; align-items: center; gap: 0.4rem; margin: 0.5rem 0 0; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.35rem; }
.dot.up { background: var(--up); }
.dot.down { background: var(--down); }
.legend .dot.down { margin-left: 0.8rem; }

.incidents { list-style: none; margin: 0; padding: 0; }
.incidents li { display: flex; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.incidents li:last-child { border-bottom: 0; }
.inc-state { font-weight: 600; min-width: 4rem; }
.incidents .open .inc-state { color: var(--down); }
.incidents .resolved .inc-state { color: var(--up); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 0.8rem; padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border); }
td { padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
tr.fail td { background: var(--down-bg); }
.role { font-size: 0.8rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 6px; background: var(--unknown-bg); }
.role.admin { background: var(--paused-bg); color: var(--paused); }

/* ---------- obvestila ---------- */
.toast {
  position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 0.7rem 1.1rem; border-radius: 8px; font-size: 0.9rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); max-width: calc(100% - 2rem);
}
.toast.error { background: var(--down); color: #fff; }

/* ---------- telefon ---------- */
@media (max-width: 800px) {
  .monitor { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-form { grid-template-columns: 1fr; }
  .me { display: none; }
}
@media (max-width: 480px) {
  .monitor-stats { grid-template-columns: repeat(2, 1fr); }
  .container { padding: 1rem 0.75rem 3rem; }
  .topbar { padding: 0.6rem 0.75rem; }
}

/* ---------- obvestila ---------- */
.lead { margin: -0.4rem 0 1rem; }
.alerts-form { grid-template-columns: 1fr 3fr; }
.channel { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 1rem; align-items: center; }
.channel-target { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, monospace; font-size: 0.85rem; }
.role.webhook { background: var(--up-bg); color: var(--up); }
@media (max-width: 800px) {
  .alerts-form { grid-template-columns: 1fr; }
  .channel { grid-template-columns: 1fr; }
}
