html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}
:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-card: #334155;
  --bg-card-hover: #475569;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-primary: #3b82f6;
  --accent-success: #10b981;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --border-color: #334155;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 16px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* Header & Top Bar */
.app-header {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-success));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-success);
}

.status-badge.offline {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-warning);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

/* Main Container */
.main-content {
  flex: 1;
  padding: 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-bottom: calc(80px + var(--safe-bottom));
}

/* Quick Action Buttons */
.hero-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.action-btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.15s ease;
  touch-action: manipulation;
  min-height: 88px;
  box-shadow: var(--shadow-md);
}

.action-btn:active {
  transform: scale(0.97);
}

.action-btn.btn-entry {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
}

.action-btn.btn-exit {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
}

.action-btn svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
}

/* KPI Summary Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-main);
}

.kpi-card.highlight {
  border-color: rgba(59, 130, 246, 0.4);
}

/* Occupancy Meter */
.occupancy-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.occupancy-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--bg-card);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-success), var(--accent-primary));
  border-radius: 9999px;
  transition: width 0.4s ease;
}

/* Recent Activity & Parked Vehicles */
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.session-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.session-item {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.plate-pill {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  background: #000;
  color: #fbbf24;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid #4b5563;
  display: inline-block;
}

.session-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.session-time {
  font-size: 12px;
  color: var(--text-muted);
}

.session-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent-primary);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  z-index: 40;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s ease;
}

.nav-item.active {
  color: var(--accent-primary);
}

.nav-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Modal Windows */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex;
}

.modal-sheet {
  background: var(--bg-surface);
  width: 100%;
  max-width: 500px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 20px 18px calc(24px + var(--safe-bottom));
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
}

.close-btn {
  background: var(--bg-card);
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

/* Vehicle Types Selector */
.type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.type-btn {
  background: var(--bg-card);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-main);
  font-size: 12px;
  font-weight: 700;
}

.type-btn.selected {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
}

/* Camera and Plate Input */
.camera-box {
  width: 100%;
  height: 180px;
  background: #000;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #475569;
}

.plate-input-field {
  width: 100%;
  background: #000;
  color: #fbbf24;
  font-family: monospace;
  font-size: 26px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 3px;
  padding: 12px;
  border: 2px solid #334155;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  text-transform: uppercase;
}

.plate-input-field:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.submit-btn {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--accent-primary);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

/* --- Phase 2: Auth, RBAC & Wizard Styles --- */

.user-profile-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

.role-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
  text-transform: uppercase;
}

.role-tag.admin {
  background: #7c3aed;
  color: #fff;
}

.role-tag.manager {
  background: #0284c7;
  color: #fff;
}

.role-tag.operator {
  background: #059669;
  color: #fff;
}

.btn-lock {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: var(--radius-sm);
}

.btn-lock:active {
  color: var(--text-main);
}

/* Fullscreen PIN Modal */
.pin-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 200;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px 16px;
}

.pin-overlay.active {
  display: flex;
}

.pin-brand-title {
  font-size: 26px;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.pin-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* User Selection Carousel/Grid */
.pin-user-grid {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
  max-width: 360px;
  width: 100%;
  overflow-x: auto;
  padding: 4px 0;
}

.pin-user-btn {
  background: var(--bg-surface);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-main);
  min-width: 90px;
  flex-shrink: 0;
}

.pin-user-btn.selected {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.15);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #fff;
}

.user-name {
  font-size: 13px;
  font-weight: 700;
}

.user-role-badge {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Masked PIN Indicator Dots */
.pin-dots-wrapper {
  display: flex;
  gap: 16px;
  margin-bottom: 32px;
}

.pin-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-color);
  background: transparent;
  transition: all 0.15s ease;
}

.pin-dot.filled {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  transform: scale(1.15);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* 3x4 Numpad Grid */
.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 280px;
  width: 100%;
}

.numpad-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  font-size: 28px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.08s ease, background-color 0.1s ease;
  margin: 0 auto;
}

.numpad-btn:active {
  transform: scale(0.92);
  background: var(--bg-card);
}

.numpad-btn.action-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

/* Responsive Form Grid */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 480px) {
  .form-grid-2 {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }
}

/* First-Run Setup Wizard */
.wizard-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 300;
  display: none;
  padding: 20px 14px;
  overflow-y: auto;
  overflow-x: hidden;
  width: 100vw;
  box-sizing: border-box;
}

.wizard-overlay.active {
  display: block;
}

.wizard-container {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
  overflow-x: hidden;
}

.wizard-header {
  text-align: center;
  margin-bottom: 8px;
}

.wizard-badge {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  display: inline-block;
  margin-bottom: 8px;
}

.wizard-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
}

.form-input {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 15px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.form-input:focus {
  border-color: var(--accent-primary);
  outline: none;
}

/* --- Phase 3: Settings & Thermal Receipt Simulator Styles --- */

.rate-config-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 8px;
}

/* Simulated Thermal Paper */
.receipt-paper {
  background: #ffffff;
  color: #000000;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  line-height: 1.35;
  padding: 16px 14px;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: width 0.2s ease;
  user-select: text;
  -webkit-user-select: text;
}

.receipt-paper.width-58mm {
  max-width: 270px;
}

.receipt-paper.width-80mm {
  max-width: 360px;
}

.receipt-header-center {
  text-align: center;
  font-size: 11px;
  line-height: 1.4;
}

.receipt-lot-title {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.receipt-divider {
  text-align: center;
  margin: 6px 0;
  overflow: hidden;
  white-space: nowrap;
  letter-spacing: -1px;
  color: #64748b;
}

.receipt-center {
  text-align: center;
}

.receipt-plate-bold {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 2px;
  margin: 4px 0;
}

.receipt-row {
  display: flex;
  justify-content: space-between;
  margin: 3px 0;
}

.receipt-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
}

.receipt-qr-mock {
  width: 90px;
  height: 90px;
  border: 2px solid #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
}

.receipt-footer-center {
  text-align: center;
  font-size: 10px;
  line-height: 1.3;
}

/* Tabs inside Settings Modal */
.settings-tab-bar {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.settings-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.settings-tab-btn.active {
  background: var(--bg-card);
  color: var(--accent-primary);
}

/* --- Phase 6 & 7: QR Scanner, Advanced Dashboard & Vehicles View Styles --- */

.view-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-bar-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 12px 14px 12px 40px;
  border-radius: var(--radius-md);
  font-size: 14px;
}

.search-input:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  fill: var(--text-muted);
}

.filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.filter-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-pill.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

.session-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.btn-mini-action {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-mini-action.accent {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #34d399;
}

.badge-tampered {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid #ef4444;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 10px;
}

.progress-bar.warning {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.progress-bar.danger {
  background: linear-gradient(90deg, #ef4444, #b91c1c);
}

/* --- Phase 10: Urdu RTL Mode Styles --- */

.rtl-mode {
  direction: rtl;
  text-align: right;
}

.rtl-mode .brand-wrapper {
  flex-direction: row-reverse;
}

.rtl-mode .session-meta {
  align-items: flex-start;
}

.rtl-mode .search-input {
  padding: 12px 40px 12px 14px;
}

.rtl-mode .search-icon {
  left: auto;
  right: 14px;
}
