:root {
  color-scheme: light;
  --bg: #f3f5f9; --panel: #fff; --panel-2: #f7f9fc; --line: #dce2ec;
  --text: #18243b; --muted: #657187; --accent: #1e4ed8; --accent-dark: #eaf0ff;
  --navy: #0a1230; --red: #cf2541; --danger: #b5223b;
  --warning: #8c5b08; --success: #167047; --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 320px; scroll-padding-top: 100px; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.5 "Segoe UI", -apple-system, BlinkMacSystemFont, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, .button { cursor: pointer; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid #7297ff; outline-offset: 3px; }
form { margin: 0; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(30px, 3.5vw, 42px); font-weight: 700; line-height: 1.15; letter-spacing: -.045em; }
h2 { margin-bottom: 5px; font-size: 20px; font-weight: 650; line-height: 1.3; letter-spacing: -.025em; }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: 9px; color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: .16em; }
.workspace-label { font-size: 12px; overflow-wrap: anywhere; }
.workspace-label a, .muted a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* Identity: the supplied artwork stays unchanged, including the compact symbol. */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 82px; padding: 10px max(24px, calc((100vw - 1440px)/2)); background: var(--navy); border-bottom: 1px solid #243153; color: #fff; }
.brand, .user-menu { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { flex-shrink: 0; }
.brand-symbol { position: relative; display: inline-block; flex: 0 0 56px; width: 56px; height: 56px; overflow: hidden; border-radius: 12px; background: #070c20; }
.brand-symbol img { position: absolute; width: 108px; height: 108px; max-width: none; left: -27px; top: -15px; object-fit: contain; }
.brand-wordmark { color: inherit; font-size: 25px; font-weight: 750; line-height: 1; letter-spacing: -.055em; white-space: nowrap; }
.brand-wordmark .brand-usa { display: inline-block; position: relative; color: #547aff; }
.brand-wordmark .brand-usa::after { position: absolute; right: 0; bottom: -7px; content: ""; width: 22px; height: 2px; background: var(--red); }
.brand-caption { display: block; margin-top: 8px; color: #a3aec7; font-size: 9px; font-weight: 600; letter-spacing: .17em; text-transform: uppercase; }
.user-menu { gap: 14px; font-size: 13px; }
.user-menu > strong { max-width: 180px; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
.role-pill { padding: 5px 9px; border: 1px solid #d6e1ff; border-radius: 6px; color: #244cac; background: #edf2ff; font-size: 10px; font-weight: 650; }
.topbar .role-pill { color: #c3d2f7; background: #162445; border-color: #293958; }
.topbar .button.ghost { color: #e2e8f5; border-color: #394462; background: transparent; font-size: 12px; }
.topbar .button.ghost:hover { background: #1a2746; border-color: #72809d; }

/* Workspace and core controls. */
.page-shell { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 34px 0 64px; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin: 16px 0 28px; }
.hero .muted { margin-bottom: 0; font-size: 14px; }
.hero-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.legend, .local-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; flex-shrink: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(22,112,71,.08); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: #33425a; font-size: 13px; font-weight: 650; line-height: 1.4; text-align: center; transition: background-color .15s, border-color .15s, box-shadow .15s; }
.button:hover { border-color: #aebbd0; background: #f2f5fa; }
.button.primary { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 2px 3px rgba(23,57,145,.08); }
.button.primary:hover { border-color: #1942ba; background: #1942ba; }
.button.ghost { background: transparent; }
.button.compact { min-height: 34px; padding: 7px 11px; font-size: 12px; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.refresh-button { background: #fff; }
input, select { width: 100%; min-width: 0; padding: 11px 12px; border: 1px solid #cfd7e4; border-radius: 8px; background: #fff; color: var(--text); outline: none; transition: border-color .15s, box-shadow .15s; }
input::placeholder { color: #738096; opacity: 1; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(30,78,216,.12); }
input[type="checkbox"] { accent-color: var(--accent); }
.device-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr)); gap: 24px; }
.device-card, .panel { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 3px 12px rgba(16,35,66,.035); }
.assignment-bar { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid #dde5f4; background: #f3f6fd; }
.assignment-bar label { color: #44516b; font-weight: 500; font-size: 12px; }
.access-members { display: flex; flex-wrap: wrap; gap: 8px 16px; min-width: 0; max-height: 180px; margin: 0; padding: 0; overflow: auto; border: 0; }
.access-members legend { margin-bottom: 8px; color: #263753; font-size: 12px; font-weight: 650; }
.access-members label { display: inline-flex; align-items: center; gap: 6px; }
.access-members input { width: auto; margin: 0; }
.device-heading { display: flex; align-items: start; justify-content: space-between; gap: 14px; padding: 22px 24px 18px; }
.device-heading > div { min-width: 0; }
.device-heading h2 { overflow-wrap: anywhere; }
.device-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.device-status { max-width: 180px; padding: 5px 9px; border-radius: 6px; background: #fff5dd; color: var(--warning); font-size: 10px; font-weight: 650; text-align: right; }
.status-ready { background: #eaf6ee; color: var(--success); }
.status-offline, .status-error { background: #fcecf0; color: var(--danger); }
.status-maintenance { color: var(--warning); }
.recovery-info { padding: 0 24px; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.recovery-info p { margin: 0 0 6px; }
.recovery-info p:empty { display: none; }
.recovery-info [data-profile-warning]:not(:empty) { color: var(--warning); }
.control-priority-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 0 24px 14px; }
.control-priority-bar p { flex: 1 1 180px; margin: 0; color: var(--muted); font-size: 12px; }
.control-priority-bar .button { flex-shrink: 0; }
.command-queue-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 24px 14px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.command-queue-bar .button { min-height: 30px; padding: 5px 9px; font-size: 11px; }

/* Keep screen sizing and coordinate space stable. Overlays never receive input. */
.phone-stage { position: relative; display: grid; place-items: center; min-height: 520px; padding: 12px 20px 20px; background: #eaf0f7; box-shadow: inset 0 1px #e3e8f1, inset 0 -1px #e3e8f1; }
.phone-screen { display: block; max-width: 100%; height: min(66vh, 670px); object-fit: contain; border-radius: 22px; background: #000; box-shadow: 0 16px 34px rgba(19,35,64,.18), 0 0 0 1px rgba(12,27,52,.08); touch-action: none; user-select: none; }
.video-status { position: absolute; left: 16px; right: 16px; bottom: 12px; z-index: 3; width: fit-content; max-width: calc(100% - 32px); margin: 0 auto; padding: 8px 12px; border: 1px solid #485778; border-radius: 8px; background: rgba(10,18,48,.96); color: #ffe3a6; font-size: 12px; text-align: center; pointer-events: none; }
.video-status[hidden] { display: none; }
.fixed-finger { position: absolute; z-index: 2; width: 30px; height: 30px; border: 2px solid #fff; border-radius: 50%; background: rgba(230,150,20,.9); box-shadow: 0 0 0 5px rgba(230,150,20,.25); color: #101820; font-weight: 900; line-height: 26px; text-align: center; transform: translate(-50%, -50%); pointer-events: none; }
.fixed-finger[hidden], [data-cancel-finger][hidden] { display: none; }
.device-card[data-can-control="false"] .phone-screen { cursor: default; touch-action: pan-y; }
.device-card[data-can-control="true"] .phone-screen { cursor: crosshair; }
.phone-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; width: min(310px, 85%); aspect-ratio: 9/16; padding: 30px; border: 2px dashed #bbc8da; border-radius: 36px; color: var(--muted); text-align: center; }
.phone-glyph, .empty-icon { color: #7185ac; font-size: 64px; line-height: 1; }
.phone-placeholder form { width: 100%; margin-top: 8px; }
.phone-placeholder form .button { width: 100%; }
.phone-placeholder small { color: #64748b; font-size: 11px; }
.provision-progress { color: var(--warning); }
.gesture-help { padding: 13px 24px; color: var(--muted); font-size: 11px; }
.gesture-help p { margin-bottom: 6px; }
.gesture-help small { display: block; margin-top: 6px; font-size: 10px; }
.controls { padding: 18px 24px; border-top: 1px solid var(--line); }
.controls.disabled { opacity: .42; pointer-events: none; }
.button-row { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.button.control { min-height: 38px; padding: 9px 6px; background: #f7f9fc; font-size: 12px; }
.button.control:hover { background: #edf2fa; }
.text-control { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; margin-top: 12px; }
.text-control input { font-size: 13px; }
.text-options { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.text-options label { display: inline-flex; align-items: center; gap: 6px; margin-right: auto; color: #53617a; font-size: 12px; cursor: pointer; }
.text-options input { width: auto; margin: 0; }
.input-help { margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.device-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 13px 24px; border-top: 1px solid var(--line); background: #fafbfd; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.link-button { padding: 0; border: 0; background: none; color: var(--accent); font-size: inherit; }
.link-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.empty-state { grid-column: 1/-1; display: grid; place-items: center; align-content: center; min-height: 340px; padding: 32px; border: 1px dashed #c8d3e3; border-radius: var(--radius); background: #fff; color: var(--muted); text-align: center; }
.empty-state h2 { margin: 18px 0 10px; color: var(--text); }
.empty-state p { max-width: 530px; margin-bottom: 0; }

/* Account administration shares the restrained surface hierarchy. */
.admin-grid { display: grid; grid-template-columns: 1.3fr .7fr; gap: 24px; margin-top: 24px; }
.panel { padding: 24px; }
.user-list { display: grid; gap: 6px; margin: 18px 0; }
.user-list > div { display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; background: #f7f9fc; font-size: 13px; }
.user-list strong { overflow-wrap: anywhere; font-weight: 600; }
.avatar { display: grid; place-items: center; width: 32px; height: 32px; border: 1px solid #dce5fc; border-radius: 8px; background: #edf2ff; color: var(--accent); font-size: 12px; font-weight: 700; }
.inline-create { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.4fr) auto; gap: 9px; }
.inline-create input, .password-form input { font-size: 13px; }
.credential-note { margin: 13px 0 0; color: var(--muted); font-size: 11px; }
code { color: var(--accent); }
.audit-list { max-height: 290px; margin-top: 14px; overflow: auto; }
.audit-list > div { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.4fr) auto; gap: 8px; padding: 11px 0; border-bottom: 1px solid #e8edf4; font-size: 11px; overflow-wrap: anywhere; }
.audit-list strong { font-weight: 600; }
.audit-list time { color: var(--muted); font-variant-numeric: tabular-nums; }
.account-panel { display: flex; align-items: center; justify-content: space-between; gap: 25px; margin-top: 24px; }
.account-panel h2 { font-size: 18px; }
.password-form { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; gap: 9px; min-width: min(100%,660px); }
.security-banner, .flash { margin-bottom: 14px; padding: 12px 15px; border: 1px solid transparent; border-radius: 8px; font-size: 13px; }
.security-banner { border-color: #eeddaa; background: #fff8e6; color: var(--warning); }
.flash.success { border-color: #c8e5d3; background: #eef8f1; color: #16633f; }
.flash.error { border-color: #f1cbd2; background: #fdf0f2; color: #a7243a; }

/* Sign-in: the original artwork is the focal point, not a replacement logo. */
.login-shell { display: grid; place-items: center; min-height: calc(100vh - 95px); padding: 40px 24px; }
.login-layout { display: grid; grid-template-columns: 1fr 1fr; width: min(1080px,100%); min-height: 650px; overflow: hidden; border: 1px solid #dbe1ec; border-radius: 18px; background: #fff; box-shadow: 0 16px 50px rgba(20,37,71,.07); }
.login-story { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; min-width: 0; padding: 36px 32px 40px; background: #070c20; color: #fff; text-align: center; }
.login-kicker { margin: 0 0 2px; color: #b8c6e5; font-size: 9px; font-weight: 600; letter-spacing: .21em; }
.login-logo { display: block; width: min(360px,100%); height: auto; margin: 0 auto 6px; object-fit: contain; }
.login-story-copy { display: flex; flex-direction: column; align-items: center; }
.login-tagline { max-width: 330px; margin: 16px 0 12px; font-size: 26px; font-weight: 550; line-height: 1.2; letter-spacing: -.035em; }
.login-story-note { max-width: 305px; margin: 0; color: #aab5cf; font-size: 13px; line-height: 1.7; }
.tricolor-rule { display: block; width: 48px; height: 3px; margin: 0 auto; border-radius: 2px; background: linear-gradient(to right, #2859ed 0 33.33%, #fff 33.33% 66.66%, #e5334d 66.66%); }
.login-card { width: min(460px,100%); padding: 40px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 10px 35px rgba(20,37,71,.05); }
.login-layout > .login-card { align-self: center; width: 100%; padding: 52px 54px; border: 0; border-radius: 0; box-shadow: none; }
.login-card h1 { margin-bottom: 14px; font-size: 36px; }
.login-card > .muted { max-width: 340px; margin-bottom: 28px; font-size: 14px; line-height: 1.7; }
.login-card .eyebrow { margin-bottom: 12px; font-size: 10px; }
.stack-form { display: grid; gap: 20px; margin-top: 28px; }
.stack-form label { display: grid; gap: 8px; color: #34435e; font-size: 12px; font-weight: 600; }
.stack-form input { min-height: 47px; font-size: 15px; }
.stack-form .button { min-height: 47px; margin-top: 4px; font-size: 13px; }
.local-note { justify-content: center; margin: 22px 0 0; font-size: 11px; }
.login-caption { margin: 24px 0 0; padding-top: 22px; border-top: 1px solid #e8edf4; color: var(--muted); font-size: 11px; line-height: 1.7; }
.error-card .brand-symbol { margin-bottom: 22px; }
.error-card h1 { font-size: 30px; }
.error-card .button { margin-top: 8px; }
.site-footer { display: grid; place-items: center; align-content: center; gap: 10px; min-height: 95px; padding: 20px 24px; border-top: 1px solid #e0e5ee; color: #6c788c; text-align: center; overflow-wrap: anywhere; }
.footer-brand { color: #506079; font-size: 12px; font-weight: 650; letter-spacing: -.025em; }
.footer-brand .brand-usa { color: #1e4ed8; }
.footer-note { margin-left: 12px; color: #6c788c; font-size: 11px; font-weight: 400; letter-spacing: 0; }
.site-footer small { font-size: 10px; line-height: 1.6; }
.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(380px,calc(100vw - 44px)); max-height: min(160px,25vh); overflow: hidden; overflow-wrap: anywhere; padding: 14px 17px; border: 1px solid #354366; border-radius: 10px; background: #14213d; color: #f1f5fc; box-shadow: 0 12px 32px rgba(10,18,48,.2); transform: translateY(calc(100% + 30px)); opacity: 0; visibility: hidden; pointer-events: none; transition: transform .2s, opacity .2s, visibility .2s; font-size: 13px; }
.toast.show { transform: none; opacity: 1; visibility: visible; }

@media (max-width: 1100px) {
  .account-panel { align-items: stretch; flex-direction: column; gap: 18px; }
  .password-form { min-width: 0; }
  .login-layout > .login-card { padding: 44px 36px; }
}
@media (max-width: 800px) {
  .page-shell { width: min(100% - 24px,1440px); padding-top: 24px; }
  .topbar { min-height: 72px; padding: 8px 12px; gap: 12px; }
  .brand { gap: 8px; }
  .brand-wordmark { font-size: 23px; }
  .brand-caption { font-size: 8px; }
  .role-pill, .user-menu > strong { display: none; }
  .hero { align-items: stretch; flex-direction: column; gap: 20px; margin-bottom: 22px; }
  .hero-actions { align-items: stretch; gap: 10px; }
  .hero-actions .button { width: 100%; }
  .admin-grid { grid-template-columns: 1fr; }
  .inline-create, .password-form { grid-template-columns: 1fr; min-width: 0; width: 100%; }
  .assignment-bar { grid-template-columns: 1fr auto; }
  .assignment-bar label { grid-column: 1/-1; }
  .phone-stage { min-height: 440px; }
  .login-layout { grid-template-columns: .9fr 1.1fr; min-height: 600px; }
  .login-story { padding: 28px 20px; }
  .login-tagline { font-size: 22px; }
  .login-story-note { font-size: 12px; }
  .login-layout > .login-card { padding: 36px 28px; }
}
@media (max-width: 620px) {
  .login-shell { min-height: calc(100vh - 95px); padding: 20px 16px; }
  .login-layout { grid-template-columns: 1fr; min-height: 0; max-width: 450px; border-radius: 14px; }
  .login-story { min-height: 228px; padding: 12px 22px 18px; }
  .login-kicker { display: none; }
  .login-logo { width: 194px; margin: -9px auto -6px; }
  .login-tagline { margin: 0; max-width: none; font-size: 18px; }
  .login-story-note, .login-story .tricolor-rule { display: none; }
  .login-layout > .login-card { padding: 30px 26px 28px; }
  .login-card h1 { font-size: 30px; }
  .login-card > .muted { margin-bottom: 22px; font-size: 13px; }
  .stack-form { gap: 17px; margin-top: 22px; }
  .login-caption { margin-top: 20px; padding-top: 18px; }
  .login-card { padding: 28px; }
  .stack-form input, .text-control input, .inline-create input, .password-form input { font-size: 16px; }
}
@media (max-width: 460px) {
  .brand-symbol { flex-basis: 46px; width: 46px; height: 50px; }
  .brand-symbol img { left: -32px; top: -18px; }
  .brand-wordmark { font-size: 20px; }
  .brand-caption { font-size: 7px; }
  .user-menu { gap: 0; }
  .topbar .button.ghost { padding: 8px 10px; font-size: 11px; }
  .device-heading, .panel { padding: 18px 16px; }
  .device-heading h2 { font-size: 18px; }
  .device-status { max-width: 120px; font-size: 9px; }
  .control-priority-bar, .command-queue-bar { padding-left: 16px; padding-right: 16px; }
  .recovery-info { padding: 0 16px; }
  .assignment-bar { grid-template-columns: 1fr; gap: 12px; padding: 15px 16px; }
  .assignment-bar > .button { justify-self: start; }
  .controls { padding: 16px; }
  .gesture-help, .device-footer { padding-left: 16px; padding-right: 16px; }
  .button-row { gap: 5px; }
  .button.control { padding: 9px 3px; font-size: 11px; }
  .text-control .button { padding: 9px 11px; font-size: 12px; }
  .text-options { gap: 6px; }
  .text-options label { flex-basis: 100%; margin-bottom: 3px; }
  .audit-list > div { grid-template-columns: minmax(0,1fr) minmax(0,1.4fr); }
  .audit-list time { grid-column: 1/-1; }
  .site-footer { padding-right: 20px; padding-left: 20px; }
  .footer-note { display: block; margin: 4px 0 0; }
  .toast { right: 12px; bottom: 12px; max-width: calc(100vw - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Keep saved workflows inside their column, including long titles/device names. */
.workflows-page .wf-sidebar,
.workflows-page .wf-saved-list,
.workflows-page .wf-saved {
  min-width: 0;
}
.workflows-page .wf-saved-list {
  grid-template-columns: minmax(0, 1fr);
}
.workflows-page .wf-saved {
  max-width: 100%;
}
.workflows-page .wf-saved small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 800px) {
  .workflows-page .wf-saved-list { flex: none; }
  .workflows-page .wf-saved { flex: 0 0 180px; }
}

/* New automation journeys use Workflows; retain legacy records and APIs. */
.automation-section-nav a[href="/automations"] {
  display: none;
}
