* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; color: #1a1a1a; }

/* ---- Login page: split screen, form left / visual right ---- */
.login-body { margin: 0; height: 100vh; display: flex; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }

.login-left {
  width: 440px;
  flex-shrink: 0;
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.login-lang { font-size: 13px; color: #444; margin-bottom: 40px; }

.login-form-wrap { max-width: 320px; margin: 0 auto; width: 100%; }
.login-logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 36px; }
.login-logo-row .brand-text { font-size: 20px; font-weight: 700; color: #1a2233; }
.logo-full-img { width: 230px; height: auto; display: block; }

.login-form-wrap label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #1a1a1a; }
.login-field { position: relative; margin-bottom: 18px; }
.login-field input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
}
.login-field input:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 3px rgba(26,115,232,0.15); }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #888;
  padding: 2px;
}

.login-row-between { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin: 4px 0 20px; }
.login-row-between label { display: flex; align-items: center; gap: 6px; font-weight: 400; color: #444; margin: 0; }
.login-link { color: #1a73e8; text-decoration: none; font-size: 13px; }
.login-link:hover { text-decoration: underline; }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-primary:disabled { opacity: 0.6; cursor: default; }
.btn-secondary {
  width: 100%;
  padding: 11px;
  background: #fff;
  color: #1a2233;
  border: 1px solid #d5d9e0;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn-secondary:hover { background: #f7f8fa; }

.login-divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: #999; font-size: 12px; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: #e2e2e2; }

.login-signup { text-align: center; font-size: 13px; color: #666; margin-top: 24px; }
.login-mobile-note { text-align: center; font-size: 12px; color: #999; margin-top: 32px; }
.login-footer { text-align: center; font-size: 11px; color: #bbb; margin-top: auto; padding-top: 24px; }

.not-available-note { font-size: 12px; color: #c0392b; text-align: center; margin-top: 10px; display: none; }
.not-available-note.visible { display: block; }

.login-right {
  flex: 1;
  position: relative;
  background: linear-gradient(160deg, #0d2b45 0%, #12588f 55%, #1a8fd1 100%);
  overflow: hidden;
}
.login-right-caption {
  position: absolute;
  left: 40px;
  bottom: 40px;
  max-width: 360px;
  background: rgba(10, 20, 35, 0.72);
  color: #fff;
  padding: 22px 24px;
  border-radius: 10px;
}
.login-right-caption h3 { margin: 0 0 8px; font-size: 16px; font-weight: 700; }
.login-right-caption p { margin: 0; font-size: 13px; color: #cfd8e6; line-height: 1.5; }

.error-message { color: #c0392b; font-size: 13px; margin-top: 12px; text-align: center; }

/* ---- Dashboard shell ---- */
.app-shell { height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 52px;
  background: #1a2233;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 12px;
  flex-shrink: 0;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.brand-text { font-weight: 700; letter-spacing: 0.2px; font-size: 14px; white-space: nowrap; }
.logo-icon-img { height: 32px; width: auto; display: block; }

.tab-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
  flex: 1;
  min-width: 0;
}
.tab-button {
  display: flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: #b7c0d6;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12.5px;
  white-space: nowrap;
  flex-shrink: 0;
}
.tab-button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tab-button.active { background: rgba(26, 115, 232, 0.25); color: #fff; }
.tab-button svg { flex-shrink: 0; }

.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; flex-shrink: 0; }
.topbar-right button {
  background: transparent;
  border: 1px solid #4a5a7a;
  color: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
}

.main-area { flex: 1; display: flex; min-height: 0; }
.tab-view { flex: 1; display: flex; min-height: 0; }
.tab-view.hidden { display: none; }

/* ---- Sidebar: vehicle list + detail, stacked ---- */
.sidebar {
  width: 380px;
  border-right: 1px solid #e2e2e2;
  display: flex;
  flex-direction: column;
  background: #fafafa;
  overflow-y: auto;
}
.sidebar-header { padding: 10px; border-bottom: 1px solid #e2e2e2; flex-shrink: 0; }
.sidebar-header input {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 13px;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #e2e2e2;
  flex-shrink: 0;
}
.filter-chip {
  background: #fff;
  border: 1px solid #d5d9e0;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11.5px;
  cursor: pointer;
  color: #444;
}
.filter-chip:hover { background: #f0f3f8; }
.filter-chip.active { background: #1a73e8; border-color: #1a73e8; color: #fff; }
.filter-chip-disabled { opacity: 0.55; cursor: help; }

.vehicle-list { list-style: none; margin: 0; padding: 0; flex-shrink: 0; max-height: 40vh; overflow-y: auto; }
.vehicle-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  font-size: 12.5px;
}
.vehicle-item:hover { background: #eef3fc; }
.vehicle-item.selected { background: #dce8fb; }
.vehicle-item .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.vehicle-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vehicle-speed { color: #777; font-size: 11.5px; width: 52px; text-align: right; flex-shrink: 0; }
.vehicle-lastcomm { color: #999; font-size: 10.5px; width: 54px; text-align: right; flex-shrink: 0; }
.vehicle-checkbox { flex-shrink: 0; cursor: pointer; }

.mini-icon { font-size: 11px; flex-shrink: 0; display: inline-block; }
.ignition-on { color: #1a9e4a; }
.ignition-off { color: #c0392b; opacity: 0.6; }
.ignition-unknown { color: #ccc; }
.heading-arrow { color: #1a73e8; display: inline-block; }
.heading-unknown { color: #ccc; }
.bell-disabled, .fuel-disabled { opacity: 0.3; cursor: help; }
.gsm-bars { font-size: 9px; letter-spacing: 1px; color: #1a73e8; }
.gsm-bars.gsm-unknown { color: #ccc; }

.detail-section {
  border-top: 4px solid #1a2233;
  padding: 14px;
  background: #fff;
}
.detail-section.hidden { display: none; }
.detail-updated { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.detail-address { color: #666; font-size: 12.5px; margin-bottom: 14px; line-height: 1.4; }

.detail-section h3 { margin: 18px 0 8px; font-size: 12px; color: #555; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; display: flex; flex-direction: column; background: #f5f6f8; border-radius: 6px; padding: 8px; }
.stat-label { font-size: 11px; color: #888; margin-bottom: 2px; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.action-btn {
  background: #1a73e8;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 11.5px;
  cursor: pointer;
}
.action-btn:hover { background: #1560c4; }
.action-btn-disabled { background: #eef0f3; color: #99a0ab; cursor: help; }
.action-btn-disabled:hover { background: #eef0f3; }

.panel-empty.small { padding: 10px 4px; font-size: 12px; margin: 0; }

.map-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.map-control-btn {
  width: 34px;
  height: 34px;
  background: #fff;
  border: 1px solid #d5d9e0;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.map-control-btn:hover { background: #f5f6f8; }

.sensor-grid { display: flex; flex-direction: column; gap: 8px; }
.sensor { display: flex; justify-content: space-between; font-size: 13px; }
.not-wired { color: #bbb; font-style: italic; font-size: 12px; }

/* ---- Map ---- */
.map-area { flex: 1; position: relative; }
#map { position: absolute; inset: 0; }

/* ---- Dashboard tab ---- */
.dashboard-scroll { flex: 1; overflow-y: auto; padding: 20px 24px; }

.date-range-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 8px;
  font-size: 13px;
}
.range-btn {
  background: transparent;
  border: 1px solid #d5d9e0;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  color: #444;
}
.range-btn:hover { background: #f5f6f8; }
.range-btn.active { background: #1a73e8; border-color: #1a73e8; color: #fff; }
.range-label { color: #777; margin-left: 6px; }
.date-range-bar input[type="date"] {
  padding: 5px 8px;
  border: 1px solid #d5d9e0;
  border-radius: 6px;
  font-size: 12.5px;
}
.btn-apply {
  background: #1a2233;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 12.5px;
  cursor: pointer;
  margin-left: 4px;
}

.widget-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1200px) { .widget-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .widget-grid { grid-template-columns: 1fr; } }
.panel-wide { grid-column: span 2; }
@media (max-width: 1200px) { .panel-wide { grid-column: span 2; } }
@media (max-width: 700px) { .panel-wide { grid-column: span 1; } }

.panel { background: #fff; border: 1px solid #e6e6e6; border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.panel-head h3 { margin: 0; font-size: 13px; color: #333; font-weight: 700; }
.live-tag { font-size: 10px; color: #1a9e4a; font-weight: 700; letter-spacing: 0.3px; cursor: help; }
.panel-empty { color: #999; font-size: 13px; margin: auto; text-align: center; padding: 30px 10px; }

.chart-wrap { height: 220px; position: relative; }
.chart-wrap.small { height: 170px; }

.mileage-body { display: flex; gap: 16px; }
.mileage-body .chart-wrap { flex: 1; height: 240px; }
.mileage-legend { list-style: none; margin: 0; padding: 0; width: 190px; flex-shrink: 0; max-height: 240px; overflow-y: auto; }
.mileage-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 6px 0; border-bottom: 1px solid #f2f2f2; }
.mileage-legend-item .dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }
.mileage-legend-name { flex: 1; color: #333; }
.mileage-legend-value { color: #777; }

.activity-feed { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; }
.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}
.activity-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.activity-text { flex: 1; color: #333; }
.activity-time { color: #999; font-size: 12px; flex-shrink: 0; }
.activity-empty { color: #999; font-size: 13px; padding: 12px 0; }

/* ---- Placeholder for not-yet-built tabs ---- */
.placeholder {
  margin: auto;
  text-align: center;
  max-width: 360px;
  color: #666;
  padding: 24px;
}
.placeholder-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: #eef1f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8892a6;
}
.placeholder-icon svg { width: 26px; height: 26px; }
.placeholder h2 { color: #1a1a1a; margin: 0 0 8px; font-size: 18px; }
.placeholder p { font-size: 13px; line-height: 1.5; }
