:root {
  color-scheme: light;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-soft: #eef3f0;
  --surface-strong: #e4ebe7;
  --ink: #17231f;
  --muted: #64716c;
  --line: #d8e0dc;
  --line-strong: #bdc9c3;
  --primary: #137b63;
  --primary-dark: #0d5b49;
  --primary-soft: #dff2eb;
  --blue: #3269c8;
  --blue-soft: #e7efff;
  --amber: #9b6810;
  --amber-soft: #fff2d6;
  --danger: #bd3d45;
  --danger-dark: #902d34;
  --danger-soft: #fde9ea;
  --charcoal: #1d2925;
  --shadow: 0 12px 34px rgba(29, 41, 37, .1);
  --sidebar-width: 248px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; letter-spacing: 0; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, p { margin-top: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.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; }

.button, .icon-button, .avatar-button {
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
}
.button { border-radius: 6px; padding: 9px 15px; font-weight: 700; }
.button.primary { background: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: var(--surface); border-color: var(--line); }
.button.secondary:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.button.danger { background: var(--danger); color: #fff; }
.button.danger:hover { background: var(--danger-dark); }
.button.ghost { border-color: var(--line); background: transparent; }
.button.large { min-height: 48px; padding: 12px 20px; }
.button.glass { color: #fff; border-color: rgba(255,255,255,.55); background: rgba(18, 31, 27, .55); }
.button:disabled, .icon-button:disabled { opacity: .45; cursor: not-allowed; }
.button svg, .icon-button svg { width: 18px; height: 18px; stroke-width: 2; }
.icon-button { width: 38px; height: 38px; min-height: 38px; border-color: var(--line); border-radius: 50%; background: var(--surface); flex: 0 0 auto; }
.icon-button:hover { border-color: var(--line-strong); background: var(--surface-soft); }
.avatar-button { width: 38px; height: 38px; min-height: 38px; border-radius: 50%; background: var(--charcoal); color: #fff; font-weight: 800; }

.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: var(--primary); flex: 0 0 auto; }
.brand-mark svg { width: 21px; height: 21px; }

/* Public portal */
.public-shell { background: var(--surface); }
.public-nav {
  position: absolute;
  z-index: 5;
  inset: 0 0 auto;
  height: 76px;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.24);
}
.public-brand, .app-brand { display: flex; align-items: center; gap: 11px; min-width: 190px; }
.public-brand strong, .app-brand strong { display: block; font-size: 17px; line-height: 1.1; }
.public-brand small, .app-brand small { display: block; margin-top: 3px; opacity: .7; font-size: 11px; }
.public-links { display: flex; gap: 26px; margin: 0 auto; }
.public-links a { padding: 8px 0; color: rgba(255,255,255,.84); font-weight: 600; }
.public-links a:hover { color: #fff; }
.public-actions { display: flex; gap: 8px; }
.public-nav .button.secondary { color: #fff; border-color: rgba(255,255,255,.5); background: rgba(20,31,27,.32); }

.hero {
  position: relative;
  height: min(860px, calc(100svh - 72px));
  min-height: 650px;
  background: #26342e url('/ui/assets/robot-platform.jpg') center 54% / cover no-repeat;
  color: #fff;
  overflow: hidden;
}
.hero-shade { position: absolute; inset: 0; background: rgba(11, 23, 19, .58); }
.hero-content { position: relative; z-index: 2; width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding-top: 176px; }
.eyebrow { margin-bottom: 14px; font-size: 12px; line-height: 1.2; font-weight: 800; text-transform: uppercase; color: #b8eee0; }
.eyebrow.dark { color: var(--primary); }
.hero h1 { margin-bottom: 18px; max-width: 800px; font-size: 64px; line-height: 1; font-weight: 760; }
.hero-copy { max-width: 680px; margin-bottom: 28px; color: rgba(255,255,255,.86); font-size: 20px; line-height: 1.7; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-signals { display: flex; gap: 12px 26px; flex-wrap: wrap; margin-top: 48px; color: rgba(255,255,255,.84); font-weight: 650; }
.hero-signals span { display: inline-flex; align-items: center; gap: 8px; }
.hero-signals svg { width: 18px; }
.photo-credit { position: absolute; z-index: 2; right: 18px; bottom: 14px; margin: 0; color: rgba(255,255,255,.62); font-size: 10px; }

.product-band, .workflow-band, .safety-band { width: 100%; }
.product-band { background: var(--surface); }
.workflow-band { background: var(--bg); }
.safety-band { background: var(--charcoal); color: #fff; }
.band-inner { width: min(1240px, calc(100% - 48px)); margin: 0 auto; padding: 88px 0; }
.split-band { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 96px; align-items: start; }
.split-band h2, .section-heading h2, .safety-copy h2 { max-width: 590px; margin-bottom: 0; font-size: 38px; line-height: 1.25; }
.capability-list { border-top: 1px solid var(--line); }
.capability-list article { display: grid; grid-template-columns: 42px minmax(0, 1fr); gap: 18px; padding: 24px 0; border-bottom: 1px solid var(--line); }
.capability-list article > svg { color: var(--primary); width: 27px; height: 27px; margin-top: 2px; }
.capability-list h3 { margin-bottom: 5px; font-size: 17px; }
.capability-list p { margin-bottom: 0; color: var(--muted); }
.section-heading { margin-bottom: 42px; }
.workflow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
.workflow li { min-width: 0; padding: 30px; border-right: 1px solid var(--line-strong); }
.workflow li:first-child { padding-left: 0; }
.workflow li:last-child { border-right: 0; padding-right: 0; }
.workflow li > span { display: block; margin-bottom: 32px; color: var(--primary); font-size: 13px; font-weight: 800; }
.workflow h3 { margin-bottom: 8px; font-size: 19px; }
.workflow p { margin-bottom: 0; color: var(--muted); }
.safety-layout { display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); gap: 90px; align-items: center; }
.safety-copy p:last-child { max-width: 560px; margin: 22px 0 0; color: #bfcac5; font-size: 16px; }
.safety-states { border-top: 1px solid #52615a; }
.safety-states > div { display: grid; grid-template-columns: 130px minmax(0, 1fr) auto; gap: 16px; align-items: center; min-height: 76px; border-bottom: 1px solid #52615a; }
.safety-states b { color: #9ee0cf; }
.safety-states span { color: #dce4e0; }
.safety-states em { color: #9facA6; font-style: normal; font-variant-numeric: tabular-nums; }
.public-footer { min-height: 90px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 max(24px, calc((100vw - 1240px) / 2)); color: var(--muted); border-top: 1px solid var(--line); }
.public-footer span:first-child { color: var(--ink); font-weight: 800; }

/* Application shell */
.app-shell { min-height: 100vh; background: var(--bg); }
.sidebar { position: fixed; z-index: 20; inset: 0 auto 0 0; width: var(--sidebar-width); display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--line); }
.app-brand { min-height: 76px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.app-nav { display: grid; gap: 3px; padding: 18px 12px; overflow-y: auto; }
.app-nav a { display: flex; align-items: center; gap: 11px; min-height: 42px; padding: 9px 11px; border-radius: 6px; color: #52605b; font-weight: 650; }
.app-nav a svg { width: 18px; height: 18px; }
.app-nav a:hover { background: var(--surface-soft); color: var(--ink); }
.app-nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
.app-nav .nav-section { margin: 15px 11px 5px; color: #8a9691; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.sidebar-foot { margin-top: auto; min-height: 76px; padding: 12px; display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); }
.user-chip { min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; }
.user-chip > span { width: 35px; height: 35px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-weight: 800; }
.user-chip div { min-width: 0; }
.user-chip strong, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: 13px; }
.user-chip small { margin-top: 2px; color: var(--muted); font-size: 11px; }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar { height: 76px; position: sticky; z-index: 15; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 28px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title p { margin: 0 0 2px; color: var(--muted); font-size: 11px; font-weight: 700; }
.topbar h1 { margin: 0; font-size: 20px; line-height: 1.2; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.connection-state { display: flex; align-items: center; gap: 7px; margin-right: 4px; color: var(--muted); font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #87918d; }
.status-dot.online { background: #20a57f; box-shadow: 0 0 0 4px rgba(32,165,127,.12); }
.mobile-menu { display: none; }
.security-banner { margin: 18px 28px 0; min-height: 52px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; background: var(--amber-soft); border: 1px solid #eed59d; border-radius: 8px; color: #69480c; }
.security-banner svg { width: 20px; flex: 0 0 auto; }
.security-banner p { margin: 0; flex: 1; }
.content { width: min(1440px, 100%); margin: 0 auto; padding: 26px 28px 50px; }
.page-loading { min-height: 360px; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--muted); }
.page-loading span { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 20px; }
.page-head h2 { margin-bottom: 5px; font-size: 22px; }
.page-head p { margin-bottom: 0; color: var(--muted); }
.page-actions, .toolbar, .filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.metric { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); }
.metric-top svg { width: 19px; color: var(--primary); }
.metric strong { display: block; margin-top: 12px; font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric small { display: block; margin-top: 9px; color: var(--muted); }
.metric.warn .metric-top svg { color: var(--amber); }
.metric.bad .metric-top svg { color: var(--danger); }
.metric.blue .metric-top svg { color: var(--blue); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 16px; align-items: start; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.panel + .panel { margin-top: 16px; }
.panel-head { min-height: 58px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); }
.panel-head h2, .panel-head h3 { margin: 0; font-size: 15px; }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }
.panel-note { color: var(--muted); font-size: 12px; }

.table-wrap { width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.dashboard-grid .data-table { min-width: 620px; }
.data-table th, .data-table td { padding: 13px 16px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.data-table th { color: var(--muted); background: #fafcfb; font-size: 11px; font-weight: 800; white-space: nowrap; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fbfdfc; }
.primary-cell { min-width: 180px; }
.primary-cell strong, .primary-cell small { display: block; }
.primary-cell small { margin-top: 3px; color: var(--muted); overflow-wrap: anywhere; }
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; white-space: nowrap; }
.row-button { width: 32px; height: 32px; min-height: 32px; }

.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 25px; max-width: 100%; padding: 3px 8px; border-radius: 999px; background: var(--surface-soft); color: #53615c; border: 1px solid transparent; font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge svg { width: 13px; height: 13px; }
.badge.ok { color: #0c6b54; background: var(--primary-soft); }
.badge.warn { color: #74500f; background: var(--amber-soft); }
.badge.bad { color: #982f37; background: var(--danger-soft); }
.badge.info { color: #2a59ad; background: var(--blue-soft); }
.badge.neutral { border-color: var(--line); background: var(--surface); }
.status-stack { display: flex; gap: 5px; flex-wrap: wrap; }

.event-list { display: grid; }
.event-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 11px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.event-row:last-child { border-bottom: 0; }
.event-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: var(--blue-soft); }
.event-icon.stop { color: var(--danger); background: var(--danger-soft); }
.event-icon.agent { color: var(--primary); background: var(--primary-soft); }
.event-icon svg { width: 17px; }
.event-main { min-width: 0; }
.event-main strong, .event-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.event-main small { margin-top: 3px; color: var(--muted); }
.event-time { color: var(--muted); font-size: 11px; white-space: nowrap; }

.empty-state { min-height: 260px; display: grid; place-items: center; align-content: center; padding: 36px; text-align: center; }
.empty-state > svg { width: 38px; height: 38px; margin-bottom: 15px; color: var(--primary); }
.empty-state h3 { margin-bottom: 6px; font-size: 17px; }
.empty-state p { max-width: 430px; margin-bottom: 18px; color: var(--muted); }

.filter-bar { justify-content: space-between; margin-bottom: 14px; }
.search-box { position: relative; flex: 1; min-width: 220px; max-width: 420px; }
.search-box svg { position: absolute; left: 11px; top: 50%; width: 17px; color: var(--muted); transform: translateY(-50%); }
.search-box input { width: 100%; padding-left: 37px; }
input, select, textarea { min-height: 40px; max-width: 100%; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink); padding: 8px 10px; outline: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(19,123,99,.12); }
input[type="range"] { padding: 0; border: 0; box-shadow: none; accent-color: var(--primary); }
textarea { min-height: 100px; resize: vertical; }
label { color: #43504b; font-weight: 650; }
label small { color: var(--muted); font-weight: 500; }
label > input, label > select, label > textarea, label > .password-input { width: 100%; margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-stack { display: grid; gap: 15px; }
.form-heading h2 { margin-bottom: 4px; font-size: 23px; }
.form-heading p { margin-bottom: 3px; color: var(--muted); }
.form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.form-error { margin: 0; padding: 9px 10px; border-radius: 6px; background: var(--danger-soft); color: var(--danger-dark); font-weight: 600; }
.switch-row { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #b6c0bc; cursor: pointer; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }

/* Robot detail workspace */
.detail-header { min-height: 72px; display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.detail-back { margin-right: 2px; }
.robot-avatar { position: relative; width: 48px; height: 48px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px; color: var(--primary-dark); background: var(--primary-soft); }
.robot-avatar > svg { width: 25px; height: 25px; }
.robot-avatar .presence { position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border: 2px solid var(--bg); border-radius: 50%; background: #8a9691; }
.robot-avatar .presence.online { background: #1b9a76; }
.detail-title { min-width: 0; flex: 1; }
.detail-title h2 { margin: 0 0 3px; font-size: 22px; }
.detail-title p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.detail-actions { display: flex; justify-content: flex-end; align-items: center; gap: 7px; flex-wrap: wrap; }
.detail-tabs { min-height: 48px; display: flex; align-items: end; gap: 22px; margin-bottom: 18px; border-bottom: 1px solid var(--line-strong); overflow-x: auto; }
.detail-tabs { scrollbar-width: none; }
.detail-tabs::-webkit-scrollbar { display: none; }
.detail-tab { position: relative; min-width: max-content; min-height: 47px; display: inline-flex; align-items: center; gap: 7px; padding: 0 1px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.detail-tab svg { width: 16px; height: 16px; }
.detail-tab::after { content: ""; position: absolute; inset: auto 0 -1px; height: 2px; background: transparent; }
.detail-tab.active { color: var(--primary-dark); }
.detail-tab.active::after { background: var(--primary); }
.detail-view { display: none; }
.detail-view.active { display: block; }
.metrics.compact { margin-bottom: 16px; }
.license-gate { min-height: 82px; display: flex; align-items: center; gap: 14px; margin-bottom: 16px; padding: 14px 16px; border: 1px solid #e5bd72; border-radius: 8px; background: var(--amber-soft); color: #68470c; }
.license-gate .gate-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: #f7d894; }
.license-gate svg { width: 21px; height: 21px; }
.license-gate strong { display: block; margin-bottom: 3px; }
.license-gate p { margin: 0; color: #7d5b1d; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.detail-grid > .panel { margin-top: 0; }
.detail-kv { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 0; padding: 5px 16px; }
.detail-kv > span, .detail-kv > strong, .detail-kv > code { min-height: 43px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.detail-kv > span:nth-last-child(-n+2), .detail-kv > strong:last-child, .detail-kv > code:last-child { border-bottom: 0; }
.detail-kv > span { color: var(--muted); font-size: 12px; }
.detail-kv > strong, .detail-kv > code { min-width: 0; overflow-wrap: anywhere; }
.detail-kv > code { color: #285d4d; font-size: 12px; }
.gps-readout { min-height: 210px; padding: 30px 20px; display: grid; place-items: center; align-content: center; text-align: center; background: #f7faf8; }
.gps-readout > svg { width: 31px; height: 31px; margin-bottom: 12px; color: var(--primary); }
.gps-readout strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.gps-readout span { margin-top: 7px; color: var(--muted); font-size: 12px; }
.motor-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.motor-grid > div { min-width: 0; min-height: 96px; display: grid; place-items: center; align-content: center; border-right: 1px solid var(--line); }
.motor-grid > div:last-child { border-right: 0; }
.motor-grid span { color: var(--muted); font-size: 11px; }
.motor-grid strong { margin-top: 5px; font-size: 24px; font-variant-numeric: tabular-nums; }
.motion-row { display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 8px 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.motion-row span { color: var(--muted); font-size: 12px; }
.motion-row strong { font-size: 12px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: end; }
.inline-form .button { margin-bottom: 1px; }
.power-panel { grid-column: 1 / -1; }
.power-actions { display: flex; gap: 10px; padding: 16px; }
.authorization-layout { display: grid; grid-template-columns: minmax(260px, .6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.authorization-layout > .panel { margin-top: 0; }
.authorization-layout > .panel:last-child { grid-column: 1 / -1; }
.authorization-status { min-height: 205px; padding: 24px; display: flex; align-items: center; gap: 17px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.authorization-status.valid { border-color: #a7d7c9; background: #f2faf7; }
.authorization-status.invalid { border-color: #e5bd72; background: #fffaf0; }
.authorization-mark { width: 54px; height: 54px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--primary-dark); background: var(--primary-soft); }
.authorization-status.invalid .authorization-mark { color: var(--amber); background: #f7dfaa; }
.authorization-mark svg { width: 27px; height: 27px; }
.authorization-status span, .authorization-status strong, .authorization-status p { display: block; }
.authorization-status span { color: var(--muted); font-size: 12px; }
.authorization-status strong { margin: 4px 0 8px; font-size: 26px; }
.authorization-status p { margin: 0; color: var(--muted); }
.agent-log-table { min-width: 1120px; }
.agent-log-table td { vertical-align: top; }
.log-time { width: 190px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.log-level { display: inline-flex; padding: 2px 6px; border-radius: 4px; color: #345c50; background: var(--surface-soft); font-size: 10px; font-weight: 800; text-transform: uppercase; }
.log-level.warn { color: #74500f; background: var(--amber-soft); }
.log-level.error, .log-level.critical { color: var(--danger-dark); background: var(--danger-soft); }
.motor-inline { min-width: 180px; }
.motor-inline span { display: inline-block; margin: 0 7px 4px 0; color: var(--muted); font-size: 10px; white-space: nowrap; }
.table-empty { min-height: 120px; display: grid; place-items: center; color: var(--muted); }
.detail-events { margin-top: 16px; }
.terminal-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, .5fr); gap: 16px; align-items: start; }
.terminal-window { min-width: 0; overflow: hidden; border: 1px solid #26332e; border-radius: 8px; background: #15201c; color: #d8e5df; }
.terminal-bar { min-height: 45px; padding: 0 14px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; border-bottom: 1px solid #32413b; background: #1d2a25; color: #9fb0a9; font-size: 11px; }
.terminal-bar > div { display: flex; gap: 6px; }
.terminal-bar > div span { width: 8px; height: 8px; border-radius: 50%; background: #77837e; }
.terminal-bar > div span:first-child { background: #d56368; }
.terminal-bar > div span:nth-child(2) { background: #d8a43c; }
.terminal-bar > div span:last-child { background: #3fa17f; }
.terminal-bar > span { text-align: right; }
.terminal-window pre { height: 420px; margin: 0; padding: 18px; overflow: auto; color: #dbe9e3; font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.terminal-command { min-height: 50px; display: grid; grid-template-columns: auto minmax(0, 1fr) 36px; gap: 8px; align-items: center; padding: 6px 8px 6px 14px; border-top: 1px solid #32413b; }
.terminal-command > span { color: #77d5b8; font-family: ui-monospace, monospace; }
.terminal-command input { min-height: 35px; border: 0; background: transparent; color: #eef8f4; box-shadow: none; font-family: ui-monospace, monospace; }
.terminal-command .icon-button { width: 34px; height: 34px; min-height: 34px; border-color: #42544d; background: #26372f; color: #dbe9e3; }
.terminal-side { display: grid; gap: 16px; }
.terminal-side .panel { margin-top: 0; }
.quick-commands { display: grid; padding: 8px; }
.quick-commands button { min-height: 38px; padding: 8px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: #315c4f; text-align: left; cursor: pointer; font: 12px ui-monospace, monospace; }
.quick-commands button:last-child { border-bottom: 0; }
.quick-commands button:hover { background: var(--surface-soft); }
.quick-commands button:disabled { opacity: .45; cursor: not-allowed; }
.terminal-security { min-height: 68px; display: flex; align-items: center; gap: 11px; padding: 13px; border: 1px solid #add6c9; border-radius: 8px; background: #f1f9f6; }
.terminal-security > svg { width: 21px; color: var(--primary); }
.terminal-security strong, .terminal-security span { display: block; }
.terminal-security span { margin-top: 2px; color: var(--muted); font-size: 11px; }

/* Control center */
.control-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, .7fr); gap: 16px; align-items: start; }
.video-panel { overflow: hidden; }
.video-toolbar { min-height: 58px; padding: 10px 14px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.video-toolbar select { min-width: 220px; margin-right: auto; }
.video-stage { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 260px; display: grid; place-items: center; overflow: hidden; background: #111a17; }
.video-stage img { width: 100%; height: 100%; object-fit: contain; }
.video-placeholder { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; color: #b9c5c0; text-align: center; background: #111a17; }
.video-placeholder svg { width: 34px; margin-bottom: 10px; }
.video-overlay { position: absolute; inset: auto 12px 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; pointer-events: none; }
.video-overlay .badge { background: rgba(18, 31, 27, .84); color: #fff; }
.control-safety { min-height: 49px; padding: 10px 14px; display: flex; align-items: center; gap: 9px; border-top: 1px solid var(--line); background: #f9fbfa; color: var(--muted); font-size: 12px; }
.control-safety strong { color: var(--ink); }
.control-safety .spacer { flex: 1; }
.control-sidebar { display: grid; gap: 16px; }
.drive-panel .panel-body { padding: 18px; }
.speed-control { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: center; margin-bottom: 18px; }
.speed-control label { color: var(--muted); font-size: 12px; }
.speed-control output { min-width: 48px; text-align: right; color: var(--primary); font-weight: 800; }
.speed-control input { grid-column: 1 / -1; width: 100%; }
.direction-pad { width: min(100%, 248px); margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 62px); gap: 8px; }
.drive-button { min-width: 0; min-height: 62px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); cursor: pointer; touch-action: none; }
.drive-button:hover, .drive-button.active { color: #fff; border-color: var(--primary); background: var(--primary); }
.drive-button svg { width: 22px; }
.drive-button.stop { color: var(--danger); border-color: #e7b9bd; background: var(--danger-soft); }
.drive-button.stop:hover { color: #fff; background: var(--danger); }
.emergency-button { width: 100%; min-height: 48px; margin-top: 14px; }
.command-feedback { min-height: 36px; margin: 12px 0 0; padding: 8px 10px; border-radius: 6px; color: var(--muted); background: var(--surface-soft); font-size: 12px; }
.telemetry-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.telemetry-grid div { padding: 13px 15px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.telemetry-grid div:nth-child(2n) { border-right: 0; }
.telemetry-grid div:nth-last-child(-n+2) { border-bottom: 0; }
.telemetry-grid span, .telemetry-grid strong { display: block; }
.telemetry-grid span { color: var(--muted); font-size: 11px; }
.telemetry-grid strong { margin-top: 4px; font-size: 14px; overflow-wrap: anywhere; }

.deployment-layout { display: grid; grid-template-columns: minmax(280px, .65fr) minmax(0, 1.35fr); gap: 16px; align-items: start; }
.command-box { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--line); }
.command-box > p { margin-bottom: 12px; color: var(--muted); }
.command-item { margin-top: 12px; }
.command-item label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.command-value { display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 7px; }
.command-value code { min-width: 0; max-height: 92px; overflow: auto; padding: 9px 10px; border: 1px solid var(--line); border-radius: 6px; background: #f7faf8; color: #25433a; font-size: 11px; overflow-wrap: anywhere; white-space: pre-wrap; }
.ports { display: flex; flex-wrap: wrap; gap: 6px; }

.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.security-note { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; padding: 11px; border: 1px solid #edd8a6; border-radius: 6px; background: var(--amber-soft); color: #6d4d12; }
.security-note svg { width: 19px; flex: 0 0 auto; }
.security-note p { margin: 0; }

/* Dialogs and toast */
.modal { width: min(480px, calc(100vw - 28px)); max-height: min(88vh, 820px); overflow: auto; padding: 26px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.wide-modal { width: min(720px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(18, 29, 25, .46); backdrop-filter: blur(3px); }
.modal-close { position: absolute; top: 13px; right: 13px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand strong, .auth-brand small { display: block; }
.auth-brand small { color: var(--muted); font-size: 11px; }
.segmented { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; margin-bottom: 24px; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.segmented button { min-height: 35px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); cursor: pointer; font-weight: 700; }
.segmented button.active { color: var(--ink); background: var(--surface); box-shadow: 0 1px 4px rgba(29,41,37,.1); }
.password-input { position: relative; }
.password-input input { width: 100%; padding-right: 44px; }
.password-input .icon-button { position: absolute; right: 2px; top: 2px; border: 0; background: transparent; }
.submit-button { width: 100%; margin-top: 3px; }
.role-note { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: 11px; }
.role-note svg { width: 15px; }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.dialog-head h2 { margin-bottom: 4px; font-size: 21px; }
.dialog-head p { margin-bottom: 0; color: var(--muted); overflow-wrap: anywhere; }
.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 18px; width: min(360px, calc(100vw - 36px)); display: grid; gap: 8px; }
.toast { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; gap: 9px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast svg { width: 18px; color: var(--primary); }
.toast.error svg { color: var(--danger); }
.toast button { border: 0; background: none; color: var(--muted); cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.sidebar-scrim { position: fixed; z-index: 19; inset: 0; width: 100%; height: 100%; border: 0; background: rgba(18,29,25,.42); }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .control-layout, .deployment-layout { grid-template-columns: 1fr; }
  .control-sidebar { grid-template-columns: minmax(280px, .8fr) minmax(0, 1.2fr); }
  .terminal-layout { grid-template-columns: 1fr; }
  .terminal-side { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .public-nav { height: 66px; padding: 0 16px; }
  .public-links { display: none; }
  .public-brand { min-width: 0; margin-right: auto; }
  .public-brand small { display: none; }
  .public-actions .button { padding: 8px 11px; }
  .hero { height: calc(100svh - 42px); min-height: 610px; background-position: 58% center; }
  .hero-content { width: calc(100% - 32px); padding-top: 144px; }
  .hero h1 { font-size: 44px; }
  .hero-copy { max-width: 530px; font-size: 17px; }
  .hero-signals { margin-top: 34px; gap: 10px 16px; }
  .band-inner { width: calc(100% - 32px); padding: 62px 0; }
  .split-band, .safety-layout { grid-template-columns: 1fr; gap: 42px; }
  .split-band h2, .section-heading h2, .safety-copy h2 { font-size: 30px; }
  .workflow { grid-template-columns: 1fr; }
  .workflow li, .workflow li:first-child, .workflow li:last-child { padding: 24px 0; border-right: 0; border-bottom: 1px solid var(--line-strong); }
  .workflow li:last-child { border-bottom: 0; }
  .workflow li > span { margin-bottom: 16px; }
  .public-footer { padding: 0 16px; }

  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .workspace { margin-left: 0; }
  .mobile-menu { display: inline-flex; }
  .topbar { height: 68px; padding: 0 16px; }
  .connection-state { display: none; }
  .content { padding: 20px 16px 42px; }
  .security-banner { margin: 14px 16px 0; }
  .settings-layout, .control-sidebar { grid-template-columns: 1fr; }
  .detail-grid, .authorization-layout { grid-template-columns: 1fr; }
  .authorization-layout > .panel:last-child { grid-column: auto; }
}

@media (max-width: 600px) {
  .hero { min-height: 630px; }
  .hero-content { padding-top: 124px; }
  .hero h1 { font-size: 38px; }
  .hero-copy { font-size: 16px; line-height: 1.6; }
  .hero-actions { display: grid; grid-template-columns: 1fr; width: min(100%, 320px); }
  .hero-signals span { width: 100%; }
  .photo-credit { font-size: 9px; }
  .safety-states > div { grid-template-columns: 1fr auto; padding: 13px 0; }
  .safety-states span { grid-column: 1 / -1; grid-row: 2; }
  .public-footer { align-items: flex-start; flex-direction: column; justify-content: center; gap: 2px; }

  .topbar-title p { display: none; }
  .topbar h1 { font-size: 18px; }
  .topbar-actions { gap: 6px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metric { padding: 13px; }
  .metric strong { font-size: 24px; }
  .metric small { display: none; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-actions .button { flex: 1; }
  .form-grid { grid-template-columns: 1fr; }
  .filter-bar { align-items: stretch; flex-direction: column; }
  .search-box { width: 100%; max-width: none; }
  .video-toolbar { align-items: stretch; flex-wrap: wrap; }
  .video-toolbar select { width: 100%; margin: 0; }
  .video-stage { min-height: 200px; }
  .direction-pad { grid-template-rows: repeat(3, 56px); }
  .drive-button { min-height: 56px; }
  .modal { padding: 22px 18px; }
  .detail-header { align-items: flex-start; flex-wrap: wrap; }
  .detail-title { flex: 1 1 calc(100% - 126px); }
  .detail-actions { width: 100%; justify-content: flex-start; padding-left: 54px; }
  .detail-tabs { gap: 18px; }
  .detail-kv { grid-template-columns: 96px minmax(0, 1fr); }
  .motor-grid { grid-template-columns: repeat(2, 1fr); }
  .motor-grid > div:nth-child(2) { border-right: 0; }
  .motor-grid > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .motion-row { grid-template-columns: auto 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .power-actions { display: grid; grid-template-columns: 1fr; }
  .terminal-side { grid-template-columns: 1fr; }
  .terminal-window pre { height: 330px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
