:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #d8dde5;
  --text: #1c2430;
  --muted: #667085;
  --ok: #146c43;
  --warn: #9a5b00;
  --bad: #b42318;
  --blue: #1d4ed8;
  --nav: #172033;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 232px 1fr;
}

.sidebar {
  background: var(--nav);
  color: #eef2ff;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  padding: 4px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-title {
  font-weight: 720;
  font-size: 18px;
}

.brand-sub {
  color: #aeb8ce;
  margin-top: 4px;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav button {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 10px 10px;
  color: #dbe5ff;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.main {
  min-width: 0;
}

.topbar {
  height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 720;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.band {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.band-header {
  min-height: 44px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.band-title {
  font-weight: 700;
}

.band-body {
  padding: 14px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.cols-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid.cols-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.grid.cols-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 88px;
  background: #fbfcfe;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  margin-top: 8px;
  font-size: 22px;
  font-weight: 760;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 720;
  border: 1px solid transparent;
}

.status.ok {
  color: var(--ok);
  background: #eaf6ef;
  border-color: #b9e3c8;
}

.status.warn {
  color: var(--warn);
  background: #fff4d9;
  border-color: #ffd999;
}

.status.bad {
  color: var(--bad);
  background: #ffeceb;
  border-color: #ffc9c5;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.compact-cell {
  display: block;
  max-width: 420px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.source-note {
  margin-top: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.error-text {
  margin: 0 0 8px;
  color: var(--bad);
  font-weight: 700;
}

.table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  background: #fbfcfe;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.button,
a.button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-height: 34px;
  padding: 7px 10px;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.button.danger {
  border-color: #f1b3ae;
  color: var(--bad);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.logbar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.logbar input,
.logbar select,
.policy-toolbar select,
.top-actions select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-height: 34px;
  padding: 7px 10px;
}

.policy-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.policy-builder {
  display: grid;
  gap: 12px;
}

.policy-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.policy-field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.policy-field input,
.policy-field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  min-height: 34px;
  padding: 7px 10px;
}

.policy-field.wide {
  width: 100%;
}

.policy-small-textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--text);
  font: 13px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.policy-editors {
  align-items: stretch;
}

.policy-editor {
  min-width: 0;
}

.policy-textarea {
  width: 100%;
  min-height: 520px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfe;
  color: var(--text);
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.logbox {
  background: #101828;
  color: #d0d5dd;
  border-radius: 8px;
  padding: 14px;
  min-height: 360px;
  max-height: 560px;
  overflow: auto;
  white-space: pre-wrap;
  line-height: 1.45;
}

.incident-list {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 420px;
}

.incident-menu {
  border-right: 1px solid var(--line);
  background: #fbfcfe;
}

.incident-menu button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 12px;
  cursor: pointer;
}

.incident-menu button.active {
  background: #eef4ff;
  color: var(--blue);
  font-weight: 720;
}

.incident-detail {
  padding: 16px;
}

.section-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  margin: 14px 0 6px;
}

.plain-list {
  margin: 0;
  padding-left: 18px;
}

.footer-note {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .grid.cols-4,
  .grid.cols-5,
  .grid.cols-6,
  .grid.cols-2,
  .incident-list {
    grid-template-columns: 1fr;
  }
}
