:root {
  --bg: #f3f4f5;
  --panel: #ffffff;
  --surface: #ffffff;
  --ink: #111111;
  --muted: #686868;
  --subtle: #8a8a8a;
  --line: #dddddd;
  --line-strong: #c8c8c8;
  --soft: #f6f6f6;
  --soft-2: #ebebeb;
  --soft-3: #d8d8d8;
  --primary: #111111;
  --primary-hover: #282828;
  --primary-text: #ffffff;
  --track-fill: #4a4a4a;
  --track-warning: #747474;
  --overlay: rgba(0, 0, 0, .64);
  --focus: rgba(0, 0, 0, .07);
  --shadow: 0 10px 30px rgba(0, 0, 0, .045);
  --modal-shadow: 0 24px 90px rgba(0, 0, 0, .24);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --control-height: 40px;
  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
  --space-4: 18px;
  --space-5: 24px;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e0f10;
  --panel: #171819;
  --surface: #1d1f20;
  --ink: #f2f2f2;
  --muted: #a7a7a7;
  --subtle: #7f8285;
  --line: #2d3032;
  --line-strong: #44484b;
  --soft: #202224;
  --soft-2: #282b2d;
  --soft-3: #303336;
  --primary: #f1f1f1;
  --primary-hover: #ffffff;
  --primary-text: #111111;
  --track-fill: #b8b8b8;
  --track-warning: #858585;
  --overlay: rgba(0, 0, 0, .78);
  --focus: rgba(255, 255, 255, .09);
  --shadow: 0 12px 34px rgba(0, 0, 0, .16);
  --modal-shadow: 0 28px 90px rgba(0, 0, 0, .55);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: light; }
html[data-theme="dark"] { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  transition: background-color .18s ease, color .18s ease;
}

button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }

.topbar {
  min-height: 82px;
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  background: var(--panel);
  border-top: 6px solid var(--ink);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-wrap,
.vehicle-switcher,
.topbar-actions,
.topbar-controls,
.unit-switcher,
.head-actions,
.form-row,
.modal-actions,
.components-head,
.component-filter,
.backup-actions,
.activity-toolbar {
  display: flex;
  align-items: center;
}

.brand-logo {
  width: 160px;
  max-height: 48px;
  object-fit: contain;
  object-position: left center;
}

.topbar-actions { gap: 12px; margin-left: auto; }
.topbar-controls { gap: 10px; }
.vehicle-switcher, .unit-switcher { gap: 9px; }
.vehicle-switcher select { min-width: 230px; }

.segmented-control {
  display: inline-flex;
  padding: 3px;
  background: var(--soft-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

.segment-button {
  min-height: 30px;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.segment-button.is-active { background: var(--primary); color: var(--primary-text); }
.segment-button:focus-visible,
.icon-text-button:focus-visible,
.icon-menu-button:focus-visible,
.button:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.icon-text-button,
.icon-menu-button,
.icon-button {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  padding-bottom: 3px;
}

.icon-text-button {
  min-height: var(--control-height);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.icon-text-button:hover,
.icon-menu-button:hover,
.icon-button:hover { background: var(--soft); }

.action-menu { position: relative; }
.action-menu > summary { list-style: none; }
.action-menu > summary::-webkit-details-marker { display: none; }
.icon-menu-button {
  width: var(--control-height);
  height: var(--control-height);
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: .08em;
  user-select: none;
}

.action-menu-popover {
  position: absolute;
  z-index: 50;
  top: calc(100% + 8px);
  min-width: 210px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--modal-shadow);
}

.action-menu-popover-right { right: 0; }
.action-menu-popover button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  font-size: 12px;
  font-weight: 700;
}
.action-menu-popover button:hover { background: var(--soft); }
.action-menu-popover .menu-danger { font-weight: 850; }
.menu-separator { height: 1px; background: var(--line); margin: 5px 4px; }

.app-shell {
  width: min(1420px, calc(100% - 36px));
  margin: 0 auto;
  padding: 38px 0 72px;
}

.empty-state {
  min-height: 520px;
  display: grid;
  place-items: center;
  text-align: center;
}
.empty-state > div { max-width: 600px; }
.empty-state h1 { font-size: clamp(36px, 6vw, 70px); line-height: .98; margin: 8px 0 20px; }
.lede { font-size: 18px; line-height: 1.6; color: var(--muted); margin: 0 auto 28px; }

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  margin-bottom: 24px;
}
.dashboard-head h1 { font-size: clamp(32px, 4vw, 52px); margin: 4px 0 6px; letter-spacing: -0.04em; }
.head-actions { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: .16em;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}
.muted { color: var(--muted); }

.button {
  appearance: none;
  min-height: var(--control-height);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 9px 15px;
  font-weight: 780;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.button-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.button-secondary { background: var(--panel); border-color: var(--line-strong); color: var(--ink); }
.button-secondary:hover { background: var(--soft); }
.button-tertiary { background: transparent; color: var(--muted); border-color: transparent; }
.button-tertiary:hover { background: var(--soft); color: var(--ink); }
.button-destructive { background: transparent; color: var(--ink); border-color: var(--ink); }
.button-destructive:hover { background: var(--ink); color: var(--bg); }
.button-small { min-height: 32px; padding: 6px 10px; font-size: 12px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.summary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(420px, .9fr);
  gap: 14px;
  margin-bottom: 14px;
}

.distance-card {
  min-height: 150px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.stat-label { font-size: 12px; color: var(--muted); font-weight: 700; }
.distance-value-row { display: flex; align-items: baseline; gap: 12px; margin-top: 24px; }
.distance-value { font-size: clamp(42px, 6vw, 72px); letter-spacing: -0.055em; line-height: .9; }
.distance-unit { color: var(--muted); font-size: 16px; }

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
}
.mini-stat { padding: 22px 18px; display: flex; flex-direction: column; justify-content: space-between; min-height: 150px; }
.mini-stat + .mini-stat { border-left: 1px solid var(--line); }
.mini-stat strong { font-size: clamp(30px, 4vw, 46px); letter-spacing: -0.04em; }

.content-grid {
  display: grid;
  grid-template-columns: 1.5fr .7fr;
  gap: 14px;
  margin-bottom: 14px;
}
.attention-panel, .activity-panel, .components-panel { padding: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-head h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: -0.02em; }

.attention-list, .activity-list { display: grid; gap: 10px; }
.attention-item, .activity-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--surface);
}
.attention-item { display: grid; grid-template-columns: 1fr auto; gap: 14px; align-items: center; }
.attention-name { font-weight: 800; }
.attention-meta { margin-top: 4px; color: var(--muted); font-size: 13px; }
.attention-right { text-align: right; }
.attention-right strong { display: block; font-size: 16px; }
.activity-item strong { display: block; font-size: 13px; margin-top: 3px; }
.activity-item p { margin: 4px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.activity-date { font-size: 11px; color: var(--subtle); }

.component-filter { gap: 8px; }
.component-filter input { min-width: 240px; }
.component-filter select { width: auto; min-width: 130px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 980px; }
th, td { text-align: left; padding: 14px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: 10px; }
td { font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
.component-name strong { display: block; font-size: 14px; }
.component-name span { color: var(--muted); font-size: 12px; }
.component-identifiers { margin-top: 3px; }
.actions-col { width: 195px; text-align: right; }
.action-buttons { display: flex; gap: 7px; justify-content: flex-end; align-items: center; }
.row-menu .action-menu-popover { min-width: 205px; }
.row-menu .icon-menu-button { width: 34px; height: 34px; border-radius: var(--radius-sm); }

.life-cell { min-width: 150px; }
.life-track { height: 7px; background: var(--soft-2); border-radius: 999px; overflow: hidden; margin-top: 7px; }
.life-fill { height: 100%; border-radius: inherit; background: var(--track-fill); }
.life-fill.warning { background: var(--track-warning); }
.life-fill.danger { background: var(--ink); }

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid var(--line-strong);
}
.status-good { background: var(--surface); color: var(--muted); }
.status-warning { background: var(--soft-2); color: var(--ink); }
.status-danger { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.status-retired { background: var(--soft); color: var(--muted); border-style: dashed; }

.small-empty { padding: 26px 0 8px; color: var(--muted); text-align: center; }

.modal {
  border: 0;
  background: transparent;
  padding: 18px;
  width: min(640px, 100%);
  max-width: none;
  color: var(--ink);
}
.modal-compact { width: min(520px, 100%); }
.modal-wide { width: min(880px, 100%); }
.modal::backdrop { background: var(--overlay); backdrop-filter: blur(4px); }
.modal-card {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--modal-shadow);
  display: grid;
  gap: 17px;
  max-height: min(86vh, 900px);
  overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.modal-head h2 { margin: 4px 0 0; font-size: 24px; }
.icon-button {
  border-radius: 999px;
  width: 34px;
  height: 34px;
  font-size: 22px;
  line-height: 1;
}

label { display: grid; gap: 7px; font-size: 12px; font-weight: 750; }
input, select, textarea {
  width: 100%;
  min-height: var(--control-height);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
}
textarea { min-height: 88px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:focus, select:focus, textarea:focus { border-color: var(--ink); box-shadow: 0 0 0 3px var(--focus); }
.optional { font-weight: 500; color: var(--muted); }
.form-row { align-items: flex-start; gap: 14px; }
.form-row > * { flex: 1; }
.modal-actions { justify-content: flex-end; gap: 10px; margin-top: 4px; }
.modal-copy { margin: -4px 0 0; line-height: 1.55; }

.advanced-fields {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--soft);
}
.advanced-fields > summary {
  list-style: none;
  padding: 13px 14px;
  font-size: 12px;
  font-weight: 800;
}
.advanced-fields > summary::-webkit-details-marker { display: none; }
.advanced-fields > summary::after { content: '+'; float: right; color: var(--muted); }
.advanced-fields[open] > summary::after { content: '−'; }
.advanced-fields > summary span { font-weight: 500; color: var(--muted); margin-left: 6px; }
.advanced-fields-body { display: grid; gap: 14px; padding: 0 14px 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.field-help { margin: -5px 0 0; font-size: 11px; color: var(--muted); line-height: 1.45; }

.reset-warning, .confirm-box, .current-value-box {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.current-value-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.current-value-box strong { color: var(--ink); font-size: 14px; }
.form-error {
  margin: 0;
  padding: 11px 13px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--soft-2);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  font-weight: 700;
}

.full-activity-list { display: grid; gap: 8px; }
.full-activity-list .activity-item { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 14px; align-items: start; }
.full-activity-list .activity-item strong { margin-top: 0; }
.activity-toolbar { justify-content: space-between; gap: 16px; }
.activity-toolbar > * { margin: 0; }
.backup-actions { gap: 10px; }
.backup-actions .button { flex: 1; }

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@media (max-width: 1100px) {
  .vehicle-switcher select { min-width: 205px; }
  .icon-text-button span:last-child { display: none; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-stats, .mini-stat { min-height: 112px; }
}

@media (max-width: 1000px) {
  .content-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column-reverse; align-items: flex-end; }
  .topbar-controls { flex-wrap: wrap; justify-content: flex-end; }
  .vehicle-switcher select { min-width: 180px; }
  .app-shell { width: min(100% - 24px, 1420px); padding-top: 24px; }
  .dashboard-head { align-items: flex-start; flex-direction: column; }
  .head-actions { justify-content: flex-start; }
  .summary-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mini-stat { min-height: 100px; }
  .components-head { align-items: flex-start; flex-direction: column; }
  .component-filter { width: 100%; }
  .component-filter input { flex: 1; min-width: 0; }
  .form-row { flex-direction: column; }
  .form-row > * { width: 100%; }
  .full-activity-list .activity-item { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; padding-inline: 14px; }
  .brand-logo { width: 120px; }
  .topbar-actions { width: 100%; flex-direction: row; align-items: center; justify-content: space-between; }
  .topbar-controls { flex: 1; flex-wrap: nowrap; }
  .vehicle-switcher { min-width: 0; flex: 1; }
  .vehicle-switcher select { min-width: 0; }
  .unit-switcher { display: none; }
  .summary-stats { grid-template-columns: 1fr 1fr 1fr; }
  .mini-stat { padding: 16px 12px; }
  .mini-stat strong { font-size: 32px; }
  .component-filter { flex-direction: column; align-items: stretch; }
  .component-filter select, .component-filter input { width: 100%; }
  .backup-actions { flex-direction: column; }
  .attention-item { grid-template-columns: 1fr; }
  .attention-right { text-align: left; }
}

.empty-actions { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; }
.row-menu .action-menu-popover { position: fixed; right: auto; top: auto; }

/* ---------------------------------------------------------
   MAM V1 refinement — restrained, Notion-inspired UI language
   Functional first: flatter surfaces, quieter borders, consistent
   control geometry and less visual competition between elements.
   --------------------------------------------------------- */

:root {
  --bg: #f1f1f0;
  --panel: #ffffff;
  --surface: #ffffff;
  --ink: #000000f2;
  --muted: #787774;
  --subtle: #9b9a97;
  --line: #e9e9e7;
  --line-strong: #d8d8d5;
  --soft: #f7f7f5;
  --soft-2: #efefed;
  --soft-3: #e6e6e3;
  --primary: #000000f2;
  --primary-hover: #202124;
  --primary-text: #ffffff;
  --track-fill: #5f6368;
  --track-warning: #8b8b87;
  --focus: rgba(47, 52, 55, .10);
  --shadow: none;
  --modal-shadow: 0 18px 55px rgba(15, 15, 15, .18);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --control-height: 38px;
}

html[data-theme="dark"] {
  --bg: #191919;
  --panel: #202020;
  --surface: #252525;
  --ink: #f1f1ef;
  --muted: #b4b4b0;
  --subtle: #868681;
  --line: #373737;
  --line-strong: #484848;
  --soft: #252525;
  --soft-2: #2c2c2c;
  --soft-3: #333333;
  --primary: #f1f1ef;
  --primary-hover: #ffffff;
  --primary-text: #191919;
  --track-fill: #c5c5c2;
  --track-warning: #8d8d89;
  --focus: rgba(255, 255, 255, .10);
  --shadow: none;
  --modal-shadow: 0 20px 60px rgba(0, 0, 0, .48);
}

body {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  min-height: 72px;
  padding-block: 12px;
  border-top: 0;
  box-shadow: 0 1px 0 var(--line);
}

.brand-logo { width: 150px; }
.brand-logo-dark { display: none; }
html[data-theme="dark"] .brand-logo-light { display: none; }
html[data-theme="dark"] .brand-logo-dark { display: block; }

.app-shell { padding-top: 32px; }

.dashboard-head { margin-bottom: 22px; }
.dashboard-head h1 {
  font-weight: 700;
  letter-spacing: -0.035em;
}

.eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}

.button,
.icon-text-button,
.action-menu-popover button,
label,
.segment-button {
  font-weight: 650;
}

.button {
  padding-inline: 13px;
  transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}

.button:hover { transform: none; }
.button-secondary { background: var(--panel); }
.button-tertiary { color: var(--muted); }
.button-destructive { border-color: var(--line-strong); color: var(--ink); }
.button-destructive:hover { border-color: var(--ink); }

.panel { box-shadow: none; }

.distance-card,
.mini-stat,
.attention-panel,
.activity-panel,
.components-panel {
  background: var(--panel);
}

.stat-label { font-weight: 600; }
.mini-stat strong { font-weight: 700; }

.panel-head { margin-bottom: 20px; }
.panel-head h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.attention-list,
.activity-list { gap: 8px; }

.attention-item,
.activity-item {
  border-radius: var(--radius-md);
  background: var(--panel);
  transition: background-color .12s ease, border-color .12s ease;
}

.attention-item:hover,
.activity-item:hover { background: var(--soft); }

.attention-name { font-weight: 700; }

/* Give the remaining-life text and status chip intentional breathing room. */
.attention-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 9px;
  text-align: right;
}
.attention-right strong { display: block; line-height: 1.15; }

.status-pill {
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-weight: 650;
}

.component-filter input,
.component-filter select,
.vehicle-switcher select,
input,
select,
textarea {
  border-radius: var(--radius-sm);
}

input,
select,
textarea {
  background: var(--panel);
  border-color: var(--line-strong);
}

input:hover,
select:hover,
textarea:hover { border-color: var(--muted); }

th {
  font-weight: 650;
  letter-spacing: .06em;
}

tbody tr { transition: background-color .12s ease; }
tbody tr:hover { background: var(--soft); }

.life-track { height: 6px; }

.action-menu-popover {
  padding: 5px;
  box-shadow: var(--modal-shadow);
}
.action-menu-popover button {
  padding: 9px 10px;
  font-size: 12px;
}

.modal::backdrop { backdrop-filter: blur(2px); }
.modal-card {
  border-radius: 12px;
  padding: 22px;
  gap: 16px;
}
.modal-head h2 { font-size: 22px; font-weight: 700; }

.icon-button {
  border-radius: var(--radius-sm);
  font-size: 20px;
}

.reset-warning,
.confirm-box,
.current-value-box,
.advanced-fields {
  background: var(--soft);
}

.last-action-person {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

@media (max-width: 560px) {
  .brand-logo { width: 118px; }
  .attention-right { align-items: flex-start; text-align: left; }
}


/* ---------------------------------------------------------
   MAM status colours
   Restrained engineering-status palette:
   green = good, orange = due soon, red = past due.
   --------------------------------------------------------- */

:root {
  --status-good-bg: #edf7ee;
  --status-good-border: #94c79a;
  --status-good-text: #2f6f3e;

  --status-warning-bg: #fff3e4;
  --status-warning-border: #e4ad68;
  --status-warning-text: #8d5618;

  --status-danger-bg: #fbecec;
  --status-danger-border: #dc9191;
  --status-danger-text: #963d3d;
}

html[data-theme="dark"] {
  --status-good-bg: #1f2b21;
  --status-good-border: #527d59;
  --status-good-text: #a8d3ae;

  --status-warning-bg: #30261c;
  --status-warning-border: #8d693c;
  --status-warning-text: #e3b97d;

  --status-danger-bg: #302020;
  --status-danger-border: #8c5050;
  --status-danger-text: #e4a3a3;
}

.status-good {
  background: var(--status-good-bg);
  color: var(--status-good-text);
  border-color: var(--status-good-border);
}

.status-warning {
  background: var(--status-warning-bg);
  color: var(--status-warning-text);
  border-color: var(--status-warning-border);
}

.status-danger {
  background: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-color: var(--status-danger-border);
}


/* ---------------------------------------------------------
   Running costs
   --------------------------------------------------------- */

.running-cost-panel {
  padding: 22px 24px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.running-cost-copy { max-width: 660px; }
.running-cost-copy h2 {
  margin: 3px 0 7px;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.running-cost-copy p:last-child {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.running-cost-summary {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-width: 430px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.running-cost-primary,
.running-cost-coverage {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.running-cost-primary { min-width: 190px; }
.running-cost-coverage {
  flex: 1;
  border-left: 1px solid var(--line);
  gap: 4px;
}
.running-cost-coverage strong { font-size: 12px; }
.running-cost-coverage span { font-size: 11px; line-height: 1.4; }

.running-cost-value-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 7px;
}
.running-cost-value-row strong {
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.04em;
}
.running-cost-value-row span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.cost-rate-cell {
  min-width: 92px;
  white-space: nowrap;
}
.cost-rate-cell strong { font-size: 13px; }
.cost-rate-cell > span:not(.cost-rate-missing) {
  color: var(--muted);
  font-size: 11px;
  margin-left: 2px;
}
.cost-rate-missing {
  color: var(--subtle);
  font-size: 11px;
}

.components-panel table { min-width: 1090px; }

label > .field-help {
  font-weight: 500;
  line-height: 1.4;
}

@media (max-width: 820px) {
  .running-cost-panel { align-items: stretch; flex-direction: column; gap: 16px; }
  .running-cost-summary { min-width: 0; width: 100%; }
}

@media (max-width: 520px) {
  .running-cost-summary { flex-direction: column; }
  .running-cost-coverage { border-left: 0; border-top: 1px solid var(--line); }
}


/* Inspection intervals */
.inspection-cell {
  min-width: 150px;
}

.inspection-cell .status-pill {
  margin-bottom: 5px;
}

.inspection-remaining,
.inspection-not-set {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.attention-right .attention-action {
  margin-top: 8px;
}

.components-panel table {
  min-width: 1260px;
}

.actions-col { width: 310px; }


/* Component hierarchy */
.panel-subcopy {
  margin: 6px 0 0;
  max-width: 620px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.parent-component-row td {
  background: var(--panel);
}

.parent-component-row + .subcomponent-row td,
.subcomponent-row + .subcomponent-row td {
  background: var(--soft);
}

.subcomponent-row td {
  border-bottom-color: var(--line);
}

.subcomponent-name-cell {
  min-width: 250px;
}

.subcomponent-indent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding-left: 12px;
}

.hierarchy-connector {
  flex: 0 0 auto;
  color: var(--subtle);
  font-size: 17px !important;
  line-height: 1.05;
  margin-top: 1px;
}

.subcomponent-indent > div {
  min-width: 0;
}

.subcomponent-na {
  color: var(--subtle);
  font-size: 11px;
}

.subcomponent-distance {
  min-width: 145px;
}

.subcomponent-distance strong,
.subcomponent-distance span {
  display: block;
}

.subcomponent-distance strong {
  font-size: 13px;
}

.subcomponent-distance span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.subcomponent-replacement-section {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--soft);
  overflow: hidden;
}

.subcomponent-replacement-head {
  padding: 14px 15px 12px;
  border-bottom: 1px solid var(--line);
}

.subcomponent-replacement-head strong {
  display: block;
  font-size: 13px;
}

.subcomponent-replacement-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.subcomponent-checklist {
  display: grid;
  max-height: 260px;
  overflow-y: auto;
}

.subcomponent-checkbox {
  display: flex;
  grid-template-columns: none;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.subcomponent-checkbox:last-child {
  border-bottom: 0;
}

.subcomponent-checkbox:hover {
  background: var(--surface);
}

.subcomponent-checkbox input {
  width: 17px;
  height: 17px;
  min-height: 0;
  margin: 1px 0 0;
  padding: 0;
  flex: 0 0 auto;
}

.subcomponent-checkbox span {
  display: grid;
  gap: 3px;
}

.subcomponent-checkbox strong {
  font-size: 12px;
}

.subcomponent-checkbox small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.components-panel table {
  min-width: 1320px;
}

.actions-col {
  width: 330px;
}

/* Usage + hours refinement */
.summary-grid.summary-grid-kpis {
  grid-template-columns: 1fr;
}

.dashboard-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 126px;
}

.dashboard-kpis .mini-stat {
  min-height: 126px;
}

.section-title-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title-inline h2 { margin: 0; }

.info-tip {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 750;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
}

.info-tip::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 80;
  left: 50%;
  bottom: calc(100% + 9px);
  width: max-content;
  max-width: 280px;
  padding: 9px 10px;
  transform: translateX(-50%) translateY(4px);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}

.info-tip:hover::after,
.info-tip:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.running-cost-panel {
  padding: 18px 20px;
}

.running-cost-copy {
  min-width: 180px;
}

.running-cost-summary-dual {
  display: grid;
  grid-template-columns: minmax(150px, .8fr) minmax(150px, .8fr) minmax(220px, 1.15fr);
  flex: 1;
  min-width: 0;
}

.running-cost-summary-dual .running-cost-primary,
.running-cost-summary-dual .running-cost-coverage {
  min-width: 0;
}

.usage-footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 14px;
  overflow: hidden;
}

.usage-footer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 68px;
  padding: 15px 18px;
}

.usage-footer-item + .usage-footer-item { border-left: 1px solid var(--line); }
.usage-footer-item strong { font-size: 17px; letter-spacing: -.01em; }

.usage-secondary {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.component-filter { flex-wrap: wrap; justify-content: flex-end; }
.component-filter select { min-width: 145px; }

.activity-item-button {
  width: 100%;
  appearance: none;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.activity-item-button .activity-date { align-self: center; }
.activity-item-button strong { margin-top: 0; }
.activity-chevron { color: var(--subtle); font-size: 21px; line-height: 1; }
.full-activity-list .activity-item-button { grid-template-columns: 120px minmax(0, 1fr) auto; }

.activity-export-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--soft);
}

.activity-date-range,
.activity-export-actions {
  display: flex;
  align-items: flex-end;
  gap: 9px;
}

.activity-date-range label { min-width: 145px; }
.activity-export-actions { align-items: center; margin-left: auto; }

.activity-detail-meta {
  margin-top: -8px;
  color: var(--muted);
  font-size: 12px;
}

.activity-detail-body {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.activity-detail-summary {
  padding: 14px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
}

.activity-detail-row {
  display: grid;
  grid-template-columns: 125px minmax(0, 1fr);
  gap: 14px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.activity-detail-row span { color: var(--muted); }
.activity-detail-row strong { font-weight: 650; overflow-wrap: anywhere; }

@media (max-width: 900px) {
  .dashboard-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-kpis .mini-stat:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .dashboard-kpis .mini-stat:nth-child(4) { border-top: 1px solid var(--line); }
  .running-cost-summary-dual { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .running-cost-summary-dual .running-cost-coverage { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 650px) {
  .activity-export-bar,
  .activity-date-range,
  .activity-export-actions { align-items: stretch; flex-direction: column; }
  .activity-date-range label { min-width: 0; width: 100%; }
  .activity-export-actions { margin-left: 0; }
  .activity-item-button,
  .full-activity-list .activity-item-button { grid-template-columns: minmax(0, 1fr) auto; }
  .activity-item-button .activity-date { grid-column: 1 / -1; }
  .usage-footer { grid-template-columns: 1fr; }
  .usage-footer-item + .usage-footer-item { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 520px) {
  .dashboard-kpis { grid-template-columns: 1fr 1fr; }
  .running-cost-summary-dual { grid-template-columns: 1fr; }
  .running-cost-summary-dual .running-cost-coverage { grid-column: auto; }
  .activity-detail-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------------------------------------------------------
   MAM V1 — component table / attention-row cleanup
   --------------------------------------------------------- */

/* Priority rows: details on the left, state in the middle, action on its own at right. */
.attention-item {
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 20px;
  padding: 16px 18px;
  align-items: center;
}

.attention-copy { min-width: 0; }

.attention-state {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  white-space: nowrap;
  text-align: right;
}

.attention-state strong {
  font-size: 14px;
  line-height: 1.2;
  font-weight: 700;
}

.attention-action-slot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.attention-action-slot:empty { display: none; }
.attention-action { margin-top: 0; white-space: nowrap; }

/* The compact component table deliberately omits schedule and per-component cost rate. */
.components-panel table { min-width: 1120px; }
.actions-col { width: 330px; }

/* Keep inspection status and remaining interval on one horizontal line. */
.inspection-cell { min-width: 205px; }

.inspection-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  white-space: nowrap;
}

.inspection-cell .status-pill { margin-bottom: 0; }

.inspection-remaining,
.inspection-not-set {
  display: inline;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  white-space: nowrap;
}

.action-buttons {
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* A visible but inactive inspection control makes the table geometry consistent. */
.button:disabled,
.button[aria-disabled="true"] {
  background: var(--soft);
  border-color: var(--line);
  color: var(--subtle);
  opacity: .58;
  cursor: not-allowed;
  transform: none;
}

.button:disabled:hover,
.button[aria-disabled="true"]:hover {
  background: var(--soft);
  border-color: var(--line);
  color: var(--subtle);
  transform: none;
}

@media (max-width: 760px) {
  .attention-item {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px 16px;
  }

  .attention-state {
    justify-content: flex-end;
  }

  .attention-action-slot {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .attention-item { grid-template-columns: 1fr; }
  .attention-state { justify-content: flex-start; text-align: left; flex-wrap: wrap; }
  .attention-action-slot { grid-column: auto; }
}

/* ---------------------------------------------------------
   MAM V1 — aligned units, custom car picker and component tools
   --------------------------------------------------------- */

.input-with-unit {
  position: relative;
  display: block;
  width: 100%;
}

.input-with-unit input { padding-right: 70px; }

.input-unit {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  line-height: 1;
  pointer-events: none;
}

.vehicle-switcher select,
.component-filter select {
  padding-right: 36px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='m4 6 4 4 4-4' stroke='%23686868' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
}

.vehicle-switcher select { width: auto; min-width: 230px; }

.topbar-add-car {
  min-height: var(--control-height);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.components-head {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(280px, 420px) minmax(320px, 1fr);
  align-items: center;
  gap: 20px;
}

.component-search {
  width: 100%;
  justify-self: center;
}

.component-search input { width: 100%; }

.component-filter {
  justify-self: end;
  flex-wrap: nowrap;
  gap: 8px;
}

.component-filter select {
  width: auto;
  min-width: 145px;
}

@media (max-width: 1100px) {
  .vehicle-switcher select { min-width: 205px; }
  .components-head { grid-template-columns: minmax(180px, 1fr) minmax(280px, 380px) minmax(300px, 1fr); }
}

@media (max-width: 900px) {
  .components-head { grid-template-columns: minmax(0, 1fr) auto; }
  .component-search { grid-column: 1 / -1; grid-row: 2; max-width: 520px; }
}

@media (max-width: 760px) {
  .vehicle-switcher select { min-width: 180px; }
  .components-head { grid-template-columns: 1fr; }
  .component-search,
  .component-filter { grid-column: 1; width: 100%; max-width: none; justify-self: stretch; }
  .component-search { grid-row: auto; }
  .component-filter select { flex: 1; min-width: 0; }
}

@media (max-width: 560px) {
  .vehicle-switcher select { width: 100%; min-width: 0; }
  .topbar-add-car { width: var(--control-height); padding: 0; }
  .topbar-add-car-text { display: none; }
  .component-filter { flex-direction: row; align-items: center; }
  .component-filter select { width: 50%; }
}

/* Compact component hierarchy and on-demand details. */
.component-title-line { display: flex; align-items: center; gap: 8px; }
.component-expand, .component-expand-spacer { width: 28px; min-width: 28px; height: 28px; }
.component-expand { display: grid; place-items: center; padding: 0; flex: 0 0 28px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: inherit; cursor: pointer; }
.component-expand span { display: grid; place-items: center; width: 14px; height: 14px; font-size: 0; line-height: 0; transition: transform .15s ease; }
.component-expand span::before { content: ""; display: block; width: 6px; height: 6px; border-top: 2px solid currentColor; border-right: 2px solid currentColor; transform: translateX(-2px) rotate(45deg); }
.component-expand[aria-expanded="true"] span { transform: rotate(90deg); }
.component-detail-trigger { padding: 6px 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.component-detail-trigger:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.component-expand:hover { background: rgba(128,128,128,.12); }
.component-expand:focus-visible, .component-detail-trigger:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }
.component-name .component-child-count { display: inline-flex; justify-content: center; min-width: 22px; padding: 2px 6px; border: 1px solid var(--line); border-radius: 12px; font-size: 11px; }
#componentDetailBody strong { white-space: pre-wrap; }
@media (prefers-reduced-motion: reduce) { .component-expand span { transition: none; } }

/* Row action menus must not inherit the toolbar's horizontal no-wrap layout. */
.row-menu .action-menu-popover {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 260px;
  min-width: 0;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  box-sizing: border-box;
  white-space: normal;
}
.row-menu .action-menu-popover > button {
  display: block;
  flex: 0 0 auto;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.4;
  text-align: left;
}
.row-menu .action-menu-popover > .menu-separator { flex: 0 0 1px; }
