:root {
  --ink: #172f2b;
  --muted: #556a65;
  --green: #19584b;
  --forest: #173831;
  --mint: #e5f3eb;
  --line: #d7e0db;
  --paper: #fff;
  --canvas: #f4f6f2;
  --radius: 16px;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  font-family: Inter, 'Segoe UI', system-ui, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
h1, h2, h3, p, fieldset { margin: 0; }
h1, h2, h3 { line-height: 1.12; }
h1 { font-size: clamp(2rem, 4.4vw, 3.25rem); font-weight: 650; letter-spacing: -.055em; }
h2 { font-size: 1.15rem; font-weight: 670; letter-spacing: -.032em; }
a { color: var(--green); }
button, input { font: inherit; }
button, summary, input[type=checkbox], input[type=radio] { cursor: pointer; }
a, input, button, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #0076aa; outline-offset: 3px; }
.skip { position: fixed; z-index: 10; top: -10em; left: 1em; padding: .6rem 1rem; background: white; }
.skip:focus { top: .6em; }

.topbar { background: var(--forest); color: white; }
.topbar-inner {
  display: flex; align-items: center; gap: clamp(1rem, 5vw, 4.5rem);
  max-width: 1240px; margin: auto; padding: 0 clamp(1rem, 3.2vw, 2.75rem);
  min-height: 76px;
}
.home { color: inherit; text-decoration: none; flex: none; }
.brand { display: inline-flex; align-items: center; gap: 11px; font-size: 1.22rem; font-weight: 720; letter-spacing: -.055em; }
.brand-light { color: #b5c8bd; font-weight: 460; letter-spacing: -.04em; }
.brand-mark {
  display: flex; align-items: center; justify-content: center; gap: 3px;
  width: 32px; height: 32px; border-radius: 8px; background: #caed9e;
}
.brand-mark i { width: 3px; height: 9px; background: #173c30; border-radius: 1px; }
.brand-mark i:nth-child(2) { height: 20px; }
.brand-mark i:nth-child(3) { height: 13px; }
.nav { display: flex; align-self: stretch; gap: clamp(.9rem, 2.6vw, 2rem); }
.nav a {
  display: flex; align-items: center; position: relative; color: #c8d5ce;
  font-size: .91rem; font-weight: 550; text-decoration: none; padding: 0 .12rem;
}
.nav a[aria-current], .nav a:hover { color: white; }
.nav a[aria-current]::after {
  content: ''; position: absolute; inset: auto 0 0; height: 3px;
  border-radius: 3px 3px 0 0; background: #c4e99c;
}
.account { display: flex; align-items: center; gap: 14px; min-width: 0; margin-left: auto; font-size: .85rem; }
.account-name { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.workspace { max-width: 1240px; margin: 0 auto; padding: clamp(2rem, 5vw, 4.25rem) clamp(1rem, 3.2vw, 2.75rem) 4rem; }
.page-heading {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  margin-bottom: clamp(1.4rem, 3vw, 2.5rem);
}
.lede { margin-top: .75rem; color: var(--muted); line-height: 1.55; }
.panel {
  min-width: 0; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 2px 4px #19382b06;
}
.panel-heading { display: flex; align-items: center; gap: .65rem; padding: 1.35rem 1.5rem; border-bottom: 1px solid var(--line); }
.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.65rem; height: 1.45rem; border-radius: .45rem;
  padding: 0 .4rem; font: 600 .76rem var(--mono); color: #52675f; background: #edf1ed;
}
.routing-layout, .admin-layout { display: grid; align-items: start; gap: clamp(1rem, 2.65vw, 2rem); }
.routing-layout { grid-template-columns: minmax(220px, .49fr) minmax(0, 1fr); }
.admin-layout { grid-template-columns: minmax(0, 1.3fr) minmax(250px, .85fr); }
.device-nav { max-height: 63vh; overflow-y: auto; overscroll-behavior: contain; padding: .55rem; }
.device-row { display: flex; align-items: center; gap: .85rem; padding: .83rem .78rem; border-radius: 10px; text-decoration: none; color: var(--ink); }
.device-row + .device-row { margin-top: 3px; }
.device-row:hover { background: #f2f5f1; }
.device-row[aria-current] { background: var(--mint); }
.device-info { display: grid; gap: .28rem; min-width: 0; }
.device-info strong, .person-info strong { font-weight: 630; line-height: 1.35; overflow-wrap: anywhere; }
.chevron { height: 8px; width: 8px; margin: 0 .18rem 0 auto; border: solid #83958c; border-width: 1.6px 1.6px 0 0; transform: rotate(45deg); flex: none; }
.device-row[aria-current] .chevron { border-color: var(--green); }
.equipment-icon {
  flex: none; display: inline-flex; align-items: center; position: relative;
  width: 29px; height: 17px; border: 1.5px solid #678176; border-radius: 4px;
}
.equipment-icon::before, .equipment-icon::after { content: ''; position: absolute; bottom: -4px; height: 3px; width: 4px; background: #678176; }
.equipment-icon::before { left: 3px; }
.equipment-icon::after { right: 3px; }
.equipment-icon i { width: 4px; height: 4px; border-radius: 50%; margin-left: 4px; background: #678176; }
.status { display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; font-size: .78rem; font-weight: 570; line-height: 1.35; color: var(--muted); }
.status i { height: 7px; width: 7px; flex: none; border-radius: 50%; background: #84908a; }
.status.online { color: #326447; }
.status.online i { background: #438359; }
.status.unknown i { background: none; border: 1.5px solid #86958e; }

.selected-heading { justify-content: space-between; }
.selected-heading > div { min-width: 0; }
.selected-heading h2 { font-size: clamp(1.3rem, 2.5vw, 1.65rem); overflow-wrap: anywhere; }
.selected-heading .status { border-radius: 20px; padding: .32rem .7rem; background: #f0f3ef; }
.selected-heading .online { background: #eaf5ea; }
.device-address { display: block; margin-top: .38rem; color: var(--muted); font: .8rem var(--mono); overflow-wrap: anywhere; }
.routing-body, .invite-body { padding: clamp(1.05rem, 2.5vw, 1.65rem); }
.signal-card {
  display: flex; align-items: center; gap: clamp(.7rem, 2vw, 1.5rem); padding: clamp(1.25rem, 2.5vw, 2rem);
  background: linear-gradient(105deg, #1c453a, #132f29); color: #f1f8ec;
  border-radius: 11px; margin-bottom: 1.8rem; min-height: 138px;
}
.signal-source { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.signal-alias { font-size: 1rem; overflow-wrap: anywhere; }
.signal-label { font-size: .78rem; font-weight: 550; color: #bfcec3; }
.signal-name { font: 520 clamp(1.45rem, 3.8vw, 2.4rem)/1.22 var(--mono); letter-spacing: -.055em; }
.signal-track { flex: 1; min-width: .55rem; height: 1px; background: repeating-linear-gradient(to right, #81a38f 0 4px, transparent 4px 8px); }
.signal-port { display: flex; flex-direction: column; align-items: center; gap: .55rem; font: 550 .67rem var(--mono); letter-spacing: .05em; color: #d2e8bd; }
.connector {
  display: grid; place-items: center; width: 33px; height: 33px;
  border: 2px solid currentColor; border-radius: 50%; position: relative;
}
.connector::before { position: absolute; content: ''; inset: 3px; border: 1px solid currentColor; border-radius: 50%; }
.connector i { width: 7px; height: 7px; border: 2px solid currentColor; border-radius: 50%; }
fieldset { min-width: 0; border: 0; padding: 0; }
legend { padding: 0; }
.source-fieldset legend { font-size: .94rem; font-weight: 630; margin-bottom: .75rem; }
.sources { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .52rem; }
.source-option, .grant-option { display: flex; align-items: center; cursor: pointer; }
.source-option {
  min-height: 50px; justify-content: center; gap: .45rem; padding: .45rem; border: 1px solid #c9d5cd;
  border-radius: 8px; background: white; color: var(--ink); font: 560 .92rem var(--mono);
}
.source-caption { min-width: 0; }
.source-caption small { display: block; margin-top: .18rem; font: 500 .8rem/1.25 system-ui, sans-serif; overflow-wrap: anywhere; }
.source-option:has(input:checked) { background: var(--mint); border-color: #437961; color: var(--green); }
.source-option:hover:has(input:enabled) { border-color: var(--green); }
.source-option:has(input:focus-visible) { outline: 3px solid #0076aa; outline-offset: 2px; }
input[type=radio], input[type=checkbox] { accent-color: var(--green); width: 16px; height: 16px; flex: none; margin: 0; }
.source-fieldset:disabled { opacity: .52; }
.source-fieldset:disabled .source-option { cursor: default; }
.source-option:has(input:disabled) { cursor: default; color: #68756e; background: #f1f3f1; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.routing-actions { margin-top: 1.6rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 43px;
  padding: .58rem 1.15rem; border: 1px solid transparent; border-radius: 8px;
  font-size: .89rem; font-weight: 620; line-height: 1.35; text-decoration: none;
}
.btn-primary { background: var(--green); color: white; }
.btn-primary:hover:not(:disabled) { background: #104637; }
.btn-light { background: white; border-color: #c9d5cd; color: var(--green); }
.btn-light:hover { border-color: #779587; background: #f7faf7; }
.btn-text { color: var(--green); background: none; }
.btn-text:hover { text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { background: #e4e9e5; color: #6a796f; cursor: not-allowed; }
.btn[aria-disabled=true] { opacity: .65; cursor: progress; }
.full { width: 100%; }
.empty-list { padding: 1.4rem; color: var(--muted); font-size: .91rem; }
.empty-routing { padding: clamp(2rem, 5vw, 4rem) 1.5rem; text-align: center; }
.empty-routing .lede { max-width: 30rem; margin-left: auto; margin-right: auto; }
.empty-port, .auth-symbol {
  display: inline-grid; place-items: center; width: 56px; height: 56px;
  border-radius: 14px; background: var(--mint); color: #40775c; margin-bottom: 1.3rem;
}

.messages { margin: 0; }
.notice { padding: .85rem 1rem; margin: 0 0 1.2rem; border: 1px solid #bcdac4; border-radius: 8px; background: #eef8ee; color: #245736; font-size: .91rem; overflow-wrap: anywhere; }
.notice-error { background: #fff1ee; border-color: #efc6bd; color: #7e352c; }
.notice-warn { background: #fbf7e9; border-color: #e8dcb3; color: #655322; }
.stack { display: grid; gap: 1.1rem; }
.field { display: grid; gap: .42rem; font-size: .89rem; font-weight: 610; }
.field input {
  min-width: 0; width: 100%; min-height: 44px; border: 1px solid #bccbc0;
  border-radius: 7px; padding: .6rem .8rem; background: white; color: var(--ink); font: inherit; font-weight: 430;
}
.field-help { margin-top: -.62rem; font-size: .8rem; color: var(--muted); }
.auth-workspace { width: min(100%, 490px); margin: clamp(2rem, 10vh, 6rem) auto 2rem; padding: 0 1rem; }
.auth-card { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(1.5rem, 4vw, 2.5rem); box-shadow: 0 6px 24px #14332808; }
.auth-card h1 { font-size: clamp(1.8rem, 4vw, 2.35rem); }
.auth-card .lede { margin-bottom: 1.6rem; }
.auth-card .stack .btn { margin-top: .35rem; }
.auth-link { display: block; width: fit-content; margin: 1.35rem auto 0; font-size: .9rem; text-underline-offset: 3px; }
.error-code { display: inline-block; margin-bottom: 1rem; font: 620 1rem var(--mono); color: var(--muted); }
.person + .person { border-top: 1px solid var(--line); }
.person summary {
  display: flex; align-items: center; gap: .8rem;
  list-style: none; padding: 1rem clamp(1rem, 2.4vw, 1.5rem);
}
.person summary::-webkit-details-marker { display: none; }
.person summary:hover { background: #f7faf6; }
.person:last-child summary { border-radius: 0 0 var(--radius) var(--radius); }
.person[open] summary { background: #f4f8f3; border-radius: 0; }
.person .chevron { margin-left: 0; transform: rotate(135deg) translate(-2px, 2px); }
.person[open] .chevron { transform: rotate(-45deg); }
.user-avatar {
  display: grid; place-items: center; flex: none; width: 38px; height: 38px;
  border-radius: 11px; color: var(--green); background: var(--mint); font-weight: 650;
}
.person-info { min-width: 0; display: grid; gap: .15rem; }
.person-info > span { color: var(--muted); overflow-wrap: anywhere; font-size: .83rem; }
.role { margin-left: auto; padding: .25rem .5rem; font-size: .71rem; font-weight: 590; color: var(--muted); background: #f1f4f0; border-radius: .4rem; }
.person-details { padding: 1.3rem clamp(1rem, 2.4vw, 1.5rem); }
.grant-fieldset legend { font-size: .88rem; font-weight: 610; margin-bottom: .55rem; }
.grant-list { max-height: 235px; overflow-y: auto; border: 1px solid var(--line); border-radius: 7px; }
.grant-option { gap: .65rem; padding: .6rem .75rem; font-size: .88rem; overflow-wrap: anywhere; }
.grant-option + .grant-option { border-top: 1px solid #e6ebe6; }
.grant-option small { display: block; color: var(--muted); font: .72rem var(--mono); margin-top: .1rem; }
.access-actions { margin-top: 1rem; padding-top: .65rem; border-top: 1px solid var(--line); }
.access-actions .btn-text { padding-left: 0; text-align: left; }
.token-field input { font-family: var(--mono); font-size: .83rem; }
.copy-result { color: var(--muted); font-size: .85rem; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
@media (max-width: 780px) {
  .routing-layout { grid-template-columns: minmax(180px, .45fr) minmax(0, 1fr); }
  .sources { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-layout { grid-template-columns: minmax(0, 1.05fr) minmax(240px, 1fr); }
  .user-avatar { display: none; }
}
@media (max-width: 650px) {
  .topbar-inner { min-height: 62px; flex-wrap: wrap; gap: 0 1rem; padding-top: .75rem; }
  .topbar-inner:has(.nav) .nav { order: 3; width: 100%; margin-top: .5rem; }
  .topbar-inner:not(:has(.nav)) { padding-top: 0; }
  .nav a { padding: .6rem .15rem .7rem; }
  .account { max-width: 49%; }
  .page-heading { align-items: start; flex-direction: column; }
  .routing-layout, .admin-layout { grid-template-columns: 1fr; }
  .panel-heading { padding: 1.05rem 1.1rem; }
  .device-nav { max-height: 220px; }
  .device-row { padding: .62rem .7rem; }
  .sources { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .signal-card { min-height: 114px; }
  .role { font-size: .67rem; }
}
@media (max-width: 420px) {
  .sources { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-name { display: none; }
}

.device-settings { margin-top: 1.5rem; border-top: 1px solid var(--line); }
.device-settings summary {
  display: flex; align-items: center; gap: .75rem; list-style: none;
  min-height: 46px; padding: .95rem .12rem .15rem; font-size: .93rem; color: var(--green); font-weight: 620;
}
.device-settings summary::-webkit-details-marker { display: none; }
.device-settings .chevron { transform: rotate(135deg); }
.device-settings[open] > summary .chevron { transform: rotate(-45deg); }
.settings-form { margin-top: 1.2rem; }
.settings-form .field small, .mapping legend small { font-size: .77rem; color: var(--muted); font-weight: 450; }
.credentials { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.confirm-output { display: flex; align-items: start; gap: .6rem; font-size: .87rem; cursor: pointer; }
.confirm-output input { margin-top: .16rem; }
.mapping legend { margin-bottom: .28rem; font-size: .9rem; font-weight: 620; }
.mapping p { font-size: .81rem; color: var(--muted); }
.mapping-ids { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-top: .75rem; }
@media (max-width: 520px) {
  .credentials { grid-template-columns: 1fr; }
  .mapping-ids { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.account-menu { position: relative; }
.account-menu > summary {
  display: flex; align-items: center; gap: .5rem; cursor: pointer; list-style: none;
  min-height: 34px; padding: .35rem .7rem; border: 1px solid #678377;
  border-radius: 7px; font-size: .84rem; color: white;
}
.account-menu > summary:hover { background: #284b40; }
.account-menu > summary::-webkit-details-marker { display: none; }
.account-menu .chevron { height: 6px; width: 6px; border-color: #d6e5d8; transform: rotate(135deg); }
.account-popover {
  position: absolute; z-index: 3; top: calc(100% + 6px); right: 0;
  min-width: 195px; padding: .35rem; background: white; border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 8px 24px #17383120;
}
.account-popover a, .account-popover button {
  display: block; width: 100%; padding: .65rem .8rem; text-align: left; border-radius: 6px;
  text-decoration: none; border: 0; background: none; font-size: .87rem; color: var(--green);
}
.account-popover a:hover, .account-popover button:hover { background: var(--mint); }
.recovery-help { margin-top: 1.2rem; color: var(--muted); font-size: .88rem; }
