* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: #0f172a;
  color: #f8fafc;
  overflow: hidden;
}
body {
  display: flex;
  flex-direction: row;
}


input[type="date"],
input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
  
  /* Restore standard box model and styling */
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem; /* Explicitly set height to match other text inputs */
  padding: 0.5rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background-color: #ffffff;
  color: #333333;
  font-family: inherit;
  font-size: 16px; /* Prevents iPadOS from auto-zooming on tap */
}

/* Fix text alignment inside the input on WebKit */
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value {
  text-align: left;
}

#sidebar {
  width: 340px;
  min-width: 340px;
  height: 100vh;
  background: #1e293b;
  border-right: 1px solid #334155;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.25s ease;
}
#header {
  padding: 14px;
  border-bottom: 1px solid #334155;
  background: #0f172a;
}
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
#header h2 {
  margin: 0;
  font-size: 18px;
  color: #38bdf8;
}
.nav-links {
  display: flex;
  gap: 6px;
  align-items: center;
}
.nav-btn {
  padding: 5px 9px;
  font-size: 12px;
  background: #334155;
  color: #f8fafc;
  text-decoration: none;
  border-radius: 4px;
  border: none;
  cursor: pointer;
}
.nav-btn.logout { background: #7f1d1d; }
.close-drawer {
  display: none;
  font-size: 18px;
  line-height: 1;
  padding: 4px 10px;
  background: #475569;
}
.user-sub {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 6px;
}
#status {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 4px;
}
#stats {
  font-size: 12px;
  font-weight: 600;
  color: #22c55e;
  margin: 4px 0 8px 0;
}
#companyFilter, #search {
  width: 100%;
  padding: 9px 10px;
  margin-top: 6px;
  border-radius: 6px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #f8fafc;
  font-size: 14px;
}
#deviceList {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
}
.card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 11px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.card:hover, .card.active {
  border-color: #38bdf8;
  background: #172554;
}
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}
.badge.online { background: #14532d; color: #4ade80; }
.badge.offline { background: #7f1d1d; color: #fca5a5; }
#historyPanel {
  padding: 12px 14px;
  border-top: 1px solid #334155;
  background: #0f172a;
  font-size: 12px;
}
#historyPanel input[type="date"] {
  width: 100%;
  padding: 8px;
  margin: 8px 0;
  border-radius: 5px;
  border: 1px solid #475569;
  background: #1e293b;
  color: #f8fafc;
  font-size: 14px;
}
.btn-row {
  display: flex;
  gap: 8px;
}
.btn-row button {
  flex: 1;
  padding: 9px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
#playBtn { background: #0284c7; color: #fff; }
#clearBtn { background: #475569; color: #fff; }
#map {
  flex: 1;
  height: 100vh;
  min-height: 400px;
  z-index: 1;
}

/* Floating top-right controls (Desktop & Tablet) */
#topFloatingControls {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1100;
  display: flex;
  gap: 8px;
}
#mobileMenuBtn {
  display: none;
  background: #0f172a;
  color: #38bdf8;
  border: 1px solid #38bdf8;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  cursor: pointer;
}
#fitAllBtn {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  cursor: pointer;
}
#fitAllBtn:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}
#drawerBackdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1150;
}

/* Tablet layout (681px - 900px) */
@media (max-width: 900px) and (min-width: 681px) {
  #sidebar {
    width: 280px;
    min-width: 280px;
  }
}

/* Mobile phone layout (<= 680px) */
@media (max-width: 680px) {
  #topFloatingControls {
    left: 54px;
    right: auto;
    top: 12px;
  }
  #mobileMenuBtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .close-drawer {
    display: inline-block;
  }
  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 86vw;
    max-width: 340px;
    min-width: 0;
    height: 100dvh;
    z-index: 1200;
    transform: translateX(-100%);
    box-shadow: 4px 0 20px rgba(0,0,0,0.65);
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #drawerBackdrop.open {
    display: block;
  }
  #map {
    width: 100vw;
    height: 100dvh;
  }
  .leaflet-control-zoom a {
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 20px !important;
  }
}
/* =========================================================
   LOGIN & ADMIN USER MANAGEMENT STYLES
   ========================================================= */
body.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #0f172a;
  color: #f8fafc;
  margin: 0;
  padding: 16px;
  overflow-y: auto;
}
.login-links { text-align: center; margin-top: 14px; font-size: 13px; } .login-links a { color: #38bdf8; text-decoration: none; }

.login-box {
  width: 100%;
  max-width: 380px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 28px 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45);
}

.login-box h2 {
  margin: 0 0 18px 0;
  font-size: 20px;
  text-align: center;
  color: #f8fafc;
}

.login-box input,
.login-box select {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  margin-bottom: 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #f8fafc;
  font-size: 14px;
}

.login-box input:focus,
.login-box select:focus {
  outline: none;
  border-color: #38bdf8;
}

.login-box button {
  width: 100%;
  padding: 11px;
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.login-box button:hover {
  background: #0369a1;
}

.login-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid #ef4444;
  color: #fca5a5;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Admin User Management Page (admin_users.php) */
body.admin-body {
  background: #0f172a;
  color: #f8fafc;
  margin: 0;
  padding: 24px 16px;
  min-height: 100vh;
  overflow-y: auto;
}

.admin-container {
  max-width: 860px;
  margin: 0 auto;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid #334155;
}

.admin-header h2 {
  margin: 0;
  font-size: 20px;
}

.admin-header a {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
  background: #0f172a;
  padding: 14px;
  border-radius: 8px;
}

.admin-form input,
.admin-form select {
  padding: 9px 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #f8fafc;
  font-size: 13px;
}

.admin-form button {
  padding: 9px 14px;
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #334155;
}

.admin-table th {
  color: #94a3b8;
  font-weight: 600;
}

.btn-danger {
  background: #dc2626;
  color: #ffffff;
  border: none;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
}

.btn-secondary {
  background: #334155;
  color: #f8fafc;
  border: none;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
}

/* =========================================================
   KEYNECT BRAND LOGO STYLES (CENTERED & TRANSPARENT)
   ========================================================= */
.login-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 380px;
}

.login-logo-wrap {
  width: 100%;
  text-align: center;
  margin-bottom: 18px;
}

.login-logo {
  max-width: 220px;
  height: auto;
  display: block;
  margin: 0 auto;
  background: transparent;
}

.sidebar-logo-wrap {
  width: 100%;
  text-align: center;
  padding: 14px 16px 8px 16px;
  border-bottom: 1px solid #1e293b;
  box-sizing: border-box;
}

.sidebar-logo {
  max-width: 170px;
  height: auto;
  display: block;
  margin: 0 auto;
  background: transparent;
}

.admin-logo-wrap {
  max-width: 860px;
  margin: 0 auto 16px auto;
  text-align: center;
}

.admin-logo {
  max-width: 190px;
  height: auto;
  display: block;
  margin: 0 auto;
  background: transparent;
}
.admin-msg-ok {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid #22c55e;
  color: #86efac;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 14px;
}

.admin-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0;
}

.input-sm {
  width: 120px;
  padding: 5px 8px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 5px;
  color: #f8fafc;
  font-size: 12px;
}

.muted-text {
  color: #94a3b8;
  font-size: 12px;
}
body.admin-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #0f172a;
  color: #f8fafc;
  margin: 0;
  padding: 24px 16px;
  min-height: 100vh;
  overflow-y: auto;
}

.admin-logo-wrap {
  width: 100%;
  max-width: 860px;
  margin: 0 auto 16px auto;
  text-align: center;
}

.admin-container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 24px;
  box-sizing: border-box;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}
/* Fix iPad landscape height clipping & enable smooth sidebar scrolling */
html, body {
  height: 100%;
  height: 100dvh;
}

#sidebar {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#header,
#historyPanel {
  flex-shrink: 0;
}

#deviceList {
  flex: 1 1 auto;
  min-height: 120px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Landscape tablet / short screen adjustment (iPad side-on) */
@media (max-height: 760px) {
  .sidebar-logo-wrap {
    padding: 8px 12px 4px 12px;
  }
  .sidebar-logo {
    max-width: 130px;
  }
  #header {
    padding: 8px 12px;
  }
  #historyPanel {
    padding: 8px 12px 16px 12px;
  }
}
.card-settings-link {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.12);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  background: #0f172a;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: #94a3b8;
}

.settings-grid input {
  padding: 9px 10px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #f8fafc;
  font-size: 13px;
}

.settings-grid button {
  padding: 10px 16px;
  background: #16a34a;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
  align-self: end;
}
.driver-photo-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.settings-driver-img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #38bdf8;
  background: #0f172a;
}
#historyBox input[type="date"],
#sidebar input[type="date"],
#sidebar input[type="text"],
#sidebar select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  display: block;
}

#historyBox {
  overflow: hidden;
  box-sizing: border-box;
}
/* ==========================================================================
   VRM, COMPLIANCE, GEOFENCE & HMRC MILEAGE FORM STYLES
   ========================================================================== */
.admin-container h3 {
  margin-top: 26px;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #334155;
  color: #f8fafc;
  font-size: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
  align-items: end;
}

.settings-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #cbd5e1;
  font-weight: 500;
}

.settings-grid input[type="text"],
.settings-grid input[type="number"],
.settings-grid input[type="email"],
.settings-grid input[type="date"],
.settings-grid input[type="time"],
.settings-grid select,
.inline-form input[type="text"],
.inline-form input[type="date"],
.inline-form select {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 11px;
  background: #0f172a;
  border: 1px solid #475569;
  border-radius: 6px;
  color: #f8fafc;
  font-size: 13px;
}

.settings-grid input:focus,
.settings-grid select:focus,
.inline-form input:focus,
.inline-form select:focus {
  outline: none;
  border-color: #38bdf8;
}

.settings-grid button[type="submit"],
.inline-form button[type="submit"] {
  padding: 10px 16px;
  background: #0284c7;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}

.settings-grid button[type="submit"]:hover,
.inline-form button[type="submit"]:hover {
  background: #0369a1;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.admin-table-wrap {
  overflow-x: auto;
  margin-bottom: 18px;
  border: 1px solid #334155;
  border-radius: 8px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #1e293b;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #334155;
  text-align: left;
  color: #e2e8f0;
}

.admin-table th {
  background: #0f172a;
  color: #94a3b8;
  font-weight: 600;
}

.btn-danger {
  background: #dc2626 !important;
  color: #ffffff !important;
  padding: 6px 12px !important;
  font-size: 12px !important;
}

.btn-danger:hover {
  background: #b91c1c !important;
}

.btn-secondary {
  background: #334155 !important;
  color: #f8fafc !important;
}

.btn-secondary:hover {
  background: #475569 !important;
}

.admin-msg-ok {
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.45);
  color: #4ade80;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}
.badge.privacy {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.vehicle-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #334155;
}

.vehicle-tabs a {
  padding: 7px 12px;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 6px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.vehicle-tabs a:hover {
  border-color: #38bdf8;
  color: #38bdf8;
}

.vehicle-tabs a.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #ffffff;
}
@media print {
  body.admin-body {
    background: #ffffff !important;
    color: #000000 !important;
    padding: 0 !important;
  }
  .admin-container {
    max-width: 100% !important;
    background: #ffffff !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .admin-header a,
  .admin-header button,
  .admin-table th:last-child,
  .admin-table td:last-child {
    display: none !important;
  }
  .admin-table th,
  .admin-table td {
    background: #ffffff !important;
    color: #000000 !important;
    border: 1px solid #cccccc !important;
  }
}
