:root {
  color-scheme: dark;
  --bg: #080b0e;
  --surface: #0e1318;
  --surface-2: #121922;
  --line: #26313c;
  --line-soft: #1b242d;
  --text: #e8eef5;
  --muted: #8794a2;
  --cyan: #31c7ce;
  --green: #31c48d;
  --amber: #f2bd4d;
  --red: #ff6670;
  --violet: #b794f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Consolas", "SFMono-Regular", ui-monospace, monospace;
  font-size: 12px;
  letter-spacing: 0;
}

button,
input { font: inherit; }

.monitor-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(8, 11, 14, 0.97);
}

.monitor-brand,
.monitor-runtime,
.monitor-toolbar,
.section-head,
.search-control,
.check-control {
  display: flex;
  align-items: center;
}

.monitor-brand { gap: 8px; }
.monitor-brand a { color: var(--cyan); text-decoration: none; }
.monitor-brand strong { font-size: 15px; }
.monitor-brand span { color: var(--muted); }
.monitor-brand .venue { color: var(--amber); }

.monitor-runtime {
  justify-content: flex-end;
  gap: 16px;
  color: var(--muted);
  white-space: nowrap;
}

.runtime-state { color: var(--muted); }
.runtime-state i {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--muted);
}
.runtime-state.running { color: var(--green); }
.runtime-state.running i { background: var(--green); }
.runtime-state.error { color: var(--red); }
.runtime-state.error i { background: var(--red); }

.monitor-main {
  width: 100%;
  padding: 12px;
  display: grid;
  gap: 12px;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(7, minmax(110px, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}

.summary-item {
  min-width: 0;
  padding: 10px 12px;
  border-right: 1px solid var(--line);
}
.summary-item:last-child { border-right: 0; }
.summary-item span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 5px;
  text-transform: uppercase;
}
.summary-item strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 17px;
}
.summary-item strong.good { color: var(--green); }
.summary-item strong.warn { color: var(--amber); }
.summary-item strong.bad { color: var(--red); }

.monitor-toolbar {
  min-height: 42px;
  gap: 12px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.active-view-switch,
.compact-control {
  display: flex;
  align-items: center;
  gap: 5px;
}
.active-view-switch { gap: 2px; }
.active-view-switch button {
  width: 30px;
  padding: 0;
  font-size: 16px;
}
.active-view-switch button.active {
  border-color: var(--cyan);
  color: var(--cyan);
  background: #0b171b;
}
.compact-control span {
  color: var(--muted);
  font-size: 10px;
}
.compact-control select {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 7px;
  outline: none;
  background: #070a0d;
  color: var(--text);
  font: inherit;
}
.compact-control select:focus { border-color: var(--cyan); }

.search-control { gap: 8px; color: var(--muted); }
.search-control input {
  width: 180px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #070a0d;
  color: var(--text);
  padding: 5px 8px;
  outline: none;
}
.search-control input:focus { border-color: var(--cyan); }
.check-control { gap: 7px; color: var(--muted); }
.check-control input { accent-color: var(--amber); }

button {
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 11px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
button:hover { border-color: var(--cyan); }
button:disabled { cursor: wait; opacity: 0.55; }
.refresh-error { margin-left: auto; color: var(--red); }
.danger-button,
.row-ban-button { border-color: var(--red); color: var(--red); }
.row-ban-button {
  width: 48px;
  height: 24px;
  padding: 2px 6px;
}
.row-ban-button.is-banned { color: var(--muted); border-color: var(--line); }
.unban-button { height: 26px; color: var(--green); border-color: var(--green); }
.icon-button {
  width: 30px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.ban-manager-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.ban-manager-dialog::backdrop { background: rgba(0, 0, 0, 0.78); }
.ban-manager-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.ban-manager-head h2 { margin: 0 0 4px; font-size: 14px; }
.ban-manager-head span,
.ban-form label > span { color: var(--muted); font-size: 10px; }
.ban-form {
  display: grid;
  grid-template-columns: 180px minmax(260px, 1fr) auto;
  align-items: end;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.ban-form label { display: grid; gap: 5px; }
.ban-form input {
  width: 100%;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 8px;
  outline: none;
  background: #070a0d;
  color: var(--text);
}
.ban-form input:focus { border-color: var(--cyan); }
.ban-manager-status {
  min-height: 34px;
  padding: 9px 14px;
  color: var(--muted);
  border-bottom: 1px solid var(--line-soft);
}
.ban-list-viewport { max-height: 500px; overflow: auto; }
.ban-list-table { min-width: 760px; }
.ban-list-table th:nth-child(2),
.ban-list-table td:nth-child(2) { text-align: left; }
.ban-reason-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.state-section {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}
.active-section { border-top: 2px solid var(--amber); }
.disarmed-section { border-top: 2px solid var(--violet); }

.section-head {
  min-height: 48px;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 11px;
  border-bottom: 1px solid var(--line);
}
.section-head h1 { margin: 0 0 3px; font-size: 13px; }
.section-head span { color: var(--muted); font-size: 10px; }
.section-state {
  padding: 3px 7px;
  border: 1px solid currentColor;
  border-radius: 3px;
}
.section-state.armed { color: var(--amber); }
.section-state.disarmed { color: var(--violet); }

.table-viewport {
  max-height: 43vh;
  overflow: auto;
}
.disarmed-viewport { max-height: 48vh; }

table {
  width: 100%;
  min-width: 1460px;
  border-collapse: collapse;
  font-size: 11px;
}
th,
td {
  height: 31px;
  padding: 6px 8px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #141b23;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) { text-align: left; }
tbody tr:hover td { background: #141b22; }

.episode-row { cursor: pointer; }

.symbol-cell { color: var(--text); font-weight: 700; }
.tag {
  display: inline-block;
  min-width: 42px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  text-align: center;
  color: var(--muted);
}
.tag.high,
.tag.armed { border-color: var(--amber); color: var(--amber); }
.tag.disarmed { border-color: var(--violet); color: var(--violet); }
.tag.exit { border-color: var(--red); color: var(--red); }
.tag.sent { border-color: var(--green); color: var(--green); }
.positive { color: var(--green); }
.warning { color: var(--amber); }
.negative { color: var(--red); }
.muted { color: var(--muted); }
.empty-row td {
  height: 60px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 900px) {
  .monitor-header { align-items: flex-start; flex-direction: column; }
  .monitor-runtime { width: 100%; justify-content: flex-start; overflow-x: auto; }
  .summary-band { grid-template-columns: repeat(3, minmax(100px, 1fr)); }
  .summary-item { border-bottom: 1px solid var(--line); }
  .monitor-toolbar { align-items: flex-start; flex-wrap: wrap; }
  .compact-control { flex: 1 1 auto; }
  .refresh-error { width: 100%; margin-left: 0; }
  .ban-form { grid-template-columns: 1fr; align-items: stretch; }
  .ban-form button { justify-self: start; }
}

@media (max-width: 520px) {
  .monitor-main { padding: 8px; }
  .monitor-brand { flex-wrap: wrap; }
  .summary-band { grid-template-columns: repeat(2, minmax(100px, 1fr)); }
  .summary-item { border-bottom: 1px solid var(--line); }
  .summary-item:nth-child(2n) { border-right: 0; }
  .summary-item:nth-last-child(-n + 2) { border-bottom: 0; }
  .search-control { width: 100%; }
  .search-control input { flex: 1; min-width: 0; }
}
