:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-alt: #f0eee8;
  --ink: #161616;
  --muted: #6b665e;
  --line: #d8d3c9;
  --accent: #1f6f5b;
  --accent-dark: #174f42;
  --amber: #9a650d;
  --red: #a83b34;
  --blue: #2f5f8f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  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-thickness: 1px;
  text-underline-offset: 3px;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 58px;
  padding: 0 28px;
  background: rgba(247, 246, 242, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0;
  text-decoration: none;
}

.environment {
  margin-left: 10px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.topnav a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 650;
}

.topnav a.active,
.topnav a:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.admin-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

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

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

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1.15;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 17px;
}

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

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

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

.metric {
  min-height: 86px;
  padding: 14px;
}

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

.metric strong {
  display: block;
  margin-top: 12px;
  overflow-wrap: anywhere;
  font-size: 26px;
  line-height: 1.1;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.panel {
  margin-bottom: 18px;
  overflow: hidden;
}

.panel-overflow-visible {
  overflow: visible;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head a {
  font-size: 13px;
  font-weight: 700;
}

.form-panel {
  padding: 16px;
}

.form-panel h2 {
  margin-bottom: 14px;
}

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

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

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

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

td.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.status-good {
  border-color: rgba(31, 111, 91, 0.35);
  color: var(--accent-dark);
  background: rgba(31, 111, 91, 0.08);
}

.status-bad {
  border-color: rgba(168, 59, 52, 0.35);
  color: var(--red);
  background: rgba(168, 59, 52, 0.08);
}

.tooltip {
  position: relative;
  display: inline-flex;
  margin-left: 6px;
  vertical-align: middle;
}

.tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  cursor: help;
}

.tooltip-panel {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  display: none;
  width: min(380px, 78vw);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  box-shadow: 0 12px 30px rgba(22, 22, 22, 0.22);
  color: #fff;
  font-size: 13px;
  line-height: 1.4;
  white-space: normal;
}

.tooltip:hover .tooltip-panel,
.tooltip:focus-within .tooltip-panel {
  display: block;
}

.button,
input[type="submit"].button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.button-primary,
input[type="submit"].button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button-ghost,
input[type="submit"].button-ghost {
  background: transparent;
}

.button:hover,
input[type="submit"].button:hover {
  border-color: var(--ink);
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.criteria-section {
  margin: 4px 0 0;
  padding: 14px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.criteria-section legend {
  padding: 0 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.criteria-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

label span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.checkline span {
  margin: 0;
}

.form-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
}

.flash {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-weight: 650;
}

.flash-notice {
  border-color: rgba(31, 111, 91, 0.35);
  background: rgba(31, 111, 91, 0.08);
  color: var(--accent-dark);
}

.flash-alert {
  border-color: rgba(168, 59, 52, 0.35);
  background: rgba(168, 59, 52, 0.08);
  color: var(--red);
}

.summary,
.json-block {
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  background: #fbfaf7;
}

.json-block {
  max-height: 520px;
}

@media (max-width: 900px) {
  .topbar,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topnav {
    flex-wrap: wrap;
  }

  .metric-grid,
  .metric-grid-small,
  .split,
  .grid-form,
  .criteria-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  th,
  td {
    padding: 10px;
  }
}
