:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #334155;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
}

* { box-sizing: border-box; }
body { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; background: var(--bg); margin: 0; color: var(--text); }

/* Layout */
#app { display: flex; min-height: 100vh; }
#sidebar { width: 260px; background: var(--sidebar-bg); color: #e2e8f0; position: fixed; top: 0; left: 0; bottom: 0; z-index: 1040; transition: transform 0.3s; overflow-y: auto; flex-shrink: 0; }
#sidebar.collapsed { transform: translateX(-260px); }
#main-content { flex: 1; margin-left: 260px; min-height: 100vh; transition: margin-left 0.3s; display: flex; flex-direction: column; max-width: calc(100vw - 260px); overflow-x: hidden; }
#main-content.expanded { margin-left: 0; max-width: 100vw; }
#page-content { padding: 24px; flex: 1; overflow-x: hidden; }

/* Sidebar */
.sidebar-brand { padding: 20px; font-size: 1.2rem; font-weight: 700; color: #fff; border-bottom: 1px solid #334155; display: flex; align-items: center; gap: 10px; }
.sidebar-brand i { font-size: 1.5rem; color: var(--primary); }
.sidebar-nav { list-style: none; padding: 10px 0; margin: 0; }
.sidebar-nav li { margin: 2px 8px; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: #94a3b8; text-decoration: none; border-radius: 8px; font-size: 0.9rem; transition: all 0.2s; }
.sidebar-nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; }
.sidebar-nav a i { font-size: 1.1rem; width: 22px; text-align: center; }
.sidebar-section { padding: 10px 24px 5px; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1px; color: #64748b; }

/* Navbar */
#navbar { background: var(--card-bg); border-bottom: 1px solid var(--border); padding: 0 24px; height: 60px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1030; }
.navbar-left { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.navbar-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
#sidebar-toggle { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text); padding: 4px 8px; }
#global-search { position: relative; flex: 1; max-width: 400px; }
#global-search input { width: 100%; padding: 8px 16px 8px 38px; border: 1px solid var(--border); border-radius: 8px; font-size: 0.9rem; background: var(--bg); }
#global-search input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
#global-search .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
#search-results { position: absolute; top: 100%; left: 0; right: 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.1); margin-top: 4px; max-height: 400px; overflow-y: auto; display: none; z-index: 1050; }
#search-results.show { display: block; }
.search-category { padding: 8px 16px; font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); background: var(--bg); font-weight: 600; }
.search-item { padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.search-item:hover { background: var(--bg); }
.search-item:last-child { border-bottom: none; }

/* Notification bell */
.notification-btn { position: relative; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text); padding: 4px 8px; }
.notification-badge { position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff; font-size: 0.65rem; padding: 2px 5px; border-radius: 10px; min-width: 16px; text-align: center; }
.notification-dropdown { position: absolute; right: 0; top: 100%; width: 360px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 10px 40px rgba(0,0,0,0.15); max-height: 400px; overflow-y: auto; display: none; z-index: 1050; }
.notification-dropdown.show { display: block; }
.notification-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 0.85rem; cursor: pointer; }
.notification-item:hover { background: var(--bg); }
.notification-item.unread { background: #eff6ff; border-left: 3px solid var(--primary); }

/* Cards */
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; padding: 20px; height: 100%; }
.stat-card .stat-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; word-break: break-word; overflow-wrap: break-word; }
.stat-card .stat-label { font-size: 0.85rem; color: var(--text-muted); }

.card { border: 1px solid var(--border); border-radius: 12px; box-shadow: none; overflow: hidden; }
.card-header { background: var(--card-bg); border-bottom: 1px solid var(--border); font-weight: 600; }

/* Tables */
.table { font-size: 0.85rem; margin-bottom: 0; }
.table th { font-weight: 600; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; border-bottom-width: 1px; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Status badges */
.badge-OPEN { background: #dbeafe; color: #1d4ed8; }
.badge-IN_PROGRESS { background: #ffedd5; color: #c2410c; }
.badge-WAITING_PARTS { background: #ede9fe; color: #6d28d9; }
.badge-COMPLETED { background: #dcfce7; color: #15803d; }
.badge-DELIVERED { background: #d1fae5; color: #047857; }
.badge-CANCELLED { background: #fee2e2; color: #b91c1c; }

.status-badge { padding: 4px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; display: inline-block; white-space: nowrap; }

/* Buttons */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-group-sm > .btn { padding: 0.2rem 0.45rem; font-size: 0.8rem; }

/* Page header */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; white-space: nowrap; }

/* Auth pages */
.auth-container { min-height: 100vh; display: flex; background: #0f172a; }
.auth-brand-panel { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #1e3a5f 100%); padding: 40px; position: relative; overflow: hidden; }
.auth-brand-panel::before { content: ''; position: absolute; top: -50%; left: -50%; width: 200%; height: 200%; background: radial-gradient(circle at 30% 50%, rgba(59,130,246,0.08) 0%, transparent 50%); }
.auth-brand-content { position: relative; z-index: 1; text-align: center; }
.auth-logo { width: 80px; height: 80px; background: linear-gradient(135deg, var(--primary), #60a5fa); border-radius: 20px; display: flex; align-items: center; justify-content: center; margin: 0 auto 24px; }
.auth-logo i { font-size: 2.2rem; color: #fff; }
.auth-brand-panel h1 { font-size: 2rem; font-weight: 800; color: #fff; margin-bottom: 8px; }
.auth-brand-subtitle { color: #94a3b8; font-size: 1.1rem; margin-bottom: 48px; }
.auth-features { text-align: left; display: inline-block; }
.auth-feature { display: flex; align-items: center; gap: 12px; color: #cbd5e1; margin-bottom: 16px; font-size: 0.95rem; }
.auth-feature i { color: var(--primary); font-size: 1.2rem; width: 20px; text-align: center; }
.auth-brand-footer { position: absolute; bottom: 24px; color: #475569; font-size: 0.8rem; }
.auth-form-panel { width: 480px; min-width: 380px; display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--card-bg); }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-weight: 700; margin-bottom: 4px; font-size: 1.6rem; }
.auth-card .subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: 0.95rem; }
.auth-card .input-group-text { background: var(--bg); border-color: var(--border); color: var(--text-muted); }
.auth-card .input-group .form-control { border-left: 0; }
.auth-card .form-control:focus { box-shadow: none; border-color: var(--primary); }
.auth-card .input-group:focus-within .input-group-text { border-color: var(--primary); color: var(--primary); }
.btn-login { padding: 10px; font-weight: 600; font-size: 1rem; }
.auth-links { text-align: center; margin-top: 16px; }
.auth-links a { color: var(--primary); text-decoration: none; font-size: 0.9rem; }
.auth-links a:hover { text-decoration: underline; }
.auth-divider { color: var(--text-muted); margin: 0 12px; }

/* Autocomplete */
.autocomplete-wrapper { position: relative; }
.autocomplete-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--card-bg); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.1); max-height: 200px; overflow-y: auto; z-index: 1050; display: none; }
.autocomplete-list.show { display: block; }
.autocomplete-item { padding: 8px 16px; cursor: pointer; font-size: 0.9rem; border-bottom: 1px solid var(--border); }
.autocomplete-item:hover { background: var(--bg); }

/* Tracking page */
.tracking-body { background: #f0f2f5; margin: 0; }
.tracking-container { max-width: 560px; margin: 0 auto; min-height: 100vh; background: #fff; box-shadow: 0 0 40px rgba(0,0,0,0.08); }
.tracking-header { background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%); color: #fff; padding: 32px 24px 24px; }
.tracking-header h2 { font-weight: 700; font-size: 1.4rem; }
.tracking-logo { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; background: #fff; padding: 4px; margin-bottom: 12px; }
.tracking-main { padding: 0; }
.tracking-footer { padding: 24px; border-top: 1px solid #e5e7eb; }

/* Progress bar */
.tracking-progress { padding: 28px 24px 20px; background: #f8fafc; }
.progress-track { position: relative; display: flex; justify-content: space-between; }
.progress-step { display: flex; flex-direction: column; align-items: center; z-index: 2; flex: 1; }
.step-dot { width: 40px; height: 40px; border-radius: 50%; background: #e2e8f0; border: 3px solid #e2e8f0; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 0.85rem; transition: all 0.3s; }
.step-dot i { font-size: 0.9rem; }
.progress-step.done .step-dot { color: #fff; }
.progress-step.current .step-dot { transform: scale(1.15); box-shadow: 0 0 0 6px rgba(37,99,235,0.15); }
.step-text { font-size: 0.65rem; font-weight: 600; color: #94a3b8; margin-top: 8px; text-align: center; text-transform: uppercase; letter-spacing: 0.3px; }
.progress-step.done .step-text { color: #334155; }
.progress-step.current .step-text { color: #2563eb; font-weight: 700; }
.progress-line { position: absolute; top: 20px; left: 10%; right: 10%; height: 3px; background: #e2e8f0; z-index: 1; border-radius: 2px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #2563eb, #3b82f6); border-radius: 2px; transition: width 0.6s ease; }

/* Cancelled */
.tracking-cancelled { text-align: center; padding: 24px; background: #fef2f2; color: #dc2626; font-weight: 600; font-size: 1.1rem; }
.tracking-cancelled i { font-size: 1.5rem; margin-right: 8px; vertical-align: middle; }

/* Vehicle card */
.tracking-vehicle-card { text-align: center; padding: 24px; border-bottom: 1px solid #f0f0f0; }
.vehicle-plate { display: inline-block; background: #1e293b; color: #fff; font-size: 1.5rem; font-weight: 800; letter-spacing: 2px; padding: 8px 24px; border-radius: 8px; border: 3px solid #334155; margin-bottom: 8px; }
.vehicle-info { font-size: 1rem; color: #475569; font-weight: 500; }
.vehicle-meta { display: flex; justify-content: center; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.vehicle-meta span { font-size: 0.8rem; color: #94a3b8; }
.vehicle-meta i { margin-right: 3px; }

/* Sections */
.tracking-section { padding: 20px 24px; border-bottom: 1px solid #f0f0f0; }
.tracking-section h6 { font-weight: 700; color: #1e293b; margin-bottom: 14px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
.tracking-section h6 i { margin-right: 6px; color: #2563eb; }

/* Items */
.tracking-items { }
.tracking-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid #f8f9fa; }
.tracking-item:last-of-type { border-bottom: none; }
.item-desc { font-size: 0.9rem; color: #334155; flex: 1; }
.item-detail { text-align: right; }
.item-price { font-weight: 600; color: #1e293b; margin-left: 12px; }
.tracking-total { margin-top: 12px; padding-top: 12px; border-top: 2px solid #e5e7eb; }

/* Photos */
.tracking-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.tracking-photo { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer; transition: all 0.3s; border: 2px solid #e5e7eb; }
.tracking-photo:hover { border-color: #2563eb; transform: scale(1.03); }
.tracking-photo.expanded { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90vw; max-width: 500px; height: auto; aspect-ratio: auto; z-index: 9999; border: 4px solid #fff; box-shadow: 0 20px 60px rgba(0,0,0,0.5); border-radius: 12px; }

/* Timeline */
.tracking-timeline { position: relative; }
.tl-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item:not(:last-child)::before { content: ''; position: absolute; left: 6px; top: 18px; bottom: 0; width: 2px; background: #e5e7eb; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; background: #2563eb; border: 3px solid #fff; box-shadow: 0 0 0 2px #2563eb; flex-shrink: 0; margin-top: 4px; }
.tl-body { flex: 1; }
.tl-transition { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tl-transition .badge { font-size: 0.7rem; font-weight: 500; }
.tl-transition i { font-size: 0.7rem; color: #94a3b8; }

/* Notes */
.tracking-note { background: #f8fafc; border-radius: 8px; padding: 12px; margin-bottom: 8px; border-left: 3px solid #2563eb; }

/* Contact */
.tracking-contact { text-align: center; padding: 20px 24px; }

@media (max-width: 560px) {
  .tracking-container { box-shadow: none; }
  .step-text { font-size: 0.58rem; }
  .step-dot { width: 34px; height: 34px; }
  .progress-line { top: 17px; }
  .vehicle-plate { font-size: 1.2rem; padding: 6px 16px; }
}

/* Chart containers */
.card-body canvas { max-height: 300px; width: 100% !important; }

/* Service detail totals */
#totals-area .d-flex { flex-wrap: wrap; }

/* Payment section in service detail */
.payment-section { background: #f8fafc; border-radius: 8px; padding: 16px; }

/* Responsive */
@media (max-width: 992px) {
  .stat-card .stat-value { font-size: 1.3rem; }
  .stat-card { padding: 16px; }
}

@media (max-width: 768px) {
  #sidebar { transform: translateX(-260px); }
  #sidebar.show { transform: translateX(0); }
  #main-content { margin-left: 0; max-width: 100vw; }
  #global-search { max-width: 200px; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header h1 { font-size: 1.2rem; }
  #page-content { padding: 12px; }
  .notification-dropdown { width: 300px; right: -50px; }
  .stat-card .stat-value { font-size: 1.2rem; }
  .table { font-size: 0.8rem; }
  .table th { font-size: 0.7rem; }
  .btn-group-sm > .btn { padding: 0.15rem 0.35rem; }
  .auth-brand-panel { display: none; }
  .auth-form-panel { width: 100%; min-width: auto; }
}

@media (max-width: 480px) {
  #global-search { max-width: 150px; }
  .auth-form-panel { padding: 24px; min-width: auto; }
  .stat-card .stat-value { font-size: 1rem; }
  #page-content { padding: 8px; }
}

/* Print */
@media print {
  #sidebar, #navbar { display: none !important; }
  #main-content { margin-left: 0 !important; max-width: 100% !important; }
  #page-content { padding: 0 !important; }
}

/* Misc */
.cursor-pointer { cursor: pointer; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,0.8); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }

/* Status Timeline */
.status-timeline { padding: 16px; }
.timeline-item { position: relative; padding-left: 24px; padding-bottom: 16px; border-left: 2px solid var(--border-color, #dee2e6); }
.timeline-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline-dot { position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--primary, #0d6efd); border: 2px solid #fff; }
.timeline-content { background: var(--card-bg, #f8f9fa); border-radius: 8px; padding: 8px 12px; }
