:root {
  --bg: #e8e4dc;
  --bg-deep: #d9d3c7;
  --ink: #1a211c;
  --muted: #5c675f;
  --panel: rgba(255, 252, 245, 0.82);
  --line: rgba(26, 33, 28, 0.12);
  --ok: #1f7a4c;
  --warn: #b86e00;
  --crit: #a32020;
  --signal: #0f6e6a;
  --glow: rgba(15, 110, 106, 0.18);
  --radius: 14px;
  --font: "Sora", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(15, 110, 106, 0.16), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(184, 110, 0, 0.10), transparent 50%),
    linear-gradient(165deg, var(--bg), var(--bg-deep));
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(26, 33, 28, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 33, 28, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(to bottom, black, transparent 90%);
}

.mono { font-family: var(--mono); }

.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.4rem 1.6rem 0.6rem;
  max-width: 1200px;
  margin: 0 auto;
}

.brand { display: flex; gap: 0.9rem; align-items: center; }

.mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background:
    linear-gradient(145deg, var(--signal), #0a4f4c 70%),
    repeating-linear-gradient(-45deg, transparent, transparent 4px, rgba(255,255,255,0.12) 4px, rgba(255,255,255,0.12) 5px);
  box-shadow: 0 10px 30px var(--glow);
}

.eyebrow {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0.1rem 0 0;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.top-meta { display: flex; gap: 0.6rem; align-items: center; }

.pill {
  font-size: 0.75rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.pill-ok { color: var(--ok); border-color: rgba(31, 122, 76, 0.35); }
.pill-warn { color: var(--warn); }
.pill-crit { color: var(--crit); border-color: rgba(163, 32, 32, 0.35); }
.pill-muted { color: var(--muted); }

.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.8rem 1.6rem 2.5rem;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.8rem;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  backdrop-filter: blur(8px);
}

.kpi-label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.kpi-value {
  margin: 0.35rem 0 0;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.9rem 0 1.1rem;
}

.status-chip {
  font-family: var(--mono);
  font-size: 0.72rem;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 252, 245, 0.55);
  color: var(--muted);
}

.status-chip.on { color: var(--ok); border-color: rgba(31,122,76,0.3); }
.status-chip.warn { color: var(--warn); }
.status-chip.crit { color: var(--crit); }

.grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem 1rem;
  backdrop-filter: blur(8px);
  min-height: 220px;
}

.panel.wide { grid-column: 1; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.7rem;
}

.panel-head.sub { margin-top: 1.1rem; }

.panel-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.hint { color: var(--muted); font-size: 0.75rem; }

.table-wrap { overflow: auto; max-height: 340px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th, td {
  text-align: left;
  padding: 0.45rem 0.35rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

td.ip { font-family: var(--mono); font-weight: 500; }
.reason { color: var(--muted); font-size: 0.75rem; max-width: 280px; }

.empty { color: var(--muted); font-size: 0.85rem; padding: 0.6rem 0; }

.rank {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rank li {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.84rem;
}

.rank .bar-wrap {
  flex: 1;
  height: 6px;
  border-radius: 99px;
  background: rgba(26, 33, 28, 0.08);
  align-self: center;
  overflow: hidden;
}

.rank .bar {
  height: 100%;
  background: linear-gradient(90deg, var(--signal), #1aa39c);
  border-radius: inherit;
}

.feed {
  max-height: 360px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.feed-compact { max-height: 360px; }

.alert-card {
  border: 1px solid var(--line);
  border-left: 3px solid var(--signal);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  background: rgba(255,255,255,0.45);
}

.alert-card.crit { border-left-color: var(--crit); }
.alert-card.high { border-left-color: var(--warn); }

.alert-card pre {
  margin: 0.25rem 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.4;
}

.audit-line {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--line);
}

.foot {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  padding-bottom: 1.5rem;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.2rem;
  background: #fffdf8;
  max-width: 360px;
  width: calc(100% - 2rem);
}

dialog::backdrop { background: rgba(26, 33, 28, 0.45); }

dialog h3 { margin: 0 0 0.4rem; }
dialog p { margin: 0 0 0.8rem; color: var(--muted); font-size: 0.9rem; }
dialog input {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-family: var(--mono);
  margin-bottom: 0.7rem;
}
dialog button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 0.7rem;
  background: var(--signal);
  color: white;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
}

@media (max-width: 900px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: 1fr; }
  .panel.wide { grid-column: auto; }
  .top { flex-direction: column; align-items: flex-start; }
}
