:root {
  color-scheme: light;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-muted: #f1f5f9;
  --border: #d6dde8;
  --text: #172033;
  --muted: #64748b;
  --success: #15803d;
  --success-bg: #dcfce7;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --warning: #a16207;
  --warning-bg: #fef3c7;
  --info-bg: #dbeafe;
  --shadow: 0 14px 28px rgb(15 23 42 / 8%);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
}

.brand-mark {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
}

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

.nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--text);
  font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
  background: var(--info-bg);
  color: var(--accent-dark);
  text-decoration: none;
}

.session-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.session-label,
.detail-label,
.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.session-token,
.mono,
.mono-link {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
}

.main-content {
  min-width: 0;
  padding: 32px;
}

.page {
  display: grid;
  gap: 20px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-header h1,
.login-panel h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.15;
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.back-link {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.9rem;
  font-weight: 700;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

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

.button.primary {
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.button.danger {
  background: var(--danger);
  color: #ffffff;
}

.full-width {
  width: 100%;
}

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

.panel,
.metric {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.metrics-grid,
.detail-grid,
.split-grid {
  display: grid;
  gap: 16px;
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.metric {
  display: grid;
  gap: 8px;
  padding: 22px;
}

.metric strong {
  font-size: 1.45rem;
}

.detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.detail-grid > div {
  display: grid;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.split-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stack {
  display: grid;
  gap: 14px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.field,
.compact-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field input,
.field select,
.field textarea,
.compact-field input,
.compact-field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}

.field input,
.field select,
.compact-field input,
.compact-field select {
  height: 40px;
  padding: 8px 10px;
}

.field textarea {
  min-height: 120px;
  padding: 10px;
  resize: vertical;
}

.filter-bar,
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
}

.pagination {
  justify-content: space-between;
}

.pagination-buttons {
  display: flex;
  gap: 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

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

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

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.badge.good,
.status-ok,
.status-text.good {
  color: var(--success);
}

.badge.good {
  background: var(--success-bg);
}

.badge.bad,
.status-text.bad {
  color: var(--danger);
}

.badge.bad {
  background: var(--danger-bg);
}

.badge.info,
.status-text.info {
  color: var(--accent-dark);
}

.badge.info {
  background: var(--info-bg);
}

.badge.muted,
.status-muted {
  color: var(--muted);
}

.badge.muted {
  background: var(--surface-muted);
}

.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
}

.alert.error {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert.success {
  background: var(--success-bg);
  color: var(--success);
}

.alert.warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.json-viewer {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 10px 12px;
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent-dark);
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 2px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    gap: 14px;
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

  .session-box {
    margin-top: 0;
  }

  .main-content {
    padding: 20px 16px;
  }

  .page-header {
    display: grid;
  }

  .pagination {
    justify-content: flex-start;
  }
}
