*, *::before, *::after { box-sizing: border-box; }
:root {

  --bg: #eef2f7;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d9e2ec;
  --line-strong: #c7d2e1;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --dark: #0f172a;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; max-width: 100%; overflow-x: hidden; }
body { min-height: 100vh; font-family: Inter, Arial, sans-serif; color: var(--text); background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%); }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select { font: inherit; }
button, .topbar nav a { transition: background-color .18s ease, border-color .18s ease, transform .18s ease, color .18s ease; }
button:hover, .topbar nav a:hover { transform: translateY(-1px); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; flex-wrap: wrap; padding: 18px 22px; background: linear-gradient(135deg, #081326 0%, #10244b 100%); color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-shell { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-logo { width: 54px; height: 54px; object-fit: cover; border-radius: 16px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.18); box-shadow: 0 8px 20px rgba(0,0,0,.12); }
.brand-logo-fallback { display: grid; place-items: center; color: #fff; font-size: 24px; font-weight: 700; }
.topbar h1 { margin: 0 0 4px; font-size: 28px; line-height: 1.05; }
.topbar p { margin: 0; color: rgba(255,255,255,.82); max-width: 820px; }
.topbar nav { display: flex; gap: 10px; flex-wrap: wrap; }
.topbar nav a { padding: 11px 15px; border-radius: 14px; border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.04); color: #fff; }
.topbar nav a.active { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.22); }
.layout, .vehicle-page, .reports-page { width: 100%; max-width: 100%; padding: 16px; display: grid; gap: 16px; }
.layout { grid-template-columns: minmax(0, 1.8fr) minmax(320px, .95fr); grid-template-areas: 'map sidebar' 'bottom bottom'; align-items: start; }
.vehicle-page { grid-template-columns: minmax(320px, 430px) minmax(0, 1fr); align-items: start; }
.reports-page { grid-template-columns: minmax(0, 1fr); }
.map-card, .panel, .kpi { background: rgba(255,255,255,.92); border: 1px solid rgba(201, 210, 223, .95); border-radius: var(--radius); box-shadow: var(--shadow); }
.map-card { grid-area: map; padding: 14px; }
.sidebar { grid-area: sidebar; display: grid; gap: 16px; }
.bottom-grid { grid-area: bottom; display: grid; gap: 16px; }
.bottom-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-panel, .detail-panel, .chart-panel, .table-panel, .report-form-panel, .panel { padding: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 1.2rem; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.wrap-mobile, .stack-mobile, .toolbar-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-input, .compact-select, .vehicle-form input, .vehicle-form select, .report-form-grid input, .report-form-grid select, .route-controls input, .route-controls select { width: 100%; min-height: 44px; padding: 10px 13px; border-radius: 14px; border: 1px solid var(--line-strong); background: #fff; color: var(--text); outline: none; }
.search-input:focus, .compact-select:focus, .vehicle-form input:focus, .vehicle-form select:focus, .report-form-grid input:focus, .report-form-grid select:focus, .route-controls input:focus { border-color: #93c5fd; box-shadow: 0 0 0 4px rgba(37, 99, 235, .10); }
button { cursor: pointer; border: 1px solid transparent; border-radius: 14px; min-height: 44px; padding: 10px 15px; background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%); color: #fff; font-weight: 600; box-shadow: 0 6px 14px rgba(37, 99, 235, .18); }
.secondary-btn { background: var(--primary-soft); color: var(--dark); box-shadow: none; border-color: #bfdbfe; }
.ghost-btn { background: #edf2f7; color: var(--dark); box-shadow: none; border-color: var(--line); }
#map { height: 470px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); }
.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { padding: 16px; }
.kpi span { display: block; color: var(--muted); margin-bottom: 8px; }
.kpi strong { font-size: 30px; line-height: 1; }
.alert-list, .vehicle-detail, .table-wrap { min-width: 0; }
.alert-list { display: grid; gap: 10px; padding-top: 4px; }
.alert-item { border: 1px solid var(--line); border-left-width: 4px; border-radius: 14px; padding: 11px 12px; display: grid; gap: 3px; background: var(--panel-soft); }
.alert-temp_high, .alert-temp_low { border-left-color: var(--danger); }
.alert-speed { border-left-color: var(--warning); }
.alert-door { border-left-color: var(--primary); }
.detail-grid, .mobile-card-grid, .report-form-grid, .form-split { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metric-box { padding: 12px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 14px; min-width: 0; }
.metric-box span, .mobile-card-grid label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.metric-box strong, .mobile-card-grid strong { font-size: 1.05rem; overflow-wrap: anywhere; word-break: break-word; }
.chart-wrap { height: 260px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
.table-wrap table { min-width: 760px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid #e5ebf3; vertical-align: top; overflow-wrap: anywhere; }
tr:hover { background: #f8fbff; }
.status-badge { display: inline-flex; align-items: center; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-moving { background: #dcfce7; color: #166534; }
.status-stopped { background: #fef3c7; color: #92400e; }
.status-offline, .status-no_data { background: #fee2e2; color: #991b1b; }
.mobile-cards { display: none; gap: 12px; }
.mobile-card { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: #fff; box-shadow: 0 4px 12px rgba(15,23,42,.04); }
.mobile-card-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 12px; align-items: start; }
.vehicle-form { display: grid; gap: 12px; }
.vehicle-form label, .report-form-grid label, .route-controls label { display: grid; gap: 6px; color: var(--muted); font-size: 14px; }
.form-actions, .route-controls, .report-options { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.checkbox-label { display: flex !important; align-items: center; gap: 8px; }
.checkbox-label input, .route-toggle input { width: 18px; height: 18px; min-height: auto; accent-color: var(--primary); }
.hidden { display: none !important; }
.route-controls { margin: 8px 0 12px; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-soft); }
.compact-select { min-width: 180px; max-width: 100%; }
.color-swatch, .mini-color { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; border: 1px solid rgba(0,0,0,.1); vertical-align: middle; }
.car-marker-wrap { background: transparent; border: 0; }
.car-marker { width: 34px; height: 34px; border-radius: 50%; background: var(--marker-color); display: grid; place-items: center; color: #fff; font-size: 18px; box-shadow: 0 6px 14px rgba(15, 23, 42, .16); border: 2px solid rgba(255,255,255,.96); }
.car-marker.open { box-shadow: 0 0 0 4px rgba(245, 158, 11, .25), 0 6px 14px rgba(15, 23, 42, .16); }
.popup-btn { margin-top: 8px; width: 100%; }
.popup-card { min-width: 180px; }
.fleet-table-wrap, .alerts-list { max-height: 420px; overflow: auto; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 10px; padding-top: 10px; flex-wrap: wrap; }
.page-info { color: var(--muted); font-size: 14px; }
.desktop-only { display: block; }
.empty { color: var(--muted); }
.brand-preview { border: 1px dashed var(--line-strong); border-radius: 16px; padding: 18px; background: var(--panel-soft); }
.brand-preview-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
@media (max-width: 1180px) { .layout { grid-template-columns: 1fr; grid-template-areas: 'map' 'sidebar' 'bottom'; } .bottom-grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .vehicle-page { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .topbar { padding: 16px; }
  .topbar h1 { font-size: 24px; }
  .layout, .vehicle-page, .reports-page { padding: 12px; }
  #map { height: 380px; }
  .desktop-only { display: none; }
  .mobile-cards { display: grid; }
  .detail-grid, .mobile-card-grid, .report-form-grid, .form-split, .kpi-grid { grid-template-columns: 1fr; }
  .route-controls, .form-actions, .report-options, .toolbar-row, .stack-mobile { flex-direction: column; align-items: stretch; }
  .compact-select, .search-input, button { width: 100%; }
  .brand-shell { width: 100%; }
  .brand-logo { width: 46px; height: 46px; }
}


.inline-actions { display:flex; flex-wrap:wrap; gap:8px; }
.inline-actions form { margin:0; }
.danger-btn { background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%); color:#fff; box-shadow:none; }
.auth-shell { min-height:100vh; display:grid; place-items:center; padding:24px; }
.auth-card { width:min(100%, 460px); padding:18px; }
.auth-brand { margin-bottom: 18px; }
.center-text { text-align:center; }
.ghost-link { display:inline-flex; align-items:center; justify-content:center; min-height:44px; padding:10px 15px; border:1px solid var(--line); border-radius:14px; background:#edf2f7; color:var(--dark); }
.modal-card { border:0; border-radius:18px; padding:0; max-width:420px; width:calc(100% - 24px); }
.modal-card::backdrop { background: rgba(15, 23, 42, .35); }

.bottom-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dashboard-clean { align-items: start; }
.sidebar-compact { align-content: start; }
.admin-tools-grid { grid-template-columns: 1fr; }
.compact-panel { padding-bottom: 12px; }
.dashboard-toggle-bar { display: flex; flex-wrap: wrap; gap: 10px; }
.dashboard-toggle-btn.is-open { background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%); color: #fff; border-color: transparent; }
.toggle-panel { animation: fadeIn .18s ease; }
.nested-panel { padding: 0; border: 0; box-shadow: none; background: transparent; }
.compact-bottom-grid { gap: 14px; }
.login-card-wide { width: min(100%, 640px); }
.login-help-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 14px; }
.compact-text { margin: 6px 0 0; }
.reports-two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.fuel-summary-grid { margin-top: 12px; }
.top-gap { margin-top: 12px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 1180px) {
  .reports-two-col, .bottom-grid-2, .login-help-grid { grid-template-columns: 1fr; }
}


/* Mobile-safe date/time controls */
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: block;
  padding-right: 10px;
  -webkit-appearance: none;
  appearance: none;
}
.route-controls label,
.vehicle-form label,
.report-form-grid label {
  min-width: 0;
  width: 100%;
}
.route-controls,
.report-form-grid,
.vehicle-form,
.toolbar-row,
.stack-mobile {
  width: 100%;
  max-width: 100%;
}
.panel,
.map-card,
.auth-card,
.route-controls {
  overflow-x: clip;
}
@media (max-width: 768px) {
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  input[type="month"] {
    font-size: 16px;
  }
  .route-controls > label,
  .report-form-grid > label,
  .vehicle-form > label {
    width: 100%;
    flex: 1 1 100%;
  }
}


/* Fullscreen dashboard drawer */
.dashboard-screen-body { overflow: hidden; }
.fullscreen-dashboard { position: relative; width: 100vw; height: 100vh; background: #dbeafe; }
.fullscreen-map-shell { position: absolute; inset: 0; }
.fullscreen-map-shell #map { height: 100vh; width: 100vw; border-radius: 0; border: 0; }
.floating-menu-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 1400;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, .22);
}
.floating-menu-btn span {
  display: block;
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: #fff;
  transition: transform .2s ease, opacity .2s ease;
}
.floating-menu-btn.is-open span:nth-child(1) { transform: translateY(9px) rotate(45deg); }
.floating-menu-btn.is-open span:nth-child(2) { opacity: 0; }
.floating-menu-btn.is-open span:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }
.dashboard-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 1350;
  width: min(560px, calc(100vw - 24px));
  max-width: 100%;
  height: 100vh;
  padding: 12px;
}
.drawer-card {
  height: 100%;
  overflow-y: auto;
  background: rgba(248, 250, 252, .98);
  border: 1px solid rgba(203, 213, 225, .95);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .25);
  padding: 14px;
  backdrop-filter: blur(10px);
}
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1300;
  background: rgba(15, 23, 42, .26);
}
.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.compact-brand-shell { padding-right: 8px; }
.drawer-card { overscroll-behavior: contain; }
.drawer-nav {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.drawer-nav a {
  text-decoration: none;
  color: var(--dark);
  background: #eef2ff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  font-weight: 600;
  text-align: center;
}
.drawer-nav a.active { background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%); color: #fff; border-color: transparent; }
.drawer-panel { margin-bottom: 14px; }
.drawer-charts-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.drawer-close-btn { width: auto; min-width: 110px; }
body.drawer-open { overflow: hidden; }
@media (max-width: 760px) {
  .dashboard-screen-body { overflow: auto; }
  .floating-menu-btn { top: 12px; right: 12px; width: 52px; height: 52px; border-radius: 16px; }
  .dashboard-drawer { width: calc(100vw - 10px); padding: 5px; }
  .drawer-card { border-radius: 18px; padding: 12px; }
  .drawer-head { align-items: flex-start; flex-direction: column; }
  .drawer-close-btn { width: 100%; }
  .drawer-nav { grid-template-columns: 1fr; }
}


.page-shell { max-width: 1280px; margin: 0 auto; padding: 24px; display: grid; gap: 18px; }
.page-header-card { background: #fff; border-radius: 24px; padding: 24px; box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08); display:flex; justify-content:space-between; gap:16px; align-items:center; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.full-span { grid-column: 1 / -1; }
.inline-check { display:flex; align-items:center; gap:8px; }
.permission-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.form-actions { display:flex; gap:10px; flex-wrap:wrap; }
.split-actions { justify-content:space-between; }
.stack-list { display:grid; gap:14px; }
.client-card { border: 1px solid #e2e8f0; border-radius: 20px; padding: 18px; background:#fff; }
.client-card-head { display:flex; justify-content:space-between; gap:12px; align-items:flex-start; }
.status-line { display:flex; flex-direction:column; gap:6px; align-items:flex-end; }
.permission-summary { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
.pill { background:#eff6ff; color:#1d4ed8; border-radius:999px; padding:6px 10px; font-size:13px; }
.form-mt { margin-top: 14px; }
.client-map { width:100%; height:420px; border-radius:18px; overflow:hidden; }
.client-vehicles-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap:16px; }
.client-vehicle-card .detail-grid { margin-top: 10px; }
.danger-btn { background:#dc2626; color:#fff; border:none; border-radius:14px; padding:12px 16px; cursor:pointer; }
@media (max-width: 900px) { .form-grid-3 { grid-template-columns: 1fr; } .page-header-card { flex-direction:column; align-items:flex-start; } .client-card-head { flex-direction:column; } .status-line { align-items:flex-start; } .page-shell { padding: 14px; } }


/* Client pages */
.clients-admin-page { align-items: start; }
.client-admin-form { gap: 14px; }
.client-admin-form .checkbox-label { color: var(--dark); font-size: 15px; }
.multi-select-box { min-height: 220px; }
.permissions-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  display: grid;
  gap: 12px;
}
.compact-permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.client-admin-card { padding: 16px; }
.client-admin-head { align-items: start; }
.client-edit-details {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
  padding: 12px 14px;
}
.client-edit-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--dark);
}
.client-edit-details[open] summary { margin-bottom: 12px; }
.client-map {
  height: 420px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.styled-map { box-shadow: inset 0 0 0 1px rgba(203, 213, 225, .35); }
.client-vehicles-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.client-vehicle-card .card-head { align-items: start; }
@media (max-width: 980px) {
  .client-vehicles-grid, .compact-permission-grid { grid-template-columns: 1fr; }
}

.name-badge { display:inline-flex; align-items:center; justify-content:center; margin-left:4px; font-size:.95em; }
.badge-adr { filter:saturate(1.15); }
.car-marker { position: relative; overflow: visible; }
.marker-truck { line-height: 1; }
.marker-corner { position:absolute; width:16px; height:16px; border-radius:999px; background:#fff; display:flex; align-items:center; justify-content:center; font-size:10px; box-shadow:0 2px 8px rgba(15,23,42,.18); }
.marker-load { right:-6px; top:-6px; }
.marker-cold { left:-6px; top:-6px; }
.marker-adr { left:-6px; bottom:-6px; }


.driver-portal-grid { align-items: start; }
.fuel-history-full { grid-column: 1 / -1; }
.docs-cards-force { display: grid; }
.load-status-form { display: grid; gap: 12px; }
.load-toggle {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(37,99,235,.10), rgba(15,23,42,.06));
  padding: 18px 20px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.load-toggle.is-loaded {
  border-color: rgba(16,185,129,.45);
  background: linear-gradient(135deg, rgba(16,185,129,.18), rgba(37,99,235,.08));
}
.toggle-emoji { font-size: 34px; line-height: 1; }
.toggle-copy { display: grid; gap: 4px; text-align: left; }
.toggle-copy strong { font-size: 18px; color: var(--dark); }
.toggle-copy small { color: var(--muted); }
.toggle-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 110px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.85);
  color: var(--primary-dark);
  font-weight: 800;
}
.docs-cards a, .table-wrap a { word-break: break-word; }
@media (max-width: 900px) {
  .fuel-history-full { grid-column: auto; }
  .load-toggle { grid-template-columns: 1fr; }
}
