* ============================================================
   style.css — CTV Sale Online
   ============================================================ */

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:      #6c63ff;
  --primary-dark: #5a52d5;
  --secondary:    #ff6584;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #3b82f6;
  --bg:           #f0f2f5;
  --white:        #ffffff;
  --card:         #ffffff;
  --text:         #1e293b;
  --text-muted:   #64748b;
  --border:       #e2e8f0;
  --sidebar-w:    240px;
  --radius:       12px;
  --shadow:       0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg:    0 8px 30px rgba(0,0,0,0.12);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar.ctv-theme  { background: linear-gradient(160deg, #1e1b4b 0%, #312e81 100%); }
.sidebar.admin-theme{ background: linear-gradient(160deg, #1c1917 0%, #292524 50%, #1e1b4b 100%); }

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo h2   { color: #fff; font-size: 17px; font-weight: 700; line-height: 1.3; }
.sidebar-logo span { color: #a5b4fc; font-size: 11px; }
.logo-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; margin-bottom: 10px;
}
.logo-icon.ctv-icon   { background: linear-gradient(135deg,#6c63ff,#ff6584); }
.logo-icon.admin-icon { background: linear-gradient(135deg,#f59e0b,#ef4444); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section-label {
  color: #818cf8; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  padding: 8px 8px 4px;
}
.admin-theme .nav-section-label { color: #f59e0b; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: #c7d2fe; text-decoration: none;
  font-size: 14px; font-weight: 500;
  transition: all 0.2s; margin-bottom: 2px;
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
}
.nav-item:hover   { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active  { background: rgba(108,99,255,0.5); color: #fff; }
.nav-item .icon   { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.user-info-box {
  background: rgba(255,255,255,0.08);
  border-radius: 10px; padding: 12px;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.user-avatar.ctv-av   { background: linear-gradient(135deg,#6c63ff,#ff6584); }
.user-avatar.admin-av { background: linear-gradient(135deg,#f59e0b,#ef4444); }
.user-name { color: #fff; font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: #a5b4fc; font-size: 11px; }
.admin-theme .user-role { color: #fde68a; }

.current-date-badge {
  background: rgba(255,255,255,0.08);
  border-radius: 8px; padding: 8px 12px;
  color: #c7d2fe; font-size: 12px; text-align: center;
  margin-top: 8px;
}
.current-date-badge strong { display: block; color: #fff; font-size: 14px; margin-top: 2px; }

/* ===== NOTIFICATION BADGE ===== */
.nav-badge {
  margin-left: auto;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  min-width: 18px; text-align: center;
}

/* ===== MAIN ===== */
.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--white);
  padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  flex-shrink: 0;
}
.topbar-title       { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-title span  { color: var(--primary); }
.topbar-actions     { display: flex; gap: 10px; align-items: center; }

.page-content { padding: 24px 28px; flex: 1; }
.page-header  { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 800; color: var(--text); }
.page-header p  { color: var(--text-muted); font-size: 13px; margin-top: 4px; }

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px,1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.purple { background: #ede9fe; }
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.orange { background: #fff7ed; }
.stat-icon.pink   { background: #fce7f3; }
.stat-icon.red    { background: #fee2e2; }
.stat-icon.yellow { background: #fef9c3; }
.stat-info h3 { font-size: 24px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-info p  { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== CARD ===== */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 24px; overflow: hidden;
}
.card-header {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.card-header h3 {
  font-size: 15px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.card-body { padding: 24px; }

/* ===== FORM ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
  gap: 16px;
}
.form-group        { display: flex; flex-direction: column; gap: 6px; }
.form-group label  { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.form-group label .required { color: var(--danger); margin-left: 2px; }
.form-full         { grid-column: 1 / -1; }

.form-control {
  padding: 9px 13px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 14px; color: var(--text);
  background: var(--white); transition: border-color .2s, box-shadow .2s;
  outline: none; width: 100%;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,99,255,.12); }
.form-control::placeholder { color: #b0b8c4; }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; font-size: 13px;
  font-weight: 600; cursor: pointer; border: none;
  transition: all .2s; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-info    { background: var(--info); color: #fff; }
.btn-info:hover    { background: #2563eb; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: #f5f3ff; }
.btn-sm   { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 7px 10px; }

/* ===== TABLE ===== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 600px; }
thead th {
  background: #f8fafc; padding: 11px 14px; text-align: left;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted);
  border-bottom: 1.5px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
tbody td { padding: 11px 14px; vertical-align: middle; color: var(--text); }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-new        { background: #e0e7ff; color: #4338ca; }
.badge-contacted  { background: #dbeafe; color: #1d4ed8; }
.badge-consulting { background: #fef3c7; color: #92400e; }
.badge-interested { background: #d1fae5; color: #065f46; }
.badge-closed     { background: #dcfce7; color: #166534; }
.badge-rejected   { background: #fee2e2; color: #991b1b; }
.badge-pending    { background: #f3f4f6; color: #374151; }

/* ===== TABS ===== */
.tabs {
  display: flex; gap: 4px;
  background: #f1f5f9; border-radius: 10px;
  padding: 4px; margin-bottom: 20px; flex-wrap: wrap;
}
.tab-btn {
  flex: 1; min-width: 120px; padding: 9px 14px;
  border: none; border-radius: 7px; background: transparent;
  cursor: pointer; font-size: 13px; font-weight: 600;
  color: #64748b; transition: all .2s;
  display: flex; align-items: center; justify-content: center;
  gap: 6px; white-space: nowrap;
}
.tab-btn:hover  { background: rgba(255,255,255,.7); color: #1e293b; }
.tab-btn.active { background: #fff; color: var(--primary); box-shadow: 0 1px 6px rgba(0,0,0,.1); }
.tab-panel              { display: none !important; }
.tab-panel.active       { display: block !important; }
.ctv-tab-panel          { display: none !important; width: 100%; }
.ctv-tab-panel.active   { display: block !important; width: 100%; }
.admin-tab-panel        { display: none !important; width: 100%; }
.admin-tab-panel.active { display: block !important; width: 100%; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; display: flex; align-items: center;
  justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white); border-radius: 16px;
  width: 100%; max-width: 760px; max-height: 90vh;
  overflow-y: auto; box-shadow: var(--shadow-lg);
  transform: translateY(20px); transition: transform .25s;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body   { padding: 24px; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}
.btn-close {
  background: none; border: none; font-size: 22px;
  color: var(--text-muted); cursor: pointer; line-height: 1;
  padding: 2px 6px; border-radius: 6px; transition: background .15s;
}
.btn-close:hover { background: #f1f5f9; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--text); color: #fff; padding: 12px 18px;
  border-radius: 10px; font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-lg); max-width: 320px;
  animation: slideIn .3s ease, fadeOut .3s ease 2.5s forwards;
}
.toast.success { background: #166534; }
.toast.error   { background: #991b1b; }
.toast.info    { background: #1e40af; }
.toast.warning { background: #92400e; }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100px); } }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 44px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ===== WEEK NAV ===== */
.week-nav {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); padding: 14px 20px;
  border-radius: var(--radius); margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.week-nav button {
  width: 36px; height: 36px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--white);
  cursor: pointer; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.week-nav button:hover { border-color: var(--primary); color: var(--primary); }
.week-nav .week-label { font-weight: 700; font-size: 15px; color: var(--text); flex: 1; text-align: center; }

/* ===== WEEKLY CTV CARDS ===== */
.week-ctv-card {
  background: var(--card); border-radius: var(--radius);
  margin-bottom: 20px; box-shadow: var(--shadow); overflow: hidden;
}
.week-ctv-header {
  background: linear-gradient(135deg,#6c63ff,#a855f7);
  padding: 16px 24px; color: white;
  display: flex; align-items: center; justify-content: space-between;
}
.week-ctv-header h4 { font-size: 15px; font-weight: 700; }
.week-ctv-header p  { font-size: 12px; opacity: .85; margin-top: 2px; }
.week-summary-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px,1fr));
  gap: 0; border-bottom: 1px solid var(--border);
}
.week-stat { padding: 14px; text-align: center; border-right: 1px solid var(--border); }
.week-stat:last-child { border-right: none; }
.week-stat h3 { font-size: 20px; font-weight: 800; color: var(--primary); }
.week-stat p  { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.platform-tags {
  padding: 12px 24px; display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.platform-tag {
  background: #f0f0ff; color: var(--primary);
  border: 1px solid #d0d0ff; border-radius: 20px;
  padding: 3px 12px; font-size: 12px; font-weight: 600;
}

/* ===== PROGRESS BAR ===== */
.progress-bar-wrap { background: #f1f5f9; border-radius: 20px; height: 8px; overflow: hidden; margin-top: 6px; }
.progress-bar { height: 100%; border-radius: 20px; background: linear-gradient(90deg,#6c63ff,#a855f7); transition: width .5s ease; }

/* ===== IMAGE THUMBNAILS ===== */
.img-thumb {
  width: 52px; height: 52px; object-fit: cover;
  border-radius: 7px; border: 2px solid #e2e8f0;
  cursor: zoom-in; transition: transform .15s, border-color .15s;
  vertical-align: middle; margin-right: 3px;
}
.img-thumb:hover { transform: scale(1.12); border-color: var(--primary); }
.img-thumb-wrap  { position: relative; display: inline-block; }
.img-remove-btn  {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; background: #ef4444; color: #fff;
  border: none; border-radius: 50%; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.img-preview-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.img-empty        { color: #b0b8c4; font-size: 13px; padding: 8px 0; }
.upload-zone {
  border: 2px dashed #c7d2fe; border-radius: 12px; padding: 20px;
  text-align: center; background: #f5f3ff; cursor: pointer;
  transition: all .2s; position: relative;
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--primary); background: #ede9fe; }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-zone .upload-icon { font-size: 28px; margin-bottom: 6px; }
.upload-zone p    { font-size: 13px; color: var(--primary); font-weight: 600; margin: 0; }
.upload-zone span { font-size: 11px; color: #94a3b8; }

/* ===== PAYROLL / BONUS CARDS ===== */
.pay-card {
  background: var(--card); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  display: flex; justify-content: space-between; align-items: flex-start;
  transition: transform .2s;
}
.pay-card:hover { transform: translateY(-2px); }
.pay-card.bonus-hot    { border-left-color: #ef4444; }
.pay-card.bonus-kpi    { border-left-color: #f59e0b; }
.pay-card.pay-salary   { border-left-color: #22c55e; }
.pay-card.pay-comm     { border-left-color: #6c63ff; }
.pay-amount {
  font-size: 22px; font-weight: 800;
  color: var(--text);
}
.pay-amount.green  { color: #16a34a; }
.pay-amount.red    { color: #dc2626; }
.pay-amount.orange { color: #d97706; }
.pay-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.pay-meta  { font-size: 11px; color: #94a3b8; margin-top: 6px; }

/* ===== MEETING CARD ===== */
.meeting-card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  border-left: 4px solid var(--info);
  display: flex; gap: 16px; align-items: flex-start;
  transition: transform .2s; margin-bottom: 12px;
}
.meeting-card:hover { transform: translateY(-2px); }
.meeting-card.urgent { border-left-color: #ef4444; }
.meeting-date-box {
  background: var(--info); color: #fff;
  border-radius: 10px; padding: 10px 14px;
  text-align: center; flex-shrink: 0; min-width: 58px;
}
.meeting-date-box .day   { font-size: 22px; font-weight: 800; line-height: 1; }
.meeting-date-box .month { font-size: 11px; font-weight: 600; opacity: .9; }
.meeting-date-box.urgent-box { background: #ef4444; }
.meeting-info h4  { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.meeting-info p   { font-size: 13px; color: var(--text-muted); }
.meeting-info .meeting-meta { font-size: 11px; color: #94a3b8; margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ===== NOTIFICATION CARD (CTV xem) ===== */
.notif-card {
  background: var(--card); border-radius: var(--radius);
  padding: 16px 20px; box-shadow: var(--shadow);
  border-left: 4px solid var(--primary);
  margin-bottom: 12px; transition: transform .2s;
}
.notif-card:hover { transform: translateX(4px); }
.notif-card.notif-meeting { border-left-color: var(--info); }
.notif-card.notif-bonus   { border-left-color: #f59e0b; }
.notif-card.notif-salary  { border-left-color: #22c55e; }
.notif-card.notif-warn    { border-left-color: #ef4444; }
.notif-card.unread        { background: #fafaff; }
.notif-card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.notif-card-title  { font-size: 14px; font-weight: 700; color: var(--text); }
.notif-card-time   { font-size: 11px; color: #94a3b8; white-space: nowrap; }
.notif-card-body   { font-size: 13px; color: var(--text-muted); margin-top: 6px; line-height: 1.6; }
.notif-badge       { display: inline-block; width: 8px; height: 8px; background: #ef4444; border-radius: 50%; margin-right: 6px; }

/* ===== HIGHLIGHT ROWS ===== */
.row-highlight  { background: #fefce8 !important; }
.row-no-img > td { background: #fffbeb !important; }
.row-no-img > td:first-child { border-left: 3px solid #f59e0b; }

/* ===== DIVIDER ===== */
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.hidden  { display: none !important; }

/* ===== FILTER ROW ===== */
.filter-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 0; }

/* ===== LIGHTBOX ===== */
#imgViewerOverlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.88);
  z-index: 9999; display: none;
  align-items: center; justify-content: center;
  padding: 20px; cursor: zoom-out;
}
#imgViewerOverlay.show { display: flex; }
#imgViewerInner { position: relative; max-width: 90vw; max-height: 90vh; }
#imgViewerImg { max-width: 90vw; max-height: 88vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,.6); display: block; }
#imgViewerClose {
  position: absolute; top: -14px; right: -14px;
  width: 32px; height: 32px; border-radius: 50%;
  background: #fff; border: none; font-size: 16px;
  cursor: pointer; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

/* ===== PRINT ===== */
@media print {
  .sidebar, .topbar, .btn, .filter-row, .modal-overlay,
  .toast-container, .no-print, .tabs { display: none !important; }
  .main { margin-left: 0; width: 100%; }
  body  { background: white; overflow: auto; height: auto; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  table { font-size: 11px; }
}

/* ===== HAMBURGER ===== */
.hamburger {
  display: none; flex-direction: column; gap: 5px;
  cursor: pointer; padding: 6px; border: none; background: none;
  flex-shrink: 0;
}
.hamburger span { display: block; width: 22px; height: 2px; background: var(--text); border-radius: 2px; }

/* ===== SIDEBAR OVERLAY (mobile) ===== */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 99;
}
.sidebar-overlay.show { display: block; }

/* ===== RESPONSIVE: TABLET (≤ 900px) ===== */
@media (max-width: 900px) {
  .pay-summary-grid { grid-template-columns: 1fr !important; }
  .layout-weekly    { grid-template-columns: 1fr !important; }
  .complaint-form-grid { grid-template-columns: 1fr !important; }
  .ctv-overview-grid { grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); }
}

/* ===== RESPONSIVE: MOBILE (≤ 768px) ===== */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  /* Sidebar: ẩn mặc định, hiện khi toggle */
  .sidebar {
    transform: translateX(-260px);
    width: 260px !important;
    z-index: 300;
    overflow-y: auto;
  }
  .sidebar.mobile-open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,.3); }

  /* Main layout */
  .main { margin-left: 0; width: 100%; }
  .hamburger { display: flex !important; }

  /* Topbar */
  .topbar {
    padding: 10px 14px;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .topbar-title { font-size: 15px; }
  .topbar-actions { gap: 6px; flex-shrink: 0; }
  .topbar-actions .btn { padding: 7px 12px; font-size: 12px; }

  /* Page content */
  .page-content { padding: 12px 14px; }
  .page-header h2 { font-size: 18px; }

  /* Stats: 2 cột trên mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .stat-card { padding: 14px 12px; gap: 10px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; border-radius: 10px; }
  .stat-info h3 { font-size: 20px; }
  .stat-info p  { font-size: 11px; }

  /* Card header */
  .card-header { padding: 14px 16px; }
  .card-body   { padding: 16px; }

  /* Modal: full screen trên mobile */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 92vh;
    max-width: 100%;
    transform: translateY(100%);
  }
  .modal-overlay.show .modal { transform: translateY(0); }
  .modal-body   { padding: 16px; }
  .modal-header { padding: 16px 16px 12px; }
  .modal-footer { padding: 12px 16px; }

  /* Form */
  .form-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Table: scroll ngang */
  .table-wrapper { -webkit-overflow-scrolling: touch; }
  table { font-size: 12px; }
  thead th { padding: 9px 10px; font-size: 10px; }
  tbody td  { padding: 9px 10px; }

  /* Pay cards: stack dọc */
  .pay-card { flex-direction: column; gap: 12px; }
  .pay-amount { font-size: 20px; }
  .pay-summary-grid { grid-template-columns: 1fr !important; }

  /* Meeting card */
  .meeting-card { padding: 14px; gap: 12px; }

  /* Notif card */
  .notif-card { padding: 14px; }
  .notif-card-header { flex-direction: column; gap: 4px; }
  .notif-card-time   { align-self: flex-start; }

  /* Profile layout */
  .profile-layout { grid-template-columns: 1fr !important; }

  /* Weekly layout */
  .layout-weekly    { grid-template-columns: 1fr !important; }

  /* Admin overview grid */
  .ctv-overview-grid { grid-template-columns: 1fr; }

  /* Week nav */
  .week-nav { padding: 10px 14px; gap: 8px; }
  .week-nav .week-label { font-size: 13px; }

  /* Toast */
  .toast-container { bottom: 16px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }

  /* Filter row */
  .filter-row { gap: 8px; }

  /* Topbar hide some buttons on very small */
  .topbar-actions .btn-outline { display: none; }
}

/* ===== RESPONSIVE: SMALL PHONE (≤ 480px) ===== */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card  { padding: 12px 10px; }
  .stat-icon  { width: 36px; height: 36px; font-size: 16px; }
  .stat-info h3 { font-size: 18px; }

  .topbar-title { font-size: 14px; }
  .topbar-actions .btn { padding: 6px 10px; font-size: 11px; }

  .page-header h2 { font-size: 16px; }
  .page-header p  { font-size: 12px; }

  .card-header h3 { font-size: 13px; }

  .btn { padding: 8px 14px; font-size: 12px; }
  .btn-sm { padding: 5px 10px; font-size: 11px; }

  /* Admin tab buttons: icon only */
  .admin-tab-btn .tab-text { display: none; }
}

/* ===== DANGER ZONE ===== */
.danger-zone {
  border: 1.5px solid #fecaca; border-radius: 12px;
  padding: 20px 24px; background: #fff5f5; margin-top: 24px;
}
.danger-zone h4 { color: #dc2626; font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.danger-zone p  { font-size: 12px; color: #ef4444; margin-bottom: 14px; }

/* ===== CTV OVERVIEW CARD (admin) ===== */
.ctv-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.ctv-ov-card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  transition: box-shadow .2s;
}
.ctv-ov-card:hover { box-shadow: var(--shadow-lg); }
.ctv-ov-top {
  padding: 14px 18px;
  background: linear-gradient(135deg,#312e81,#6c63ff);
  display: flex; align-items: center; gap: 12px;
}
.ctv-ov-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 20px; flex-shrink: 0;
}
.ctv-ov-name { color: #fff; font-weight: 700; font-size: 14px; }
.ctv-ov-sub  { color: #c7d2fe; font-size: 11px; }
.ctv-ov-stats {
  display: grid; grid-template-columns: repeat(3,1fr);
  border-top: 1px solid #f1f5f9;
}
.ctv-ov-stat { padding: 12px; text-align: center; border-right: 1px solid #f1f5f9; }
.ctv-ov-stat:last-child { border-right: none; }
.ctv-ov-stat strong { display: block; font-size: 18px; font-weight: 800; color: var(--text); }
.ctv-ov-stat span   { font-size: 10px; color: #94a3b8; font-weight: 600; text-transform: uppercase; }
.ctv-ov-footer {
  padding: 10px 14px; display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid #f1f5f9; font-size: 12px; color: #64748b;
}

.badge-img-ok   { background: #dcfce7; color: #166534; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-img-warn { background: #fef3c7; color: #92400e; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.pw-note { font-size: 11px; color: #94a3b8; margin-top: 3px; }
.acc-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg,#6c63ff,#a855f7);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 18px; flex-shrink: 0;
}

/* ===== PROFILE LAYOUT ===== */
@media (max-width: 760px) {
  .profile-layout { grid-template-columns: 1fr !important; }
}

/* ===== BOTTOM TAB BAR (mobile only) ===== */
.mobile-bottom-bar {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: #fff; border-top: 1px solid var(--border);
  z-index: 150; padding: 6px 0 max(6px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  justify-content: space-around; align-items: center;
}
.mbb-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  background: none; border: none; cursor: pointer;
  padding: 4px 2px; position: relative;
  color: var(--text-muted); transition: color .2s;
  -webkit-tap-highlight-color: transparent;
}
.mbb-item.active { color: var(--primary); }
.mbb-icon  { font-size: 20px; line-height: 1; }
.mbb-label { font-size: 10px; font-weight: 600; }
.mbb-badge {
  position: absolute; top: 0; right: calc(50% - 18px);
  background: #ef4444; color: #fff;
  font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 20px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}

@media (max-width: 768px) {
  .mobile-bottom-bar { display: flex; }
  /* Padding để content không bị che bởi bottom bar */
  .page-content { padding-bottom: 80px; }
  /* Ẩn sidebar nav items ít dùng trên mobile — dùng bottom bar thay */
  .sidebar { overflow-y: auto; }
}

/* ===== SIDEBAR LOGO WITH IMAGE ===== */
.sidebar-logo-img {
  width: 52px; height: 52px; border-radius: 14px;
  overflow: hidden; margin-bottom: 10px;
  background: #0d1117;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  flex-shrink: 0;
}
.sidebar-logo-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sidebar-logo-fallback { margin-bottom: 10px; }

/* ===== LANG SWITCHER IN TOPBAR ===== */
.lang-float-topbar {
  display: flex; align-items: center; gap: 0;
  background: #f1f5f9; border-radius: 20px; padding: 3px;
  border: 1px solid var(--border);
}
.lang-float-topbar .lang-btn {
  padding: 4px 10px; border-radius: 16px; border: none;
  background: transparent; color: #64748b;
  font-size: 11px; font-weight: 700; cursor: pointer;
  transition: all .2s;
}
.lang-float-topbar .lang-btn:hover  { color: var(--primary); }
.lang-float-topbar .lang-btn.active { background: var(--primary); color: #fff; }

@media (max-width: 480px) {
  .lang-float-topbar { display: none; }
}

/* ===== NEW STATUS BADGES ===== */
.badge-new        { background: #e0e7ff; color: #4338ca; }  /* Mới tiếp nhận */
.badge-consulting { background: #fef3c7; color: #92400e; }  /* Đang tư vấn */
.badge-contacted  { background: #dbeafe; color: #1d4ed8; }  /* Đã báo giá */
.badge-closed     { background: #dcfce7; color: #166534; }  /* Đã chốt */
.badge-interested { background: #d1fae5; color: #065f46; }  /* Đã thanh toán */

/* ===== CHART PERIOD BUTTONS ===== */
.chart-period-btn.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
}

/* ===== REPORT REVIEW STATUS ROW ===== */
tr.rpt-approved { background: #f0fdf4 !important; }
tr.rpt-rejected { background: #fff5f5 !important; }
tr.rpt-revise   { background: #eff6ff !important; }

/* ===== CUSTOMER TABLE ===== */
#admin-tab-customers .table-wrapper table { min-width: 1100px; }

/* ===== STAT SECTION HEADERS ===== */
.stat-section-label {
  font-size: 11px; font-weight: 700; color: #64748b;
  text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 10px; margin-top: 4px;
  padding-left: 2px;
}

/* ===== CUSTOMER MODAL TABS ===== */
#custModalTabContent .form-grid { gap: 14px; }

/* ===== PIE LEGEND ===== */
#customerPieLegend { gap: 5px !important; }

/* ============================================================
   CHAT STYLES
   ============================================================ */
.chat-list-item:hover { background: #f1f5f9; }
.chat-list-item.active { background: #ede9fe; }

/* Leave grid responsive */
@media (max-width: 768px) {
  .leave-grid { grid-template-columns: 1fr !important; }
  .admin-chat-grid { grid-template-columns: 1fr !important; }
}

/* broadcast & admin grids */
@media (max-width: 768px) {
  .broadcast-grid { grid-template-columns: 1fr !important; }
}
/* KPI star rating */
.kpi-star { opacity: .5; }
.kpi-star.active { opacity: 1; transform: scale(1.1); }
.kpi-star:hover { opacity: 1; transform: scale(1.2); }
/* Chat sidebar */
#chatSidebarList { min-width: 0; }
@media (max-width: 640px) {
  #chatMainWrap > div { grid-template-columns: 1fr !important; }
  #chatSidebarList { max-height: 180px; border-right: none !important; border-bottom: 1.5px solid #f1f5f9; }
}

/* ============================================================
   MOBILE ENHANCEMENTS v2 — Responsive toàn diện
   ============================================================ */

/* --- Base: box-sizing and tap highlight --- */
*, *::before, *::after { box-sizing: border-box; }
a, button { -webkit-tap-highlight-color: transparent; }

/* --- Topbar: always single line on mobile --- */
@media (max-width: 768px) {
  .topbar { min-height: 54px; padding: 8px 12px; }
  .topbar-title span { display: none; }
  .topbar-title strong { font-size: 14px; }
  .topbar-actions { flex-wrap: nowrap; }
  .topbar-actions .btn { padding: 6px 10px; font-size: 11px; min-width: 0; }
  /* Dark mode button compact */
  #btnDarkMode span:last-child { display: none; }
}

/* --- Sidebar: better slide + overlay --- */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transition: transform .25s cubic-bezier(.4,0,.2,1);
    will-change: transform;
  }
  .sidebar-logo h2 { font-size: 16px; }
  .sidebar-logo span { font-size: 11px; }
  .nav-section-label { font-size: 10px; padding: 6px 14px 2px; }
  .nav-item { padding: 9px 14px; font-size: 13px; }
  .nav-item .icon { font-size: 16px; min-width: 22px; }
}

/* --- Cards: full width, no shadow on mobile --- */
@media (max-width: 768px) {
  .card { border-radius: 12px; margin-bottom: 14px; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card-header h3 { font-size: 14px; }
  .card-body { padding: 14px; }
}

/* --- Salary / Lương chốt được khách --- */
@media (max-width: 768px) {
  #admin-tab-salary .stats-grid { grid-template-columns: repeat(2,1fr); }
  .admin-bonus-grid { grid-template-columns: 1fr !important; }
}

/* --- Gate overlay: full screen on mobile --- */
@media (max-width: 768px) {
  #profileGateOverlay.modal-overlay { padding: 0; align-items: flex-start; }
  #profileGateOverlay .modal {
    border-radius: 0; max-height: 100vh; height: 100vh;
    max-width: 100%; overflow-y: auto;
  }
  #profileGateOverlay .form-grid { grid-template-columns: 1fr; }
}

/* --- end --- */

/* --- Attendance tab: 2 shift cards stack on very small --- */
@media (max-width: 480px) {
  #ctv-tab-attendance > div:first-child > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}
@media (max-width: 480px) {
  #ctv-tab-attendance > div:first-child > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* --- Chat: full width panel on mobile --- */
@media (max-width: 640px) {
  #chatMainWrap > div { grid-template-columns: 1fr !important; }
  #chatSidebarList { max-height: 160px; overflow-y: auto; border-right: none !important; border-bottom: 1.5px solid #f1f5f9; }
  #chatRoomPane { min-height: 300px; }
  #adminChatPanelWrap > div { grid-template-columns: 1fr !important; }
  #adminChatUserList { max-height: 140px; overflow-y: auto; border-right: none !important; border-bottom: 1.5px solid #e2e8f0; }
}

/* --- Admin: reduce tab button text on mobile --- */
@media (max-width: 900px) {
  .sidebar-nav .nav-item span:not(.icon):not(.nav-badge) { font-size: 12px; }
}

/* --- Settings grid: 1 column on mobile --- */
@media (max-width: 640px) {
  .settings-grid { grid-template-columns: 1fr !important; }
  #setSmtpHost, #setSmtpUser, #setSmtpFrom { grid-column: 1 !important; }
}

/* --- Profile layout improvements --- */
@media (max-width: 900px) {
  .profile-layout { grid-template-columns: 1fr !important; }
  .profile-layout > div:first-child { max-width: 100%; }
}

/* --- Weekly page mobile --- */
@media (max-width: 768px) {
  .layout-weekly { grid-template-columns: 1fr !important; }
  #weeklyPage .topbar-actions { gap: 4px; }
  #weeklyPage .btn { padding: 6px 10px; font-size: 11px; }
}

/* --- Stat cards: 1 col on very small --- */
@media (max-width: 360px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* --- Table overflow with momentum scroll --- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0 0 8px 8px;
}

/* --- Buttons: larger tap target on mobile --- */
@media (max-width: 768px) {
  .btn { min-height: 38px; }
  .btn-sm { min-height: 30px; }
  select.form-control, input.form-control { min-height: 40px; font-size: 14px; }

/* Adjust requests table fit mobile */
@media (max-width: 768px) {
  #attAdjustWrap .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #attAdjustWrap table { min-width: 640px; font-size: 11px; }
  #attAdjustWrap th, #attAdjustWrap td { padding: 4px 2px; word-break: break-word; overflow-wrap: anywhere; white-space: normal; }
}

/* Attendance history table fit mobile */
@media (max-width: 768px) {
  #attendanceHistTable table { table-layout: fixed; width: 100%; font-size: 11px; }
  #attendanceHistTable th, #attendanceHistTable td { padding: 4px 2px; word-break: break-word; overflow-wrap: anywhere; }
}


  textarea.form-control { font-size: 14px; }
}

/* --- Dark mode mobile adjustments --- */
body.dark-mode .mobile-bottom-bar { display: none; }

/* ===== MOBILE REPAIR PATCH ===== */
@media (max-width: 768px) {
  body { overflow-x: hidden; }
  .layout { display: block !important; }
  .sidebar { position: fixed; left: -280px; top: 0; bottom: 0; width: 280px; z-index: 1000; transition: left .25s ease; }
  .sidebar.mobile-open { left: 0; }
  .sidebar-overlay { display: none; }
  .sidebar-overlay.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 999; }
  .main { margin-left: 0 !important; width: 100% !important; }
  .topbar { position: sticky; top: 0; z-index: 100; }
  .page-content { padding: 12px !important; }
  .card { width: 100% !important; max-width: 100% !important; }
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  .modal-overlay { padding: 12px !important; align-items: flex-start !important; }
  .modal { max-width: 100% !important; margin: 0 auto; }
  .form-grid { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .ctv-tab-panel { width: 100% !important; }
  .mobile-bottom-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 900; display: flex !important; }
  .main { padding-bottom: 80px !important; }
  /* overlays */
  #attRequiredBanner, #riskLockBlockOverlay, #shiftSelectOverlay, #emailOTPOverlay {
    padding: 12px !important;
  }
  #attRequiredBanner .modal, #riskLockBlockOverlay > div, #shiftSelectOverlay > div {
    max-width: 100% !important; width: 100% !important;
  }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .topbar-title { font-size: 14px; }
  .btn { font-size: 12px; padding: 8px 12px; }
}

body.dark-mode .mobile-bottom-bar {
  background: #1e293b;
  border-top-color: #334155;
}
body.dark-mode .mbb-item { color: #94a3b8; }
body.dark-mode .mbb-item.active { color: #818cf8; }

/* --- Admin chat panel mobile --- */
@media (max-width: 768px) {
  #admin-tab-chat .admin-chat-grid { grid-template-columns: 1fr !important; }
}

/* --- Salary form compact on mobile --- */
@media (max-width: 640px) {
  #salForm .form-grid { grid-template-columns: 1fr !important; }
  #salFilterRow { flex-direction: column; gap: 8px; }
  #salFilterRow select { width: 100% !important; }
}

/* --- Violation filters on mobile --- */
@media (max-width: 640px) {
  #violFilterRow { flex-direction: column; }
  #violFilterRow select { width: 100% !important; }
}

/* --- Smooth transitions --- */
.card, .modal, .nav-item, .btn { transition: all .15s ease; }

/* --- Fix overflow on admin page --- */
#adminPage { overflow-x: hidden; }
.admin-tab-panel { word-break: break-word; }

/* --- Safe area for iPhone notch --- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .mobile-bottom-bar { padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  @media (max-width: 768px) { .page-content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); } }
}
