:root {
  --ink: #213a31;
  --muted: #647a6f;
  --green: #2c6d4a;
  --line: #dce4dc;
  --paper: #f6f7f1;
  --blue: #4b8dc0;
  --warn: #9f5a22;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font:
    14px/1.5 system-ui,
    -apple-system,
    sans-serif;
}
button,
input,
select {
  font: inherit;
}
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 14px;
  cursor: pointer;
}
button:hover {
  border-color: var(--green);
  background: #f0f5ec;
}
button:disabled {
  cursor: default;
  opacity: 0.45;
}
.primary {
  background: var(--green);
  color: white;
  border-color: var(--green);
}
.primary:hover {
  background: #205336;
  color: white;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 32px;
  letter-spacing: -1px;
  font-weight: 550;
  line-height: 1.2;
}
h2 {
  font-size: 19px;
  letter-spacing: -0.3px;
}
h3 {
  font-size: 14px;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 12px;
}
#workspace {
  min-height: 100vh;
}
#workspace:not([hidden]) {
  display: grid;
  grid-template-columns: 250px 1fr;
}
aside {
  padding: 26px 20px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100vh;
}
.brand img {
  display: block;
  width: 116px;
  height: 100px;
  object-fit: contain;
  margin-bottom: 24px;
}
aside h2 {
  font-size: 15px;
}
aside .eyebrow {
  margin: 0;
}
#fleet {
  display: grid;
  gap: 7px;
}
#fleet button {
  text-align: left;
  padding: 13px 12px;
  border-color: transparent;
  background: transparent;
}
#fleet button.selected {
  background: #eaf1e7;
  border-color: #cfddc9;
}
#fleet small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
}
.asideBottom {
  margin-top: auto;
  padding-top: 36px;
  display: grid;
  gap: 12px;
  font-size: 11px;
  overflow-wrap: anywhere;
}
main {
  padding: 38px 44px;
  max-width: 1600px;
  width: 100%;
  min-width: 0;
}
header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}
#subtitle {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
header h1 {
  margin-bottom: 8px;
}
.badge {
  background: #e7eee3;
  color: #426342;
  border-radius: 25px;
  padding: 6px 12px;
  font-size: 11px;
  white-space: nowrap;
}
.badge.offline {
  background: #f3e8d9;
  color: var(--warn);
}
nav {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  margin: 26px 0 28px;
  overflow-x: auto;
}
nav button {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 12px 0;
  white-space: nowrap;
  color: var(--muted);
}
nav button.selected {
  color: var(--green);
  border-bottom-color: var(--green);
}
.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 21px;
  min-width: 0;
  margin-bottom: 18px;
}
.metric small {
  display: block;
  color: var(--muted);
  font-size: 11px;
}
.value {
  font-size: 30px;
  letter-spacing: -1px;
  margin: 12px 0 4px;
}
.unit {
  font-size: 14px;
  margin-left: 5px;
  color: var(--muted);
}
.two {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 20px;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}
.row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #edf0e9;
}
.row:last-child {
  border-bottom: 0;
}
.row small {
  color: var(--muted);
  display: block;
}
.row .actions {
  margin: 0;
}
.empty {
  padding: 40px 24px;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 12px;
  text-align: center;
  color: var(--muted);
}
.muted {
  color: var(--muted);
  font-size: 12px;
}
.fault {
  padding: 14px;
  background: #fff1e7;
  color: #8c4b29;
  border-radius: 8px;
  margin-bottom: 20px;
}
.health {
  font-size: 11px;
  color: var(--muted);
}
.health.invalid {
  color: #ac5733;
}
.summary {
  display: flex;
  gap: 20px;
  align-items: center;
}
.level {
  background: #eef4ec;
  border-radius: 12px;
  width: 80px;
  height: 110px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.water {
  position: absolute;
  bottom: 0;
  width: 100%;
  background: var(--blue);
  opacity: 0.65;
}
.level span {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  color: var(--ink);
  font-size: 20px;
  font-weight: 600;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12px;
}
th {
  text-align: left;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 8px;
}
td {
  padding: 12px 8px;
  border-top: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}
.scroll {
  overflow: auto;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font:
    12px/1.7 ui-monospace,
    monospace;
  max-height: 550px;
  overflow: auto;
  background: #213a31;
  color: #e7eee3;
  padding: 20px;
  border-radius: 8px;
}
.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  margin-bottom: 20px;
}
label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
input,
select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px;
  color: var(--ink);
  max-width: 100%;
  min-width: 0;
}
form .actions {
  margin-top: 18px;
}
.setting {
  display: grid;
  grid-template-columns: 1fr 125px auto;
  gap: 10px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.setting label {
  color: var(--ink);
}
.setting small {
  color: var(--muted);
}
footer {
  font-size: 11px;
  color: var(--muted);
  margin-top: 30px;
}
#notice {
  padding: 13px 18px;
  border-radius: 8px;
  background: #e6eee0;
  margin: 18px 0;
}
#notice.error {
  background: #f9e8de;
  color: #924c2c;
}
.login {
  max-width: 420px;
  margin: 7vh auto;
  padding: 28px;
}
.login > img {
  width: 150px;
  margin-bottom: 36px;
}
.login h1 {
  font-size: 38px;
}
.login p {
  color: var(--muted);
}
.login form {
  display: grid;
  gap: 18px;
  margin-top: 30px;
}
.login #loginError {
  color: #924c2c;
}
dialog {
  max-width: 530px;
  width: calc(100% - 32px);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px;
}
dialog::backdrop {
  background: #13251c77;
}
dialog form {
  display: grid;
  gap: 15px;
}
dialog p {
  font-size: 12px;
  color: var(--muted);
}
dialog code {
  overflow-wrap: anywhere;
}
.chart {
  width: 100%;
  height: 150px;
  display: block;
}
.chart text {
  font: 10px system-ui;
  fill: var(--muted);
}
.chart path {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2;
}
.chart line {
  stroke: var(--line);
}
.chartCaption {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
}
.pill {
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 12px;
  background: #edf2e8;
  white-space: nowrap;
}
.pill.rejected,
.pill.failed,
.pill.timeout,
.pill.unknown {
  background: #f9e7dc;
  color: #994b25;
}
[hidden] {
  display: none !important;
}
@media (max-width: 1100px) {
  main {
    padding: 30px 25px;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .two {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 700px) {
  #workspace:not([hidden]) {
    display: block;
  }
  aside {
    min-height: 0;
    padding: 14px 18px;
  }
  .brand img {
    width: 82px;
    height: 55px;
    margin: 0;
  }
  aside > .eyebrow,
  aside > h2 {
    display: none;
  }
  #fleet {
    display: flex;
    overflow-x: auto;
  }
  #fleet button {
    min-width: 180px;
  }
  .asideBottom {
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  main {
    padding: 24px 18px;
  }
  h1 {
    font-size: 26px;
  }
  nav {
    gap: 20px;
    margin: 16px 0 20px;
  }
  .grid {
    gap: 10px;
  }
  .card {
    padding: 16px;
  }
  .value {
    font-size: 25px;
  }
  .row {
    flex-wrap: wrap;
  }
  .setting {
    grid-template-columns: 1fr 90px;
  }
  .setting button {
    grid-column: 2;
  }
  .badge {
    padding: 5px 8px;
  }
  header {
    gap: 6px;
  }
}

/* Diagnostics use only immutable event payloads, never the live overview. */
.fault > button {
  margin: 0 0 0 16px;
}
.incidentCard {
  border-left: 3px solid #bd7c47;
}
.incidentHeading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}
.incidentHeading h2 {
  margin-bottom: 8px;
}
.incidentHeading .eyebrow {
  margin-bottom: 8px;
}
.incidentHeading .badge {
  white-space: normal;
  max-width: 190px;
  flex-shrink: 0;
}
.incidentId,
.sourceDetail,
.triggerRule {
  overflow-wrap: anywhere;
}
.triggerRule {
  padding: 13px 16px;
  background: #f7f2e9;
  border: 1px solid #eadbc9;
  border-radius: 8px;
  font-size: 13px;
}
.faultTimeline {
  list-style: none;
  padding-left: 18px;
  margin: 18px 0 0 5px;
  border-left: 1px solid #d8dfd2;
}
.faultTimeline > li {
  position: relative;
  padding-bottom: 18px;
}
.faultTimeline > li:last-child {
  padding-bottom: 0;
}
.faultTimeline > li::before {
  content: "";
  position: absolute;
  left: -23px;
  top: 15px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #fff;
}
.faultEvent {
  min-width: 0;
}
.faultEvent > summary {
  cursor: pointer;
  padding: 9px 0 14px;
}
.faultEvent > summary > span {
  display: block;
  margin-top: 3px;
}
.faultEvent h3,
.diagnosticSection h4 {
  margin: 0 0 12px;
  font-size: 13px;
}
.diagnosticGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.diagnosticSection {
  background: #f7f9f4;
  border: 1px solid #e6eae0;
  border-radius: 9px;
  padding: 16px;
  min-width: 0;
}
.diagnosticFacts {
  margin: 0;
  font-size: 12px;
}
.diagnosticFacts > div {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #e6eae0;
}
.diagnosticFacts > div:last-child {
  border-bottom: 0;
}
.diagnosticFacts dt {
  color: var(--muted);
  overflow-wrap: anywhere;
}
.diagnosticFacts dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.diagnosticFacts > .factGroup {
  display: block;
}
.factGroup > dt {
  color: var(--ink);
  font-weight: 600;
}
.nestedFacts {
  margin-left: 8px;
}
.eventTimes {
  margin-bottom: 14px;
}
.eventTimes > div {
  grid-template-columns: 165px minmax(0, 1fr);
}
.rawEvent {
  margin-top: 18px;
  font-size: 12px;
  color: var(--muted);
}
.rawEvent summary {
  cursor: pointer;
}
.commandCorrelation {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.commandCorrelation p {
  font-size: 12px;
}
.correlatedCommand {
  margin-top: 12px;
}
@media (max-width: 950px) {
  .diagnosticGrid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 700px) {
  .incidentHeading {
    display: block;
  }
  .incidentHeading .badge {
    display: inline-block;
    max-width: 100%;
    margin: 5px 0 12px;
  }
  .eventTimes > div {
    display: block;
  }
  .eventTimes dd {
    margin-top: 4px;
  }
  .fault > button {
    margin: 12px 0 0;
  }
}
.triggerRule p {
  margin-bottom: 0;
}
.triggerRule details {
  margin-top: 10px;
  font-size: 11px;
}
.triggerRule summary {
  cursor: pointer;
  color: var(--muted);
}
.triggerRule code {
  display: block;
  margin-top: 8px;
  white-space: normal;
}

.portalNav {
  display: grid;
  gap: 7px;
  padding: 8px 0 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.portalNav button {
  text-align: left;
  background: transparent;
  border-color: transparent;
}
.portalNav button.selected {
  background: #eaf1e7;
  border-color: #cfddc9;
}
.authLinks {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 24px;
}
.authLinks button {
  padding: 0;
  border: 0;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  background: transparent;
  text-align: left;
}
.login #loginError:not(.error) {
  color: var(--green);
}
#authAvailability {
  margin-top: 16px;
  font-size: 12px;
}
.portalForm {
  display: grid;
  gap: 16px;
}
.compactForm {
  max-width: 620px;
}
.portalForm > button {
  justify-self: start;
}
.accountEmail {
  font-size: 20px;
  overflow-wrap: anywhere;
}
.memberRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.memberRow > div:first-child {
  overflow-wrap: anywhere;
  min-width: 0;
}
.memberRow small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 5px;
}
.memberRow .actions {
  margin: 0;
  justify-content: flex-end;
}
.inviteForm,
.transferForm,
.claimCode {
  margin: 24px 0;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.permissionChoices {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  display: grid;
  gap: 9px;
}
.permissionChoices legend {
  font-size: 12px;
  color: var(--muted);
  padding: 0 5px;
}
.checkLabel {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--ink);
}
.checkLabel input,
.fleetChoice input {
  margin-top: 3px;
  accent-color: var(--green);
  flex-shrink: 0;
}
.claimCodeResult {
  margin-top: 18px;
}
.claimCodeResult code {
  font-size: 20px;
  overflow-wrap: anywhere;
  display: block;
}
.claimCodeResult img {
  display: block;
  max-width: 100%;
  height: auto;
}
.campaignForm {
  display: grid;
  gap: 17px;
}
.campaignForm > label,
.campaignForm > .checkLabel {
  max-width: 720px;
}
.campaignForm > button {
  justify-self: start;
}
.campaignForm p {
  margin-bottom: 0;
}
.scheduleGrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.campaignDevices h3 {
  margin-bottom: 10px;
}
.fleetSelection {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}
.fleetChoice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: #f8faf5;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
  cursor: pointer;
  color: var(--ink);
}
.fleetChoice span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.fleetChoice small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
.fleetChoice .selectionReason {
  color: var(--warn);
}
.campaignReview {
  margin-top: 24px;
  border-color: #9bb78d;
  background: #f5f9f0;
}
.campaignReview > button {
  margin-top: 16px;
}
.reviewTitle {
  font-weight: 600;
}
.campaignStatus {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}
.campaignStatus h3 {
  font-size: 16px;
}
.campaignStatus button {
  margin-top: 12px;
}
@media (max-width: 900px) {
  .memberRow {
    display: block;
  }
  .memberRow .actions {
    margin-top: 12px;
    justify-content: flex-start;
  }
}
@media (max-width: 700px) {
  .portalNav {
    display: flex;
    overflow: auto;
    padding: 0 0 8px;
  }
  .portalNav button {
    flex-shrink: 0;
  }
  .scheduleGrid {
    grid-template-columns: 1fr;
  }
  .campaignReview {
    padding: 15px;
  }
}

.directoryFilters {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) repeat(2, minmax(130px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-top: 18px;
}
.directoryGrid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(0, 1.8fr);
  gap: 20px;
  align-items: start;
}
.directoryUsers {
  display: grid;
  gap: 8px;
}
.directoryUser {
  display: block;
  text-align: left;
  width: 100%;
  padding: 12px;
  overflow-wrap: anywhere;
}
.directoryUser.selected {
  background: #eef5e9;
  border-color: #9bb78d;
}
.directoryUser small {
  display: block;
  margin-top: 6px;
  font-size: 10px;
  line-height: 1.5;
  color: var(--muted);
}
.directoryUser .selectionReason {
  color: var(--warn);
}
.directoryPagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 20px;
}
.directoryPagination button {
  font-size: 11px;
  padding: 7px 10px;
}
.directoryDetail {
  min-width: 0;
}
.userIdentity h2 {
  overflow-wrap: anywhere;
}
.userIdentity .actions {
  margin: 0 0 15px;
}
.userIdentity .badge {
  white-space: normal;
}
.adminActionReview {
  background: #fff8eb;
  border-color: #d6b88f;
}
.adminActionReview .portalForm {
  margin-top: 18px;
}
.adminDeviceRow {
  border-bottom: 1px solid var(--line);
  padding: 15px 0;
  overflow-wrap: anywhere;
}
.adminDeviceRow small {
  display: block;
  color: var(--muted);
  margin-top: 5px;
  font-size: 11px;
}
.adminDeviceRow .actions {
  margin-top: 12px;
}
.allocationForm {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 20px;
}
.allocationForm h3,
.allocationForm p {
  margin-bottom: 0;
}
@media (max-width: 1100px) {
  .directoryFilters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .directoryGrid {
    grid-template-columns: minmax(210px, 0.75fr) minmax(0, 1.5fr);
    gap: 15px;
  }
}
@media (max-width: 850px) {
  .directoryGrid {
    grid-template-columns: 1fr;
  }
  .directoryUsers {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 500px) {
  .directoryFilters,
  .directoryUsers {
    grid-template-columns: 1fr;
  }
}

.claimDeviceId {
  max-width: 220px;
  font:
    600 24px ui-monospace,
    monospace;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.ownerRelease,
.ownershipInfo {
  margin: 18px 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.releaseReview:not(:empty) {
  margin-top: 16px;
  padding: 18px;
  background: #fff8eb;
  border: 1px solid #d6b88f;
  border-radius: 12px;
}
.pendingDeviceRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
}
.pendingDeviceRow small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.shortDeviceId {
  display: inline-block;
  margin-left: 12px;
  padding: 5px 8px;
  background: #edf4e8;
  border-radius: 6px;
  font-size: 15px;
  letter-spacing: 0.08em;
}
.pendingCount {
  font-weight: 600;
}
@media (max-width: 600px) {
  .pendingDeviceRow {
    display: block;
  }
  .pendingDeviceRow button {
    margin-top: 12px;
  }
}
