:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #eef2f5;
  --surface-soft: #f7fafc;
  --text: #18202a;
  --muted: #66717f;
  --border: #d8e0e7;
  --brand: #126a5a;
  --brand-strong: #0d4f43;
  --blue: #2367aa;
  --green: #16845f;
  --amber: #a66300;
  --red: #b12d2d;
  --shadow: 0 12px 28px rgba(24, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, Segoe UI, Roboto, Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-width: 0;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.topbar,
.summary-strip,
.workspace,
.detail-header,
.panel-header {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-button {
  min-height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 0 14px;
}

.tab-button.active {
  border-color: var(--brand);
  background: #edf7f4;
  color: var(--brand-strong);
}

.demo-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: var(--surface);
  margin-bottom: 14px;
  padding: 12px 14px;
}

.demo-context div {
  min-width: 0;
}

.demo-context span,
.panel-note {
  color: var(--muted);
  font-size: 12px;
}

.demo-context span {
  display: block;
  font-weight: 800;
  text-transform: uppercase;
}

.demo-context strong {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
}

h3 {
  margin-bottom: 0;
  font-size: 15px;
}

.muted,
.updated-at {
  color: var(--muted);
}

.updated-at {
  margin: 0;
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-email {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand-strong);
  cursor: pointer;
}

.text-button,
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  max-width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
  word-break: break-word;
}

.text-button {
  background: var(--surface);
  color: var(--brand-strong);
  padding: 8px 12px;
  white-space: normal;
}

.primary-button {
  width: 100%;
  background: var(--brand);
  color: #ffffff;
}

.icon-button:hover,
.text-button:hover,
.vehicle-item:hover {
  border-color: var(--brand);
}

.icon-button:focus-visible,
.text-button:focus-visible,
.primary-button:focus-visible,
.vehicle-item:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(18, 106, 90, 0.22);
  outline-offset: 2px;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.summary-strip article,
.panel,
.vehicle-pane,
.detail-pane {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.summary-strip article {
  padding: 14px 16px;
}

.metric-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-strip strong,
.health-grid strong {
  font-size: 26px;
  line-height: 1;
}

.workspace {
  align-items: flex-start;
  gap: 14px;
  min-height: 0;
}

.vehicle-pane {
  width: 390px;
  min-width: 320px;
  padding: 14px;
}

.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

select {
  min-width: 144px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.vehicle-list,
.event-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vehicle-item {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.vehicle-item.active {
  border-color: var(--brand);
  background: #edf7f4;
}

.vehicle-main,
.vehicle-sub,
.vehicle-signals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.vehicle-main strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-sub {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.vehicle-signals {
  margin-top: 10px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--muted);
}

.dot.online {
  background: var(--green);
}

.dot.offline {
  background: var(--red);
}

.status-badge,
.count-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.status-muted {
  background: var(--surface-strong);
  color: var(--muted);
}

.status-low,
.status-healthy {
  background: #e7f5ee;
  color: var(--green);
}

.status-moderate,
.status-satisfactory {
  background: #eef4fb;
  color: var(--blue);
}

.status-elevated,
.status-degraded,
.status-high {
  background: #fff3df;
  color: var(--amber);
}

.status-critical,
.status-poor {
  background: #fdeaea;
  color: var(--red);
}

.detail-pane {
  flex: 1;
  min-width: 0;
  padding: 18px;
}

.empty-state {
  display: grid;
  min-height: 620px;
  place-content: center;
  text-align: center;
}

.empty-state p {
  max-width: 360px;
  margin-bottom: 0;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  visibility: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  pointer-events: none !important;
  border: 0 !important;
}

.detail-header {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-header .muted {
  margin: 6px 0 0;
}

.health-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.health-grid article {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 14px;
}

.meter {
  height: 8px;
  overflow: hidden;
  margin-top: 12px;
  border-radius: 999px;
  background: #dbe3ea;
}

.meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.meter.risk span {
  background: var(--red);
}

.meter.coverage span {
  background: var(--blue);
}

.vehicle-facts {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.vehicle-facts article {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px;
}

.vehicle-facts span,
.measurement small {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-facts strong {
  display: block;
  overflow: hidden;
  margin-top: 5px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vehicle-section-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.vehicle-section-tab {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
  font-weight: 900;
}

.vehicle-section-tab.active {
  border-color: var(--brand);
  background: #edf7f4;
  color: var(--brand-strong);
}

.vehicle-section-panel[hidden] {
  display: none;
}

.vehicle-section-panel[data-vehicle-active-panel="true"] {
  max-height: clamp(420px, calc(100dvh - 260px), 680px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.panel {
  min-width: 0;
  min-height: 320px;
  padding: 14px;
  box-shadow: none;
}

.panel-header {
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-actions {
  display: flex;
  flex: 1 1 280px;
  max-width: 100%;
  min-width: 0;
  align-items: stretch;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-actions select {
  flex: 1 1 150px;
  min-width: 0;
  max-width: 100%;
}

.event-filter-actions {
  display: grid;
  flex: 1 1 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  align-items: center;
  justify-content: stretch;
}

.event-filter-actions select {
  width: 100%;
  min-width: 0;
  max-width: none;
}

.event-filter-actions .count-pill {
  justify-self: end;
  min-width: 0;
}

.diagnostic-panel {
  min-height: 0;
  margin-bottom: 14px;
}

.diagnostic-filter-actions select {
  flex-basis: 150px;
}

.diagnostic-code-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: clamp(260px, 42vh, 460px);
  overflow: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.diagnostic-code-row {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--amber);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.diagnostic-code-row.selected {
  border-color: var(--brand);
  border-left-color: var(--brand);
  background: #f4fbf8;
}

.diagnostic-code-main {
  flex: 1 1 auto;
  min-width: 0;
}

.diagnostic-code-main strong,
.diagnostic-code-main span {
  display: block;
}

.diagnostic-code-main strong {
  font-size: 15px;
}

.diagnostic-code-main span {
  overflow: visible;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  text-overflow: clip;
  white-space: normal;
}

.diagnostic-code-main span + span {
  margin-top: 4px;
}

.diagnostic-code-main .diagnostic-code-event {
  color: var(--text);
}

.diagnostic-code-main .diagnostic-code-lifecycle {
  color: var(--muted);
}

.diagnostic-code-side {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  flex-direction: column;
  gap: 6px;
}

.diagnostic-code-side small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
}

.diagnostic-code-side .text-button {
  min-width: 78px;
  padding: 4px 8px;
}

.diagnostic-event-history {
  margin-top: 10px;
}

.diagnostic-event-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.diagnostic-event-history-header strong {
  color: var(--text);
  font-size: 13px;
}

.diagnostic-event-history-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding-right: 4px;
}

.diagnostic-event-history-list .event small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.count-pill {
  background: var(--surface-strong);
  color: var(--muted);
}

.measurement-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 430px;
  overflow: auto;
  padding-right: 4px;
}

#events {
  max-height: 520px;
  overflow: auto;
  padding-right: 4px;
}

.measurement {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.measurement span,
.event time {
  color: var(--muted);
  font-size: 12px;
}

.measurement strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.measurement small {
  margin-top: 6px;
}

.event {
  border-left: 4px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 10px 12px;
}

.event.warning {
  border-color: var(--amber);
}

.event.critical {
  border-color: var(--red);
}

.event.resolved {
  border-color: var(--green);
  background: #f5faf8;
}

.event h4 {
  margin: 0 0 4px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.event p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.event small {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.event-resolution {
  color: var(--brand-strong);
  font-weight: 700;
}

.event-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(96px, auto);
  gap: 8px;
  margin-top: 10px;
}

.event-actions textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 10px;
}

.event-actions .text-button {
  align-self: end;
}

.message {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  text-align: center;
}

.message.error {
  border-color: var(--red);
  background: #fdeaea;
  color: var(--red);
}

.admin-workspace {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.admin-statusbar {
  margin-bottom: 0;
}

.admin-statusbar .message {
  padding: 10px 12px;
  text-align: left;
}

.admin-section-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 118px), 1fr));
  align-items: stretch;
  gap: 6px;
  margin-bottom: 8px;
  padding: 0 0 8px;
  background: var(--bg);
  overflow-x: visible;
}

.admin-section-tab {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 6px 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: normal;
}

.admin-section-tab.active {
  border-color: var(--brand);
  background: #edf7f4;
  color: var(--brand-strong);
}

.admin-section {
  min-width: 0;
}

.admin-section[hidden] {
  display: none;
}

.admin-section-grid {
  display: grid;
  align-items: start;
  justify-items: stretch;
  min-width: 0;
  gap: 10px;
}

.admin-section-grid--overview {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.admin-section-grid--single {
  grid-template-columns: minmax(0, 1fr);
}

.admin-section-grid--single > .admin-panel {
  width: 100%;
  max-width: none;
  justify-self: stretch;
}

.admin-section-grid--reports > .admin-panel {
  width: 100%;
}

.admin-panel {
  width: 100%;
  min-width: 0;
  min-height: 0;
  padding: 12px;
}

.admin-panel[data-admin-active-panel="true"],
.reports-section-panel[data-admin-active-panel="true"] {
  width: 100%;
}

.admin-panel[data-admin-active-panel="true"]:not(.admin-overview-panel) {
  max-height: clamp(360px, calc(100dvh - 172px), 720px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.mobile-demo-panel {
  border-top: 4px solid var(--brand);
}

.admin-overview-panel {
  border-top: 4px solid var(--brand);
}

.admin-overview-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.admin-overview-card {
  display: grid;
  min-width: 0;
  min-height: 58px;
  align-content: start;
  gap: 3px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 8px 9px;
  text-align: left;
}

.admin-overview-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-overview-card strong {
  font-size: 20px;
  line-height: 1;
}

.admin-overview-card small {
  display: block;
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  border-radius: 7px;
  padding: 2px 6px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-overview-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 130px), 1fr));
  gap: 8px;
  margin-top: 12px;
}

.admin-overview-link {
  width: 100%;
}

.panel-note {
  margin: -4px 0 12px;
  line-height: 1.35;
}

.admin-action-details {
  margin: 0 0 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.admin-action-details summary {
  min-height: 32px;
  padding: 7px 9px;
  color: var(--brand-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  list-style-position: inside;
}

.admin-action-details summary:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.admin-action-details[open] {
  padding-bottom: 8px;
}

.admin-action-details[open] summary {
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.admin-action-details .admin-form {
  margin: 0 10px;
}

.compact-filter-details {
  margin: 10px 0 12px;
}

.compact-filter-details summary {
  font-size: 12px;
}

.compact-filter-details .admin-form {
  margin-bottom: 0;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.admin-form--compact {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.admin-form input,
.admin-form select {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.admin-form select[multiple] {
  height: auto;
  min-height: 104px;
  padding: 6px 10px;
}

#adminUserRoles {
  min-height: 132px;
}

.admin-form button {
  align-self: end;
}

.admin-form .primary-button {
  width: auto;
  min-width: 140px;
  justify-self: start;
  padding-inline: 14px;
  white-space: normal;
}

.admin-overview-link,
.admin-panel .text-button,
.admin-panel .primary-button,
.admin-section-tab,
.reports-section-tab,
.device-section-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 9px;
  line-height: 1.2;
  text-align: center;
  vertical-align: middle;
}

.admin-panel .text-button,
.admin-panel .primary-button {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12px;
  white-space: normal;
}

.assignment-form {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.subsection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 14px;
}

.subsection-header h4 {
  margin: 0;
  font-size: 14px;
}

.admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

#adminVehicleList,
#adminUserList,
#assignmentHistoryList {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

#adminDeviceList {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

.work-session-list,
.mobile-token-list,
.measurement-quality-list {
  max-height: 420px;
  overflow: auto;
  padding-right: 4px;
}

[data-admin-scroll-region="true"] {
  min-width: 0;
  max-height: clamp(220px, 34vh, 360px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.admin-row {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
}

.admin-row div {
  min-width: 0;
}

.admin-row > :first-child {
  flex: 1 1 260px;
  min-width: 0;
}

.admin-row:is(.device-row, .user-row, .editable-vehicle-row) > :first-child {
  flex: 1 1 260px;
}

.admin-row > .status-badge,
.admin-row > .work-session-side,
.admin-row > .mobile-token-side,
.admin-row > .measurement-quality-side {
  margin-left: auto;
  max-width: min(100%, 210px);
}

.admin-row strong,
.admin-row span {
  display: block;
  overflow-wrap: break-word;
  word-break: normal;
}

.admin-row strong {
  max-width: 100%;
  overflow-wrap: anywhere;
}

.admin-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.device-row {
  align-items: flex-start;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.device-row > div:first-child {
  width: 100%;
  min-width: 0;
}

.device-row strong {
  overflow-wrap: anywhere;
  word-break: normal;
}

.device-assignment-actions {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  width: 100%;
  min-width: 0;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  max-width: 100%;
}

.device-assignment-actions .text-button {
  flex: 0 1 auto;
  min-width: 88px;
  max-width: 100%;
}

.assignment-target {
  flex: 1 1 160px;
  max-width: 100%;
  text-align: left;
  overflow-wrap: break-word;
  word-break: normal;
  white-space: normal;
}

.technical-line {
  max-width: 100%;
  color: var(--muted);
  overflow-wrap: anywhere;
  white-space: normal;
}

.assignment-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.work-session-filter-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mobile-token-filter-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.work-session-row {
  align-items: stretch;
  flex-direction: column;
}

.mobile-token-row {
  align-items: flex-start;
}

.work-session-side,
.mobile-token-side,
.measurement-quality-side {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-end;
  flex-direction: column;
  gap: 8px;
  min-width: min(100%, 160px);
  max-width: min(100%, 210px);
}

.work-session-side code,
.mobile-token-side code {
  color: var(--brand-strong);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
}

.work-session-id {
  color: var(--brand-strong);
  font-weight: 800;
}

.admin-row.work-session-row > :first-child,
.admin-row.work-session-row > .work-session-side {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
}

.work-session-side {
  align-items: center;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  min-width: 0;
}

.measurement-quality-side span:last-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.assignment-history-row {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.assignment-history-row div {
  min-width: 0;
}

.assignment-history-row strong,
.assignment-history-row span {
  display: block;
  overflow-wrap: break-word;
  word-break: normal;
}

.assignment-history-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.admin-message-panel {
  min-height: 0;
}

.reports-section-panels,
.device-section-panels {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.admin-message-panel .export-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  max-height: clamp(260px, 44vh, 420px);
  max-height: none;
  overflow: visible;
  padding-right: 0;
  overscroll-behavior: auto;
  scrollbar-gutter: auto;
}

.admin-message-panel .audit-filter-form,
.admin-message-panel .export-filter-form {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
}

.admin-message-panel .panel-actions {
  flex: 0 1 auto;
}

.reports-section-tabs,
.device-section-tabs {
  display: grid;
  gap: 6px;
  margin: 8px 0 10px;
}

.reports-section-tabs {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
}

.device-section-tabs {
  width: min(100%, 360px);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  width: min(100%, 420px);
}

.reports-section-tab,
.device-section-tab {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  padding: 0 9px;
  font-weight: 900;
  white-space: normal;
}

.reports-section-tab.active,
.device-section-tab.active {
  border-color: var(--brand);
  background: #edf7f4;
  color: var(--brand-strong);
}

.reports-section-panel[hidden],
.device-section-panel[hidden] {
  display: none;
}

.reports-section-panel,
.device-section-panel {
  min-width: 0;
}

.reports-section-panel[data-admin-active-panel="true"] {
  max-height: clamp(300px, 58vh, 560px);
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.audit-filter-form {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  margin-top: 14px;
}

.audit-filter-form .text-button {
  width: auto;
  min-width: 0;
  max-width: min(100%, 180px);
  justify-self: start;
  white-space: nowrap;
}

.export-panel {
  margin-top: 0;
}

.export-header {
  border-top: 0;
  margin-top: 0;
  padding-top: 0;
}

.export-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 8px;
  margin-top: 0;
}

.export-filter-form {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  margin: 10px 0 14px;
}

.export-row {
  display: flex;
  min-width: 0;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
}

.export-row div {
  flex: 1 1 auto;
  min-width: 0;
}

.export-row strong,
.export-row span {
  display: block;
}

.export-row span {
  overflow: visible;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  text-overflow: clip;
  white-space: normal;
}

.export-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}

.export-actions .text-button {
  min-width: 62px;
}

.export-actions .text-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.user-row {
  align-items: stretch;
  flex-direction: column;
}

.admin-row.user-row > .user-main,
.admin-row.user-row > .row-action-details {
  flex: 0 0 auto;
  width: 100%;
}

.user-row > .user-main,
.user-row > .row-action-details {
  flex: 0 1 auto;
}

.editable-vehicle-row {
  align-items: stretch;
  flex-direction: column;
}

.admin-row.editable-vehicle-row > .editable-row-main,
.admin-row.editable-vehicle-row > .row-action-details {
  flex: 0 0 auto;
  width: 100%;
}

.row-action-details {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.row-action-details summary {
  min-height: 34px;
  padding: 8px 10px;
  color: var(--brand-strong);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  list-style-position: inside;
}

.row-action-details[open] {
  padding: 10px;
}

.row-action-details[open] summary {
  border-bottom: 1px solid var(--border);
  margin: -10px -10px 10px;
  padding: 8px 10px;
}

.editable-row-main,
.user-main,
.vehicle-management,
.user-management {
  display: grid;
  gap: 10px;
}

.editable-row-main,
.user-main {
  grid-template-columns: minmax(0, 1fr) minmax(0, auto);
  align-items: start;
  min-height: 0;
}

.vehicle-management {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  align-items: end;
}

.vehicle-management .text-button,
.assignment-form .text-button,
.work-session-filter-form .text-button,
.mobile-token-filter-form .text-button {
  width: auto;
  max-width: 100%;
  justify-self: start;
  white-space: nowrap;
}

.panel-actions,
.vehicle-management,
.user-management,
.export-actions,
.work-session-side,
.mobile-token-side,
.measurement-quality-side {
  min-width: 0;
}

.panel-actions .text-button,
.vehicle-management .text-button,
.user-management .text-button,
.device-assignment-actions .text-button,
.export-actions .text-button {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
  text-align: center;
}

.vehicle-management .text-button,
.assignment-form .text-button,
.work-session-filter-form .text-button,
.mobile-token-filter-form .text-button,
.device-assignment-actions .text-button,
.export-actions .text-button {
  align-self: end;
  justify-content: center;
}

.vehicle-management label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.vehicle-management input,
.vehicle-management select {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.user-role-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 5px;
}

.user-management {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  align-items: end;
}

.user-password-form {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
}

.user-management .user-password-form {
  min-width: 0;
}

.user-management label:first-child {
  grid-column: 1 / -1;
}

.user-management label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.user-management input,
.user-management select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.user-management input {
  height: 38px;
}

.user-management select {
  height: auto;
  min-height: 118px;
  padding: 6px 10px;
}

.user-management .text-button {
  width: auto;
  min-height: 38px;
  justify-self: start;
  overflow-wrap: anywhere;
  white-space: normal;
}

.admin-row code,
.audit-row code {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.technical-chip,
.audit-row code,
.mobile-token-side code {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--brand-strong);
  padding: 3px 8px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
}

.admin-row .role-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 8px;
  background: #edf7f4;
  color: var(--brand-strong);
  padding: 3px 8px;
  font-size: 12px;
  font-weight: 800;
}

.audit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.mobile-audit-header {
  margin-bottom: 10px;
}

.mobile-audit-list {
  margin-top: 0;
}

.audit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.mobile-audit-row {
  border-left: 4px solid var(--brand);
  background: #f5faf8;
}

.audit-row div {
  min-width: 0;
}

.audit-row strong,
.audit-row span {
  display: block;
}

.audit-row span {
  color: var(--muted);
  font-size: 12px;
}

.audit-row code {
  flex: 0 1 auto;
  max-width: min(100%, 180px);
  overflow: hidden;
  color: var(--brand-strong);
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: normal;
  overflow-wrap: anywhere;
}

.auth-page {
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(18, 106, 90, 0.08), rgba(35, 103, 170, 0.08)),
    var(--bg);
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  padding: 24px;
  place-items: center;
}

.auth-panel {
  width: min(420px, 100%);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-panel h1 {
  margin-bottom: 22px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-form input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0 12px;
}

.form-error {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--red);
  font-size: 13px;
}

@media (max-width: 980px) {
  .summary-strip,
  .demo-context,
  .health-grid {
    grid-template-columns: 1fr 1fr;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .admin-section-grid--overview {
    grid-template-columns: 1fr;
  }

  .admin-overview-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    flex-direction: column;
  }

  .vehicle-pane {
    width: 100%;
  }

  .vehicle-management {
    grid-template-columns: 1fr 1fr;
  }

  .vehicle-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .audit-filter-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .export-filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .work-session-filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mobile-token-filter-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-section-tabs {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 112px), 1fr));
  }

  .export-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 20px, 1480px);
    padding: 14px 0;
  }

  .topbar,
  .detail-header,
  .pane-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "email logout refresh"
      "updated logout refresh";
    align-items: center;
    justify-content: stretch;
    column-gap: 8px;
    row-gap: 2px;
  }

  .topbar-actions .account-email {
    grid-area: email;
  }

  .topbar-actions .updated-at {
    grid-area: updated;
  }

  #logoutButton {
    grid-area: logout;
  }

  #refreshButton {
    grid-area: refresh;
  }

  .account-email {
    max-width: 100%;
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }

  .summary-strip,
  .demo-context,
  .diagnostic-code-list,
  .diagnostic-event-history-list,
  .content-grid,
  .admin-section-grid,
  .admin-form,
  .audit-filter-form,
  .editable-row-main,
  .export-filter-form,
  .work-session-filter-form,
  .mobile-token-filter-form,
  .vehicle-management,
  .user-main,
  .user-management {
    grid-template-columns: 1fr;
  }

  .summary-strip,
  .vehicle-facts,
  .measurement-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .health-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .diagnostic-code-row {
    align-items: stretch;
    flex-direction: column;
  }

  .diagnostic-code-side {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    align-items: center;
    justify-content: stretch;
  }

  .diagnostic-code-side small {
    width: 100%;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .diagnostic-code-side .text-button {
    min-width: 82px;
    justify-self: end;
    max-width: 100%;
  }

  .summary-strip article,
  .health-grid article,
  .vehicle-facts article {
    padding: 10px;
  }

  .summary-strip strong,
  .health-grid strong {
    font-size: 22px;
  }

  .device-row {
    grid-template-columns: 1fr;
  }

  .device-assignment-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .device-assignment-actions .text-button {
    width: auto;
    max-width: 100%;
  }

  .admin-form .primary-button {
    width: 100%;
    min-width: 0;
    align-self: stretch;
    white-space: normal;
  }

  .audit-filter-form .text-button {
    min-width: 0;
    align-self: end;
    justify-self: start;
  }

  .admin-section-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: stretch;
    gap: 4px;
    overflow-x: visible;
    padding: 0;
    scrollbar-width: none;
    scroll-snap-type: none;
  }

  .admin-section-tabs::after {
    content: none;
  }

  .admin-section-tabs::-webkit-scrollbar {
    display: none;
  }

  .admin-section-tab {
    width: 100%;
    min-width: 0;
    max-width: none;
    min-height: 28px;
    padding: 2px 4px;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.05;
    white-space: normal;
    scroll-snap-align: none;
  }

  .admin-overview-summary,
  .admin-overview-links,
  .reports-section-tabs,
  .device-section-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-overview-link:nth-child(n+3) {
    display: none;
  }

  .vehicle-section-panel[data-vehicle-active-panel="true"] {
    max-height: clamp(360px, calc(100dvh - 320px), 560px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
  }

  .assignment-target {
    max-width: 100%;
    text-align: left;
  }

  h1 {
    font-size: 24px;
  }

  .export-row {
    align-items: flex-start;
    flex-direction: column;
    padding: 8px;
  }

  .export-row span {
    display: block;
  }

  .export-actions {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

  .export-actions .text-button {
    min-width: 52px;
    flex: 1 1 112px;
    padding-inline: 8px;
  }

  .event-actions {
    grid-template-columns: 1fr;
  }

  .audit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .audit-row code {
    align-self: flex-start;
    max-width: 100%;
  }

  .user-management select {
    min-height: 132px;
  }

  .user-management {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-management .user-password-form {
    grid-column: 1 / -1;
  }

  .user-management .text-button {
    height: auto;
    min-height: 34px;
    min-width: 0;
    width: 100%;
    padding: 4px 8px;
    overflow: visible;
    font-size: 11px;
    line-height: 1.15;
    text-overflow: clip;
    white-space: normal;
  }

  .user-management > .text-button,
  .user-password-form .text-button {
    max-height: 42px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions select {
    width: 100%;
    height: 38px;
    flex: 0 0 auto;
  }

  .admin-panel .panel-header > .panel-actions {
    flex: 0 1 auto;
    align-items: center;
    flex-direction: row;
    justify-content: flex-start;
  }

  .admin-panel .panel-header > .panel-actions .text-button {
    width: auto;
  }

  .event-filter-actions {
    grid-template-columns: 1fr;
  }

  .event-filter-actions .count-pill {
    justify-self: stretch;
  }

  .diagnostic-panel .panel-header {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .diagnostic-filter-actions select {
    flex-basis: auto;
  }

  .diagnostic-event-history-list,
  .measurement-grid,
  #events {
    max-height: 260px;
  }
}
