:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  --canvas: #111d2c;
  --sidebar: #142234;
  --surface: #192a3e;
  --surface-soft: #20334a;
  --field: #132337;
  --ink: #f2f6fc;
  --muted: #a9bdd4;
  --line: #32485f;
  --control-line: #516b87;
  --accent: #91c5ff;
  --accent-strong: #c8e2ff;
  --primary: #1764ba;
  --primary-hover: #1d70cd;
  --active: #233f5e;
  --focus: #a5d2ff;
  --good: #8fe1b4;
  --good-bg: #1d3a3b;
  --warn: #ffd394;
  --warn-bg: #3c332e;
  --danger: #ffbebd;
  --danger-bg: #3e2c38;
  --nav-width: clamp(198px, 17vw, 236px);
  --page-width: 1450px;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: radial-gradient(ellipse at 90% 0, #1a2d44 0, transparent 55%), var(--canvas);
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button, summary, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
input, select, textarea { min-width: 0; }
summary { overflow-wrap: anywhere; }
h1, h2, h3, p, dl, dd { margin: 0; }
h1 {
  font-size: clamp(1.95rem, 3.35vw, 2.85rem);
  font-weight: 750;
  letter-spacing: -.052em;
  line-height: 1.08;
}
h2 { font-size: 1.19rem; font-weight: 700; letter-spacing: -.027em; line-height: 1.23; }
h3 { font-size: .98rem; font-weight: 680; line-height: 1.32; }
code { font: .86em var(--mono); overflow-wrap: anywhere; }
time { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.skip-link {
  position: fixed;
  z-index: 10;
  top: .5rem;
  left: .5rem;
  padding: .6rem 1rem;
  border-radius: 6px;
  background: var(--surface);
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.site-header { background: var(--sidebar); }
.site-header-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 22px;
  min-height: 72px;
  padding-inline: clamp(16px, 4vw, 32px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  justify-self: start;
  color: var(--ink);
  line-height: 1.2;
  text-decoration: none;
}
.brand-mark { display: block; flex: 0 0 auto; width: 38px; height: 38px; }
.brand-text { display: grid; gap: 3px; }
.brand-text strong { font-size: 1.04rem; letter-spacing: -.035em; white-space: nowrap; }
.brand-text span { color: var(--muted); font-size: .76rem; }

.site-nav { display: flex; gap: 5px; }
.site-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding-inline: 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 650;
  text-decoration: none;
}
.site-nav a:hover { color: var(--ink); background: var(--surface-soft); }
.site-nav a[aria-current="page"] { color: var(--accent-strong); background: var(--active); }
.nav-icon {
  position: relative;
  display: inline-block;
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  color: var(--accent);
}
.nav-machines::before, .nav-machines::after {
  position: absolute;
  left: 1px;
  right: 1px;
  height: 6px;
  border: 1px solid currentColor;
  border-radius: 2px;
  content: "";
}
.nav-machines::before { top: 1px; }
.nav-machines::after { bottom: 1px; }
.nav-updates::before {
  position: absolute;
  inset: 6px 1px 1px;
  border: 1px solid currentColor;
  border-top: 0;
  border-radius: 0 0 2px 2px;
  content: "";
}
.nav-updates::after {
  position: absolute;
  top: 2px;
  left: 5px;
  width: 6px;
  height: 6px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg);
  content: "";
}
.logout { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.operator-name {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: .84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page { width: min(var(--page-width), 100%); min-width: 0; margin-inline: auto; padding: 35px clamp(16px, 3.5vw, 50px) 56px; }
.page-heading { margin-bottom: 24px; }
.page-heading p { margin-top: 7px; color: var(--muted); font-size: .91rem; }
.dashboard-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 14px 22px;
}
.surface { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 22px;
  padding: 18px 20px;
}
.section-heading p { margin-top: 4px; color: var(--muted); font-size: .82rem; }
.empty { padding: 20px; color: var(--muted); font-size: .92rem; }
.empty strong { color: var(--ink); }
.empty p { margin-top: 4px; }
.hint { color: var(--muted); font-size: .83rem; }
.back-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  gap: 8px;
  margin-bottom: 10px;
  font-size: .86rem;
  font-weight: 650;
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; text-underline-offset: .2em; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; }
.overview-metrics {
  background: linear-gradient(100deg, var(--surface-soft), var(--surface) 75%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.metric { min-width: 0; padding: 15px 18px; border-inline-end: 1px solid var(--line); }
.metric:last-child { border-inline-end: 0; }
.metric dt { color: var(--muted); font-size: .79rem; line-height: 1.25; font-weight: 650; }
.metric dd {
  margin-top: 5px;
  font-size: clamp(1.25rem, 2.28vw, 1.88rem);
  font-weight: 740;
  letter-spacing: -.043em;
  line-height: 1.17;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.overview-metrics .metric:nth-child(2) dd:not(.metric-detail) { color: var(--good); }
.metric dd.metric-detail { margin-top: 4px; color: var(--muted); font-size: .73rem; font-weight: 500; letter-spacing: 0; line-height: 1.25; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 680;
  line-height: 1.22;
  text-align: center;
  text-decoration: none;
}
.button-primary { color: #fff; background: var(--primary); border-color: #3687dc; }
.button-primary:hover { background: var(--primary-hover); }
.button-secondary { color: var(--accent-strong); border-color: var(--control-line); background: var(--surface-soft); }
.button-secondary:hover, .button-quiet:hover { color: var(--ink); background: var(--active); }
.button-danger { color: var(--danger); border-color: #8c5665; background: var(--danger-bg); }
.button-danger:hover { background: #553444; }
.button-quiet { color: var(--muted); border-color: var(--line); background: transparent; }

.registration { position: relative; align-self: start; justify-self: end; min-width: 0; }
.registration > summary { position: relative; width: max-content; max-width: 100%; list-style: none; }
.registration > summary::-webkit-details-marker { display: none; }
.registration-plus { display: inline-block; font-size: 1.23em; line-height: 1; }
.registration[open] .registration-plus { transform: rotate(45deg); }
.registration-form {
  position: absolute;
  z-index: 3;
  top: calc(100% + 10px);
  right: 0;
  width: min(36rem, calc(100vw - var(--nav-width) - 65px));
  padding: 18px 20px;
  background: var(--surface);
  box-shadow: 0 15px 36px #050d19a6;
}
.registration-form .button { margin-top: 14px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); align-items: start; gap: 13px; }
.form-grid > .field:last-child { grid-column: 1 / -1; }
.form-stack, .field { display: grid; min-width: 0; align-content: start; }
.form-stack { gap: 16px; }
.field { gap: 5px; color: var(--muted); font-size: .81rem; font-weight: 650; }
.field input, .field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--control-line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--field);
  font-size: .91rem;
  font-weight: 500;
}
.field small { font-weight: 500; }
.field input::placeholder { color: var(--muted); opacity: 1; }
.notice { margin-bottom: 14px; padding: 10px 13px; border: 1px solid; border-radius: 8px; font-size: .88rem; overflow-wrap: anywhere; }
.notice-error { color: var(--danger); border-color: #8c5665; background: var(--danger-bg); }
.notice-success { color: var(--good); border-color: #467967; background: var(--good-bg); }

.filters { display: flex; align-items: flex-end; gap: 10px; }
.filters .field:first-child { min-width: 171px; }
.filters .field:last-child { min-width: 134px; }
.data-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .86rem; }
.data-table th, .data-table td { padding: 13px 10px; text-align: left; vertical-align: middle; overflow-wrap: anywhere; }
.data-table thead th {
  border-block: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 650;
}
.data-table tbody tr { border-bottom: 1px solid var(--line); }
.data-table tbody tr:last-child { border-bottom: 0; }
.data-table tbody tr:hover, .data-table tbody tr:focus-within { background: #20344b; }
.data-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }
.roster-table thead th:nth-child(1) { width: 25%; }
.roster-table thead th:nth-child(2) { width: 21%; }
.roster-table thead th:nth-child(3) { width: 18%; }
.roster-table thead th:nth-child(4) { width: 10%; }
.report-table thead th:nth-child(1), .report-table thead th:nth-child(2) { width: 23%; }
.machine-link {
  display: inline-block;
  color: var(--accent-strong);
  font-weight: 720;
  text-decoration: none;
  text-underline-offset: .19em;
}
.machine-link:hover, .machine-link:focus-visible { text-decoration: underline; }
.machine-link-indicator { margin-left: 3px; color: var(--accent); font-size: .77rem; white-space: nowrap; }
.cell-detail { display: block; margin-top: 4px; color: var(--muted); font-size: .76rem; font-weight: 480; }
.version-tag { font: .77rem var(--mono); color: var(--muted); }
.mobile-label { display: none; }
.filtered-empty, .roster > .empty { border-top: 1px solid var(--line); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 7px;
  border-radius: 5px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: .73rem;
  font-weight: 660;
  line-height: 1.22;
  overflow-wrap: anywhere;
}
.badge-dot { display: block; flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-recent, .badge-status-completed, .badge-status-running { color: var(--good); background: var(--good-bg); }
.badge-stale, .badge-warning, .badge-status-interrupted, .badge-status-stopping { color: var(--warn); background: var(--warn-bg); }
.badge-disabled, .badge-status-error { color: var(--danger); background: var(--danger-bg); }
.cell-contact .badge + .badge { margin-top: 4px; }

.machine-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px 20px; flex-wrap: wrap; }
.machine-heading h1, .machine-heading p { overflow-wrap: anywhere; }
.detail-grid, .release-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 16px; margin-bottom: 20px; }
.release-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.detail-panel, .release-card { padding: 0 18px 18px; }
.detail-panel > .section-heading, .release-card > .section-heading { padding-inline: 0; }
.facts { display: grid; }
.facts > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
  gap: 4px 10px;
  align-items: start;
  padding-block: 9px;
  border-top: 1px solid var(--line);
  font-size: .86rem;
}
.facts dt, .snapshot-metrics dt { color: var(--muted); font-size: .8rem; }
.facts dd { font-weight: 600; overflow-wrap: anywhere; }
.registration-facts > div { grid-template-columns: minmax(0, 1fr); }
.snapshot { margin-top: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.snapshot-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 9px; }
.snapshot-metrics dd { margin-top: 3px; font-size: .85rem; font-weight: 710; overflow-wrap: anywhere; }
.snapshot-warning { margin-top: 10px; color: var(--muted); font-size: .8rem; }
.snapshot-warning > .badge { margin-right: 5px; }
.disclosure-action { margin-top: 10px; padding: 0 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.disclosure-action > summary { min-height: 44px; padding-block: 11px; color: var(--accent-strong); font-size: .87rem; font-weight: 680; }
.disclosure-action p { margin: 0 0 11px; color: var(--muted); font-size: .82rem; }
.disclosure-action form, .disclosure-action .facts { margin-bottom: 11px; }
.enable-form { margin-top: 12px; }
.section-metrics { margin: 0 20px 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--field); }
.section-metrics .metric { padding: 12px; }
.reports-limit { padding: 0 20px 8px; color: var(--muted); font-size: .8rem; }
.release-version { display: grid; padding-bottom: 14px; color: var(--muted); font-size: .81rem; }
.release-version strong { color: var(--ink); font: 680 1.75rem/1.2 var(--mono); letter-spacing: -.045em; }
.release-card .empty { padding-inline: 0; border-top: 1px solid var(--line); }

.login-page .site-header-inner { display: flex; }
.login-page .page { padding-top: clamp(32px, 9vw, 96px); }
.login-card, .token-card { width: min(100%, 620px); padding: clamp(18px, 4vw, 30px); }
.login-card { width: min(100%, 420px); margin-inline: auto; box-shadow: 0 16px 45px #0a152576; }
.login-card h1, .token-card h1 { font-size: clamp(1.64rem, 3.6vw, 2.18rem); }
.login-card h1 { margin-bottom: 18px; }
.token-card > p { margin-top: 10px; color: var(--muted); font-size: .9rem; }
.token-card > .notice { margin-top: 15px; }
.token-card > h1 + .button { margin-top: 16px; }
.token-card .token-machine { color: var(--ink); font-weight: 650; overflow-wrap: anywhere; }
.token-card .field { margin-top: 15px; }
.token-card textarea { min-height: 66px; resize: vertical; font-family: var(--mono); overflow-wrap: anywhere; }
.token-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 15px; }
.copy-status { color: var(--accent-strong); font-size: .83rem; }

@media (min-width: 981px) {
  .portal-page { display: grid; grid-template-columns: var(--nav-width) minmax(0, 1fr); }
  .portal-page .site-header { position: sticky; top: 0; align-self: start; height: 100vh; border-right: 1px solid var(--line); }
  .portal-page .site-header-inner {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 29px;
    height: 100%;
    padding: 29px 16px 18px;
  }
  .portal-page .brand { padding-inline: 5px; }
  .portal-page .site-nav { flex-direction: column; }
  .portal-page .site-nav a[aria-current="page"]::before {
    position: absolute;
    inset: 11px auto 11px 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent);
    content: "";
  }
  .portal-page .logout { justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 15px; border-top: 1px solid var(--line); }
}

@media (min-width: 751px) {
  .data-table tr > :first-child { padding-left: 20px; }
  .data-table tr > :last-child { padding-right: 20px; }
}

@media (max-width: 980px) {
  .site-header { border-bottom: 1px solid var(--line); }
  .registration-form { width: min(36rem, calc(100vw - 40px)); }
}

@media (max-width: 750px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .data-table, .data-table tbody { display: block; }
  .data-table tbody { padding: 0 15px 15px; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .data-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px;
    margin-top: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--field);
  }
  .data-table tbody tr:last-child { border-bottom: 1px solid var(--line); }
  .data-table tbody tr > th, .data-table tbody tr > td { display: block; min-width: 0; padding: 0; text-align: left; }
  .data-table tbody tr > .numeric { text-align: left; }
  .data-table .cell-identity { grid-column: 1; }
  .data-table .cell-contact { grid-column: 2; }
  .mobile-label { display: block; margin-bottom: 2px; color: var(--muted); font-size: .73rem; font-weight: 600; }
}

@media (max-width: 620px) {
  .site-header-inner { min-height: 0; grid-template-columns: minmax(0, 1fr) auto; gap: 9px 14px; padding-block: 11px; }
  .site-nav { grid-row: 2; grid-column: 1 / -1; }
  .site-nav > a { flex: 1; justify-content: center; }
  .logout { grid-row: 1; grid-column: 2; }
  .operator-name { display: none; }
  .page { padding-top: 23px; }
  .page-heading { margin-bottom: 16px; }
  .dashboard-heading { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .registration { justify-self: start; }
  .registration[open] { width: 100%; }
  .registration-form { position: static; width: 100%; margin-top: 9px; padding: 15px; box-shadow: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 15px; }
  .metric, .section-metrics .metric { padding: 10px 12px; }
  .metric:nth-child(even) { border-inline-end: 0; }
  .metric:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .section-heading { align-items: stretch; flex-direction: column; padding: 15px; }
  .release-card > .section-heading { align-items: start; }
  .section-metrics { margin-inline: 15px; }
  .reports-limit { padding-inline: 15px; }
  .detail-panel, .release-card { padding-inline: 15px; }
  .release-grid { grid-template-columns: minmax(0, 1fr); }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 8px; }
  .filters .field:first-child, .filters .field:last-child { min-width: 0; }
  .snapshot-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 385px) {
  .brand { gap: 8px; }
  .brand-mark { width: 33px; height: 33px; }
  .filters { grid-template-columns: minmax(0, 1fr); }
  .data-table tbody tr { gap: 8px; }
  .facts > div { grid-template-columns: minmax(0, 1fr); }
}
