/* card – clean, elevated, with subtle border */
.dispatch-card {
  background: #ffffff;
  border-radius: 28px;
  padding: 1.8rem 2rem 2rem 2rem;
}

/* header: lorry + badge */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 0.5rem;
  border-bottom: 2px solid #f0f4f9;
  padding-bottom: 1rem;
  margin-bottom: 1.25rem;
}

.lorry-id {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0b1a26;
}

.lorry-id i {
  color: #1e5f8e;
  font-size: 1.6rem;
  width: 2rem;
  text-align: center;
}

.lorry-plate {
  background: #eef3f9;
  padding: 0.25rem 1rem 0.25rem 0.9rem;
  border-radius: 40px;
  font-size: 1.3rem;
  font-weight: 650;
  color: #003057;
  border: 1px solid #d0dce8;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.02);
  letter-spacing: 0.5px;
}

.badge-status {
  background: #d4e6f7;
  color: #004b7c;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 0.3rem 1rem 0.3rem 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #b8d1e9;
  background: #e3effa;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.badge-status i {
  font-size: 0.75rem;
  color: #0077be;
}

/* main content rows */
.route-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.3rem 0.75rem;
  font-size: 1rem;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
}

.route-line .from,
.route-line .to {
  font-weight: 500;
  color: #1f3a4b;
}

.route-line .from i,
.route-line .to i {
  margin-right: 0.3rem;
  color: #3c6e8f;
  width: 1.1rem;
}

.route-line .time {
  font-weight: 600;
  color: #003b66;
  background: #e6edf5;
  border-radius: 24px;
  padding: 0.1rem 0.8rem;
  font-size: 0.9rem;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.route-line .cust-ref {
  font-weight: 600;
  color: #005b8c;
  background: #e5eef7;
  padding: 0.1rem 0.8rem;
  border-radius: 30px;
  font-size: 0.9rem;
  white-space: nowrap;
}

/* cargo grid – two columns */
.cargo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.2rem;
  border-radius: 24px;
  border: 1px solid #e3ecf5;
}

.cargo-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
}

.cargo-item i {
  color: #2f6f96;
  width: 1.4rem;
  font-size: 1rem;
  text-align: center;
}

.cargo-item strong {
  font-weight: 600;
  color: #0e2b3d;
}

.cargo-item .qty {
  font-weight: 600;
  color: #003057;
  background: #ff980030;
  border: 1px solid #ff9800;
  border-radius: 8px;
  padding: 1px 5px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.cargo-item .unit {
  font-weight: 500;
  color: #1f4a66;
}

.cargo-item .kg-badge {
  background: #d1e2f0;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #004070;
}

/* invoice & value row */
.invoice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  padding: 0.8rem 1rem 0.8rem 1rem;
  margin-top: 0.6rem;
  gap: 0.5rem 1rem;
}

.invoice-number {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  color: #1d3b4f;
}

.invoice-number i {
  color: #3a779b;
  font-size: 1rem;
  width: 1.4rem;
}

.invoice-number span {
  background: #ecf3fa;
  padding: 0.1rem 0.9rem;
  border-radius: 40px;
  font-weight: 600;
  color: #003d66;
  letter-spacing: 0.3px;
}

.value {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: #0b3d2b;
  background: #e5f2ea;
  padding: 0.25rem 1.2rem 0.25rem 1rem;
  border-radius: 40px;
  border: 1px solid #c4decb;
}

.value i {
  color: #2b7a4b;
  font-size: 0.9rem;
}

.value .amount {
  font-size: 1.2rem;
  font-weight: 700;
  color: #004d2b;
  letter-spacing: 0.2px;
}

/* small meta / footer */
.card-footer {
  margin-top: 1.2rem;
  font-size: 0.7rem;
  color: #6b8396;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid #eef4fa;
  padding-top: 0.7rem;
  letter-spacing: 0.2px;
  gap: 0.5rem;
}

.card-footer i {
  color: #6f8da3;
  margin-right: 0.2rem;
}

/* responsive */
@media (max-width: 550px) {
  .cargo-grid {
    grid-template-columns: 1fr;
    gap: 0.4rem;
  }
  .route-line {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
  }
  .route-line .time {
    margin-left: 0;
    align-self: flex-start;
  }
  .invoice-row {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    border-radius: 24px;
    padding: 0.8rem 1rem;
  }
  .lorry-id {
    font-size: 1.2rem;
    flex-wrap: wrap;
  }
  .badge-status {
    font-size: 0.7rem;
    padding: 0.2rem 0.8rem;
  }
}

@media (max-width: 400px) {
  .lorry-plate {
    font-size: 1rem;
    padding: 0.1rem 0.8rem;
  }
  .cargo-item {
    font-size: 0.85rem;
  }
}

/* tweak for print / selection */

.copyable-code:hover {
  background-color: #e2e2e2 !important;
}

.otp-item-row {
  vertical-align: middle;
}

.sim-badge {
  background: #e1f5fe;
  /* background: #fff01f8b; */
  clip-path: polygon(0% 0%, 70% 0%, 100% 25%, 100% 100%, 0% 100%);
  border-radius: 2px;
  color: #333;
  padding: 1px 4px;
  font-size: 11px;
  margin: 1px 6px;
}

/* logs start */
.content {
  padding: 24px;
  /* Chart resizing must not anchor the page back to the top and re-expand it. */
  overflow-anchor: none;
}

.logs-message {
  font-size: 1em;
  color: #333;
  line-height: 1.4;
  word-break: break-word;
}

.leakage-alert {
  color: #ff0000;
  font-weight: bold;
  margin-bottom: 4px;
}
/* logs end */

@supports (position-area: end) {
  [popover] {
    margin: 0;
    position-area: end span-end;
    position-try-fallbacks:
      flip-block,
      flip-inline,
      flip-block flip-inline;
  }
}

:popover-open {
  background-color: transparent;
  border: 0;
  outline: 0;
}

.device-popover-image {
  width: auto;
  max-height: 78px;
  max-width: 64px;
  top: -14px;
  right: 8px;
  position: absolute;
}

.device-popover-container {
  background: white;
  border: 0;
  margin: 16px;
  padding: 16px;
  position: relative;
  min-height: 64px;
}

.log-filter-bar {
  display: flex;
  gap: 10px;
  padding: 12px;
  background: #fafafa;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  flex-wrap: wrap;
  position: sticky;
  top: calc(var(--superpulse-sticky-offset, 76px) + var(--panel-switch-height, 0px));
  z-index: 4;
  box-shadow: none;
}

.segment > ul {
  padding-left: 2px;
  margin-top: 8px;
}

.segment > ul > li {
  list-style-type: none;
  margin-bottom: 6px;
}

/* one standalone list item per date group, inserted before that group's first message. As a top-level
   <li> (not nested inside a message row) it can stick to the top of the list on its own while the
   day's messages scroll underneath it. */
.date-divider {
  position: sticky;
  top: calc(var(--superpulse-sticky-offset, 76px) + var(--panel-switch-height, 0px) + var(--filter-height, 64px));
  z-index: 2;
  background: #fff;
  padding: 8px 12px 4px;
}

.date-divider .date-p {
  left: 0;
}

/* day/month badge, styled after the #custom-date template, nudged slightly to the left */
.date-p {
  text-align: center;
  width: fit-content;
  line-height: 0.7em;
  position: relative;
  left: -6px;
}

.date-p p {
  font-weight: 700;
  color: black;
  margin: 0;
}

.date-p hr {
  border: 1px solid black;
  margin: 2px 0 0 0;
}

.filter-select {
  padding: 6px 12px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  font-size: 13px;
}

.range-filter-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #555;
  font-size: 13px;
  white-space: nowrap;
}

.range-filter-label .filter-select {
  width: auto;
}

.segment-container {
  /* The normal page flow covers the pinned graph from the bottom up. */
  position: relative;
  z-index: 21;
  background: #fff;
  display: flex;
  flex-direction: row;
  gap: 1em;
}

.segment,
.segment > ul {
  background: #fff;
}

.segment {
  min-width: 0;
}

.segment[data-segment="1"] {
  flex: 1.8 1 0;
}

.segment[data-segment="2"] {
  flex: 0.9 1 0;
  max-width: 42rem;
}

.mobile-panel-switch {
  display: none;
}

.mobile-panel-switch button {
  flex: 1;
  border: 1px solid #d8d8d8;
  background: #fff;
  padding: 10px 12px;
  font-weight: 650;
}

.mobile-panel-switch button.active {
  background: #111;
  border-color: #111;
  color: #fff;
}

.sticky-list {
}

.notification-badge {
  background: #eb2f06;
  padding: 2px 4px;
  border-radius: 2em;
  position: absolute;
  right: 12px;
  color: white;
}

.msg-item-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  line-height: 0.8rem;
}

table {
  border: 1px solid #ddd;
  border-radius: 8px;
}

table thead th {
  border-bottom: 1px solid #ddd;
  font-style: normal;
  background: #f8f8f8;
}

tr {
  border-bottom: 1px solid #ddd;
}

td {
  padding: 0.62em;
}

@media (max-width: 800px) {
  .content {
    padding: 12px;
  }

  .mobile-panel-switch {
    display: flex;
    position: sticky;
    top: var(--superpulse-sticky-offset, 76px);
    z-index: 22;
    gap: 0;
    margin: 8px 0;
    background: #fff;
    border-radius: 10px;
    box-shadow: none;
  }

  .mobile-panel-switch button:first-child {
    border-radius: 10px 0 0 10px;
  }

  .mobile-panel-switch button:last-child {
    border-radius: 0 10px 10px 0;
  }

  .segment-container {
    display: block;
  }

  .segment {
    display: none;
  }

  .segment.active {
    display: block;
  }

  .filter-select {
    width: 100%;
    min-width: 0 !important;
  }

  .msg-item-header {
    gap: 8px;
    line-height: 1.1rem;
  }
}

.settings-button {
  margin-left: 10px;
  padding: 6px 10px;
  border: 1px solid #d8d8d8;
  border-radius: 6px;
  background: #fff;
  color: #333;
  cursor: pointer;
  font-weight: 650;
}

.settings-dialog {
  border: 0;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

.settings-dialog::backdrop {
  background: rgba(0, 0, 0, 0.42);
}

.settings-card {
  display: grid;
  gap: 14px;
  min-width: min(340px, 86vw);
  padding: 20px;
}

.settings-card h2 {
  margin: 0;
}

.settings-card label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

.settings-checkbox {
  align-items: center;
  display: flex !important;
  gap: 8px !important;
}

.settings-card menu {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 4px 0 0;
  padding: 0;
}

.settings-card menu button {
  padding: 7px 12px;
}

body.logs-dark {
  background: #000 !important;
  color: #d8e1e7 !important;
}

body.logs-dark .content,
body.logs-dark .segment-container,
body.logs-dark .segment,
body.logs-dark .segment > ul {
  background: #000;
  color: #d8e1e7;
}

body.logs-dark h1,
body.logs-dark .logs-message,
body.logs-dark .range-filter-label,
body.logs-dark .date-p p,
body.logs-dark .date-p small {
  color: #d8e1e7 !important;
}

body.logs-dark .log-filter-bar,
body.logs-dark .settings-dialog {
  background: #12191f;
  border-color: rgba(255, 255, 255, 0.06);
  color: #d8e1e7;
}

body.logs-dark .filter-select,
body.logs-dark .settings-button,
body.logs-dark .settings-card menu button,
body.logs-dark .mobile-panel-switch button {
  background: #151d23 !important;
  border-color: #344653 !important;
  color: #d8e1e7 !important;
}

body.logs-dark .msg-list-item {
  background: transparent !important;
  border-bottom-color: #24313a !important;
}

body.logs-dark .app-chart-header,
body.logs-dark .date-divider {
  background: #000;
}

body.logs-dark .copyable-code {
  background: #1c2932 !important;
  border-color: #3a4d5b !important;
  color: #e8f2f7 !important;
}

body.logs-dark a,
body.logs-dark .insignificant {
  color: #8ec7ff !important;
}

body.logs-dark .filter-select::placeholder {
  color: #748693;
}

body.logs-dark .msg-list-item:hover {
  background: transparent !important;
}

body.logs-dark .msg-item-header,
body.logs-dark .msg-item-header small,
body.logs-dark .device-name-button {
  color: #93a7b4 !important;
}

body.logs-dark .msg-item-header span {
  color: #e4edf2;
}

body.logs-dark .date-p hr {
  border-color: #d8e1e7 !important;
}

body.logs-dark .copyable-code:hover {
  background: #263847 !important;
}

body.logs-dark .sim-badge,
body.logs-dark .route-line .time,
body.logs-dark .route-line .cust-ref,
body.logs-dark .invoice-number span,
body.logs-dark .cargo-item .kg-badge {
  background: #1c2a34 !important;
  color: #b8d9ee !important;
  border-color: #334b5b !important;
}

body.logs-dark .leakage-alert {
  color: #ff7b86 !important;
}

body.logs-dark .msg-list-item[style*="fff5f5"] {
  background: #2a1418 !important;
  border-left-color: #ff5c6c !important;
}

body.logs-dark .dispatch-card,
body.logs-dark .device-popover-container {
  background: #121a21 !important;
  border-color: #26333d !important;
}

body.logs-dark #device-info-popover:popover-open,
body.logs-dark .device-popover-container p {
  color: #d8e1e7;
}

body.logs-dark #p-assigned-to {
  background: #1c2a34;
  color: #b8d9ee;
  padding: 1px 5px;
}

body.logs-dark .card-header,
body.logs-dark .card-footer,
body.logs-dark .cargo-grid,
body.logs-dark table thead th,
body.logs-dark tr {
  border-color: #26333d !important;
}

body.logs-dark table thead th {
  background: #17212a !important;
}

body.logs-dark .lorry-id,
body.logs-dark .route-line .from,
body.logs-dark .route-line .to,
body.logs-dark .cargo-item strong,
body.logs-dark .invoice-number,
body.logs-dark .value,
body.logs-dark table,
body.logs-dark th,
body.logs-dark td {
  color: #d8e1e7 !important;
}

body.logs-dark .lorry-id i,
body.logs-dark .route-line i,
body.logs-dark .cargo-item i,
body.logs-dark .invoice-number i,
body.logs-dark .card-footer i {
  color: #8db7d0 !important;
}

body.logs-dark .lorry-plate,
body.logs-dark .badge-status,
body.logs-dark .value {
  background: #172530 !important;
  border-color: #335066 !important;
  color: #c9e3f2 !important;
}

body.logs-dark .cargo-item .qty {
  background: rgba(255, 152, 0, 0.14) !important;
  border-color: rgba(255, 183, 77, 0.58) !important;
  color: #ffd18a !important;
}

body.logs-dark .value .amount {
  color: #7ee0a3 !important;
}

body.logs-dark .card-footer,
body.logs-dark .range-filter-label {
  color: #8fa2ae !important;
}

body.logs-dark .mobile-panel-switch {
  background: #111920 !important;
  box-shadow: none !important;
}

body.logs-dark .mobile-panel-switch button.active {
  background: #e4edf2 !important;
  border-color: #e4edf2 !important;
  color: #111920 !important;
}

body.logs-light {
  background: #fff !important;
  color: #333 !important;
}

body.logs-light .content,
body.logs-light .app-chart-header,
body.logs-light .date-divider,
body.logs-light .segment-container,
body.logs-light .segment,
body.logs-light .segment > ul {
  background: #fff !important;
  color: #333 !important;
}

body.logs-light h1,
body.logs-light .logs-message,
body.logs-light .range-filter-label,
body.logs-light .date-p p,
body.logs-light .date-p small {
  color: #333 !important;
}

body.logs-light .log-filter-bar {
  background: #fafafa !important;
  border-color: rgba(0, 0, 0, 0.04) !important;
  box-shadow: none !important;
}

body.logs-light .filter-select,
body.logs-light .settings-button,
body.logs-light .mobile-panel-switch button {
  background: #fff !important;
  border-color: #ccc !important;
  color: #333 !important;
}

body.logs-light .msg-list-item {
  background: transparent !important;
  border-bottom-color: #f2f2f2 !important;
}

body.logs-light .msg-item-header span {
  color: inherit !important;
}

body.logs-light .msg-item-header small,
body.logs-light .device-name-button {
  color: #727272 !important;
}

body.logs-light #device-info-popover:popover-open,
body.logs-light .device-popover-container,
body.logs-light .device-popover-container p {
  background: #fff !important;
  color: #333 !important;
}

body.logs-light #p-assigned-to {
  background: #eef3f9;
  color: #003057;
  padding: 1px 5px;
}

.app-chart-header {
  box-sizing: border-box;
  background: #fff;
  margin-bottom: 0;
  padding-bottom: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

/* Scroll handoff measures the new mode immediately; do not animate its layout. */
.app-chart-header .app-header-chart {
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

/* Once covered, keep only PulseBar above the scrolling panel. The header
   retains its consumed layout space, but must not mask the filters below it. */
.app-chart-header:has(.tva-pulse-bar) {
  z-index: 23;
  clip-path: inset(0 0 max(0px, calc(100% - var(--superpulse-sticky-offset))) 0);
}

.app-chart-header:has(.tva-pulse-graph-max) {
  z-index: 30;
  clip-path: none;
}

/* Fill the rounded corners too: messages must not peek through sticky layers. */
.log-filter-bar::before,
.mobile-panel-switch::before {
  content: "";
  position: absolute;
  inset: -1px;
  background: inherit;
  z-index: -1;
}

.app-version {
  color: #888;
  font: 700 10px/1 monospace;
  letter-spacing: 0.08em;
  opacity: 0.45;
  position: fixed;
  right: 10px;
  text-orientation: mixed;
  text-transform: uppercase;
  top: 14px;
  writing-mode: vertical-rl;
  z-index: 4;
}

.chat-launcher {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin: 0 34px 8px 0;
  position: relative;
  z-index: 7;
}

.chat-launcher sso-user-button,
.chat-launcher .settings-icon-button {
  position: static;
}

.settings-icon-button {
  aspect-ratio: 1;
  display: inline-grid;
  font-size: 16px;
  left: 10px;
  margin: 0;
  min-width: 30px;
  padding: 0;
  place-items: center;
  position: absolute;
  top: 38px;
  z-index: 6;
}

.tva-chart-controls .settings-icon-button {
  border-color: var(--tva-control-border);
  border-radius: 0;
  color: var(--tva-control-text);
  font-size: 13px;
  left: auto;
  min-height: 22px;
  min-width: 22px;
  position: static;
  top: auto;
}

.app-header-chart.action-chart-container {
  height: 240px;
  margin-bottom: 0;
}

.app-header-chart.action-chart-container.tva-pulse-bar:not(.tva-pulse-graph-max) {
  height: var(--tva-pulse-bar-height);
}

.app-header-chart.tva-pulse-bar:not(.tva-pulse-graph-max) canvas {
  height: 31px !important;
  max-height: 31px !important;
}

.app-header-chart.tva-pulse-graph-max,
.tva-pulse-graph-max {
  bottom: 16px !important;
  height: auto !important;
  left: 16px !important;
  max-height: none !important;
  position: fixed !important;
  right: 16px !important;
  top: 16px !important;
  width: auto !important;
  z-index: 10001 !important;
}

.app-header-chart.tva-pulse-graph-max canvas,
.tva-pulse-graph-max canvas {
  max-height: none !important;
}

@media (max-width: 800px) {
  .app-header-chart.action-chart-container {
    height: 220px;
  }
}
