:root {
  color-scheme: light;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-soft: #f2f6fa;
  --text: #0b1f33;
  --muted: #596a7a;
  --border: #d9e2ec;
  --primary: #1e63c8;
  --primary-dark: #071827;
  --primary-light: #39a0ff;
  --sensor-teal: #00b8a9;
  --success: #22c55e;
  --danger: #dc2626;
  --warning: #f59e0b;
  --shadow: 0 12px 28px rgba(11, 31, 51, 0.06);
}

svg.ti {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  overflow: visible;
  vertical-align: -0.14em;
}

/* V1 temperature report console: hybrid Tabler-inspired light/dark design */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0b1728;
  --surface-soft: #111f33;
  --text: #e8eef7;
  --muted: #9aabc0;
  --border: #293b54;
  --primary: #38bdf8;
  --primary-dark: #0ea5e9;
  --primary-light: #7dd3fc;
  --sensor-teal: #2dd4bf;
  --success: #34d399;
  --danger: #fb7185;
  --warning: #fbbf24;
  --shadow: 0 18px 42px rgba(0, 0, 0, .24);
}

:root[data-theme="dark"] .login-shell { background: #07111f; }
:root[data-theme="dark"] .menu-button.active,
:root[data-theme="dark"] .tabs button.active,
:root[data-theme="dark"] .report-table-head b { background: #122744; }
:root[data-theme="dark"] .report-table .out-of-range span { background: #2a1724; color: #fecdd3; }
:root[data-theme="dark"] .notice { background: #34280e; color: #fde68a; }
:root[data-theme="dark"] .route-table > div,
:root[data-theme="dark"] .freshness.fresh { background: #0f2b25; color: #a7f3d0; }
:root[data-theme="dark"] .leaflet-map .leaflet-tile-pane {
  filter: brightness(.68) invert(1) contrast(1.75) hue-rotate(180deg) saturate(.65);
}
:root[data-theme="dark"] .leaflet-map .leaflet-control-zoom a,
:root[data-theme="dark"] .leaflet-map .leaflet-control-attribution {
  background: var(--surface);
  color: var(--text);
}

.report-console {
  width: 100%;
  max-width: 1540px;
  margin-inline: auto;
  gap: 18px;
}

.report-command-surface {
  display: grid;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(15, 42, 70, .045);
}

.report-command-bar {
  display: grid;
  grid-template-columns: auto auto minmax(150px, .75fr) minmax(290px, 1.25fr) auto;
  align-items: end;
  gap: 10px;
  padding: 14px;
}

.report-command-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 185px;
  align-self: center;
}
.report-command-title > i { color: var(--primary); font-size: 1.45rem; }
.report-command-title span { display: grid; gap: 3px; min-width: 0; }
.report-command-title strong { font-size: 1.16rem; line-height: 1.2; }
.report-command-title small { overflow: hidden; color: var(--muted); font-size: .75rem; text-overflow: ellipsis; white-space: nowrap; }

.report-command-ranges { align-self: center; }
.report-command-ranges .tabs { flex-wrap: nowrap; gap: 7px; margin: 0; padding: 0; overflow: visible; }
.report-command-ranges .tabs button { min-height: 40px; padding-inline: 10px; }

.report-command-control,
.report-command-dates label,
.report-interval {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: .74rem;
  font-weight: 800;
}
.report-command-control select,
.report-command-dates input,
.report-interval select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
}
.report-command-dates { display: grid; grid-template-columns: repeat(2, minmax(138px, 1fr)); gap: 8px; }
.report-command-actions { display: flex; align-items: center; gap: 7px; align-self: end; }
.report-command-actions > button { min-height: 40px; padding-inline: 10px; white-space: nowrap; }
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  white-space: nowrap;
}
.theme-toggle i { color: var(--warning); font-size: 1.15rem; }
:root[data-theme="dark"] .theme-toggle i { color: #93c5fd; }
.report-more-menu { position: relative; }
.report-more-menu > summary {
  width: 40px;
  min-height: 40px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}
.report-more-menu > summary::-webkit-details-marker { display: none; }
.report-more-menu > div {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  width: 180px;
  display: grid;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.report-more-menu button { display: flex; align-items: center; gap: 8px; min-height: 38px; border: 0; border-radius: 7px; background: transparent; color: var(--text); text-align: start; }
.report-more-menu button:hover { background: var(--surface-soft); }

.report-advanced { border-top: 1px solid var(--border); }
.report-advanced > summary,
.report-table-shell > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
}
.report-advanced > summary::-webkit-details-marker,
.report-table-shell > summary::-webkit-details-marker { display: none; }
.report-advanced > summary span,
.report-table-shell > summary span { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; }
.report-advanced > summary i,
.report-table-shell > summary i { color: var(--primary); }
.report-advanced > summary small,
.report-table-shell > summary small { max-width: 58%; color: var(--muted); font-size: .78rem; font-weight: 600; text-align: end; }
.report-advanced-grid {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 0 14px 14px;
}
.report-advanced-grid .report-options { grid-template-columns: repeat(4, minmax(116px, 1fr)); }
.report-load-button { min-height: 42px; white-space: nowrap; }

.report-insight-layout {
  direction: ltr;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(285px, 310px);
  gap: 16px;
  align-items: stretch;
}
.report-insight-layout.no-summary { grid-template-columns: minmax(0, 1fr); }
.temperature-hero,
.temperature-summary-rail {
  direction: rtl;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.temperature-hero { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; overflow: hidden; }
.temperature-hero > *,
.event-timeline,
.event-timeline-track { min-width: 0; max-width: 100%; }
.temperature-chart-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-height: 54px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.report-chart-series,
.report-chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}
.report-chart-series {
  padding-bottom: 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
}
.report-chart-series-label {
  display: grid;
  gap: 2px;
  flex: 0 0 auto;
}
.report-chart-series-label strong { color: var(--text); font-size: .88rem; }
.report-chart-series-label small { color: var(--muted); font-size: .72rem; }
.report-chart-series-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}
.chart-series-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: .78rem;
  font-weight: 800;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease, box-shadow .16s ease;
}
.chart-series-option i { color: var(--series-color); font-size: 1rem; }
.chart-series-option:hover:not(:disabled) { border-color: var(--series-color); color: var(--text); }
.chart-series-option.active {
  border-color: color-mix(in srgb, var(--series-color) 72%, var(--border));
  background: color-mix(in srgb, var(--series-color) 11%, var(--surface));
  color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--series-color) 12%, transparent);
}
.chart-series-option:disabled { opacity: .78; cursor: default; }
.report-chart-legend { margin: 0; }
.report-chart-legend .temp { background: var(--primary); }
.report-chart-legend .normal { height: 0; border-top: 2px dashed var(--success); }
.report-chart-legend .high { background: var(--danger); }
.temperature-chart-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-inline-start: auto;
}
.chart-zoom-guide {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding-inline: 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 7%, var(--surface));
  color: var(--primary);
  font-size: .78rem;
  font-weight: 800;
  white-space: nowrap;
}
.chart-zoom-guide i { font-size: 1rem; }
.chart-zoom-reset,
.exception-focus {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-weight: 750;
  white-space: nowrap;
}
.chart-zoom-reset:not(:disabled):hover { border-color: var(--primary); color: var(--primary); }
.chart-zoom-reset:disabled { cursor: default; opacity: .45; }
.exception-focus.active { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, var(--surface)); color: var(--danger); }
.temperature-chart-wrap { height: clamp(330px, 33vw, 450px); border: 0; border-radius: 0; overscroll-behavior: contain; }
.temperature-chart-wrap.is-zoomed { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 20%, transparent); }

.event-timeline { padding: 12px 16px 8px; border-top: 1px solid var(--border); }
.event-timeline header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: .78rem; }
.event-timeline-heading { display: grid; gap: 3px; }
.event-timeline-heading > span,
.event-timeline-heading > small { display: inline-flex; align-items: center; gap: 7px; }
.event-timeline-heading > span { color: var(--text); font-weight: 800; }
.event-timeline-heading > small { color: var(--muted); font-size: .68rem; font-weight: 700; }
.event-timeline-heading > small i { color: var(--primary); }
.event-timeline-controls { display: inline-flex; align-items: center; gap: 6px; }
.event-timeline-controls > small { margin-inline-end: 3px; white-space: nowrap; }
.event-timeline-nav {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--primary);
  cursor: pointer;
}
.event-timeline-nav:hover:not(:disabled) { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.event-timeline-nav:disabled { color: var(--muted); cursor: default; opacity: .38; }
.event-timeline-track {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(170px, 21vw, 205px);
  gap: 8px;
  margin-top: 14px;
  padding: 12px 2px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  direction: ltr;
  scroll-behavior: smooth;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--primary) 42%, var(--border)) transparent;
  overscroll-behavior-inline: contain;
  touch-action: pan-x pan-y;
  cursor: grab;
}
.event-timeline-track:focus-visible { outline: 2px solid color-mix(in srgb, var(--primary) 52%, transparent); outline-offset: 3px; border-radius: 8px; }
.event-timeline-track.is-dragging { scroll-behavior: auto; scroll-snap-type: none; cursor: grabbing; user-select: none; }
.event-timeline-track::before { content: ""; position: absolute; top: 5px; inset-inline: 3%; height: 2px; background: var(--border); }
.event-marker {
  position: relative;
  min-width: 138px;
  min-height: 126px;
  display: grid;
  justify-items: stretch;
  align-content: start;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .7rem;
  line-height: 1.3;
  text-align: start;
  direction: rtl;
  scroll-snap-align: start;
}
.event-marker::before { content: ""; position: absolute; top: -13px; left: 50%; width: 8px; height: 8px; border: 2px solid var(--surface); border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 1px var(--border); transform: translateX(-50%); }
.event-marker-index { color: var(--muted); font-size: .65rem; font-weight: 800; }
.event-marker-title { display: flex; align-items: center; gap: 6px; color: var(--text); }
.event-marker-title i { flex: 0 0 auto; font-size: 1.08rem; }
.event-marker-title b { font-size: .78rem; }
.event-marker > small { min-height: 2.5em; color: var(--muted); font-size: .67rem; }
.event-marker time { display: flex; align-items: baseline; justify-content: space-between; gap: 5px; margin-top: 1px; padding-top: 6px; border-top: 1px solid var(--border); color: var(--text); direction: ltr; }
.event-marker time strong { font-size: .7rem; }
.event-marker time em { color: var(--muted); font-size: .7rem; font-style: normal; font-weight: 800; }
.event-marker.danger { border-color: color-mix(in srgb, var(--danger) 32%, var(--border)); background: color-mix(in srgb, var(--danger) 6%, var(--surface)); }
.event-marker.success { border-color: color-mix(in srgb, var(--success) 32%, var(--border)); background: color-mix(in srgb, var(--success) 6%, var(--surface)); }
.event-marker.danger i, .event-marker.danger::before { color: var(--danger); background: var(--danger); }
.event-marker.success i, .event-marker.success::before { color: var(--success); background: var(--success); }
.event-marker.selected { box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 22%, transparent); }
.event-marker.selected .event-marker-title { color: var(--primary); }
.event-timeline-empty { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 72px; border-top: 1px solid var(--border); color: var(--success); font-weight: 800; }

.temperature-summary-rail { display: flex; flex-direction: column; padding: 18px; }
.range-verdict { display: grid; gap: 10px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.range-verdict > span { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.range-verdict > span i { color: var(--success); font-size: 1.3rem; }
.temperature-summary-rail.warning .range-verdict > span i { color: var(--warning); }
.temperature-summary-rail.danger .range-verdict > span i { color: var(--danger); }
.range-verdict h2 { margin: 0; font-size: clamp(1.18rem, 2vw, 1.55rem); line-height: 1.35; }
.range-verdict h2 strong { color: var(--success); font-size: 1.2em; }
.temperature-summary-rail.warning .range-verdict h2 strong { color: var(--warning); }
.temperature-summary-rail.danger .range-verdict h2 strong { color: var(--danger); }
.range-progress { height: 8px; overflow: hidden; border-radius: 99px; background: var(--surface-soft); }
.range-progress span { display: block; height: 100%; border-radius: inherit; background: var(--success); }
.temperature-summary-rail.warning .range-progress span { background: var(--warning); }
.temperature-summary-rail.danger .range-progress span { background: var(--danger); }
.range-verdict small { color: var(--muted); font-weight: 700; }
.temperature-stat-list { display: grid; padding: 8px 0; border-bottom: 1px solid var(--border); }
.temperature-stat-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 54px; }
.temperature-stat-row > i { color: var(--primary); font-size: 1.2rem; }
.temperature-stat-row > span { color: var(--muted); font-size: .8rem; font-weight: 750; }
.temperature-stat-row > strong { font-size: 1.08rem; }
.temperature-stat-row.danger > i { color: var(--danger); }
.incident-list { display: grid; gap: 7px; padding: 14px 0; }
.incident-list > header { display: flex; align-items: center; justify-content: space-between; }
.incident-list > header span { font-weight: 850; }
.incident-list > header strong { color: var(--danger); font-size: 1.35rem; }
.incident-item { overflow: hidden; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.incident-item.selected { border-color: color-mix(in srgb, var(--danger) 42%, var(--border)); }
.incident-item > button { width: 100%; min-height: 48px; display: grid; grid-template-columns: minmax(0, 1fr) 24px 18px; align-items: center; gap: 7px; padding: 7px 9px; border: 0; background: transparent; color: var(--text); text-align: start; }
.incident-item > button span { display: grid; gap: 2px; }
.incident-item > button small { color: var(--muted); font-size: .68rem; font-weight: 600; }
.incident-item > button em { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid var(--danger); border-radius: 50%; color: var(--danger); font-size: .72rem; font-style: normal; font-weight: 850; }
.incident-detail { display: grid; gap: 7px; padding: 9px; border-top: 1px solid var(--border); background: var(--surface-soft); }
.incident-detail span { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 6px; color: var(--muted); font-size: .74rem; }
.incident-detail span i { color: var(--primary); }
.incident-detail span b { color: var(--text); }
.incident-detail span.ok i { color: var(--success); }
.incident-detail span.danger i { color: var(--danger); }
.incident-none { display: flex; align-items: center; gap: 8px; padding: 12px; color: var(--success); font-weight: 800; }
.summary-pdf { width: 100%; min-height: 46px; margin-top: auto; }

.report-no-data { min-height: 320px; display: grid; place-items: center; align-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--muted); text-align: center; }
.report-command-surface.is-loading { opacity: .84; }
.report-loading-state {
  position: relative;
  min-height: clamp(390px, 54vh, 600px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 22px;
  padding: 38px 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background:
    radial-gradient(circle at 50% 16%, color-mix(in srgb, var(--primary) 13%, transparent), transparent 38%),
    linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--primary) 4%, var(--surface-soft)));
  text-align: center;
}
.report-loading-state::before,
.report-loading-state::after {
  content: "";
  position: absolute;
  width: 260px;
  height: 260px;
  border: 1px solid color-mix(in srgb, var(--primary) 10%, transparent);
  border-radius: 50%;
}
.report-loading-state::before { top: -155px; inset-inline-start: -70px; }
.report-loading-state::after { right: -125px; bottom: -185px; }
.report-loading-visual { position: relative; z-index: 1; display: grid; place-items: center; }
.report-loading-logo-shell {
  position: relative;
  isolation: isolate;
  width: min(440px, 78vw);
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 24px) clamp(20px, 4vw, 32px);
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 20px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 14px 38px rgba(0,26,54,.14), 0 0 0 1px color-mix(in srgb, var(--primary) 8%, transparent);
  animation: report-brand-pulse 1.8s ease-in-out infinite;
}
.report-loading-logo-shell::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -10px;
  border: 2px solid color-mix(in srgb, var(--primary) 24%, transparent);
  border-radius: 28px;
  animation: report-brand-halo 1.8s ease-out infinite;
}
.report-loading-logo { display: block; width: 100%; height: auto; }
.report-loading-copy { position: relative; z-index: 1; display: grid; justify-items: center; gap: 7px; }
.report-loading-copy strong { color: var(--text); font-size: clamp(1.05rem, 2vw, 1.3rem); }
.report-loading-copy p { max-width: 560px; margin: 0; color: var(--muted); line-height: 1.55; }
.report-loading-copy small { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; color: var(--primary); font-weight: 800; }
.report-loading-progress { position: relative; z-index: 1; width: min(390px, 76vw); height: 5px; overflow: hidden; border-radius: 999px; background: color-mix(in srgb, var(--primary) 11%, var(--border)); direction: ltr; }
.report-loading-progress span { display: block; width: 34%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #38bdf8, var(--primary)); box-shadow: 0 0 16px color-mix(in srgb, var(--primary) 50%, transparent); animation: report-progress-sweep 1.25s ease-in-out infinite; }
.report-load-error { min-height: 320px; display: grid; place-items: center; align-content: center; gap: 10px; padding: 28px; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border)); border-radius: 14px; background: color-mix(in srgb, var(--danger) 5%, var(--surface)); text-align: center; }
.report-load-error > i { color: var(--danger); font-size: 2rem; }
.report-load-error strong { color: var(--text); font-size: 1.08rem; }
.report-load-error p { max-width: 560px; margin: 0 0 6px; color: var(--muted); }
@keyframes report-brand-pulse {
  0%, 100% { transform: scale(.975); opacity: .78; box-shadow: 0 10px 28px rgba(0,26,54,.10), 0 0 0 1px color-mix(in srgb, var(--primary) 7%, transparent); }
  50% { transform: scale(1.025); opacity: 1; box-shadow: 0 20px 48px rgba(0,26,54,.18), 0 0 28px color-mix(in srgb, var(--primary) 18%, transparent); }
}
@keyframes report-brand-halo {
  0% { transform: scale(.96); opacity: .42; }
  72%, 100% { transform: scale(1.11); opacity: 0; }
}
@keyframes report-progress-sweep { 0% { transform: translateX(-125%); } 100% { transform: translateX(395%); } }
@media (prefers-reduced-motion: reduce) {
  .report-loading-logo-shell,
  .report-loading-logo-shell::before,
  .report-loading-progress span { animation: none; }
  .report-loading-logo-shell { transform: none; opacity: 1; }
  .report-loading-logo-shell::before { opacity: .18; }
  .report-loading-progress span { width: 62%; transform: none; }
}
.report-table-shell { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.report-table-shell .report-table { margin: 0 14px 14px; }
.report-table-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0 14px 12px; color: var(--muted); font-size: .78rem; font-weight: 750; }
.report-table-meta span { display: inline-flex; align-items: center; gap: 6px; }
.report-table-meta i { color: var(--primary); }
.report-table-meta .has-missing, .report-table-meta .has-missing i { color: var(--warning); }
.report-table-pagination { display: grid; gap: 10px; padding: 0 14px 14px; }
.report-table-pagination-main { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; min-width: 0; }
.report-table-pagination button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 0 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--primary); font: inherit; font-weight: 800; }
.report-table-pagination button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); background: var(--surface-soft); }
.report-table-pagination button:disabled { opacity: .45; cursor: not-allowed; }
.report-table-pagination strong { color: var(--muted); font-size: .8rem; }
.report-table-pages { display: flex; gap: 6px; min-width: 0; padding: 2px; overflow-x: auto; overscroll-behavior-inline: contain; direction: ltr; scrollbar-width: thin; scroll-snap-type: x proximity; }
.report-table-page-number { flex: 0 0 auto; min-width: 38px; padding-inline: 9px !important; direction: ltr; scroll-snap-align: center; font-variant-numeric: tabular-nums; }
.report-table-page-number.is-current { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 5px 14px rgba(37,99,235,.22); }
.report-table-page-number.is-current:hover { background: var(--primary) !important; color: #fff; }
.report-table-pagination-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px; }
.report-table-page-jump { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 7px; color: var(--muted); font-size: .8rem; font-weight: 750; }
.report-table-page-jump input { width: 72px; min-height: 38px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); text-align: center; direction: ltr; font-variant-numeric: tabular-nums; }
.report-table-page-jump input:focus-visible,
.report-table-pagination button:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 28%, transparent); outline-offset: 2px; }
.report-table-page-jump button { min-height: 38px; padding-inline: 12px; }

@media (max-width: 1920px) {
  .report-command-bar { grid-template-columns: auto auto minmax(180px, 1fr); }
  .report-command-dates { grid-column: span 2; }
  .report-command-actions { justify-content: end; }
  .report-advanced-grid { grid-template-columns: 180px minmax(0, 1fr); }
  .report-load-button { grid-column: 1 / -1; }
}

@media (max-width: 1180px) {
  .report-command-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-command-title,
  .report-command-ranges,
  .report-command-device,
  .report-command-dates,
  .report-command-actions { grid-column: 1 / -1; }
  .report-command-actions { justify-content: stretch; flex-wrap: wrap; }
  .report-command-actions > button { flex: 1 1 130px; }
  .report-insight-layout { grid-template-columns: 1fr; }
  .temperature-summary-rail { order: initial; }
}

@media (max-width: 960px) {
  .report-command-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-command-title,
  .report-command-ranges,
  .report-command-dates,
  .report-command-actions { grid-column: 1 / -1; }
  .report-command-actions { justify-content: stretch; flex-wrap: wrap; }
  .report-command-actions > button { flex: 1 1 130px; }
  .report-advanced-grid { grid-template-columns: 1fr; }
  .report-advanced-grid .report-options { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}

@media (max-width: 600px) {
  .report-command-bar { grid-template-columns: 1fr; }
  .report-command-title,
  .report-command-ranges,
  .report-command-device,
  .report-command-dates,
  .report-command-actions { grid-column: 1; }
  .report-command-ranges { overflow: visible; }
  .report-command-ranges .tabs { width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .report-command-ranges .tabs button { width: 100%; min-width: 0; padding-inline: 6px; }
  .report-command-dates { grid-template-columns: 1fr; }
  .report-command-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-more-menu { justify-self: stretch; }
  .report-more-menu > summary { width: 100%; }
  .report-advanced > summary { align-items: flex-start; flex-direction: column; }
  .report-advanced > summary small { max-width: 100%; text-align: start; }
  .report-advanced-grid .report-options { grid-template-columns: 1fr; }
  .temperature-chart-head { align-items: stretch; }
  .report-chart-series,
  .report-chart-toolbar { align-items: stretch; flex-direction: column; }
  .report-chart-series-label { width: 100%; }
  .report-chart-series-options { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-series-option { width: 100%; min-width: 0; padding-inline: 7px; }
  .report-chart-legend { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .report-chart-legend span { min-width: 0; }
  .temperature-chart-actions { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
  .chart-zoom-guide { grid-column: 1 / -1; justify-content: center; }
  .chart-zoom-reset,
  .exception-focus { width: 100%; justify-content: center; }
  .temperature-chart-wrap { height: 270px; }
  .event-timeline { padding-inline: 10px; }
  .event-timeline header { align-items: flex-end; }
  .event-timeline-heading { flex: 1 1 180px; }
  .event-timeline-controls { margin-inline-start: auto; }
  .event-timeline-track { grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: minmax(220px, 82%); gap: 8px; padding-top: 12px; overflow-x: auto; }
  .event-marker { min-width: 0; min-height: 126px; padding: 10px; }
  .temperature-summary-rail { padding: 14px; }
  .report-table-pagination { padding-inline: 10px; }
  .report-table-pagination-main { grid-template-columns: 40px minmax(0, 1fr) 40px; gap: 6px; }
  .report-table-nav-step { width: 40px; padding: 0 !important; }
  .report-table-nav-step span { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
  .report-table-pages { gap: 5px; }
  .report-table-pagination-footer { align-items: stretch; flex-direction: column; }
  .report-table-pagination-footer > strong { text-align: center; }
  .report-table-page-jump { width: 100%; }
}

/* V1 protected customer and user administration */
.admin-directory { max-width: 1500px; }
.admin-intro { margin: 0 0 8px; line-height: 1.7; color: var(--text); }
.admin-actions-grid { align-items: start; }
.admin-form { display: grid; gap: 14px; }
.admin-form label { display: grid; gap: 7px; font-weight: 800; }
.admin-form input,
.admin-form select,
.admin-search input {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.admin-form button[disabled] { opacity: .5; cursor: not-allowed; }
.admin-search {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.admin-search i { color: var(--muted); font-size: 1.25rem; }
.admin-search input { min-height: 36px; padding: 4px; border: 0; outline: 0; }
.admin-customer-list { display: grid; gap: 12px; }
.admin-customer-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.admin-customer-card > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px;
  cursor: pointer;
  list-style: none;
}
.admin-customer-card > summary::-webkit-details-marker { display: none; }
.admin-customer-card > summary > span { display: flex; align-items: center; gap: 8px; }
.admin-customer-card > summary > span:last-child { color: var(--muted); font-size: .9rem; }
.admin-customer-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}
.admin-customer-columns section { min-width: 0; }
.admin-customer-columns h3 { margin: 16px 0 10px; }
.admin-list-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.admin-list-row:last-child { border-bottom: 0; }
.admin-list-row > i { color: var(--primary); font-size: 1.2rem; }
.admin-list-row span { min-width: 0; }
.admin-list-row b,
.admin-list-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list-row small { margin-top: 3px; color: var(--muted); }
.admin-list-row em,
.freshness { font-size: .75rem; font-style: normal; font-weight: 800; }
.freshness { padding: 5px 8px; border-radius: 999px; }
.freshness.fresh { background: #dcfce7; color: #166534; }
.freshness.stale { background: #fef3c7; color: #92400e; }
.freshness.offline,
.freshness.no_data { background: #fee2e2; color: #991b1b; }

@media (max-width: 800px) {
  .admin-customer-card > summary { align-items: flex-start; flex-direction: column; }
  .admin-customer-columns { grid-template-columns: 1fr; }
  .admin-list-row { grid-template-columns: auto minmax(0, 1fr); }
  .admin-list-row > em { grid-column: 2; justify-self: start; }
}

* { box-sizing: border-box; }
html, body, #root { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, #f8fbfd, #edf8ff);
}
.login-card {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  justify-items: center;
  text-align: center;
}
.login-brand-lockup {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 0;
  margin: 0 auto 2px;
}
.login-card img.login-mark { width: 128px; max-width: 42%; margin: 0 auto; }
.login-card img.login-wordmark {
  width: 420px;
  max-width: 96%;
  margin: 0 auto;
  object-fit: contain;
}
.login-card p { margin: 0; color: var(--muted); }
.login-card label {
  width: 100%;
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
  text-align: start;
}
.password-field {
  position: relative;
  display: block;
  width: 100%;
}
.password-field input { padding-inline-end: 46px; }
.password-toggle {
  position: absolute;
  inset-inline-end: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
.password-toggle:hover {
  background: var(--surface-soft);
  color: var(--primary);
}
.password-toggle i { font-size: 1.15rem; }
.login-actions {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.login-actions .primary,
.login-actions .ghost {
  min-width: 132px;
  justify-content: center;
}
.login-actions .theme-login-toggle,
.theme-header-toggle {
  width: 40px;
  min-width: 40px;
  padding: 0;
}
.login-help {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: -2px;
}
.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
  padding: 4px 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-button:hover {
  color: var(--primary-dark);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}

[dir="ltr"] .app-shell { grid-template-columns: 280px minmax(0, 1fr); }

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  padding: 18px 16px;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
}

.brand {
  display: grid;
  justify-items: center;
  align-content: center;
  align-items: center;
  width: 100%;
  min-height: 70px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: center;
}
.brand img { width: min(188px, 100%); height: 64px; object-fit: contain; }
.brand-fallback { color: var(--text); font-size: 1rem; font-weight: 650; letter-spacing: .03em; }
.brand-fallback b { color: var(--primary); font-weight: 850; }

.menu { display: grid; gap: 4px; align-content: start; }
.menu-button {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  text-align: start;
}
.menu-button i { font-size: 1.25rem; }
.menu-button span { flex: 1; }
.menu-button:hover { background: var(--surface-soft); color: var(--text); }
.menu-button.active { background: #eff6ff; color: var(--primary); font-weight: 700; }

.main { min-width: 0; padding: 24px; }
.menu-toggle { display: none; }
.user-strip {
  display: inline-flex;
  align-items: center;
  align-self: end;
  gap: 8px;
  color: var(--muted);
  font-size: .9rem;
  white-space: nowrap;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 1.75rem; }
.top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-actions [data-action="lang"],
.top-actions [data-action="push"],
.top-actions [data-page="reports"] { display: none; }
.top-title { min-width: 0; }
.top-title:empty { min-height: 1px; }
.theme-header-toggle i { font-size: 1.15rem; }

.primary, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  font-weight: 700;
}
.primary:hover { background: var(--primary-dark); }
.ghost:hover { background: var(--surface-soft); }
.ghost.push-on { border-color: color-mix(in srgb, var(--success) 38%, var(--border)); background: color-mix(in srgb, var(--success) 13%, var(--surface)); color: var(--success); font-weight: 700; }
.ghost.push-off { border-color: color-mix(in srgb, var(--danger) 38%, var(--border)); background: color-mix(in srgb, var(--danger) 13%, var(--surface)); color: var(--danger); font-weight: 700; }
.wide { width: fit-content; }
.live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, var(--surface));
  font-size: .82rem;
  font-weight: 800;
}
.muted-live {
  color: var(--muted);
  background: var(--surface-soft);
}
.muted-live i { color: var(--muted); }

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #eff6ff;
  color: #1e40af;
}

.report-recovery-dialog {
  width: min(620px, calc(100vw - 28px));
  max-height: min(760px, calc(100vh - 28px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(7, 24, 39, .24);
}
.report-recovery-dialog::backdrop { background: rgba(7, 24, 39, .58); backdrop-filter: blur(2px); }
.report-recovery-dialog form { display: grid; max-height: inherit; }
.report-recovery-dialog header {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.report-recovery-dialog header > div { min-width: 0; }
.report-recovery-dialog header small { display: block; margin-bottom: 3px; color: var(--muted); font-size: .75rem; font-weight: 800; }
.report-recovery-dialog h2 { margin: 0; font-size: 1.12rem; line-height: 1.35; }
.report-recovery-icon { display: grid; width: 44px; height: 44px; place-items: center; background: #fff7ed; color: #c2410c; }
.report-recovery-icon i { font-size: 1.45rem; }
.report-dialog-close { display: grid; width: 38px; height: 38px; padding: 0; place-items: center; border-color: transparent; background: transparent; color: var(--muted); }
.report-dialog-close:hover { background: var(--surface-soft); color: var(--text); }
.report-recovery-body { padding: 18px 20px; overflow: auto; }
.report-recovery-body > p { margin: 0 0 16px; color: var(--muted); line-height: 1.6; }
.report-recovery-body dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0 0 14px; border: 1px solid var(--border); background: var(--border); }
.report-recovery-body dl > div { padding: 12px; background: var(--surface); }
.report-recovery-body dt { color: var(--muted); font-size: .75rem; font-weight: 800; }
.report-recovery-body dd { margin: 5px 0 0; font-size: 1.3rem; font-weight: 900; }
.report-recovery-body ul { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.report-recovery-body li { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 9px 10px; border-inline-start: 3px solid var(--warning); background: var(--surface-soft); color: var(--text); font-size: .82rem; }
.report-recovery-body li i { flex: 0 0 auto; color: var(--warning); }
.report-recovery-body li span { min-width: 0; overflow-wrap: anywhere; }
.report-recovery-dialog footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-soft); }
.report-recovery-dialog footer button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; }
:root[data-theme="dark"] .report-recovery-icon { background: #3a2415; color: #fdba74; }

@media (max-width: 620px) {
  .report-recovery-dialog { width: calc(100vw - 18px); max-height: calc(100vh - 18px); }
  .report-recovery-dialog header, .report-recovery-body { padding-inline: 14px; }
  .report-recovery-dialog footer { display: grid; grid-template-columns: 1fr; padding: 12px 14px; }
  .report-recovery-dialog footer .primary { grid-row: 1; }
  .report-recovery-body dl { grid-template-columns: 1fr 1fr; }
}
.muted-text { color: var(--muted); line-height: 1.6; }

.stack { display: grid; gap: 16px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.device-layout { align-items: start; }

.card, .kpi, .device-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border);
}
.card h2 {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  font-size: 1rem;
}
.card h2 i { color: var(--primary); font-size: 1.25rem; }
.card-body { padding: 16px; }
.card-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.icon-action {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
}
.icon-action:hover { border-color: var(--primary); background: #eff6ff; }

.ti-temperature { color: #2563eb; }
.ti-droplet { color: #16a34a; }
.ti-battery, .ti-battery-2, .ti-battery-4 { color: #16a34a; }
.ti-door { color: #d97706; }
.ti-wifi, .ti-antenna-bars-5 { color: #475569; }
.ti-alert-triangle, .ti-alert-circle, .ti-bell-ringing { color: #dc2626; }
.ti-bolt { color: #ca8a04; }
.ti-map-pin, .ti-map-2, .ti-route { color: #2563eb; }
.ti-heartbeat, .ti-activity { color: #0891b2; }

.kpi {
  position: relative;
  overflow: hidden;
  min-height: 116px;
  padding: 16px;
}
.kpi > i {
  position: absolute;
  inset-inline-end: 18px;
  top: 18px;
  font-size: 1.7rem;
  color: var(--primary);
}
.kpi span { display: block; color: var(--muted); font-weight: 700; }
.kpi strong { display: block; margin-top: 16px; font-size: 1.9rem; line-height: 1; }
.kpi small { display: block; margin-top: 8px; color: var(--muted); }
.kpi.danger > i, .kpi.danger strong { color: var(--danger); }
.kpi.warning > i, .kpi.warning strong { color: var(--warning); }

.toolbar {
  display: flex;
  justify-content: flex-end;
}
input {
  min-height: 40px;
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  padding: 0 12px;
}
.toolbar input { max-width: 360px; }

.device-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.device-grid.device-list { grid-template-columns: 1fr; gap: 10px; }
.device-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  text-align: start;
  color: inherit;
}
.device-card:hover { border-color: var(--primary); }
.device-card.selected { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(20, 121, 201, .16), var(--shadow); }

.device-selector-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.device-selector-row > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.device-selector-row span {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 800;
}

.device-selector-row strong {
  color: var(--text);
  font-size: .98rem;
  overflow-wrap: anywhere;
}

.device-selector-row label {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: min(360px, 100%);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.device-selector-row i {
  color: var(--primary);
  font-size: 1.2rem;
}

.device-selector-row select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  outline: none;
}
.device-card.has-alert { border-color: color-mix(in srgb, var(--danger) 38%, var(--border)); background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--danger) 7%, var(--surface))); }
.device-card.has-warning { border-color: color-mix(in srgb, var(--warning) 42%, var(--border)); background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--warning) 8%, var(--surface))); }
.device-card.is-ok { border-color: color-mix(in srgb, var(--primary) 24%, var(--border)); background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--primary) 8%, var(--surface))); }
.device-card.has-alert:hover { border-color: var(--danger); }
.device-card.has-warning:hover { border-color: var(--warning); }
.dashboard-device { width: 100%; }
.device-row {
  grid-template-columns: minmax(190px, 1.2fr) minmax(360px, 2.2fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 86px;
  padding: 14px 16px;
}
.device-row-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.device-row-main strong,
.device-row-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-row-main span { color: var(--muted); font-size: .86rem; }
.device-row-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(92px, 1fr));
  gap: 8px;
}
.device-row-metric {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 2px 7px;
  align-items: center;
  min-height: 48px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-soft));
}
.device-row-metric > :is(i, svg.ti) {
  grid-column: 1;
  grid-row: 1 / span 2;
  font-size: 1.16rem;
}
.device-row-metric small {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-row-metric strong {
  grid-column: 2;
  min-width: 0;
  overflow: visible;
  color: var(--text);
  font-size: .9rem;
  text-overflow: clip;
  white-space: nowrap;
}
.card-head { display: flex; justify-content: space-between; gap: 12px; }
.card-head strong, .card-head span { display: block; }
.card-head span, .device-card small { color: var(--muted); }
.mini-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.device-overview {
  display: grid;
  gap: 16px;
}
.device-identity {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 700;
}
.device-identity b { color: var(--text); }
.device-primary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.device-overview-section {
  display: grid;
  gap: 10px;
}
.device-overview-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: .95rem;
}
.mini {
  padding: 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}
.mini span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: .85rem;
}
.mini strong { display: block; margin-top: 8px; font-size: 1.35rem; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .78rem;
}
.pill.ok { background: rgba(37, 99, 235, .12); color: var(--primary); }
.pill.menu-ok {
  min-width: 30px;
  min-height: 30px;
  padding: 0;
  border: 2px solid #22c55e;
  background: #dcfce7;
  color: #16a34a;
  font-size: 1rem;
}
.pill.menu-ok i { color: #16a34a; }
.pill.danger { background: #fee2e2; color: var(--danger); }
.pill.warning { background: #fef3c7; color: #b45309; }

.info-list { display: grid; gap: 10px; }
.info-list span {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.info-list i { color: var(--primary); }

.app-shell i.ti-temperature { color: #2563eb; }
.app-shell i.ti-droplet { color: #16a34a; }
.app-shell i.ti-battery, .app-shell i.ti-battery-2, .app-shell i.ti-battery-4 { color: #16a34a; }
.app-shell i.ti-door { color: #d97706; }
.app-shell i.ti-wifi, .app-shell i.ti-antenna-bars-5 { color: #475569; }
.app-shell i.ti-alert-triangle, .app-shell i.ti-alert-circle, .app-shell i.ti-bell-ringing { color: #dc2626; }
.app-shell i.ti-bolt { color: #ca8a04; }
.app-shell i.ti-map-pin, .app-shell i.ti-map-2, .app-shell i.ti-route { color: #2563eb; }
.app-shell i.ti-heartbeat, .app-shell i.ti-activity { color: #0891b2; }

.state-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.state-tile {
  display: grid;
  gap: 7px;
  min-height: 132px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}
.state-tile i { font-size: 1.35rem; }
.state-tile span { color: var(--muted); font-size: .85rem; }
.state-tile strong { font-size: 1rem; }
.state-tile b {
  width: fit-content;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, .12);
  color: var(--primary);
  font-size: .76rem;
}
.state-tile.bad { border-color: color-mix(in srgb, var(--danger) 38%, var(--border)); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.state-tile.bad i { color: var(--danger); }
.state-tile.bad b { background: color-mix(in srgb, var(--danger) 16%, var(--surface)); color: var(--danger); }
.state-tile.stale { border-color: color-mix(in srgb, var(--warning) 42%, var(--border)); background: color-mix(in srgb, var(--warning) 8%, var(--surface)); }
.state-tile.stale i { color: #ca8a04; }
.state-tile.stale b { background: color-mix(in srgb, var(--warning) 17%, var(--surface)); color: color-mix(in srgb, var(--warning) 76%, var(--text)); }
.state-tile.good { border-color: rgba(37, 99, 235, .18); background: rgba(37, 99, 235, .06); }
.state-tile.temperature i { color: #2563eb; }
.state-tile.humidity i { color: #16a34a; }
.state-tile.battery-full i { color: #16a34a; }
.state-tile.battery-mid i { color: #ca8a04; }
.state-tile.battery-low i { color: #dc2626; }
.state-tile.door i { color: #d97706; }
.state-tile.online i { color: #475569; }

.state-grid.compact { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.metric-chip {
  display: grid;
  gap: 5px;
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.metric-chip i { font-size: 1.25rem; }
.metric-chip b { color: var(--muted); font-size: .78rem; }
.metric-chip strong { font-size: .98rem; }
.metric-chip.temperature i { color: #2563eb; }
.metric-chip.humidity i { color: #16a34a; }
.metric-chip.battery-full i { color: #16a34a; }
.metric-chip.battery-mid i { color: #ca8a04; }
.metric-chip.battery-low i { color: #dc2626; }
.metric-chip.door i { color: #d97706; }
.metric-chip.online i { color: #475569; }
.metric-chip.good { border-color: rgba(37, 99, 235, .16); background: rgba(37, 99, 235, .05); }
.metric-chip.bad { border-color: color-mix(in srgb, var(--danger) 38%, var(--border)); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.metric-chip.bad i { color: var(--danger); }

.compact-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.compact-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}
.muted-text { color: var(--muted); margin: 0 0 14px; }

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 14px;
}
.tabs button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.tabs button.active { border-color: var(--primary); background: #eff6ff; color: var(--primary); font-weight: 700; }

.history-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.summary-item {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}
.summary-item i { color: var(--primary); font-size: 1.2rem; }
.summary-item span { color: var(--muted); font-size: .82rem; }
.summary-item strong { font-size: 1.1rem; }
.chart-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: clamp(260px, 34vw, 380px);
  direction: ltr;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
#historyCanvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: 100%;
}
#historyCanvas[data-navigation="enabled"] { touch-action: none; cursor: grab; }
#historyCanvas[data-navigation="enabled"]:active { cursor: grabbing; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: .86rem;
}
.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chart-legend b {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 999px;
}
.chart-legend .temp { background: #16a34a; }
.chart-legend .hum { height: 10px; background: #93c5fd; }
.chart-legend .high { background: #dc2626; }
.chart-legend .low { background: #2563eb; }

.alert-list { display: grid; gap: 2px; }
.alert-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.alert-row:last-child { border-bottom: 0; }
.alert-row > i { font-size: 1.3rem; color: var(--success); }
.alert-row.active > i { color: var(--danger); }
.alert-row strong {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 1rem;
  line-height: 1.35;
}
.alert-row strong span {
  min-width: 0;
  overflow-wrap: anywhere;
}
.alert-row strong em {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--primary);
  font-size: .82rem;
  font-style: normal;
  font-weight: 800;
}
.alert-row.active strong em {
  background: color-mix(in srgb, var(--danger) 14%, var(--surface));
  color: var(--danger);
}
.alert-row.system strong em {
  background: var(--surface-soft);
  color: var(--muted);
}
.alert-row span { display: block; }
.alert-row span, .alert-row time { color: var(--muted); font-size: .94rem; }
.alert-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}
.alert-meta b {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .84rem;
  font-weight: 700;
}
.tiny-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--primary);
  font-weight: 700;
}
.tiny-action:hover { border-color: var(--primary); }
.alert-filter {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}
.alert-filter label {
  display: grid;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-weight: 800;
  font-size: .88rem;
}
.alert-filter select {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: .94rem;
  font-weight: 700;
}
.alert-filter b {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  height: 42px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  color: var(--primary);
  font-size: 1.05rem;
}

iframe {
  width: 100%;
  min-height: 390px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.leaflet-map {
  width: 100%;
  min-height: 390px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  direction: ltr;
}
.leaflet-map.fleet-map-compact { min-height: 320px; }
.leaflet-map.route-map { min-height: 390px; }
.route-dashboard-large .leaflet-map.route-map {
  min-height: clamp(620px, calc(100vh - 250px), 860px);
}
.leaflet-map .leaflet-control-attribution {
  font-size: 10px;
}
body.map-expanded-open { overflow: hidden; }
.leaflet-map.map-expanded {
  position: fixed !important;
  inset: 12px;
  z-index: 5000;
  width: auto;
  height: auto;
  min-height: 0 !important;
  max-height: none !important;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .3);
}
.endi-map-tools {
  display: grid;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, .16);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(15, 23, 42, .16);
}
.endi-map-tools button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  color: var(--text);
}
.endi-map-tools button:last-child { border-bottom: 0; }
.endi-map-tools button:hover,
.endi-map-tools button:focus-visible {
  background: var(--surface-soft);
  color: var(--primary);
}
.endi-map-tools svg {
  width: 19px;
  height: 19px;
}
.endi-map-pin {
  display: grid;
  place-items: center;
}
.endi-map-pin span {
  position: relative;
  display: grid;
  place-items: center;
  width: 28px;
  height: 38px;
  color: #2563eb;
  filter: drop-shadow(0 8px 14px rgba(37, 99, 235, .28));
}
.endi-map-pin i,
.endi-map-pin svg {
  color: #2563eb;
  width: 2.35rem;
  height: 2.35rem;
  font-size: 2.35rem;
  line-height: 1;
}
.route-marker {
  display: grid;
  place-items: center;
}
.route-marker span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(37, 99, 235, .28);
}
.route-marker.start span { background: #16a34a; }
.route-marker.stop span { background: #d97706; }
.route-marker.current span {
  width: 34px;
  height: 34px;
  background: #2563eb;
  box-shadow: 0 10px 22px rgba(37, 99, 235, .38);
}
.route-marker.end span { background: #dc2626; }
.route-marker i,
.route-marker svg {
  width: 1rem;
  height: 1rem;
  color: #ffffff;
  font-size: 1rem;
}
@media (max-width: 800px) {
  .leaflet-map.map-expanded {
    inset: 0;
    border: 0;
    border-radius: 0;
  }
}

.route-page {
  display: grid;
  gap: 16px;
}

.route-filter {
  margin: 0;
}

.route-filter .report-main-panel {
  margin: 0;
}

.current-location-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.current-location-panel > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 9px;
  align-items: center;
  min-width: 0;
  padding: 12px;
  border: 1px solid rgba(37, 99, 235, .18);
  border-radius: 10px;
  background: rgba(37, 99, 235, .06);
}

.current-location-panel i {
  grid-row: span 2;
  color: var(--primary);
  font-size: 1.25rem;
}

.current-location-panel span {
  color: var(--muted);
  font-size: .82rem;
}

.current-location-panel b {
  min-width: 0;
  color: var(--text);
  font-size: .94rem;
  overflow-wrap: anywhere;
}

.route-dashboard {
  display: grid;
  gap: 14px;
}
.route-dashboard-large {
  gap: 16px;
}

.route-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 10px;
}

.route-summary-grid > div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}

.route-summary-grid i {
  font-size: 22px;
  color: var(--primary);
}

.route-summary-grid span {
  color: var(--muted);
  font-size: 0.82rem;
}

.route-summary-grid b {
  color: var(--text);
  font-size: 1rem;
}

.route-table {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--surface);
}

.route-table > div {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.route-table > div:first-child {
  background: var(--surface-soft);
  color: var(--muted);
}

.route-table > div:last-child {
  border-bottom: 0;
}

.route-table span,
.route-table b {
  min-width: 0;
  overflow-wrap: anywhere;
}

.route-side-note {
  padding: 12px;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}
.route-gaps {
  display: grid;
  gap: 10px;
}
.route-gap-note {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(217, 119, 6, .28);
  border-radius: 10px;
  background: rgba(217, 119, 6, .08);
  color: var(--text);
}
.route-gap-note i {
  grid-row: span 2;
  color: #d97706;
  font-size: 1.35rem;
}
.route-gap-note strong {
  font-weight: 900;
}
.route-gap-note span {
  color: var(--muted);
  line-height: 1.5;
}
.map-tooltip {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 5px 10px;
  min-width: 160px;
  color: var(--text);
  direction: rtl;
}
.map-tooltip strong {
  grid-column: 1 / -1;
  font-size: .82rem;
}
.map-tooltip span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 800;
  white-space: nowrap;
}
.map-tooltip i,
.map-tooltip svg {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
  color: var(--primary);
}
.map-device-link {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  border-radius: 10px;
  color: inherit;
  text-align: start;
}
.map-device-link iframe {
  display: block;
  min-height: 320px;
  pointer-events: none;
}
.map-device-link span {
  position: absolute;
  inset-inline-start: 14px;
  bottom: 14px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
  font-weight: 800;
}
.fleet-map {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.fleet-map iframe {
  display: block;
  min-height: 390px;
  border: 0;
  border-radius: 0;
  pointer-events: none;
}
.fleet-map.compact iframe { min-height: 320px; }
.fleet-pins {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.fleet-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: #2563eb;
  box-shadow: 0 8px 20px rgba(37, 99, 235, .28);
  color: #ffffff;
  pointer-events: auto;
}
.fleet-pin i { color: #ffffff; font-size: 1rem; }
.fleet-pin span {
  position: absolute;
  inset-inline-start: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  display: none;
  max-width: min(220px, 55vw);
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: .78rem;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fleet-pin:hover span,
.fleet-pin:focus-visible span {
  display: block;
}
.route-svg {
  width: 100%;
  min-height: 390px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: linear-gradient(135deg, #f8fafc, #eef2ff);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.settings-grid label { display: grid; gap: 7px; color: var(--muted); font-weight: 700; }
.settings-grid .check {
  display: flex;
  align-items: center;
  gap: 8px;
}
.settings-grid .check input { width: 18px; min-height: 18px; }
.settings-toggle-group {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: var(--surface-soft);
}
.settings-toggle-group legend {
  padding: 0 8px;
  font-weight: 900;
  color: var(--text);
}
.settings-toggle-group p {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: .88rem;
}
.settings-toggle-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.account-settings { display: grid; gap: 10px; }
.notification-settings {
  display: grid;
  gap: 12px;
}
.language-row { display: none; }
.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.language-switcher span {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  opacity: .55;
  font-size: 1.05rem;
}
.language-switcher span.active {
  background: color-mix(in srgb, var(--primary) 10%, var(--surface));
  opacity: 1;
  box-shadow: inset 0 0 0 1px rgba(30, 99, 200, .2);
}
.setting-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: inherit;
  text-align: start;
}
.setting-row i { color: var(--primary); font-size: 1.2rem; }
.setting-row span { color: var(--text); font-weight: 700; }
.setting-row b { color: var(--muted); font-size: .86rem; }
.settings-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}
.settings-field textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
}
.input-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}
.input-with-unit input {
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--text);
}
.input-with-unit b {
  padding: 0 12px;
  color: var(--muted);
  font-size: .84rem;
  font-weight: 800;
}
.email-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}
.email-list legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 800;
}
.email-list-rows { display: grid; gap: 8px; }
.email-recipient-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
}
.email-recipient-row > i { color: var(--primary); font-size: 1.1rem; }
.email-recipient-row input {
  min-width: 0;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
.icon-action {
  display: inline-grid;
  place-items: center;
  width: 36px;
  min-height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
}
.icon-action:hover { border-color: color-mix(in srgb, var(--danger) 38%, var(--border)); color: var(--danger); background: color-mix(in srgb, var(--danger) 7%, var(--surface)); }
.add-email {
  width: fit-content;
  min-width: 0;
}
.settings-save {
  justify-self: start;
  min-width: 140px;
}
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 48px;
  height: 28px;
}
.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.switch b {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
  transition: .18s ease;
}
.switch b::after {
  content: "";
  position: absolute;
  top: 4px;
  inset-inline-start: 4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, .22);
  transition: .18s ease;
}
.switch input:checked + b { background: var(--primary); }
.switch input:checked + b::after { transform: translateX(20px); }
[dir="rtl"] .switch input:checked + b::after { transform: translateX(-20px); }

.report-page {
  display: grid;
  gap: 16px;
}
.report-builder {
  display: grid;
  grid-template-columns: minmax(360px, 1.25fr) minmax(260px, .85fr) minmax(210px, .65fr);
  gap: 14px;
  margin: 16px 0;
}
.report-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
}
.report-main-panel { grid-column: span 1; }
.report-panel h3 {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--text);
  font-size: .98rem;
  line-height: 1.25;
}
.report-panel h3 i { color: var(--primary); font-size: 1.15rem; }
.report-control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: end;
}
.report-control-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 700;
}
.report-control-grid input,
.report-control-grid select {
  min-width: 0;
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: clamp(.86rem, 1.8vw, .95rem);
  font-weight: 700;
}
.report-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}
.report-option {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-weight: 800;
  min-width: 0;
}
.report-option:hover { border-color: #bfdbfe; }
.report-option input { width: 18px; min-height: 18px; accent-color: var(--primary); }
.report-option span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.25;
  color: var(--text);
  font-family: inherit;
  font-size: clamp(.78rem, 1.7vw, .92rem);
  font-weight: 800;
}
.report-option i { color: var(--primary); font-size: 1.1rem; }
.report-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
.report-actions button { width: 100%; min-width: 0; }
.report-device {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  min-width: 0;
}
.report-device span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  font-family: inherit;
  font-size: clamp(.9rem, 2vw, 1rem);
  font-weight: 800;
  overflow-wrap: anywhere;
}
.report-device small {
  max-width: 100%;
  color: var(--muted);
  font-family: inherit;
  font-size: clamp(.76rem, 1.6vw, .86rem);
  overflow-wrap: anywhere;
}
.report-visuals {
  display: grid;
  gap: 12px;
}
.report-table {
  display: grid;
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.report-table > div {
  display: grid;
  grid-template-columns: repeat(var(--report-cols, 4), minmax(120px, 1fr));
  min-width: max(760px, 100%);
  gap: 1px;
  border-bottom: 1px solid var(--border);
}
.report-table > div:last-child { border-bottom: 0; }
.report-table b, .report-table span {
  min-width: 0;
  padding: 10px;
  background: var(--surface);
  overflow-wrap: anywhere;
}
.report-table-head b { background: #eff6ff; color: var(--primary); }
.report-table .out-of-range span { background: #fff7f7; color: #991b1b; }
.report-table .out-of-range span:last-child { font-weight: 800; }
.report-table .missing-data span { background: var(--surface-soft); color: var(--muted); font-style: italic; }
.report-table .missing-data span:first-child { color: var(--text); font-style: normal; }
.report-table .recovered-data span { box-shadow: inset 0 2px #0f766e, inset 0 -2px #0f766e; }
.report-table .recovered-data span:last-child { color: #0f766e; font-weight: 850; }
:root[data-theme="dark"] .report-table .recovered-data span:last-child { color: #5eead4; }

.table {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
}
.table div { padding: 12px; background: var(--surface-soft); }

.telemetry-table {
  display: grid;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.telemetry-table > div {
  display: grid;
  grid-template-columns: 1fr 1fr 150px;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.telemetry-table > div:last-child { border-bottom: 0; }
.telemetry-head { background: var(--surface-soft); color: var(--muted); }
.telemetry-table span { font-family: Consolas, monospace; color: var(--primary); }
.telemetry-table strong { font-weight: 700; }
.telemetry-table time { color: var(--muted); font-size: .85rem; }

.diagnostic-list {
  display: grid;
  gap: 10px;
}
.diagnostic-row code {
  display: block;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: Consolas, "Courier New", monospace;
  font-size: .78rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.empty {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 82px;
  color: var(--muted);
  text-align: center;
}
.empty i { font-size: 1.6rem; color: var(--primary); }

@media (max-width: 1600px) {
  .device-row { grid-template-columns: 1fr; }
  .device-row-metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 230px minmax(0, 1fr); }
  .kpi-grid, .device-grid, .state-grid, .state-grid.compact, .history-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid, .report-builder { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-control-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .report-main-panel { grid-row: auto; grid-column: 1 / -1; }
  .report-actions-panel { grid-column: 1 / -1; }
  .report-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .current-location-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-wrap { height: clamp(260px, 42vw, 360px); }
  .device-row { grid-template-columns: 1fr; }
  .device-row-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .device-primary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 800px) {
  .app-shell { display: block; }
  .login-card { padding: 26px 22px; }
  .login-card img.login-mark { width: 116px; max-width: 46%; }
  .login-card img.login-wordmark { width: 340px; max-width: 98%; }
  .login-actions .primary,
  .login-actions .ghost { min-width: 118px; }
  .login-actions .theme-login-toggle { width: 42px; min-width: 42px; }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto auto;
    align-items: center;
    gap: 8px 10px;
    padding: 10px 14px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
  }
  .brand {
    grid-column: 2;
    min-height: 48px;
    padding: 0;
    justify-items: center;
  }
  .brand img { width: min(164px, 52vw); height: 46px; }
  .menu-toggle { grid-column: 1; grid-row: 1; align-self: center; display: inline-flex; align-items: center; justify-content: center; width: 46px; min-height: 46px; padding: 0; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
  .menu-toggle i { font-size: 1.35rem; }
  .menu { display: none; grid-column: 1 / -1; flex-direction: column; overflow: visible; }
  .menu-button { width: 100%; }
  .menu-open .menu { display: flex; }
  .user-strip { display: none; grid-column: 1 / -1; justify-content: space-between; }
  .menu-open .user-strip { display: inline-flex; }
  .main { padding: 16px; }
  .topbar, .two-col { grid-template-columns: 1fr; display: grid; }
  .topbar { gap: 10px; }
  .top-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }
  .top-actions .live,
  .top-actions .ghost {
    width: 100%;
    min-width: 0;
  }
  .top-actions .muted-live { justify-content: center; }
  .kpi-grid, .device-grid, .mini-metrics, .settings-grid, .settings-toggle-grid, .report-builder, .report-control-grid, .report-options, .state-grid, .state-grid.compact, .history-summary, .compact-form, .setting-row { grid-template-columns: 1fr; }
  .device-primary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .device-selector-row {
    display: grid;
    gap: 10px;
  }
  .device-selector-row label {
    width: 100%;
    min-width: 0;
  }
  .device-identity { display: grid; }
  .device-row-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table { grid-template-columns: 1fr; }
  .alert-filter { grid-template-columns: 1fr; align-items: stretch; }
  .report-builder { gap: 12px; }
  .report-actions { grid-template-columns: 1fr; }
  .report-device { align-items: flex-start; flex-direction: column; }
  .current-location-panel,
  .route-summary-grid { grid-template-columns: 1fr; }
  .route-dashboard-large .leaflet-map.route-map {
    min-height: calc(100vh - 190px);
  }
  .route-table {
    border: 0;
    gap: 10px;
    background: transparent;
  }
  .route-table > div {
    grid-template-columns: 1fr;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
  }
  .route-table > div:first-child { display: none; }
  .chart-wrap { height: 270px; }
  .chart-legend { gap: 8px; font-size: .8rem; }
  .tabs { flex-wrap: nowrap; }
  .telemetry-table > div { grid-template-columns: 1fr; }
  .report-table {
    overflow: visible;
    border: 0;
    gap: 10px;
  }
  .report-table-head { display: none !important; }
  .report-table > div {
    grid-template-columns: 1fr;
    min-width: 0;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
  }
  .report-table span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 42px;
    border-bottom: 1px solid var(--border);
    text-align: end;
  }
  .report-table span:last-child { border-bottom: 0; }
  .report-table span::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 800;
    text-align: start;
  }
}

@media (max-width: 520px) {
  .stack,
  .stack > *,
  .kpi-grid,
  .card { min-width: 0; max-width: 100%; }
  .card header {
    min-height: 0;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 12px 14px;
  }
  .card h2 { min-width: 0; overflow-wrap: anywhere; }
  .card-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .card-actions > * { width: 100%; min-width: 0; }
  .device-row-metrics { grid-template-columns: 1fr; }
}
