:root {
  color-scheme: light;
  --ink: #172f40;
  --muted: #506677;
  --accent: #2d5873;
  --navy: #1c3d53;
  --header-color: #1c3d53;
  --header-text: #fff;
  --header-shade: #000;
  --primary-color: #2d5873;
  --primary-text: #fff;
  --lime: #7bc242;
  --line: #cedce5;
  --line-strong: #9db5c6;
  --surface: #fff;
  --canvas: #f3f7fa;
  --canvas-text: #172f40;
  --table-header: #e2edf4;
  --table-stripe: #f6f9fc;
  background: var(--canvas);
  color: var(--ink);
  font: 15px/1.5 system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; }
header {
  background: var(--header-color);
  background: linear-gradient(105deg, var(--header-color), color-mix(in srgb, var(--header-color) 94%, var(--header-shade)));
  border-bottom: 3px solid var(--lime);
  color: var(--header-text);
}
.header, main { max-width: 1260px; margin: auto; padding: 18px 24px; }
.header, nav, .title, .inline { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; }
.header, .title { justify-content: space-between; }
header a { color: inherit; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: 750;
  letter-spacing: -.025em;
  text-decoration: none;
  font-size: 19px;
}
.brand-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 120px;
  max-height: 44px;
  object-fit: contain;
  flex: none;
}
main { padding-block: 26px 60px; color: var(--canvas-text); }
main > .back, main > .title a:not(.button), main > .search a, .paging a { color: inherit; }
h1 { margin: 0 0 12px; line-height: 1.2; font-size: clamp(25px, 4vw, 40px); letter-spacing: -.045em; }
h2 { font-size: 23px; letter-spacing: -.025em; }
.title { margin-bottom: 14px; }
.title h1 { margin: 0; }
.facilities span, dt { color: var(--muted); }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
button, .button { cursor: pointer; font: inherit; font-weight: 650; border: 1px solid transparent; border-radius: 7px; background: var(--primary-color); color: var(--primary-text); text-decoration: none; padding: 9px 14px; }
button:hover, .button:hover { box-shadow: inset 0 0 0 2px currentColor; }
.quiet { background: transparent; color: inherit; border-color: currentColor; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
header :focus-visible { outline-color: var(--lime); }
.card { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 17px; }
.signin { max-width: 420px; margin: 6vh auto; padding: 26px; border-top: 3px solid var(--lime); }
.stack, label { display: grid; gap: 7px; }
.stack { gap: 15px; }
label, summary { font-weight: 650; }
summary { cursor: pointer; }
input, select, textarea { min-width: 0; width: 100%; font: inherit; color: var(--ink); border: 1px solid var(--line-strong); border-radius: 6px; padding: 8px 10px; background: var(--surface); }
.inline { align-items: end; }
details .inline { margin-top: 14px; }
.add, .search { margin-bottom: 16px; }
.search label { width: min(380px, 100%); }
.facilities { list-style: none; padding: 0; display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
.facilities a { display: grid; padding: 13px 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); text-decoration: none; }
.facilities a:hover { border-color: var(--accent); box-shadow: inset 3px 0 var(--lime); }
.facility-view { gap: 6px; }
.facility-view span { margin-inline-end: 8px; }
.facility-view form { display: flex; gap: 6px; }
.facility-view button { padding: 5px 10px; background: transparent; color: inherit; }
.facility-view button[aria-pressed="true"] { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.back { display: inline-block; margin-bottom: 10px; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; background: var(--surface); color: var(--ink); }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; }
thead { background: var(--table-header); color: var(--navy); }
tbody tr:last-child > * { border-bottom: 0; }
tbody tr:nth-child(even) { background: var(--table-stripe); }
tbody tr:focus-within { background: #edf5e6; }
.port-table th, .port-table td { padding-block: 6px; white-space: nowrap; }
.facility-list { min-width: 54rem; }
.api-audit-table { min-width: 44rem; }
.facility-list th, .facility-list td, .api-audit-table th, .api-audit-table td {
  white-space: normal;
  overflow-wrap: normal;
}
.facility-list thead th, .facility-list td:nth-child(5), .facility-list td:nth-child(6) { white-space: nowrap; }
.api-audit-table th, .api-audit-table td:first-child, .api-audit-table td:nth-child(4) { white-space: nowrap; }
.facility-list tr > :first-child { min-width: 9rem; }
.facility-list tr > :nth-child(2) { min-width: 12rem; }
.paging { margin-top: 12px; }
.port-show { padding: 0 2px; border: 0; background: transparent; color: var(--accent); font-size: .8rem; text-decoration: underline; text-underline-offset: 3px; }
.port-show:hover { box-shadow: none; text-decoration-thickness: 2px; }
.port-popup {
  position: fixed;
  inset: auto;
  margin: 0;
  width: max-content;
  max-width: min(360px, calc(100vw - 16px));
  max-height: min(320px, calc(100dvh - 16px));
  overflow: auto;
  padding: 12px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 8px 22px #172f4033;
  white-space: normal;
}
.port-popup dl, .port-popup p { margin: 6px 0 0; }
.port-popup p { white-space: pre-wrap; overflow-wrap: anywhere; }
.port-popup dl > div { display: grid; grid-template-columns: 1fr auto; gap: 16px; }
.fields { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr)); margin-bottom: 15px; }
.wide { grid-column: 1 / -1; }
.facility-info { margin-bottom: 16px; }
.facility-info h2 { margin: 0; }
.facility-info dl { margin: 0; }
dt { font-weight: 650; }
dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.history { margin-bottom: 9px; }
.history .table-wrap { margin-top: 12px; }
.error { color: #a02a1c; }
.delete-facility { margin-top: 24px; }
.danger { background: #a02a1c; color: white; }
.danger:hover { background: #792014; }
.appearance-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; align-items: start; }
.appearance-card h2 { margin-top: 0; }
.appearance-logo { display: block; max-width: min(100%, 260px); max-height: 110px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(135px, 1fr)); gap: 14px; }
.color-grid input { height: 44px; cursor: pointer; padding: 3px; }
.appearance-secondary { margin-top: 12px; }
.secondary { background: var(--surface); color: var(--accent); border-color: var(--line-strong); }
.totp-card { max-width: 520px; }
.totp-card code { overflow-wrap: anywhere; }
.totp-qr { display: block; width: 220px; max-width: 100%; height: auto; }
.recovery-codes { columns: 2 150px; padding-left: 20px; }
.history form.stack, .history details { margin-top: 14px; }
.role-permissions { min-width: 0; border: 1px solid var(--line); border-radius: 8px; }
.role-permissions label { display: flex; align-items: center; margin: 6px 0; font-weight: 500; }
.role-permissions input { width: auto; accent-color: var(--primary-color); }
.role-permissions .api-facility-selector { display: grid; margin-top: 12px; }
