/* Panel servera. Tamna tema je osnovna, svetla prati podesavanje telefona. */
:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f5;
  --line: #dde1ea;
  --text: #151922;
  --muted: #5d6576;
  --accent: #5b52e0;
  --ok: #138a5a;
  --warn: #b7791f;
  --bad: #d23f37;
  --ok-bg: rgba(19, 138, 90, 0.1);
  --warn-bg: rgba(183, 121, 31, 0.12);
  --bad-bg: rgba(210, 63, 55, 0.1);
  --spark: #5b52e0;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117;
    --surface: #151a22;
    --surface-2: #1c2230;
    --line: #262e3d;
    --text: #e7eaf0;
    --muted: #8d95a6;
    --accent: #968ff7;
    --ok: #3ecf8e;
    --warn: #f0b429;
    --bad: #f36b63;
    --ok-bg: rgba(62, 207, 142, 0.12);
    --warn-bg: rgba(240, 180, 41, 0.13);
    --bad-bg: rgba(243, 107, 99, 0.14);
    --spark: #968ff7;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #151a22;
  --surface-2: #1c2230;
  --line: #262e3d;
  --text: #e7eaf0;
  --muted: #8d95a6;
  --accent: #968ff7;
  --ok: #3ecf8e;
  --warn: #f0b429;
  --bad: #f36b63;
  --ok-bg: rgba(62, 207, 142, 0.12);
  --warn-bg: rgba(240, 180, 41, 0.13);
  --bad-bg: rgba(243, 107, 99, 0.14);
  --spark: #968ff7;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }

.app {
  max-width: 1180px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
}

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

/* ---------- prijava ---------- */
.login {
  max-width: 360px;
  margin: 12vh auto 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.02em; }
.login p { margin: 0; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input {
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  font-size: 17px;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.field input.code { font-family: var(--mono); letter-spacing: 0.3em; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  cursor: pointer;
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; height: 48px; }
.btn--small { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn--danger { color: var(--bad); }
.btn:disabled { opacity: 0.55; cursor: default; }

/* ---------- zaglavlje ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 14px;
}
.top h1 { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.top .sub { margin: 2px 0 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- traka stanja ---------- */
.verdict {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.verdict--ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.verdict--warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.verdict--bad { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.verdict h2 { margin: 0; font-size: 17px; }
.verdict ul { margin: 6px 0 0; padding-left: 18px; }
.verdict li { margin: 2px 0; }

/* ---------- mreza ---------- */
.grid { display: grid; gap: 14px; }
@media (min-width: 820px) {
  .grid { grid-template-columns: 1fr 1fr; align-items: start; }
  .span-2 { grid-column: 1 / -1; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px 12px;
  min-width: 0;
}
.card h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* redovi */
.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 4px 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row .name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.row .meta { grid-column: 2 / -1; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.row .end { text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.row .spark { grid-column: 2 / -1; }

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--bad { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-bg); }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}
.tag--ok { background: var(--ok-bg); color: var(--ok); }
.tag--warn { background: var(--warn-bg); color: var(--warn); }
.tag--bad { background: var(--bad-bg); color: var(--bad); }

/* merila */
.meters { display: grid; gap: 12px; }
.meter .label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; font-variant-numeric: tabular-nums; }
.meter .label span:last-child { color: var(--muted); }
.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 12px 0 2px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.spark svg { display: block; width: 100%; height: 28px; }
.spark path.line { fill: none; stroke: var(--spark); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark path.area { fill: var(--spark); opacity: 0.12; }
.spark rect.down { fill: var(--bad); opacity: 0.55; }

details.errors { grid-column: 2 / -1; font-size: 13px; }
details.errors summary { cursor: pointer; color: var(--warn); min-height: 28px; display: flex; align-items: center; }
details.errors pre {
  margin: 6px 0 0;
  padding: 10px;
  background: var(--surface-2);
  border-radius: 10px;
  font: 12px/1.45 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 260px;
  overflow: auto;
}

.log { list-style: none; margin: 0; padding: 0; font: 12.5px/1.5 var(--mono); color: var(--muted); }
.log li { padding: 5px 0; border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.log li:first-child { border-top: 0; }
.empty { color: var(--muted); font-size: 14px; margin: 4px 0; }

.foot { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 14px;
  max-width: calc(100% - 32px);
  z-index: 10;
}

@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color 0.15s ease, opacity 0.15s ease; }
}

.row a.name { color: inherit; text-decoration: none; }
.row a.name:hover { color: var(--accent); }
