:root {
  --bg: #e8edf2;
  --bg-elev: #f7f9fb;
  --ink: #142033;
  --muted: #5a6b7d;
  --line: #c5d0dc;
  --accent: #0d6e6e;
  --accent-ink: #063838;
  --crit: #b42318;
  --crit-bg: #fdecea;
  --high: #b54708;
  --high-bg: #fff4e5;
  --med: #175cd3;
  --med-bg: #eff4ff;
  --ok: #067647;
  --shadow: 0 10px 30px rgba(20, 32, 51, 0.08);
  --font: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.4;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 420px at 8% -10%, rgba(13, 110, 110, 0.14), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(180, 35, 24, 0.08), transparent 55%),
    linear-gradient(180deg, #f3f6f9 0%, var(--bg) 40%, #dfe7ef 100%);
}

.top {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 249, 251, 0.88);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; gap: 0.85rem; align-items: center; }
.mark {
  width: 2.6rem; height: 2.6rem;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 0.45rem;
}
.brand h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.sub { margin: 0.1rem 0 0; color: var(--muted); font-size: 0.85rem; }

.auth {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.auth label { font-size: 0.8rem; color: var(--muted); }
.auth input {
  border: 1px solid var(--line);
  background: #fff;
  padding: 0.45rem 0.65rem;
  border-radius: 0.35rem;
  font: inherit;
  min-width: 12rem;
}
.auth button, .toolbar select {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 0.45rem 0.85rem;
  border-radius: 0.35rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.toolbar select {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  font-weight: 500;
}

.pill {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill.on { background: #e8f8ef; color: var(--ok); border-color: #abefc6; }
.pill.off { background: #f2f4f7; color: var(--muted); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  padding: 0.9rem 1.4rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.45);
}
.toolbar label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.toolbar .check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.9rem;
  color: var(--ink);
  padding-bottom: 0.35rem;
}
.stats {
  margin-left: auto;
  display: flex;
  gap: 1rem;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  padding-bottom: 0.35rem;
}
.stats strong { color: var(--ink); }

main { padding: 1rem 1.4rem 2.5rem; max-width: 1100px; margin: 0 auto; }

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.65rem;
}

.alert-row {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 0.95rem;
  align-items: stretch;
  padding: 0.75rem;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  animation: enter 280ms ease-out;
}
.alert-row:hover { border-color: #9aafc2; }
.alert-row.flash { outline: 2px solid var(--accent); }

@keyframes enter {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.thumb {
  width: 160px;
  min-height: 100px;
  border-radius: 0.35rem;
  overflow: hidden;
  background: #0f1720;
  display: grid;
  place-items: center;
}
.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  min-height: 100px;
  max-height: 140px;
}
.thumb.empty {
  color: #8aa0b5;
  font-size: 0.75rem;
  font-family: var(--mono);
}

.body { min-width: 0; padding: 0.15rem 0.35rem 0.15rem 0; }
.row-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.row-top h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  flex: 1;
  min-width: 10rem;
}
.prio {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.3rem 0.45rem;
  border-radius: 0.3rem;
  white-space: nowrap;
}
.prio.p0, .prio.p1 { background: var(--crit-bg); color: var(--crit); }
.prio.p2 { background: var(--high-bg); color: var(--high); }
.prio.p3, .prio.p4, .prio.p5 { background: var(--med-bg); color: var(--med); }

.meta {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.meta span { margin-right: 0.75rem; }
.meta .warn { color: var(--high); font-weight: 600; }
.meta .ok { color: var(--ok); font-weight: 600; }
.desc {
  margin: 0.55rem 0 0;
  color: var(--ink);
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.when {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  margin-left: auto;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 3rem 1rem;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  padding: 0;
  width: min(720px, 94vw);
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(20, 32, 51, 0.35); }
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  margin: 0;
}
.detail-head h2 { margin: 0; font-size: 1.05rem; }
.detail-head button {
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--muted);
}
.detail-body { padding: 1rem; display: grid; gap: 1rem; }
.detail-media {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: start;
}
.detail-body img {
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #0f1720;
  border-radius: 0.35rem;
}
#detail-crop {
  width: 160px;
  max-height: 220px;
  object-fit: cover;
}
.detail-desc {
  margin: 0;
  padding: 0.85rem 0 0;
  border-top: 1px solid var(--line);
  white-space: pre-wrap;
  line-height: 1.5;
  font-size: 0.98rem;
}
.detail-body dl {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 0.35rem 0.75rem;
  margin: 0;
  font-size: 0.9rem;
}
.detail-body dt { color: var(--muted); }
.detail-body dd { margin: 0; font-family: var(--mono); font-size: 0.82rem; }

@media (max-width: 700px) {
  .alert-row { grid-template-columns: 1fr; }
  .thumb { width: 100%; }
  .thumb img { max-height: 200px; }
  .detail-media { grid-template-columns: 1fr; }
  #detail-crop { width: 100%; max-height: 200px; }
  .stats { margin-left: 0; width: 100%; }
}
