/* HMI Forge public pages: landing, sign in, account, user admin.
   Same shell as the editor: steel graphite with an instrument-cyan accent. Red, amber, yellow and purple
   stay out of the chrome so colour on these pages only ever comes from the HMI screenshots or means a fault,
   the way a high-performance (ISA-101) screen uses it. */
:root {
  --bg: #0f1418;
  --bg2: #12181d;
  --panel: #182027;
  --panel2: #1f2831;
  --line: #2b3742;
  --line2: #3a4955;
  --fg: #dde4ea;
  --fg2: #b9c4cd;
  --muted: #92a1ad;
  --accent: #5cb8c4;
  --accent-ink: #061a1d;
  --accent-soft: rgba(92, 184, 196, .12);
  --good: #6fbf8a;
  --bad: #ec8178;
  --field: #0b1014;
  --hover: #25303a;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Cantarell, "Noto Sans", sans-serif;
  /* DIN-style faces where the system has one: the lettering of plant signage and panel labels. */
  --display: Bahnschrift, "DIN Alternate", "DIN 2014", "D-DIN", "Barlow Semi Condensed", "Roboto Condensed", "Arial Narrow", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --r: 6px;
  --wrap: 1180px;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--fg); font: 16px/1.6 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: #7fcad4; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
button, input, select { font: inherit; color: inherit; }
code, .mono { font-family: var(--mono); font-size: .92em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 14px; border-radius: var(--r); font-weight: 600; }
.skip:focus { top: 12px; color: var(--accent-ink); }
[hidden] { display: none !important; }

/* logo: an HMI faceplate in miniature (same mark as the editor) */
.logo { display: inline-block; width: 24px; height: 24px; border-radius: 4px; flex: none; border: 1px solid #b4b4b4;
  background: linear-gradient(var(--accent) 0 0) 5px 14px / 13px 3px no-repeat, linear-gradient(#9a9a9a 0 0) 5px 6px / 8px 3px no-repeat, #d8d8d8; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font: 600 18px/1 var(--display); letter-spacing: .01em; }
.brand:hover { color: var(--fg); }

/* ---------- buttons and fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 18px; border-radius: var(--r);
  border: 1px solid var(--line2); background: var(--panel2); color: var(--fg); font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { background: var(--hover); color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover:not(:disabled) { background: #74c5cf; color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg2); }
.btn.ghost:hover:not(:disabled) { background: var(--hover); }
.btn.danger { border-color: rgba(236, 129, 120, .6); color: var(--bad); background: transparent; }
.btn.danger:hover:not(:disabled) { background: rgba(236, 129, 120, .12); color: var(--bad); }
.btn.small { min-height: 32px; padding: 4px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.large { min-height: 48px; padding: 10px 24px; font-size: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 14px; font-weight: 600; color: var(--fg2); }
.field small { color: var(--muted); font-size: 13px; }
input:not([type=checkbox]):not([type=radio]), select { width: 100%; min-width: 0; min-height: 42px; padding: 8px 11px; border-radius: var(--r);
  border: 1px solid var(--line2); background: var(--field); color: var(--fg); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); border-radius: var(--r); }
input[aria-invalid=true] { border-color: var(--bad); }
select { padding-right: 8px; }

.msg { margin: 0; padding: 10px 12px; border-radius: var(--r); border: 1px solid; font-size: 14.5px; }
.msg.error { border-color: rgba(236, 129, 120, .55); background: rgba(236, 129, 120, .1); color: #f3b1aa; }
.msg.ok { border-color: rgba(111, 191, 138, .5); background: rgba(111, 191, 138, .1); color: #a9dcb9; }
.msg.note { border-color: var(--line2); background: var(--panel2); color: var(--fg2); }
.msg:empty { display: none; }

/* ---------- site header and footer ---------- */
.site-head { position: sticky; top: 0; z-index: 20; background: rgba(15, 20, 24, .92); border-bottom: 1px solid var(--line); }
@supports (backdrop-filter: blur(8px)) { .site-head { background: rgba(15, 20, 24, .78); backdrop-filter: blur(10px); } }
.site-head .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a { color: var(--fg2); text-decoration: none; font-size: 15px; padding: 6px 10px; border-radius: var(--r); }
.site-nav a:hover { color: var(--fg); background: var(--hover); }
.site-head .btn { min-height: 36px; padding: 6px 16px; }
.head-actions { margin-left: auto; flex-wrap: nowrap; gap: 6px; }
@media (max-width: 520px) { .app-page .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } .head-actions .btn.small { padding: 4px 9px; } }
@media (max-width: 820px) { .site-nav { display: none; } .site-head .wrap > .btn { margin-left: auto; } }

.site-foot { border-top: 1px solid var(--line); margin-top: 96px; padding: 28px 0 36px; color: var(--muted); font-size: 14px; }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: center; }
.site-foot .brand { font-size: 15px; }
.site-foot .brand .logo { width: 18px; height: 18px; background-size: auto; background-position: 3px 10px, 3px 4px; }
.site-foot p { margin: 0; }
.site-foot .end { margin-left: auto; display: flex; gap: 20px; }
@media (max-width: 560px) { .site-foot .end { margin-left: 0; } }
.app-page .site-foot { margin-top: 64px; }

/* ---------- landing ---------- */
.hero { padding: clamp(48px, 9vw, 104px) 0 0; position: relative; }
.hero::before { /* engineering grid, fading out below the headline */
  content: ""; position: absolute; inset: 0 0 auto; height: 620px; pointer-events: none;
  background-image: linear-gradient(rgba(92, 184, 196, .055) 1px, transparent 1px), linear-gradient(90deg, rgba(92, 184, 196, .055) 1px, transparent 1px);
  background-size: 32px 32px; background-position: -1px -1px;
  -webkit-mask-image: linear-gradient(#000 20%, transparent); mask-image: linear-gradient(#000 20%, transparent); }
.hero .wrap { position: relative; }
.hero h1 { font: 600 clamp(38px, 6.6vw, 76px)/1.02 var(--display); letter-spacing: -.015em; margin: 0; max-width: 15ch; text-wrap: balance; }
.hero .lede { font-size: clamp(17px, 2vw, 20px); line-height: 1.55; color: var(--fg2); max-width: 60ch; margin: 24px 0 0; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 32px; }
.hero .signal { margin: 28px 0 0; color: var(--muted); font-size: 14.5px; max-width: 72ch; }

/* The hero screenshot sits in a drawing frame with a title block, like a sheet from the project's drawings. */
.sheet { margin: clamp(40px, 6vw, 64px) 0 0; border: 1px solid var(--line2); border-radius: 8px; background: var(--bg2); padding: 10px; box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7); }
.sheet img { border-radius: 4px; border: 1px solid var(--line); width: 100%; }
.title-block { display: grid; grid-template-columns: 2.2fr 1.3fr 1fr 1fr; gap: 1px; margin: 10px 0 0; background: var(--line); border: 1px solid var(--line); border-radius: 4px; overflow: hidden; font-size: 13.5px; }
.title-block > div { padding: 8px 12px; background: var(--bg2); min-width: 0; }
.title-block dt { color: var(--muted); font-size: 12px; }
.title-block dd { margin: 0; color: var(--fg); }
.title-block .state { color: var(--good); }
@media (max-width: 760px) { .title-block { grid-template-columns: 1fr 1fr; } .title-block > div:nth-child(-n+2) { grid-column: 1 / -1; } }

.section { padding-top: clamp(72px, 10vw, 120px); scroll-margin-top: 64px; }
.section-head { max-width: 760px; }
.section h2 { font: 600 clamp(28px, 4vw, 44px)/1.1 var(--display); letter-spacing: -.01em; margin: 0; text-wrap: balance; }
.section-head p { color: var(--fg2); font-size: 18px; margin: 16px 0 0; max-width: 62ch; }
.section h3 { font: 600 21px/1.25 var(--display); margin: 0; letter-spacing: .005em; }
.section p { max-width: 68ch; }

/* How it works: three steps on one process line, with instrument balloons as the step marks. */
.flow { list-style: none; margin: 48px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 40px; position: relative; }
.flow > li { position: relative; padding-top: 72px; }
/* process line from each balloon to the next one */
.flow > li:not(:last-child)::before { content: ""; position: absolute; top: 23px; left: 48px; right: -40px; height: 2px; background: var(--accent); }
.flow > li:nth-child(2)::before { background: linear-gradient(90deg, var(--accent), var(--good)); }
.balloon { position: absolute; top: 0; left: 0; width: 48px; height: 48px; border-radius: 50%; border: 2px solid var(--accent); background: var(--bg);
  display: grid; place-items: center; font: 600 18px/1 var(--display); color: var(--accent); }
.flow li:last-child .balloon { border-color: var(--good); color: var(--good); }
.flow p { color: var(--fg2); margin: 10px 0 0; }
.flow .list { margin: 14px 0 0; padding: 0; list-style: none; font-size: 14.5px; color: var(--muted); }
.flow .list li { padding: 6px 0 0 16px; position: relative; }
.flow .list li::before { content: ""; position: absolute; left: 0; top: 15px; width: 8px; height: 2px; background: var(--line2); }
@media (max-width: 860px) {
  .flow { grid-template-columns: 1fr; gap: 36px; }
  .flow > li { padding: 4px 0 0 76px; }
  .flow > li:not(:last-child)::before { top: 48px; bottom: -36px; left: 23px; right: auto; width: 2px; height: auto; }
  .flow > li:nth-child(2)::before { background: linear-gradient(var(--accent), var(--good)); }
}

/* Feature blocks: an image and its text side by side. */
.feature { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: clamp(28px, 4vw, 56px); align-items: start; margin-top: 48px; }
.feature.flip { grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); }
.feature.flip .shot { order: 2; }
.feature figure { margin: 0; }
.shot { border: 1px solid var(--line2); border-radius: 8px; overflow: hidden; background: #0b1117; }
.feature figcaption { color: var(--muted); font-size: 14px; margin-top: 10px; }
.points { list-style: none; margin: 0; padding: 0; }
.points > li { padding: 16px 0; border-top: 1px solid var(--line); }
.points > li:first-child { border-top: 0; padding-top: 4px; }
.points h3 { font-size: 18px; }
.points p { margin: 6px 0 0; color: var(--fg2); font-size: 15.5px; }
@media (max-width: 900px) { .feature, .feature.flip { grid-template-columns: 1fr; } .feature.flip .shot { order: 0; } }

.wide-shot { margin: 40px 0 0; }
.wide-shot .shot { width: 100%; }
.points.cols { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 32px; margin-top: 28px; }
.points.cols > li, .points.cols > li:first-child { border-top: 1px solid var(--line2); padding: 16px 0 0; }
@media (max-width: 960px) { .points.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 32px; } }
@media (max-width: 560px) { .points.cols { grid-template-columns: 1fr; gap: 20px; } }
.wide-shot figcaption { color: var(--muted); font-size: 14px; margin-top: 10px; }

/* Protocol chips: the connection list as a terminal strip. */
.terminals { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 0; padding: 0; list-style: none; }
.terminals li { border: 1px solid var(--line2); border-radius: 4px; padding: 3px 10px; font-size: 14px; color: var(--fg2); background: var(--panel); }

/* Safety: rules and where each one is enforced. */
.rules { margin: 40px 0 0; border-top: 1px solid var(--line2); }
.rule { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.6fr) minmax(0, .7fr); gap: 8px 32px; padding: 20px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.rule h3 { font-size: 19px; }
.rule p { margin: 0; color: var(--fg2); }
.rule .where { color: var(--muted); font-size: 14px; }
.rule .where b { display: block; font-weight: 600; color: var(--fg2); font-size: 13px; }
@media (max-width: 860px) { .rule { grid-template-columns: 1fr; } }
.caveat { margin: 24px 0 0; padding-left: 14px; border-left: 3px solid var(--line2); color: var(--fg2); }

/* Targets */
.targets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-top: 40px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.target { background: var(--panel); padding: 22px 20px 24px; }
.target h3 { font-size: 19px; }
.target .ver { color: var(--accent); font-size: 14px; margin: 2px 0 0; }
.target p { color: var(--fg2); font-size: 15px; margin: 12px 0 0; }
@media (max-width: 960px) { .targets { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 540px) { .targets { grid-template-columns: 1fr; } }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 48px; margin-top: 48px; }
.two-col h3 { font-size: 19px; }
.two-col p { color: var(--fg2); margin: 8px 0 0; font-size: 15.5px; }
@media (max-width: 760px) { .two-col { grid-template-columns: 1fr; } }

.closing { margin-top: clamp(72px, 10vw, 112px); padding: clamp(28px, 4vw, 44px); border: 1px solid var(--line2); border-radius: 8px; background: var(--panel);
  display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: center; justify-content: space-between; }
.closing h2 { font: 600 clamp(24px, 3vw, 32px)/1.15 var(--display); margin: 0; }
.closing p { margin: 6px 0 0; color: var(--fg2); }

/* ---------- signed-in pages ---------- */
.app-page main { padding-top: 40px; }
.page-title { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 24px; justify-content: space-between; margin-bottom: 28px; }
.page-title h1 { font: 600 clamp(28px, 4vw, 38px)/1.1 var(--display); margin: 0; }
.page-title p { margin: 6px 0 0; color: var(--fg2); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: clamp(18px, 3vw, 28px); min-width: 0; }
.panel h2 { font: 600 21px/1.2 var(--display); margin: 0; }
.panel > p { color: var(--fg2); margin: 8px 0 0; }
.panel-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.grid .span { grid-column: 1 / -1; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

.form { display: flex; flex-direction: column; gap: 16px; margin-top: 20px; }
.form .btn { align-self: flex-start; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; margin: 20px 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.role-tag { display: inline-block; border: 1px solid var(--line2); border-radius: 999px; padding: 0 10px; font-size: 14px; }
.role-tag.admin { border-color: var(--accent); color: var(--accent); }

.sessions { list-style: none; margin: 16px 0 0; padding: 0; }
.sessions li { display: grid; grid-template-columns: 1fr auto; gap: 2px 16px; padding: 12px 0; border-top: 1px solid var(--line); }
.sessions li:first-child { border-top: 0; }
.sessions .dev { font-weight: 600; }
.sessions .meta { color: var(--muted); font-size: 14px; grid-column: 1; }
.sessions .here { color: var(--good); font-size: 13.5px; font-weight: 600; grid-row: 1; grid-column: 2; align-self: center; }

/* Sign in */
.login-page { min-height: 100vh; display: flex; flex-direction: column; }
.login-page main { flex: 1; display: grid; place-items: center; padding: 48px 16px; position: relative; }
.login-page main::before { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(92, 184, 196, .05) 1px, transparent 1px), linear-gradient(90deg, rgba(92, 184, 196, .05) 1px, transparent 1px);
  background-size: 32px 32px; -webkit-mask-image: radial-gradient(closest-side, #000, transparent); mask-image: radial-gradient(closest-side, #000, transparent); }
.login-card { position: relative; width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line2); border-radius: 10px; padding: clamp(24px, 5vw, 36px); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .7); }
.login-card h1 { font: 600 30px/1.1 var(--display); margin: 22px 0 0; }
.login-card .form .btn { align-self: stretch; }
.login-card .foot { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14.5px; }
.login-page .site-foot { margin-top: 0; }

/* Users table */
.table-wrap { margin-top: 16px; }
table.users { width: 100%; border-collapse: collapse; font-size: 15px; }
.users th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13.5px; padding: 8px 10px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
.users td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.users tr:last-child td { border-bottom: 0; }
.users .who strong { display: block; font-weight: 600; }
.users .who span { color: var(--muted); font-size: 14px; overflow-wrap: break-word; }
.users td.num { white-space: nowrap; }
.users select { min-height: 34px; padding: 4px 8px; width: auto; min-width: 104px; }
.users .row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.users tr.off .who strong, .users tr.off .who span { color: var(--muted); }
.status { display: inline-block; font-size: 13.5px; white-space: nowrap; }
.status.disabled { color: var(--bad); }
.status.pending { color: var(--fg2); }
.you { color: var(--accent); font-size: 13px; font-weight: 600; margin-left: 6px; }
@media (max-width: 880px) {
  table.users, .users tbody, .users tr, .users td { display: block; }
  .users thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .users tr { border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; margin-bottom: 12px; background: var(--panel2); }
  .users tr:last-child td, .users td { border-bottom: 1px solid var(--line); padding: 10px 0; display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; align-items: center; }
  .users td:last-child { border-bottom: 0; }
  .users td::before { content: attr(data-label); color: var(--muted); font-size: 13.5px; }
  .users tr td.who { display: block; }
  .users tr td.who::before { content: none; }
  .users .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .users td.num { white-space: normal; }
}

.role-help { margin: 16px 0 0; padding: 0; list-style: none; font-size: 14.5px; color: var(--fg2); display: grid; gap: 4px; }
.role-help b { color: var(--fg); font-weight: 600; display: inline-block; min-width: 62px; }

.audit { list-style: none; margin: 16px 0 0; padding: 0; font-size: 14.5px; }
.audit li { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 2px 16px; padding: 10px 0; border-top: 1px solid var(--line); }
.audit li:first-child { border-top: 0; }
.audit time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.audit .what { overflow-wrap: anywhere; }
.audit .actor { font-weight: 600; }
.audit .detail { color: var(--muted); }
@media (max-width: 560px) { .audit li { grid-template-columns: 1fr; } }

.empty { color: var(--muted); margin: 16px 0 0; }
.loading { color: var(--muted); }

/* Dialogs */
dialog { width: min(480px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 1px solid var(--line2); border-radius: 10px; background: var(--panel); color: var(--fg); padding: 0; box-shadow: 0 30px 90px rgba(0, 0, 0, .6); }
dialog::backdrop { background: rgba(5, 8, 10, .7); }
dialog form, dialog .dlg { padding: 24px; display: flex; flex-direction: column; gap: 16px; margin: 0; }
dialog h2 { font: 600 22px/1.2 var(--display); margin: 0; }
dialog p { margin: 0; color: var(--fg2); }
.dlg-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.secret { display: flex; gap: 8px; }
.secret input { font-family: var(--mono); font-size: 16px; letter-spacing: .03em; }
.no-admin { max-width: 560px; }
.feature h3.spaced { margin-top: 28px; }
.feature h3 + p.muted { margin: 8px 0 0; color: var(--fg2); }
.page-title + .msg:not(:empty) { margin: -8px 0 20px; }
