:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --text: #172026;
  --muted: #66727c;
  --line: #d9dee3;
  --panel: #ffffff;
  --green: #1c7c54;
  --orange: #b35c00;
  --red: #b42318;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body.detail-open {
  overflow: hidden;
}

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

.login-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.login-panel label {
  display: grid;
  gap: 7px;
  font-weight: 700;
  color: #34414b;
}

.login-panel input {
  width: 100%;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
}

.shell {
  width: min(1760px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

h1 {
  margin: 0 0 4px;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

p {
  margin: 0;
  color: var(--muted);
}

.button {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

.button.primary {
  justify-content: center;
  border-color: #1d6fe8;
  background: #1d6fe8;
  color: #fff;
}

.button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.button.danger {
  border-color: #f2b8b5;
  color: var(--red);
}

.cell-button {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.cell-button:not(:disabled) {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.cell-button:disabled {
  cursor: default;
  font-weight: 500;
}

.admin-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #1766bd;
}

.admin-url-form {
  padding: 16px 0;
  border-bottom: 1px solid #d9dfe5;
}

.admin-url-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.admin-url-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.admin-url-controls input {
  flex: 1 1 240px;
  min-width: 0;
  max-width: 100%;
}

.site-link {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

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

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.probe-auto-toggle input {
  width: 16px;
  height: 16px;
  padding: 0;
}

.probe-auto-toggle {
  font-size: 13px;
}

.deployment-status {
  font-size: 11px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

button.version-badge {
  border: 0;
  cursor: pointer;
}

.admin-console {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1.2fr);
  gap: 14px;
  margin-bottom: 14px;
}

.mail-console {
  margin-bottom: 14px;
}

.site-form,
.credentials-panel,
.smtp-form,
.inventory-panel {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.smtp-form {
  max-width: 860px;
}

.inventory-console {
  margin-bottom: 14px;
}

.inventory-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

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

.inventory-summary span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.inventory-list {
  overflow: auto;
}

.inventory-table {
  min-width: 760px;
}

.site-form label,
.smtp-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  color: #34414b;
}

.switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
}

.switch-row label,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.switch-row input,
.checkbox-label input {
  min-width: 0;
  min-height: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 160px;
  gap: 12px;
}

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

.form-message {
  min-height: 20px;
  color: var(--muted);
  font-weight: 700;
}

dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

input,
select {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
}

input {
  min-width: min(420px, 100%);
}

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

.site-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(23, 32, 38, 0.28);
}

.site-detail {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 21;
  width: min(680px, 100vw);
  height: 100vh;
  display: grid;
  align-content: start;
  gap: 14px;
  overflow-y: auto;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -18px 0 48px rgba(23, 32, 38, 0.2);
}

.site-detail-header {
  position: sticky;
  top: -18px;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

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

.site-detail-header h2 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.15;
}

.site-detail-header p {
  margin: 0;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.detail-box {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.detail-box h3 {
  margin: 0;
  font-size: 15px;
}

.detail-box p {
  color: var(--muted);
}

.detail-credentials dd {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.detail-box ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  overflow-wrap: anywhere;
}

.compact-dl {
  gap: 6px;
}

.compact-dl div {
  grid-template-columns: 120px minmax(0, 1fr);
}

.alert-list li {
  overflow-wrap: anywhere;
}

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.alert-severity {
  display: inline-flex;
  min-width: 62px;
  justify-content: center;
  margin-right: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.alert-severity.critical {
  background: var(--red);
}

.alert-severity.warning,
.alert-severity.notice {
  background: var(--orange);
}

.ignored-alerts summary {
  color: var(--muted);
  cursor: pointer;
  font-weight: 700;
}

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

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.history-item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.history-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

.history-metrics div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px;
}

.history-item p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.detail-loading {
  padding: 18px;
  color: var(--muted);
  font-weight: 700;
}

.detail-loading.error {
  color: var(--red);
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  min-width: 1280px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
  overflow-wrap: anywhere;
}

th {
  background: #eef1f4;
  color: #3d4a53;
  font-size: 11px;
  text-transform: uppercase;
}

th:nth-child(1),
td:nth-child(1) {
  width: 76px;
}

th:nth-child(2),
td:nth-child(2) {
  width: 58px;
}

th:nth-child(3),
td:nth-child(3) {
  width: 70px;
}

th:nth-child(4),
td:nth-child(4) {
  width: 220px;
}

th:nth-child(5),
td:nth-child(5) {
  width: 76px;
}

th:nth-child(6),
td:nth-child(6) {
  width: 48px;
}

th:nth-child(7),
td:nth-child(7) {
  width: 62px;
}

th:nth-child(8),
td:nth-child(8) {
  width: 76px;
}

th:nth-child(9),
td:nth-child(9),
th:nth-child(10),
td:nth-child(10) {
  width: 66px;
}

th:nth-child(11),
td:nth-child(11),
th:nth-child(12),
td:nth-child(12),
th:nth-child(13),
td:nth-child(13) {
  width: 92px;
}

th:nth-child(14),
td:nth-child(14) {
  width: 82px;
}

th:nth-child(15),
td:nth-child(15) {
  width: 96px;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.sort-button::after {
  content: "";
  color: var(--muted);
  font-size: 11px;
}

.sort-button[data-active="true"][data-direction="asc"]::after {
  content: "▲";
}

.sort-button[data-active="true"][data-direction="desc"]::after {
  content: "▼";
}

small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 64px;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 7px;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.score-badge {
  display: inline-flex;
  width: 38px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
}

.score-badge.pending {
  border: 1px solid var(--line);
  background: #eef1f4;
  color: var(--muted);
}

.contract-pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.contract-pill.yes {
  background: #e7f6ed;
  color: #13744a;
}

.contract-pill.no {
  border: 1px solid var(--line);
  background: #f4f6f8;
  color: var(--muted);
}

.version-badge {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.version-badge.pending {
  border: 1px solid var(--line);
  background: #eef1f4;
  color: var(--muted);
}

.green {
  background: var(--green);
}

.orange {
  background: var(--orange);
}

.red {
  background: var(--red);
}

.details td {
  color: var(--muted);
  background: #fafbfc;
  font-size: 13px;
}

.expanded-details td {
  background: #fff;
}

.detail-panel {
  display: grid;
  gap: 8px;
  max-width: 980px;
}

.detail-panel strong {
  color: var(--text);
}

.detail-panel ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 18px;
}

.detail-panel li {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

@media (max-width: 720px) {
  .shell {
    padding: 16px;
  }

  .topbar,
  .toolbar,
  .admin-console,
  .inventory-header,
  .site-detail-header,
  .form-grid,
  .form-actions,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .admin-console {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  dl div {
    grid-template-columns: 1fr;
  }

  input,
  select,
  .button {
    width: 100%;
  }
}
