:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #eef3f7;
  --border: #d7dee6;
  --text: #17212b;
  --muted: #667385;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warning: #b54708;
  --shadow: 0 10px 24px rgba(23, 33, 43, 0.08);
}

* {
  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;
  font-size: 15px;
  line-height: 1.45;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--text);
  font-weight: 800;
  white-space: nowrap;
}

.nav {
  display: flex;
  flex: 1;
  gap: 6px;
}

.nav a,
.ghost-button,
button,
.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border-radius: 6px;
  font: inherit;
}

.nav a {
  padding: 0 12px;
  color: var(--muted);
}

.nav a.active,
.nav a:hover {
  background: var(--surface-soft);
  color: var(--text);
  text-decoration: none;
}

button,
.primary-link {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 14px;
}

button:hover,
.primary-link:hover {
  background: var(--accent-dark);
  text-decoration: none;
}

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

.ghost-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
}

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

.page {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  margin-bottom: 14px;
  font-size: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.visually-hidden {
  position: absolute;
  width: 1px !important;
  min-height: 1px !important;
  height: 1px !important;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.alert.success {
  border-color: #99d5c9;
  color: #14532d;
}

.alert.error {
  border-color: #f0a9a1;
  color: var(--danger);
}

.login-panel {
  width: min(420px, 100%);
  margin: 12vh auto 0;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-grid,
.split-grid,
.content-grid,
.detail-grid {
  display: grid;
  gap: 20px;
}

.split-grid > *,
.content-grid > *,
.detail-grid > *,
.metric-grid > * {
  min-width: 0;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
}

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

.metric {
  min-height: 112px;
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 34px;
}

.split-grid {
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.7fr);
}

.content-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: start;
}

.detail-grid {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  align-items: start;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin-bottom: 10px;
}

.section-title h2 {
  margin-bottom: 0;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.pill.ok {
  background: #dcfce7;
  color: #166534;
}

.empty {
  color: var(--muted);
  padding: 16px;
}

.list {
  overflow: hidden;
}

.list-row {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.list-row:last-child {
  border-bottom: 0;
}

.list-row span {
  color: var(--muted);
}

.list-row:hover {
  background: var(--surface-soft);
  text-decoration: none;
}

.list-row.static:hover {
  background: transparent;
}

.side-panel,
.message-panel {
  padding: 20px;
}

.stacked-form {
  display: grid;
  gap: 10px;
}

.stacked-form.compact {
  margin-top: 14px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

textarea,
.body-text,
.json-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  line-height: 1.55;
}

textarea {
  resize: vertical;
}

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

.checkbox input {
  width: 16px;
  min-height: 16px;
}

.inline-form,
.actions,
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inline-form input {
  width: 96px;
}

.filter-bar {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.filter-bar select {
  width: min(240px, 100%);
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 18px;
}

.meta-grid div {
  min-width: 0;
}

.meta-grid dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.meta-grid dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.body-text,
.json-box {
  overflow: auto;
  max-height: 58vh;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fbfcfd;
  white-space: pre-wrap;
}

.json-box {
  max-height: 220px;
}

@media (max-width: 1000px) {
  .metric-grid,
  .split-grid,
  .content-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 18px;
  }

  .nav {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
  }
}

@media (max-width: 640px) {
  .page {
    padding: 18px;
  }

  .page-heading,
  .filter-bar,
  .actions,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .meta-grid {
    grid-template-columns: 1fr;
  }

  .inline-form input {
    width: 100%;
  }
}
