:root {
  color-scheme: light;
  font-family: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  color: #162641;
  background: #f2f5fa;
  --paper: #fff;
  --line: #e0e7f1;
  --muted: #52647d;
  --blue: #245cde;
  --blue-ink: #204fbd;
  --blue-wash: #edf3ff;
  --navy: #101e35;
  --green: #137552;
  --green-wash: #e7f6ef;
  --orange: #9b5420;
  --orange-wash: #fff1e1;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .65; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, #map:focus-visible {
  outline: 2px solid #5384ff;
  outline-offset: 3px;
}
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.topbar { background: var(--navy); color: #fff; }
.topbar-inner { width: min(100%, 1600px); margin: auto; height: 66px; padding: 0 34px; display: flex; align-items: center; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; font-size: 19px; font-weight: 750; letter-spacing: -.45px; white-space: nowrap; }
.topbar-section { border-left: 1px solid #3a4a62; padding-left: 23px; color: #c4d0e2; font-size: 13px; }
.topbar-status { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.source-tag { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 650; color: #dce9ff; background: #233955; border: 1px solid #3d5370; border-radius: 6px; padding: 7px 10px; white-space: nowrap; }
.source-dot { width: 7px; height: 7px; border-radius: 50%; background: #ffd17f; }
.source-tag[data-source="traccar"] .source-dot { background: #67dea8; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 7px; }
.refresh { background: transparent; border: 1px solid #3a4a62; color: #e5efff; }
.refresh:hover { background: #223551; }
.page { max-width: 1600px; margin: auto; padding: 30px 34px 44px; }
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.day { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 0 0 7px; }
.day::first-letter { text-transform: uppercase; }
.day .icon { width: 15px; height: 15px; }
h1 { margin: 0; font-size: clamp(27px, 3vw, 37px); line-height: 1.12; font-weight: 750; letter-spacing: -.055em; }
h2 { font-size: 16px; font-weight: 730; letter-spacing: -.018em; margin: 0; }
.summary { display: flex; background: var(--paper); border: 1px solid var(--line); border-radius: 11px; padding: 9px 0; }
.summary-item { display: flex; align-items: center; gap: 9px; padding: 0 14px; min-width: 111px; }
.summary-item + .summary-item { border-left: 1px solid var(--line); }
.summary-icon, .device-icon { display: inline-grid; place-items: center; flex: 0 0 auto; width: 34px; height: 34px; border-radius: 8px; }
.fleet-color, .device-icon { color: var(--blue-ink); background: var(--blue-wash); }
.online-color { color: var(--green); background: var(--green-wash); }
.offline-color { color: var(--orange); background: var(--orange-wash); }
.summary-item strong { display: block; font-size: 19px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.summary-item small { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; white-space: nowrap; }
.workspace { display: grid; grid-template-columns: minmax(245px, 296px) minmax(0, 1fr); align-items: start; gap: 17px; }
.panel { min-width: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 5px #1c385b07; }
.panel-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.section-icon { color: var(--blue-ink); }
.panel-header, .fleet-header { padding: 14px 17px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 60px; }
.count-tag { display: inline-grid; place-items: center; min-width: 23px; min-height: 22px; border-radius: 6px; padding: 0 5px; color: var(--blue-ink); background: var(--blue-wash); font-size: 11px; font-weight: 700; }
.fleet-header { padding-top: 17px; border-bottom: 1px solid var(--line); }
.search { margin: 14px 0 11px; display: flex; align-items: center; gap: 8px; border: 1px solid #dbe4f1; border-radius: 7px; padding: 0 10px; background: #f8fafd; color: var(--muted); }
.search:focus-within { border-color: #6389f3; background: white; }
.search input { appearance: none; min-width: 0; width: 100%; height: 38px; color: #233653; padding: 0; border: 0; background: transparent; font-size: 13px; }
.search input:focus { outline: 0; }
.search input::placeholder { color: #596b83; }
.filters, .ranges { display: flex; gap: 4px; }
.filters button, .ranges button { border: 1px solid transparent; padding: 6px 8px; background: transparent; color: var(--muted); border-radius: 6px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.filters button:hover, .ranges button:hover { background: #f0f4fa; }
.filters button[aria-pressed="true"], .ranges button[aria-pressed="true"] { background: var(--blue-wash); border-color: #d9e5ff; color: var(--blue-ink); }
.fleet-list { min-height: 200px; max-height: 60dvh; overflow: auto; }
.fleet-row { width: 100%; display: grid; grid-template-columns: 36px minmax(0, 1fr) 15px; align-items: center; gap: 10px; padding: 13px 13px; min-height: 77px; text-align: left; background: white; border: 0; border-left: 3px solid transparent; color: inherit; }
.fleet-row + .fleet-row { border-top: 1px solid #edf1f6; }
.fleet-row:hover { background: #f6f9fe; }
.fleet-row[aria-pressed="true"] { background: #edf3ff; border-left-color: var(--blue); }
.fleet-row:focus-visible { outline-offset: -3px; }
.fleet-row .device-icon { width: 36px; height: 36px; background: #eef2f8; color: #49617f; }
.fleet-row[aria-pressed="true"] .device-icon { color: var(--blue-ink); background: #dce8ff; }
.fleet-row-name { display: block; font-weight: 720; font-size: 13px; overflow-wrap: anywhere; }
.fleet-row-meta { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.fleet-row-arrow { color: #647c97; width: 15px; height: 15px; }
.status-inline { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 650; margin-top: 4px; }
.status-inline i, .status-tag i, .live-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.status-inline[data-status="online"], .status-tag[data-status="online"] { color: var(--green); }
.status-inline[data-status="offline"], .status-tag[data-status="offline"] { color: var(--orange); }
.status-inline[data-status="unknown"], .status-tag[data-status="unknown"] { color: var(--muted); }
.fleet-footer { display: flex; align-items: center; gap: 7px; color: var(--muted); padding: 12px 17px; border-top: 1px solid var(--line); font-size: 11px; }
.fleet-footer .live-dot { color: #3c76e8; }
.main-panels { display: grid; gap: 15px; min-width: 0; }
.map-panel { overflow: hidden; }
.secondary { display: inline-flex; align-items: center; gap: 6px; border: 1px solid #dae3f0; border-radius: 7px; padding: 7px 10px; background: #fff; color: #3d5370; font-size: 12px; font-weight: 680; white-space: nowrap; }
.secondary:hover { background: #f3f7fd; }
.secondary .icon { width: 16px; height: 16px; }
.map-area { position: relative; min-height: 348px; height: clamp(375px, 51vh, 600px); border-top: 1px solid var(--line); isolation: isolate; }
#map { height: 100%; width: 100%; background: #edf0ef; }
.map-controls { position: absolute; right: 13px; top: 13px; z-index: 500; background: white; border: 1px solid #d8e1ed; border-radius: 9px; box-shadow: 0 2px 8px #18355721; overflow: hidden; }
.map-controls button { display: grid; place-items: center; border: 0; color: #203550; background: white; width: 36px; height: 34px; }
.map-controls button + button { border-top: 1px solid #e2e8f1; }
.map-controls button:hover { background: #edf3ff; }
.map-controls button:focus-visible { outline-offset: -3px; }
.map-key, .map-notice { position: absolute; z-index: 500; left: 12px; background: #ffffffed; border: 1px solid #dce4ee; border-radius: 8px; box-shadow: 0 1px 5px #193b5d12; color: #304461; font-size: 11px; }
.map-key { bottom: 19px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 8px 10px; }
.map-key span { display: inline-flex; align-items: center; gap: 6px; }
.map-notice { top: 11px; padding: 6px 9px; }
.key-position { width: 9px; height: 9px; background: var(--blue); border-radius: 50%; }
.key-route { width: 16px; height: 3px; background: var(--blue); border-radius: 3px; }
.leaflet-container { font: inherit; }
.leaflet-tile-pane { filter: saturate(.64) brightness(1.03); }
.leaflet-container .leaflet-control-attribution { line-height: 1.3; }
.leaflet-container .leaflet-interactive { cursor: pointer; }
.map-marker { display: grid; place-items: center; border: 2px solid #fff; border-radius: 50%; background: #62758e; color: #fff; box-shadow: 0 1px 7px #1a36555c; }
.map-marker.is-online { background: #16805e; }
.map-marker.is-selected { background: var(--blue); box-shadow: 0 0 0 5px #3266f433, 0 2px 8px #123d6060; }
.map-marker .icon { width: 17px; height: 17px; }
.point-tooltip { border: 1px solid #dee6f1; font-weight: 650; color: #233853; }
.selected-device { display: flex; align-items: center; gap: 10px; min-width: 0; }
.selected-device h2 { overflow-wrap: anywhere; }
.selected-device p { font-size: 12px; color: var(--muted); margin: 3px 0 0; }
.details-header { padding-block: 12px; }
.status-tag { display: inline-flex; align-items: center; flex: 0 0 auto; gap: 5px; background: #eef2f7; border-radius: 20px; padding: 5px 9px; font-size: 11px; font-weight: 700; }
.status-tag[data-status="online"] { background: var(--green-wash); }
.status-tag[data-status="offline"] { background: var(--orange-wash); }
.telemetry { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-block: 1px solid var(--line); background: #fafcff; }
.telemetry > div { display: flex; align-items: center; gap: 9px; min-width: 0; padding: 12px 15px; }
.telemetry > div + div { border-left: 1px solid var(--line); }
.telemetry .icon { color: var(--blue-ink); }
.telemetry small, .telemetry strong { display: block; }
.telemetry small { color: var(--muted); font-size: 11px; }
.telemetry strong { font-size: 13px; font-weight: 700; margin-top: 3px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.history { padding: 14px 17px 13px; }
.history-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.history-status, .empty { font-size: 13px; color: var(--muted); }
.history-status { margin: 9px 0; min-height: 15px; }
.empty { margin: 0; padding: 20px 16px; line-height: 1.45; }
.history-list { margin: 0; padding: 0; list-style: none; max-height: 230px; overflow: auto; }
.history-list li { border-top: 1px solid #edf1f6; }
.history-point { border: 0; width: 100%; text-align: left; display: grid; grid-template-columns: 1.1fr 1fr 65px; gap: 8px; background: white; padding: 8px 4px; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.history-point:hover, .history-point[aria-pressed="true"] { color: var(--blue-ink); background: var(--blue-wash); }
.history-point:focus-visible { outline-offset: -2px; }
.history-point time { color: #243d61; font-weight: 650; }
.history-point span:last-child { text-align: right; }
.topbar-button { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 11px; border-radius: 7px; background: transparent; border: 1px solid #3a4a62; color: #e5efff; font-size: 12px; font-weight: 650; white-space: nowrap; }
.topbar-button:hover, .topbar-button[aria-pressed="true"] { background: #223551; }
.topbar-button .icon { width: 16px; height: 16px; }
.user-name { color: #c4d0e2; font-size: 12px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login { min-height: calc(100dvh - 66px); display: grid; place-items: center; padding: 30px 16px; }
.login-card { width: min(100%, 380px); padding: 26px 24px 24px; display: grid; }
.login-card h1 { font-size: 27px; }
.login-lead { color: var(--muted); font-size: 13px; margin: 8px 0 18px; }
.login-card label, .user-form label { font-size: 12px; font-weight: 680; color: #304461; margin: 10px 0 5px; }
.login-card input, .user-form input { height: 40px; border: 1px solid #d3ddeb; border-radius: 7px; padding: 0 11px; background: #f8fafd; color: #162641; font-size: 14px; }
.login-card input:focus, .user-form input:focus { outline: 2px solid #5384ff; outline-offset: 1px; background: #fff; }
.primary { margin-top: 18px; height: 40px; border: 0; border-radius: 7px; background: var(--blue); color: #fff; font-size: 14px; font-weight: 700; }
.primary:hover { background: var(--blue-ink); }
.form-error, .form-ok { font-size: 13px; margin: 12px 0 0; padding: 8px 10px; border-radius: 7px; line-height: 1.4; }
.form-error { background: #fff4e8; color: #71390f; border: 1px solid #ead5c0; }
.form-ok { background: var(--green-wash); color: #0d5a3e; border: 1px solid #bfe3d2; }
.hint { font-size: 11px; color: var(--muted); margin: 5px 0 0; }
.accounts-grid { display: grid; grid-template-columns: minmax(260px, 360px) minmax(0, 1fr); gap: 17px; align-items: start; }
.accounts-side { display: grid; gap: 15px; }
.users-list { border-top: 1px solid var(--line); max-height: 45dvh; overflow: auto; }
.user-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 15px; text-align: left; background: #fff; border: 0; border-left: 3px solid transparent; color: inherit; }
.user-row + .user-row { border-top: 1px solid #edf1f6; }
.user-row:hover { background: #f6f9fe; }
.user-row[aria-pressed="true"] { background: #edf3ff; border-left-color: var(--blue); }
.user-row:focus-visible { outline-offset: -3px; }
.user-row .fleet-row-meta { overflow-wrap: anywhere; }
.role-tag { flex: 0 0 auto; font-size: 10px; font-weight: 700; color: var(--blue-ink); background: var(--blue-wash); border-radius: 20px; padding: 3px 8px; }
.role-tag.is-off { color: var(--orange); background: var(--orange-wash); }
.user-form { padding: 17px; display: grid; }
.user-form h2 { margin-bottom: 4px; }
.assign-status { margin: 0; padding: 12px 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.assign-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); max-height: 62dvh; overflow: auto; }
.assign-list li + li { border-top: 1px solid #edf1f6; }
.assign-row { display: flex; align-items: center; gap: 11px; padding: 11px 17px; font-size: 13px; font-weight: 620; cursor: pointer; }
.assign-row:hover { background: #f6f9fe; }
.assign-row input { width: 17px; height: 17px; accent-color: var(--blue); }
.assign-row input:disabled + span { color: var(--muted); }
.admin-nav { display: flex; gap: 6px; }
.topbar-button[aria-current="page"] { background: #223551; border-color: #58709a; }
.devices-grid { grid-template-columns: minmax(280px, 420px) minmax(0, 1fr); }
.inventory-list { max-height: 68dvh; }
.inventory-row { align-items: start; padding-block: 12px; }
.inventory-caption { min-width: 0; }
.inventory-caption .status-inline { display: flex; }
.inventory-caption .fleet-row-meta { overflow-wrap: anywhere; }
.admin-tag { flex: 0 0 auto; font-size: 10px; font-weight: 700; border-radius: 20px; padding: 3px 8px; color: var(--green); background: var(--green-wash); }
.admin-tag[data-state="disabled"], .admin-tag[data-state="expired"] { color: var(--orange); background: var(--orange-wash); }
.device-form { padding: 17px; }
.device-form-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.device-form-header h2 { overflow-wrap: anywhere; }
.device-state { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.device-form > .hint { margin-top: 6px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; margin-top: 4px; }
.sim-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 9px; padding: 2px 13px 13px; margin: 16px 0 0; min-width: 0; }
.sim-fields legend { font-size: 12px; font-weight: 720; color: #304461; padding: 0 5px; }
.field { display: grid; align-content: start; min-width: 0; }
.field label { font-size: 12px; font-weight: 680; color: #304461; margin: 12px 0 5px; }
.field input, .field select { width: 100%; min-width: 0; height: 40px; border: 1px solid #d3ddeb; border-radius: 7px; padding: 0 11px; background: #f8fafd; color: #162641; font-size: 14px; }
.field input:focus, .field select:focus { outline: 2px solid #5384ff; outline-offset: 1px; background: #fff; }
.form-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.form-actions .primary { margin-top: 0; padding: 0 18px; }
.form-actions .secondary { height: 40px; padding: 0 14px; }
.page-error { background: #fff4e8; color: #71390f; border: 1px solid #ead5c0; border-radius: 7px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }

@media (max-width: 1100px) {
  .sim-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .devices-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar-inner, .page { padding-inline: 19px; }
  .workspace { grid-template-columns: 216px minmax(0, 1fr); gap: 11px; }
  .fleet-header, .panel-header, .history { padding-inline: 12px; }
  .summary-item { padding-inline: 8px; min-width: 0; }
  .summary-icon { width: 29px; height: 29px; }
  .telemetry > div { padding-inline: 10px; gap: 5px; }
  .telemetry .icon { display: none; }
}

@media (max-width: 620px) {
  .topbar-inner { gap: 11px; height: 57px; }
  .topbar-section, .user-name, .topbar-button span, .brand span { display: none; }
  .topbar-button { padding: 0 9px; }
  .accounts-grid, .devices-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-nav { gap: 4px; }
  .topbar-status { gap: 6px; }
  .source-tag { padding: 7px; }
  #data-source-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .inventory-list { max-height: 300px; }
  .form-grid, .sim-fields { grid-template-columns: minmax(0, 1fr); }
  .page { padding-top: 20px; }
  .page-header { align-items: start; flex-direction: column; gap: 13px; margin-bottom: 13px; }
  .summary { width: 100%; }
  .summary-item { flex: 1; justify-content: center; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .fleet-list { min-height: 0; max-height: 183px; }
  .fleet-row { padding-block: 8px; min-height: 65px; }
  .map-area { height: 380px; }
  .history-point { grid-template-columns: 1fr auto; }
  .history-point span:nth-child(2) { display: none; }
}
