:root {
  --blue: #2B3D80;
  --green: #80BA42;
  --blue-soft: #e8ebf5;
  --green-soft: #eef6e5;
  --bg: #f4f5f9;
  --surface: #ffffff;
  --text: #1b2033;
  --muted: #5d6478;
  --line: #dfe2eb;
  --shadow: 0 1px 3px rgba(20, 28, 60, .08);
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --blue: #7f93dd;
    --green: #92c95a;
    --blue-soft: #1f2748;
    --green-soft: #1f2d17;
    --bg: #0f1220;
    --surface: #181c2e;
    --text: #e6e8f0;
    --muted: #9aa1b5;
    --line: #2a3048;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --blue: #7f93dd;
  --green: #92c95a;
  --blue-soft: #1f2748;
  --green-soft: #1f2d17;
  --bg: #0f1220;
  --surface: #181c2e;
  --text: #e6e8f0;
  --muted: #9aa1b5;
  --line: #2a3048;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
a { color: var(--blue); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- barra superior ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: #2B3D80; color: #fff;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  display: flex; align-items: center; gap: 10px;
}
.top h1 { font-size: 17px; margin: 0; font-weight: 650; flex: 1; letter-spacing: .2px; }
.top .back { background: none; border: 0; color: #fff; font-size: 22px; padding: 0 6px 0 0; cursor: pointer; }
.nodes { display: flex; gap: 8px; font-size: 12px; }
.node { display: inline-flex; align-items: center; gap: 5px; background: rgba(255,255,255,.12); padding: 3px 8px; border-radius: 99px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa1b5; display: inline-block; }
.dot.ok { background: #80BA42; }
.dot.bad { background: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.35); animation: pulse 1s infinite alternate; }
.dot.down { background: var(--blue); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }

main { max-width: 860px; margin: 0 auto; padding: 14px 16px; }

/* ---------- navegacion inferior ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a.on { color: var(--blue); font-weight: 600; }

/* ---------- componentes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px;
}
.card h2 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 10px; }

.seg { display: flex; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; overflow-x: auto; }
.seg button {
  flex: 1; border: 0; background: none; padding: 7px 8px; border-radius: 7px; cursor: pointer;
  white-space: nowrap; color: var(--muted); font-size: 13px;
}
.seg button.on { background: var(--blue); color: #fff; font-weight: 600; }

.btn {
  border: 1px solid var(--blue); background: var(--blue); color: #fff;
  padding: 10px 14px; border-radius: 10px; cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.ghost { background: transparent; color: var(--blue); }
.btn.green { background: var(--green); border-color: var(--green); color: #14200a; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 6px 10px; font-size: 13px; }

.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface);
}
.input:focus { outline: 2px solid var(--blue); outline-offset: -1px; }
label.f { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }

/* ---------- incidentes ---------- */
.inc {
  display: flex; gap: 12px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.inc .bar { width: 4px; border-radius: 4px; background: var(--line); flex: none; }
.inc.s-open .bar { background: var(--blue); }
.inc.s-acknowledged .bar { background: repeating-linear-gradient(180deg, var(--blue) 0 6px, transparent 6px 10px); }
.inc.s-recovered .bar { background: var(--green); }
.inc .t { font-weight: 600; }
.inc .d { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .3px;
  padding: 2px 8px; border-radius: 99px; text-transform: uppercase;
  border: 1px solid var(--blue); color: var(--blue);
}
.badge.critical { background: var(--blue); color: #fff; }
.badge.warning { background: var(--blue-soft); }
.badge.info { border-color: var(--line); color: var(--muted); }
.badge.open { background: var(--blue); color: #fff; }
.badge.acknowledged { background: var(--blue-soft); }
.badge.recovered { border-color: var(--green); background: var(--green-soft); color: var(--text); }
.badge.resolved { border-color: var(--green); background: var(--green); color: #14200a; }

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

.actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.act {
  border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  padding: 12px 10px; cursor: pointer; text-align: left; display: flex; gap: 8px; align-items: center;
}
.act .e { font-size: 20px; }
.act.on { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 12px 20px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li::before {
  content: ""; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--surface); border: 2px solid var(--blue);
}
.timeline li.k-resolved::before, .timeline li.k-recovered::before { border-color: var(--green); background: var(--green); }
.timeline li.k-notified::before { border-color: var(--line); }
.timeline .when { font-size: 12px; color: var(--muted); }

.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photos a { display: block; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--blue-soft); }
.photos img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview { max-width: 160px; border-radius: 10px; display: block; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2B3D80; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 50;
  box-shadow: 0 4px 14px rgba(0,0,0,.2); max-width: calc(100% - 32px);
}
.banner { background: var(--blue-soft); border: 1px solid var(--blue); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }

.login { max-width: 380px; margin: 8vh auto 0; }
.brand { text-align: center; margin-bottom: 18px; }
.brand .logo { width: 64px; height: 64px; }
.brand h1 { margin: 8px 0 0; font-size: 22px; color: var(--blue); }
.brand p { margin: 2px 0 0; color: var(--muted); }

code.tok { display: block; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; word-break: break-all; }
details summary { cursor: pointer; }
