:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-alt: #edf2ef;
  --ink: #161616;
  --muted: #66716c;
  --line: #d8dfda;
  --accent: #1f6f5b;
  --accent-dark: #174f42;
  --amber: #9a650d;
  --red: #a83b34;
  --blue: #2f5f8f;
  --sidebar: #fbfcfb;
  --shadow: 0 14px 34px rgba(21, 31, 27, 0.08);
}

* {
  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;
}

.admin-body {
  min-height: 100vh;
}

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);
}

.admin-frame {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  padding: 20px 16px;
  border-right: 1px solid var(--line);
  background: var(--sidebar);
}

.sidebar-branding {
  padding: 4px 6px 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-branding p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.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;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.side-nav a,
.sidebar-account a {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 750;
  text-decoration: none;
}

.side-nav a.active,
.side-nav a:hover,
.sidebar-account a.active,
.sidebar-account a:hover {
  background: var(--surface-alt);
  color: var(--ink);
}

.sidebar-account {
  display: grid;
  gap: 8px;
  margin-top: auto;
  padding: 14px 6px 0;
  border-top: 1px solid var(--line);
}

.sidebar-account span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.sidebar-account strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.sidebar-account form {
  margin: 0;
}

.sidebar-button {
  width: 100%;
}

.admin-main {
  min-width: 0;
}

.admin-toolbar {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 244, 0.92);
  backdrop-filter: blur(10px);
}

.admin-toolbar strong {
  font-size: 18px;
}

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

.topnav form {
  margin: 0;
}

.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(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

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

.dashboard-head {
  align-items: center;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.page-subtitle {
  max-width: 720px;
  margin: 8px 0 0;
  color: var(--muted);
}

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

.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;
}

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

.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;
  box-shadow: var(--shadow);
}

.metric-emphasis {
  border-color: rgba(31, 111, 91, 0.4);
  background: linear-gradient(180deg, #ffffff, #f3faf6);
}

.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;
  box-shadow: var(--shadow);
}

.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-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.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;
}

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

.dense-table th,
.dense-table td {
  padding-top: 10px;
  padding-bottom: 10px;
}

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;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.dashboard-primary {
  margin-bottom: 0;
}

.dashboard-side {
  display: grid;
  gap: 18px;
}

.dashboard-side .panel {
  margin-bottom: 0;
}

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

.advanced-panel {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.advanced-panel summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.advanced-panel textarea {
  margin-top: 10px;
}

.status-list {
  display: grid;
  gap: 0;
}

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

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

.status-row strong,
.status-row span {
  display: block;
}

.status-row div span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.status-row-subtle {
  padding-top: 8px;
  padding-bottom: 8px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 13px;
}

.inventory-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.inventory-list div {
  padding: 14px;
  border-right: 1px solid var(--line);
}

.inventory-list div:last-child {
  border-right: 0;
}

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

.inventory-list strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.panel-note {
  padding: 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="email"],
input[type="password"],
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;
}

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

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

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

.credential-fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.credential-fieldset legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-panel {
  width: min(420px, 100%);
  margin: 56px auto;
}

.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) {
  .admin-frame,
  .dashboard-grid {
    display: block;
  }

  .admin-sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .admin-toolbar {
    display: none;
  }

  .topbar,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topnav {
    flex-wrap: wrap;
  }

  .metric-grid,
  .metric-grid-small,
  .split,
  .grid-form,
  .criteria-grid,
  .quick-scan-grid,
  .dashboard-metrics,
  .inventory-list {
    grid-template-columns: 1fr;
  }

  .dashboard-side {
    margin-top: 18px;
  }

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

  th,
  td {
    padding: 10px;
  }
}
