:root {
  --bg: #0a0a0a;
  --panel: #111;
  --border: #222;
  --text: #e8e8e8;
  --muted: #888;
  --accent: #f87225;
  --danger: #d64545;
  --ok: #3d9a6a;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a120c 0%, transparent 55%),
    radial-gradient(800px 400px at 90% 0%, #12181a 0%, transparent 50%),
    var(--bg);
  color: var(--text);
}

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 20px 40px;
  min-height: 100vh;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-screen[hidden],
#app-shell[hidden],
[hidden] {
  display: none !important;
}
.login-card {
  width: min(400px, 100%);
  display: grid;
  gap: 14px;
  padding: 28px 26px;
  background: rgba(13, 13, 13, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.login-brand { margin-bottom: 8px; }
.login-error {
  margin: 0;
  color: #ffb4b4;
  font-size: 0.88rem;
}
.who-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 42px; height: 42px; border-radius: 8px;
  background: linear-gradient(145deg, #f87225, #a03a10);
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px; color: #fff;
}
h1 { margin: 0; font-size: 1.35rem; font-weight: 600; letter-spacing: -0.02em; }
.sub { margin: 4px 0 0; color: var(--muted); font-size: 0.85rem; }
.who {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 6px;
  background: rgba(0,0,0,.35);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 20px;
  align-items: start;
}
.main-col {
  display: grid;
  gap: 20px;
  min-width: 0;
}
.activity-col {
  position: sticky;
  top: 16px;
  align-self: start;
  height: calc(100vh - 96px);
  min-height: 480px;
}
.activity-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(13, 13, 13, 0.9);
  padding: 16px;
  overflow: hidden;
}
.activity-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.activity-head h2 { margin: 0; }
.activity-filters {
  max-width: none;
  grid-template-columns: 88px 1fr;
  gap: 10px;
}
.activity-log {
  flex: 1;
  min-height: 120px;
  max-height: none;
}

.block {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(13, 13, 13, 0.75);
  padding: 20px 18px;
}
h2 { margin: 0 0 8px; font-size: 1.1rem; font-weight: 560; }
h3 {
  margin: 8px 0 6px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.hint { color: var(--muted); font-size: 0.88rem; margin: 0 0 16px; line-height: 1.5; }
.hint code, code {
  font-family: var(--mono); font-size: 0.82em;
  background: #1a1a1a; padding: 1px 6px; border-radius: 4px;
}

.form { display: grid; gap: 12px; max-width: 520px; }
.form.row {
  max-width: none;
  grid-template-columns: 1fr auto;
  align-items: end;
}
@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .activity-col {
    position: static;
    height: auto;
    min-height: 0;
  }
  .activity-panel {
    height: auto;
    max-height: 70vh;
  }
  .activity-log {
    max-height: 220px;
  }
}
@media (max-width: 720px) {
  .form.row,
  .activity-filters { grid-template-columns: 1fr; }
}

label {
  display: grid; gap: 6px;
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
}
input, select, textarea {
  font: inherit; font-size: 0.95rem; text-transform: none; letter-spacing: normal;
  color: var(--text); background: #0d0d0d;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--accent); border-color: #5a3418; }
.check {
  display: flex; align-items: center; gap: 10px;
  text-transform: none; letter-spacing: normal; font-size: 0.9rem; color: var(--text);
}
.check input { width: auto; }

.btn {
  appearance: none; border: 1px solid var(--border);
  background: #181818; color: var(--text);
  padding: 9px 14px; border-radius: 6px; cursor: pointer;
  font: inherit; font-size: 0.85rem; font-weight: 560;
}
.btn:hover { border-color: #444; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: #c45a18; color: #fff; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { background: #2a1212; border-color: #5a2020; color: #ffb4b4; }
.btn.small { padding: 6px 10px; font-size: 0.78rem; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.status-card {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  line-height: 1.45;
}
.status-card.ok {
  border-color: #1e3d2c;
  background: #0e1a14;
  color: #b8e6c9;
}
.status-card.err {
  border-color: #4a1e1e;
  background: #1a0e0e;
  color: #ffc9c9;
}
.status-card .status-title {
  font-weight: 650;
  margin-bottom: 4px;
}
.status-card .status-detail {
  color: inherit;
  opacity: 0.85;
  font-size: 0.85rem;
  font-family: var(--mono);
  word-break: break-all;
}

.log-details {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 12px;
  background: #0d0d0d;
}
.log-details summary {
  cursor: pointer;
  padding: 10px 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.out {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
  background: transparent;
  font-family: var(--mono); font-size: 0.75rem; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word; color: #c8c8c8;
  max-height: 240px; overflow: auto;
}

.cards { display: grid; gap: 14px; margin-top: 16px; }
.card {
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); padding: 16px 18px;
  display: grid;
  gap: 12px;
}
.card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.card h4 {
  margin: 6px 0 0; font-family: var(--mono); font-size: 0.85rem;
  color: var(--accent); word-break: break-all;
}
.meta { display: grid; gap: 4px; font-size: 0.85rem; color: #bbb; }
.meta span { color: var(--muted); }
.badge {
  display: inline-block; font-size: 0.7rem; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 3px 8px; border-radius: 4px;
  border: 1px solid var(--border);
}
.badge.active { color: #8fd6b0; border-color: #1e3d2c; background: #0e1a14; }
.badge.revoked { color: #ffb4b4; border-color: #4a1e1e; background: #1a0e0e; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding-top: 4px;
  border-top: 1px solid #1c1c1c;
}
.card-actions .reason {
  flex: 1 1 160px;
  min-width: 140px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.devices { margin-top: 2px; }
.devices-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.device-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #1c1c1c;
}
.device-row:last-child { border-bottom: 0; }
.device-meta {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #aaa;
  display: grid;
  gap: 2px;
  min-width: 0;
}
.device-meta .hwid { color: #ddd; word-break: break-all; }
.device-empty {
  font-size: 0.82rem;
  color: var(--muted);
  padding: 4px 0;
}

.log {
  border: 1px solid var(--border); border-radius: 8px;
  background: #0d0d0d; overflow: auto;
  font-family: var(--mono); font-size: 0.7rem;
}
.log .row {
  padding: 7px 10px; border-bottom: 1px solid #181818;
  display: grid; grid-template-columns: 72px 1fr; gap: 8px;
}
.log .row:last-child { border-bottom: 0; }
.log .ts { color: var(--muted); }
.log .svc { color: var(--accent); display: block; margin-bottom: 2px; }
.log .msg { color: #cfcfcf; word-break: break-word; }
.empty { padding: 14px; color: var(--muted); font-size: 0.85rem; }

.anomaly-list {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  margin-bottom: 4px;
}
.anomaly-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: #0d0d0d;
  font-size: 0.82rem;
  line-height: 1.4;
}
.anomaly-card.critical {
  border-color: #6a2020;
  background: #1a0c0c;
}
.anomaly-card.high {
  border-color: #6a3a10;
  background: #1a1208;
}
.anomaly-card.medium {
  border-color: #3a3a10;
  background: #14140a;
}
.anomaly-card.low {
  border-color: #222;
}
.anomaly-sev {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 4px;
  border: 1px solid currentColor;
}
.anomaly-card.critical .anomaly-sev { color: #ff9a9a; }
.anomaly-card.high .anomaly-sev { color: #ffb46a; }
.anomaly-card.medium .anomaly-sev { color: #d6d66a; }
.anomaly-card.low .anomaly-sev { color: #888; }
.anomaly-title { font-weight: 650; margin-bottom: 4px; }
.anomaly-detail { color: #bbb; font-size: 0.78rem; }
.anomaly-actors {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #d0c4b0;
  word-break: break-word;
}
.anomaly-evidence {
  margin-top: 8px;
  display: grid;
  gap: 4px;
  max-height: 140px;
  overflow: auto;
}
.anomaly-ev {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 6px;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: #aaa;
  padding: 4px 0;
  border-top: 1px solid #1a1a1a;
}
.anomaly-ev-time { color: var(--muted); }
.anomaly-ev-fields span { color: var(--muted); }
.anomaly-ev-fields { word-break: break-word; }
.anomaly-meta {
  margin-top: 6px;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}
