/* ============================================================
   AppThueXe.com — Mobile-First CSS
   ============================================================ */

/* ===== TOKENS ===== */
:root {
  --primary:       #3b82f6;
  --primary-dark:  #2563eb;
  --primary-light: #eff6ff;
  --success:       #10b981;
  --success-light: #d1fae5;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --info:          #06b6d4;
  --info-light:    #cffafe;
  --purple:        #8b5cf6;
  --purple-light:  #ede9fe;

  --sidebar-w:     260px;
  --topbar-h:      56px;
  --bottom-nav-h:  60px;

  --bg:            #f1f5f9;
  --bg-card:       #ffffff;
  --border:        #e2e8f0;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --text-light:    #94a3b8;

  --radius-sm:     6px;
  --radius:        10px;
  --radius-lg:     14px;
  --radius-xl:     20px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow:    0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top:    env(safe-area-inset-top, 0px);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
img { max-width: 100%; height: auto; }
a { color: inherit; }

/* ===== LAYOUT ===== */
.wrapper { display: flex; min-height: 100vh; }

/* ===== SIDEBAR OVERLAY ===== */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 999;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  will-change: transform;
}
.sidebar.open { transform: translateX(0); }

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px;
  height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar-brand-icon {
  width: 34px; height: 34px;
  background: var(--primary); border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; flex-shrink: 0;
  color: #fff;
}
.sidebar-brand span { font-size: 1rem; font-weight: 700; flex: 1; letter-spacing: -.3px; }
.sidebar-close {
  background: none; border: none;
  color: rgba(255,255,255,.5); font-size: 1.1rem;
  cursor: pointer; padding: 8px; border-radius: var(--radius-sm);
  transition: color .15s; flex-shrink: 0;
  min-width: 36px; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-close:hover { color: #fff; }

.sidebar-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 8px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar-scroll::-webkit-scrollbar { display: none; }

.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav .nav-section {
  padding: 14px 20px 4px;
  font-size: .62rem; font-weight: 700;
  letter-spacing: .1em; color: rgba(255,255,255,.3);
  text-transform: uppercase;
}
.sidebar-nav li a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .875rem; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .15s;
  min-height: 46px;
}
.sidebar-nav li a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-nav li a.active {
  color: #fff;
  background: rgba(59,130,246,.18);
  border-left-color: var(--primary);
}
.sidebar-nav li a i { width: 18px; text-align: center; font-size: .9rem; }

.sidebar-notif-badge {
  margin-left: auto;
  min-width: 18px; height: 18px; padding: 0 5px;
  background: var(--danger, #ef4444); color: #fff;
  border-radius: 10px; font-size: .65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1; flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.sidebar-user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; flex-shrink: 0;
}
.sidebar-user-name {
  font-size: .825rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: .7rem; color: rgba(255,255,255,.4); }
.btn-logout {
  color: rgba(255,255,255,.4); text-decoration: none;
  font-size: 1rem; padding: 8px; border-radius: var(--radius-sm);
  transition: color .15s; flex-shrink: 0;
  min-width: 36px; min-height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.btn-logout:hover { color: var(--danger); }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  padding-top: var(--safe-top);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.sidebar-toggle {
  background: none; border: none;
  font-size: 1.15rem; color: var(--text-muted);
  cursor: pointer; padding: 8px; border-radius: var(--radius);
  min-width: 40px; min-height: 40px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--bg); }
.page-title {
  font-size: .95rem; font-weight: 700; margin: 0; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-right { display: flex; align-items: center; gap: 8px; margin-left: auto; flex-shrink: 0; }
.topbar-date {
  font-size: .72rem; color: var(--text-muted);
  background: var(--bg); padding: 4px 10px;
  border-radius: 20px; white-space: nowrap;
  display: none; /* Hidden on mobile */
}
.btn-quick-add {
  width: 36px; height: 36px;
  background: var(--primary); color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; font-size: .875rem;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}
.btn-quick-add:hover { background: var(--primary-dark); color: #fff; transform: scale(1.08); }
.btn-quick-add:active { transform: scale(.93); }

/* ===== NOTIFICATION BELL ===== */
.notif-bell-wrap { position: relative; }
.notif-bell-btn {
  width: 36px; height: 36px; border: none; background: var(--bg);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  color: var(--text); font-size: .95rem; cursor: pointer; position: relative;
  transition: background .15s;
}
.notif-bell-btn:hover { background: #e5e7eb; }
.notif-badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--danger, #ef4444); color: #fff;
  border-radius: 10px; font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-width: calc(100vw - 24px);
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0,0,0,.15);
  z-index: 1000; display: none; overflow: hidden;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: .85rem;
}
.notif-mark-all {
  border: none; background: none; color: var(--primary);
  font-size: .72rem; font-weight: 600; cursor: pointer; padding: 0;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-dropdown-body { max-height: 380px; overflow-y: auto; }
.notif-empty { padding: 24px 14px; text-align: center; color: var(--text-muted); font-size: .85rem; }
.notif-item {
  display: block; padding: 10px 14px; border-bottom: 1px solid #f3f4f6;
  text-decoration: none; color: var(--text); transition: background .15s;
  position: relative;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg); }
.notif-item.unread { background: #eff6ff; }
.notif-item.unread::before {
  content: ''; position: absolute; left: 4px; top: 16px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
}
.notif-item-title { font-weight: 700; font-size: .8rem; margin-bottom: 2px; padding-left: 10px; }
.notif-item-msg { font-size: .78rem; color: var(--text-muted); padding-left: 10px; line-height: 1.4; }
.notif-item-time { font-size: .68rem; color: #9ca3af; padding-left: 10px; margin-top: 3px; display: block; }
.notif-icon-reg { color: #f59e0b; }
.notif-icon-maint { color: #ef4444; }
.notif-icon-rental { color: #10b981; }

/* ===== TRANG DANH SACH THONG BAO DAY DU (/notifications) =====
   Khac voi .notif-item (dung trong dropdown chuong, nho gon) - day la dang card lon hon,
   co icon rieng o ben trai va nut "danh dau da doc" rieng cho tung dong, du khong gian de
   doc tren man hinh lon va van gon tren mobile. */
.notif-page-list { padding: 4px 0; }
.notif-page-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid #f3f4f6;
  transition: background .15s; position: relative;
}
.notif-page-item:last-child { border-bottom: none; }
.notif-page-item:hover { background: var(--bg); }
.notif-page-item.unread { background: #eff6ff; }
.notif-page-item.unread:hover { background: #e0eefe; }
.notif-page-item-icon {
  width: 38px; height: 38px; border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.notif-page-item-body { flex: 1; min-width: 0; text-decoration: none; color: var(--text); }
.notif-page-item-title { font-weight: 700; font-size: .88rem; margin-bottom: 3px; }
.notif-page-item-msg { font-size: .82rem; color: var(--text-muted); line-height: 1.5; }
.notif-page-item-time { font-size: .72rem; color: #9ca3af; margin-top: 5px; display: block; }
.notif-page-mark-btn { flex-shrink: 0; align-self: center; }

@media (max-width: 639px) {
  .notif-page-item { padding: 12px; gap: 10px; }
  .notif-page-item-icon { width: 32px; height: 32px; font-size: .88rem; }
  .notif-page-mark-btn { align-self: flex-start; }
}

/* ===== REALTIME TOAST (goc man hinh, dung cho thong bao hop dong moi...) ===== */
#realtimeToastWrap {
  position: fixed; top: 16px; right: 16px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px;
  max-width: calc(100vw - 32px); width: 340px;
}
.rt-toast {
  background: #fff; border-radius: var(--radius-lg); box-shadow: 0 12px 32px rgba(0,0,0,.18);
  padding: 12px 14px; display: flex; gap: 10px; align-items: flex-start;
  border-left: 4px solid var(--success, #10b981);
  animation: rtToastIn .25s ease;
}
@keyframes rtToastIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform: translateX(0); } }
.rt-toast-icon { font-size: 1.1rem; color: var(--success, #10b981); margin-top: 1px; }
.rt-toast-body { flex: 1; min-width: 0; }
.rt-toast-title { font-weight: 700; font-size: .82rem; margin-bottom: 2px; }
.rt-toast-msg { font-size: .78rem; color: var(--text-muted); line-height: 1.4; }
.rt-toast-close { border: none; background: none; color: #9ca3af; cursor: pointer; font-size: .8rem; padding: 0; }

/* ===== CONTENT AREA ===== */
.content-area {
  padding: 14px;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px);
  flex: 1;
  min-width: 0; overflow-x: hidden;
}

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
}
.bottom-nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; color: var(--text-light);
  text-decoration: none; font-size: .6rem; font-weight: 600;
  gap: 3px; transition: color .15s; padding: 8px 4px;
  min-height: 44px;
}
.bottom-nav-item i { font-size: 1.15rem; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-fab {
  width: 52px; height: 52px;
  background: var(--primary); color: #fff;
  border-radius: 50%; margin: auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; text-decoration: none;
  box-shadow: 0 4px 16px rgba(59,130,246,.4);
  transition: transform .15s; flex-shrink: 0;
  margin-top: -8px;
}
.bottom-nav-fab:hover { color: #fff; transform: scale(1.06); }
.bottom-nav-fab:active { transform: scale(.92); }

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  font-weight: 600; font-size: .875rem;
}
.card-body { padding: 14px; }
.card-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 10px 14px;
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-sm);
}
.stat-icon {
  width: 42px; height: 42px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; flex-shrink: 0;
}
.stat-primary .stat-icon { background: #dbeafe; color: #1d4ed8; }
.stat-success .stat-icon { background: var(--success-light); color: #065f46; }
.stat-warning .stat-icon { background: var(--warning-light); color: #92400e; }
.stat-info .stat-icon    { background: var(--info-light); color: #0e7490; }
.stat-danger .stat-icon  { background: var(--danger-light); color: #991b1b; }
.stat-purple .stat-icon  { background: var(--purple-light); color: #5b21b6; }
.stat-number { font-size: 1.35rem; font-weight: 800; line-height: 1; }
.stat-label  { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

/* ===== TABLES ===== */
.table-responsive {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.table { font-size: .825rem; margin-bottom: 0; }
.table th {
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); white-space: nowrap;
  padding: 10px 12px;
  background: var(--bg);
}
.table td { padding: 10px 12px; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* Mobile table cards - vertical layout for small screens */
@media (max-width: 639px) {
  .table-mobile-card thead { display: none; }
  .table-mobile-card tbody tr {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 10px;
    padding: 12px;
    box-shadow: var(--shadow-sm);
  }
  .table-mobile-card tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border: none;
    border-bottom: 1px solid var(--border);
    font-size: .85rem;
  }
  .table-mobile-card tbody td:last-child { border-bottom: none; padding-bottom: 0; }
  .table-mobile-card tbody td::before {
    content: attr(data-label);
    font-weight: 700; font-size: .72rem;
    color: var(--text-muted); text-transform: uppercase;
    flex-shrink: 0; margin-right: 12px;
  }
}

/* ===== FORMS ===== */
.form-label { font-size: .825rem; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.form-label.required::after { content: ' *'; color: var(--danger); }
.form-control, .form-select {
  font-size: .9rem;
  border-radius: var(--radius);
  border-color: var(--border);
  padding: 9px 12px;
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
  outline: none;
}
.input-group-text {
  font-size: .875rem; min-height: 44px;
  background: var(--bg); border-color: var(--border);
}
.form-control-sm, .form-select-sm { min-height: 38px; font-size: .825rem; padding: 6px 10px; }
.form-text { font-size: .775rem; }

/* ===== BUTTONS ===== */
.btn {
  border-radius: var(--radius); font-weight: 600;
  font-size: .875rem; min-height: 40px;
  transition: all .15s; display: inline-flex;
  align-items: center; justify-content: center;
}
.btn:active { transform: scale(.97); }
.btn-lg { min-height: 48px; font-size: .95rem; }
.btn-sm { min-height: 34px; font-size: .8rem; padding: 0 12px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* Full-width buttons on mobile forms */
.btn-mobile-full { width: 100%; }

/* ===== BADGES ===== */
.badge { font-weight: 600; border-radius: 6px; }

/* ===== CARS GRID ===== */
.cars-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.car-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.car-card-header {
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  background: #fef5f5;
}
.car-plate { font-weight: 800; font-size: .95rem; font-family: monospace; letter-spacing: .5px; }
.car-card-body { padding: 12px 14px; }
.car-name { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.car-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 12px; }
.car-meta span {
  font-size: .72rem; color: var(--text-muted);
  background: var(--bg); padding: 3px 8px; border-radius: 20px;
}
.car-rate { display: flex; justify-content: space-between; align-items: center; }
.rate-label { font-size: .75rem; color: var(--text-muted); }
.rate-value { font-weight: 800; color: var(--primary); font-size: .95rem; }
.car-card-footer {
  padding: 10px 14px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; background: var(--bg);
}

/* ===== AVATAR ===== */
.avatar-sm {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem; flex-shrink: 0;
}
.avatar-xl {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.75rem; margin: 0 auto;
}
.car-avatar {
  width: 38px; height: 38px; border-radius: var(--radius);
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; flex-shrink: 0;
}
.car-big-icon {
  width: 72px; height: 72px; border-radius: 18px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; margin: 0 auto;
}

/* ===== STATUS TABS ===== */
.status-tabs {
  display: flex; border-bottom: 2px solid var(--border);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; gap: 0; margin-bottom: 14px;
}
.status-tabs::-webkit-scrollbar { display: none; }
.tab-item {
  padding: 9px 14px; text-decoration: none;
  color: var(--text-muted); font-size: .825rem; font-weight: 600;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  white-space: nowrap; transition: all .15s; flex-shrink: 0;
}
.tab-item:hover { color: var(--primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===== SECTION CARDS (form) ===== */
.section-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  margin-bottom: 14px;
}
.section-card-title {
  font-weight: 700; font-size: .825rem; color: var(--text);
  margin-bottom: 12px; padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}

/* ===== INFO BOX ===== */
.info-box {
  background: var(--primary-light); border: 1px solid #bfdbfe;
  border-radius: var(--radius); padding: 12px 14px;
}
.info-row { font-size: .85rem; margin-bottom: 5px; display: flex; align-items: flex-start; gap: 6px; }
.info-row:last-child { margin-bottom: 0; }

/* ===== STAT MINI ===== */
.stat-mini {
  font-size: .82rem; padding: 6px 11px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ===== HANDOVER TOPBAR (trang Giao nhan xe) =====
   Desktop: 2 nhom (thong ke trai, nut hanh dong phai) tren cung 1 dong, giong layout cu.
   Mobile: xep doc, nut hanh dong full-width tranh bi flex bop nho lam chu vo 3 dong. */
.hov-topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hov-stats { display: flex; gap: 12px; flex-wrap: wrap; }
.hov-actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 639px) {
  .hov-topbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .hov-stats { width: 100%; }
  .hov-stats .stat-mini { flex: 1 1 auto; text-align: center; }
  .hov-actions { width: 100%; flex-direction: column; }
  .hov-actions .btn { width: 100%; }
}

/* ===== RENTAL SUMMARY ===== */
.rental-summary {
  background: linear-gradient(135deg, var(--primary-light), #f0fdf4);
  border: 1px solid #bfdbfe; border-radius: var(--radius-lg); padding: 14px;
}
.summary-title { font-weight: 700; color: #1e40af; margin-bottom: 12px; font-size: .875rem; }
.summary-item {
  text-align: center; padding: 10px 6px;
  background: rgba(255,255,255,.7); border-radius: var(--radius);
}
.summary-item.total { background: #fff; border: 2px solid var(--primary); }
.summary-label { font-size: .67rem; color: var(--text-muted); margin-bottom: 3px; text-transform: uppercase; font-weight: 700; letter-spacing: .03em; }
.summary-val { font-size: 1.05rem; font-weight: 800; }

/* ===== ALERTS ===== */
.alert { border-radius: var(--radius); font-size: .875rem; }

/* ===== ICON BADGES ===== */
.icon-badge {
  width: 38px; height: 38px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .9rem; flex-shrink: 0;
}
.icon-badge-xl {
  width: 64px; height: 64px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 1.6rem;
}

/* ===== CONDITION GRID ===== */
.condition-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.condition-item {
  text-align: center; padding: 10px 6px;
  background: var(--bg); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.condition-icon { font-size: 1.2rem; margin-bottom: 3px; }
.condition-label { font-size: .7rem; color: var(--text-muted); margin-bottom: 5px; }

/* ===== SIGNATURE BOX ===== */
.signature-box {
  padding: 12px 14px; background: var(--bg);
  border: 2px dashed var(--border); border-radius: var(--radius);
}
.signature-box-contract { height: 80px; }

/* ===== DAMAGE ROW ===== */
.damage-row { background: #fff8f0; border-radius: var(--radius); padding: 8px; border: 1px solid #fde68a; }

/* ===== QUICK ACTIONS GRID ===== */
.quick-actions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-action-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 14px 8px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); text-decoration: none; color: var(--text);
  font-size: .75rem; font-weight: 600; text-align: center;
  transition: all .15s; min-height: 68px;
}
.quick-action-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.quick-action-btn i { font-size: 1.25rem; }
.quick-action-btn.qa-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.quick-action-btn.qa-primary:hover { background: var(--primary-dark); color: #fff; }
.quick-action-btn.qa-success { background: var(--success); color: #fff; border-color: var(--success); }
.quick-action-btn.qa-warning { background: var(--warning); color: #fff; border-color: var(--warning); }

/* ===== REGISTRATION / MAINTENANCE ===== */
.badge-expiry {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px; border-radius: 20px; font-size: .75rem;
}
.expiry-valid    { background: var(--success-light); color: #065f46; }
.expiry-expiring { background: var(--warning-light); color: #92400e; }
.expiry-expired  { background: var(--danger-light); color: #991b1b; }

/* ===== RANK BADGE ===== */
.rank-badge {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .78rem; flex-shrink: 0;
}

/* ===== ID CARD UPLOAD ===== */
.idcard-upload-box {
  position: relative; width: 100%; height: 170px;
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  cursor: pointer; overflow: hidden; background: var(--bg);
  transition: border-color .2s, background .2s;
  display: flex; align-items: center; justify-content: center;
}
.idcard-upload-box:hover, .idcard-upload-box:active {
  border-color: var(--primary); background: var(--primary-light);
}
.idcard-placeholder { text-align: center; padding: 14px; pointer-events: none; }
.idcard-preview { width: 100%; height: 100%; object-fit: cover; display: block; }
.idcard-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s;
}
.idcard-upload-box:hover .idcard-overlay { opacity: 1; }

/* ===== LEGEND ===== */
.legend-item { display: flex; align-items: center; gap: 5px; font-size: .8rem; }
.legend-dot   { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* ===== SEARCH LIVE ===== */
.search-live-wrap { position: relative; }
.search-live-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 999;
  background: #fff; border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  box-shadow: var(--shadow);
  max-height: 260px; overflow-y: auto; display: none;
}
.search-live-dropdown.open { display: block; }
.search-result-item {
  padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid #f3f4f6; transition: background .12s;
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item:active { background: var(--primary-light); }
.search-result-item .result-main { font-weight: 600; font-size: .875rem; }
.search-result-item .result-sub { font-size: .775rem; color: var(--text-muted); margin-top: 2px; }
.search-no-result, .search-loading { padding: 12px 14px; color: var(--text-muted); font-size: .875rem; }

/* ===== SELECTED CARD ===== */
.selected-card {
  background: #f0fdf4; border: 1.5px solid #86efac;
  border-radius: var(--radius); padding: 12px 14px;
}
.selected-card-meta { display: flex; flex-wrap: wrap; gap: 5px; font-size: .775rem; color: var(--text-muted); margin-top: 6px; }

/* ===== ALL CARS GRID ===== */
.all-cars-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 7px;
  max-height: 200px; overflow-y: auto;
}
.all-car-item {
  padding: 9px; border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all .12s; background: #fff; font-size: .82rem;
}
.all-car-item:hover, .all-car-item:active { border-color: var(--primary); background: var(--primary-light); }

/* ===== LOGIN ===== */
.login-body {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-wrapper { width: 100%; max-width: 400px; }
.login-card {
  background: #fff; border-radius: var(--radius-xl);
  padding: 28px 22px; box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 26px; }
.logo-icon {
  width: 58px; height: 58px; background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; color: #fff; margin: 0 auto 12px;
}
.login-logo h1 { font-size: 1.35rem; font-weight: 800; margin-bottom: 4px; }
.login-logo p  { color: var(--text-muted); font-size: .875rem; margin: 0; }
.login-footer  { text-align: center; margin-top: 18px; color: var(--text-muted); font-size: .825rem; }

/* ===== PRINT ===== */
@media print {
  @page { size: A4; margin: 10mm 12mm; }

  .sidebar, .topbar, .bottom-nav, .btn, .no-print, .sidebar-overlay { display: none !important; }
  #realtimeToastWrap, .notif-dropdown { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .content-area { padding: 0 !important; padding-bottom: 0 !important; }
  body { background: #fff !important; }
  .card { border: none !important; box-shadow: none !important; }

  /* Thu nho toan bo font + khoang cach khi in de hop dong gon trong 1 trang A4,
     thay vi giu nguyen kich thuoc desktop (qua to, day cot tran sang trang 2) */
  #contractDoc { font-size: 11px; margin-bottom: 0 !important; }
  #contractDoc .card-body { padding: 6px 4px !important; }
  #contractDoc h4 { font-size: 1.05rem; margin-bottom: 2px !important; }
  #contractDoc .text-center.mb-4 { margin-bottom: 8px !important; padding-bottom: 8px !important; }

  /* 2 section-card tren cung 1 dong (Xe + Khach hang, Thoi gian + Chi phi) luon canh nhau,
     khong de trinh duyet tu xep cot khi in (tranh keo dai chieu cao tong) */
  #contractDoc .row.g-4 { display: flex !important; flex-wrap: wrap !important; margin: 0 -4px !important; }
  #contractDoc .row.g-4 > .col-md-6 { width: 50% !important; padding: 0 4px !important; flex: 0 0 50% !important; max-width: 50% !important; }
  #contractDoc .row.g-4 > .col-12 { width: 100% !important; flex: 0 0 100% !important; max-width: 100% !important; padding: 0 4px !important; }

  #contractDoc .section-card { padding: 6px 8px !important; margin-bottom: 6px !important; }
  #contractDoc .section-card-title { font-size: .72rem; margin-bottom: 4px !important; padding-bottom: 3px !important; }

  /* Bang trong card: giam padding moi dong, bo border thua, chu nho lai */
  #contractDoc table.table-sm th, #contractDoc table.table-sm td { padding: 1.5px 6px !important; font-size: 10.5px; border-color: #ddd !important; }
  #contractDoc .fs-5 { font-size: .95rem !important; }

  #contractDoc .info-box { padding: 5px 8px !important; margin-bottom: 4px !important; }
  #contractDoc .info-box p { font-size: 10.5px; margin: 0 !important; }

  /* Khu vuc ky ten: giam chieu cao khung ky de khong day trang */
  #contractDoc .signature-box-contract { height: 40px !important; }
  #contractDoc .row.g-4.mt-2 { margin-top: 6px !important; }
}

/* ===== TABLET ≥ 640px ===== */
@media (min-width: 640px) {
  .content-area { padding: 18px; padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 18px); }
  .topbar-date { display: flex; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .cars-grid  { grid-template-columns: repeat(2, 1fr); }
  .quick-actions-grid { grid-template-columns: repeat(4, 1fr); }
  .card-header { padding: 14px 16px; }
  .card-body   { padding: 16px; }
  .section-card { padding: 16px; }
  .btn-mobile-full { width: auto; }
}

/* ===== DESKTOP ≥ 1024px ===== */
@media (min-width: 1024px) {
  .sidebar { transform: translateX(0) !important; }
  .sidebar-close { display: none; }
  .sidebar-overlay { display: none !important; }
  .main-content { margin-left: var(--sidebar-w); }
  .bottom-nav { display: none; }
  .content-area { padding: 24px; padding-bottom: 24px; }
  .page-title { font-size: 1.05rem; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .cars-grid  { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .quick-actions-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== WIDE ≥ 1280px ===== */
@media (min-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(6, 1fr); }
}
