*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,.1);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.15);
}

body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--gray-50); color: var(--gray-800); }

/* ─── HEADER ──────────────────────────────────────────────────────────── */
header {
  background: var(--primary); color: #fff; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
header .logo { font-weight: 700; font-size: 1.1rem; }
header .user-info { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
header .btn-logout { background: rgba(255,255,255,.2); border: none; color: #fff;
  padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: .85rem; }
header .btn-cart { background: var(--accent); color: #fff; border: none;
  padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 600;
  display: flex; align-items: center; gap: 6px; position: relative; }
.cart-count { background: var(--danger); color: #fff; border-radius: 50%;
  width: 20px; height: 20px; font-size: .75rem; display: flex; align-items: center;
  justify-content: center; font-weight: 700; }

/* ─── AUTH SCREEN ─────────────────────────────────────────────────────── */
#auth-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
}
.auth-box {
  background: #fff; border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 400px; box-shadow: var(--shadow-lg);
}
.auth-box h2 { text-align: center; margin-bottom: 24px; color: var(--primary); }
.auth-tabs { display: flex; gap: 4px; margin-bottom: 24px; background: var(--gray-100);
  padding: 4px; border-radius: 8px; }
.auth-tab { flex: 1; padding: 8px; border: none; background: none; border-radius: 6px;
  cursor: pointer; font-size: .9rem; color: var(--gray-600); transition: all .2s; }
.auth-tab.active { background: #fff; color: var(--primary); font-weight: 600;
  box-shadow: var(--shadow); }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: .85rem; font-weight: 500;
  margin-bottom: 6px; color: var(--gray-600); }
.form-group input { width: 100%; padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: .95rem; outline: none; transition: border .2s; }
.form-group input:focus { border-color: var(--primary); }
.btn-primary { width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: 8px; font-size: 1rem; font-weight: 600;
  cursor: pointer; transition: background .2s; }
.btn-primary:hover { background: var(--primary-dark); }
.auth-msg { margin-top: 12px; text-align: center; font-size: .85rem; }
.auth-msg.error { color: var(--danger); }
.auth-msg.success { color: var(--success); }

/* ─── MAIN LAYOUT ─────────────────────────────────────────────────────── */
#app-screen { display: none; }
.main-content { max-width: 1200px; margin: 0 auto; padding: 20px 16px; }

/* ─── TOOLBAR ─────────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.toolbar-secondary { margin-top: 0; margin-bottom: 16px; }
.toolbar input[type=text] { flex: 1; min-width: 200px; padding: 10px 14px;
  border: 1.5px solid var(--gray-200); border-radius: 8px; font-size: .95rem; outline: none; }
.toolbar input:focus { border-color: var(--primary); }
.toolbar select { padding: 10px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: .95rem; outline: none; cursor: pointer; }
/* Price range filter */
.price-range-wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.price-range-label { font-size: .88rem; color: var(--gray-600); white-space: nowrap; }
.price-input { width: 130px; padding: 8px 12px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: .9rem; outline: none; }
.price-input:focus { border-color: var(--primary); }

/* Flash animation cho UI actions của bot */
@keyframes tab-flash {
  0%,100% { background: transparent; }
  30%,70% { background: var(--accent); color: #fff; transform: scale(1.06); }
}
.tab-flash { animation: tab-flash .6s ease 2; }

/* ─── PRODUCT GRID ────────────────────────────────────────────────────── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.product-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; cursor: pointer; transition: transform .2s, box-shadow .2s;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.product-img { width: 100%; height: 150px; object-fit: contain; background: var(--gray-50);
  padding: 8px; }
.product-img-placeholder { width: 100%; height: 150px; background: var(--gray-100);
  display: flex; align-items: center; justify-content: center; font-size: 2.5rem; }
.product-info { padding: 12px; }
.product-name { font-size: .88rem; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 6px; }
.product-sku { font-size: .75rem; color: var(--gray-400); margin-bottom: 6px; }
.product-price { font-size: 1rem; font-weight: 700; color: var(--primary); }
.product-price-original { font-size: .8rem; color: var(--gray-400); text-decoration: line-through; }
.product-discount { font-size: .75rem; color: var(--danger); font-weight: 600; }
.product-unit { font-size: .78rem; color: var(--gray-600); }
.product-stock { font-size: .75rem; margin-top: 4px; }
.stock-ok { color: var(--success); }
.stock-low { color: var(--accent); }
.stock-out { color: var(--danger); }
.qty-row { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.qty-input { width: 52px; text-align: center; padding: 5px 4px; border: 1.5px solid var(--gray-200);
  border-radius: 6px; font-size: .9rem; font-weight: 600; outline: none; }
.qty-input:focus { border-color: var(--primary); }
.btn-add-cart { flex: 1; margin-top: 6px; padding: 8px; background: var(--primary);
  color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: .88rem;
  font-weight: 600; transition: background .2s; }
.btn-add-cart:hover { background: var(--primary-dark); }
.btn-add-cart:disabled { background: var(--gray-400); cursor: not-allowed; }

/* ─── PAGINATION ──────────────────────────────────────────────────────── */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 24px; }
.pagination button { padding: 8px 16px; border: 1.5px solid var(--gray-200);
  border-radius: 6px; cursor: pointer; background: #fff; }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ─── CART DRAWER ─────────────────────────────────────────────────────── */
.cart-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 200; }
.cart-overlay.open { display: block; }
.cart-drawer { position: fixed; right: 0; top: 0; bottom: 0; width: 420px; max-width: 100vw;
  background: #fff; box-shadow: var(--shadow-lg); z-index: 201;
  display: flex; flex-direction: column; transform: translateX(100%);
  transition: transform .3s ease; }
.cart-overlay.open .cart-drawer { transform: translateX(0); }
.cart-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
  display: flex; justify-content: space-between; align-items: center; }
.cart-header h3 { font-size: 1.1rem; font-weight: 700; }
.btn-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--gray-600); }
.cart-items { flex: 1; overflow-y: auto; padding: 16px; }
.cart-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); }
.cart-item-name { flex: 1; font-size: .88rem; font-weight: 600; }
.cart-item-meta { font-size: .78rem; color: var(--gray-600); margin-top: 2px; }
.cart-item-actions { display: flex; align-items: center; gap: 8px; }
.qty-btn { width: 28px; height: 28px; border: 1.5px solid var(--gray-200); background: #fff;
  border-radius: 6px; cursor: pointer; font-size: 1rem; display: flex; align-items: center;
  justify-content: center; }
.qty-btn:hover { border-color: var(--primary); color: var(--primary); }
.qty-val { font-weight: 600; min-width: 24px; text-align: center; }
.btn-remove { background: none; border: none; color: var(--danger); cursor: pointer;
  font-size: 1.1rem; padding: 4px; }
.cart-item-price { font-weight: 700; font-size: .9rem; color: var(--primary); text-align: right;
  min-width: 80px; }
.cart-empty { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.cart-footer { padding: 16px 20px; border-top: 1px solid var(--gray-200); }
.cart-total { display: flex; justify-content: space-between; font-weight: 700;
  font-size: 1.05rem; margin-bottom: 12px; }
.cart-note { width: 100%; padding: 8px 12px; border: 1.5px solid var(--gray-200);
  border-radius: 8px; font-size: .9rem; resize: none; outline: none; margin-bottom: 12px; }
.btn-order { width: 100%; padding: 13px; background: var(--success); color: #fff;
  border: none; border-radius: 8px; font-size: 1rem; font-weight: 700;
  cursor: pointer; transition: opacity .2s; }
.btn-order:hover { opacity: .9; }
.btn-order:disabled { opacity: .5; cursor: not-allowed; }

/* ─── CHAT WIDGET ─────────────────────────────────────────────────────── */
.chat-fab { position: fixed; right: 24px; bottom: 24px; width: 56px; height: 56px;
  background: var(--primary); color: #fff; border: none; border-radius: 50%;
  font-size: 1.5rem; cursor: pointer; box-shadow: var(--shadow-lg); z-index: 300;
  transition: transform .2s; display: flex; align-items: center; justify-content: center; }
.chat-fab:hover { transform: scale(1.1); }
.chat-fab .chat-notif { position: absolute; top: 0; right: 0; width: 14px; height: 14px;
  background: var(--danger); border-radius: 50%; border: 2px solid #fff; display: none; }
.chat-fab .chat-notif.show { display: block; }

.chat-window { position: fixed; right: 24px; bottom: 90px; width: 360px;
  max-width: calc(100vw - 32px); height: 480px; background: #fff;
  border-radius: 16px; box-shadow: var(--shadow-lg); z-index: 300;
  display: none; flex-direction: column; overflow: hidden; }
.chat-window.open { display: flex; }
.chat-win-header { padding: 12px 16px; background: var(--primary); color: #fff;
  display: flex; justify-content: space-between; align-items: center; }
.chat-win-header h4 { font-size: .95rem; font-weight: 600; }
.chat-mode-badge { font-size: .75rem; padding: 3px 8px; border-radius: 20px;
  font-weight: 600; }
.mode-bot { background: #22c55e; color: #fff; }
.mode-human { background: var(--accent); color: #fff; }
.chat-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex;
  flex-direction: column; gap: 8px; }
.chat-bubble { max-width: 80%; padding: 8px 12px; border-radius: 12px;
  font-size: .88rem; line-height: 1.4; }
.bubble-user { align-self: flex-end; background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px; }
.bubble-bot { align-self: flex-start; background: var(--gray-100); color: var(--gray-800);
  border-bottom-left-radius: 4px; }
.bubble-admin { align-self: flex-start; background: #fef3c7; color: var(--gray-800);
  border-bottom-left-radius: 4px; }
.bubble-time { font-size: .7rem; opacity: .6; margin-top: 2px; }
.chat-input-area { padding: 10px; border-top: 1px solid var(--gray-200);
  display: flex; gap: 8px; }
.chat-input { flex: 1; padding: 8px 12px; border: 1.5px solid var(--gray-200);
  border-radius: 20px; outline: none; font-size: .9rem; resize: none; }
.chat-input:focus { border-color: var(--primary); }
.btn-send { background: var(--primary); color: #fff; border: none; border-radius: 50%;
  width: 38px; height: 38px; cursor: pointer; font-size: 1rem; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; }

/* ─── MODAL ───────────────────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 400; align-items: center; justify-content: center; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px;
  width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); }
.modal h3 { margin-bottom: 16px; font-size: 1.05rem; }
.toast { position: fixed; top: 70px; right: 20px; padding: 12px 20px;
  border-radius: 8px; color: #fff; font-weight: 600; z-index: 500;
  animation: slideIn .3s ease; box-shadow: var(--shadow); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; } }

.loading { text-align: center; padding: 40px; color: var(--gray-400); font-size: 1rem; }
.spinner { display: inline-block; width: 24px; height: 24px; border: 3px solid var(--gray-200);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── APP TABS ────────────────────────────────────────────────────────── */
.app-tabs {
  background: #fff; border-bottom: 2px solid var(--gray-200);
  display: flex; gap: 0; position: sticky; top: 56px; z-index: 90;
  box-shadow: 0 2px 4px rgba(0,0,0,.06);
}
.app-tab-btn {
  flex: 1; padding: 13px 8px; border: none; background: none;
  font-size: .88rem; font-weight: 600; color: var(--gray-600);
  cursor: pointer; transition: all .2s; border-bottom: 3px solid transparent;
  margin-bottom: -2px; white-space: nowrap;
}
.app-tab-btn:hover { color: var(--primary); background: var(--gray-50); }
.app-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.app-tab-panel { display: none; }
.app-tab-panel.active { display: block; }

/* ─── KPI CARDS ───────────────────────────────────────────────────────── */
.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 20px;
}
.kpi-card {
  background: #fff; border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 4px;
}
.kpi-label { font-size: .78rem; color: var(--gray-600); font-weight: 500; }
.kpi-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-800); line-height: 1.2; }
.kpi-sub { font-size: .75rem; color: var(--gray-400); }
.kpi-change { font-size: .78rem; font-weight: 600; margin-top: 2px; }
.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* ─── OVERVIEW GRID ───────────────────────────────────────────────────── */
.overview-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 0;
}
.overview-box {
  background: #fff; border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.overview-box-title {
  font-size: .9rem; font-weight: 700; color: var(--gray-800); margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--gray-100);
}

/* Overview tables */
.ov-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.ov-table th { text-align: left; padding: 6px 8px; color: var(--gray-600);
  font-weight: 600; border-bottom: 1px solid var(--gray-100); }
.ov-table td { padding: 8px 8px; border-bottom: 1px solid var(--gray-50);
  vertical-align: middle; }
.ov-table tr:last-child td { border-bottom: none; }
.ov-name { font-weight: 600; color: var(--gray-800); display: -webkit-box;
  -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.ov-sku { font-size: .72rem; color: var(--gray-400); }

/* Monthly trend bar chart */
.trend-chart { display: flex; flex-direction: column; gap: 6px; }
.trend-row { display: flex; align-items: center; gap: 8px; }
.trend-month { font-size: .75rem; color: var(--gray-600); width: 42px; flex-shrink: 0;
  text-align: right; }
.trend-bar-wrap { flex: 1; background: var(--gray-100); border-radius: 4px; height: 18px;
  overflow: hidden; }
.trend-bar { height: 100%; background: var(--primary); border-radius: 4px;
  transition: width .4s ease; min-width: 2px; }
.trend-val { font-size: .72rem; color: var(--gray-600); width: 60px; flex-shrink: 0;
  text-align: right; font-weight: 600; }

/* ─── URGENCY BADGES ──────────────────────────────────────────────────── */
.urg {
  display: inline-block; font-size: .7rem; font-weight: 700;
  padding: 2px 8px; border-radius: 12px; white-space: nowrap;
}
.urg-overdue { background: #fee2e2; color: #991b1b; }
.urg-due     { background: #fef3c7; color: #92400e; }
.urg-soon    { background: #dcfce7; color: #166534; }
.urg-ok      { background: var(--gray-100); color: var(--gray-600); }

/* ─── STATUS BADGES ───────────────────────────────────────────────────── */
.status-badge {
  display: inline-block; font-size: .72rem; font-weight: 700;
  padding: 2px 9px; border-radius: 12px; white-space: nowrap;
}
.status-new        { background: #f3f4f6; color: #374151; }
.status-pending    { background: #fef9c3; color: #854d0e; }
.status-confirmed  { background: #dbeafe; color: #1e40af; }
.status-processing { background: #ede9fe; color: #4c1d95; }
.status-shipped    { background: #cffafe; color: #155e75; }
.status-done       { background: #dcfce7; color: #166534; }
.status-delivered  { background: #dcfce7; color: #166534; }
.status-cancelled  { background: #fee2e2; color: #991b1b; }

/* ─── HISTORY TABLE ───────────────────────────────────────────────────── */
.hist-table-wrap { overflow-x: auto; }
.hist-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.hist-table th { text-align: left; padding: 8px 10px; color: var(--gray-600);
  font-weight: 600; border-bottom: 2px solid var(--gray-200);
  background: var(--gray-50); white-space: nowrap; }
.hist-table td { padding: 9px 10px; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle; }
.hist-table tr:hover td { background: var(--gray-50); }
.hist-table tr:last-child td { border-bottom: none; }
.hist-name { font-weight: 600; color: var(--gray-800); display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  max-width: 200px; line-height: 1.3; }
.hist-sku { font-size: .72rem; color: var(--gray-400); margin-top: 2px; }
.hist-empty { text-align: center; padding: 40px; color: var(--gray-400); }

/* Small button */
.btn-xs {
  padding: 4px 10px; font-size: .75rem; font-weight: 600; border: none;
  border-radius: 6px; cursor: pointer; background: var(--primary); color: #fff;
  transition: background .2s; white-space: nowrap;
}
.btn-xs:hover { background: var(--primary-dark); }
.btn-xs.outline {
  background: #fff; color: var(--primary); border: 1.5px solid var(--primary);
}
.btn-xs.outline:hover { background: #eff6ff; }
.btn-xs.success { background: var(--success); }
.btn-xs.success:hover { background: #059669; }

/* ─── TREND FILTER BAR ────────────────────────────────────────────────── */
.trend-filter-bar {
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px;
}
.filter-row { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.filter-item { display: flex; flex-direction: column; gap: 3px; }
.filter-item label { font-size: .72rem; font-weight: 600; color: var(--gray-600); }
.filter-item input[type=date],
.filter-item select {
  padding: 5px 8px; border: 1.5px solid var(--gray-200); border-radius: 6px;
  font-size: .82rem; outline: none; background: #fff;
}
.filter-item input[type=date]:focus,
.filter-item select:focus { border-color: var(--primary); }
/* Thanh tương đối (thay số doanh thu thực) */
.trend-rel-bar {
  display: flex; align-items: center; gap: 6px; min-width: 120px;
}
.trend-rel-fill {
  height: 8px; background: var(--primary); border-radius: 4px; min-width: 2px;
  flex-shrink: 0;
}
.trend-rel-pct { font-size: .75rem; color: var(--gray-600); font-weight: 600; }

/* ─── ORDER SUB-NAV PILLS ─────────────────────────────────────────────── */
.order-subnav {
  display: flex; gap: 6px; flex-wrap: wrap; padding: 12px 0 8px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.order-subnav::-webkit-scrollbar { display: none; }
.order-subnav-btn {
  flex-shrink: 0; padding: 7px 14px; border: 1.5px solid var(--gray-200);
  border-radius: 20px; background: #fff; color: var(--gray-600);
  font-size: .82rem; font-weight: 600; cursor: pointer; transition: all .18s;
  white-space: nowrap;
}
.order-subnav-btn:hover { border-color: var(--primary); color: var(--primary); }
.order-subnav-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(37,99,235,.25);
}

/* ─── ORDER SECTION TABLES ────────────────────────────────────────────── */
.order-section {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 14px; overflow: hidden;
}
.section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap; gap: 8px; background: #fafafa;
}
.section-ttl { font-size: .9rem; font-weight: 700; color: var(--gray-800); }
.section-body { overflow-x: auto; }
.section-tbl {
  width: 100%; border-collapse: collapse; font-size: .82rem;
}
.section-tbl th {
  padding: 7px 10px; background: var(--gray-50); color: var(--gray-600);
  font-weight: 600; text-align: left; border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}
.section-tbl td {
  padding: 8px 10px; border-bottom: 1px solid var(--gray-50);
  vertical-align: middle;
}
.section-tbl tr:last-child td { border-bottom: none; }
.section-tbl tr:hover td { background: #f9fafb; }
.sn {
  font-weight: 600; color: var(--gray-800);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden; max-width: 200px;
}
.ss { font-size: .72rem; color: var(--gray-400); margin-top: 1px; }
/* Scope toggle buttons */
.scope-btns { display: flex; gap: 4px; }
.scope-btn {
  padding: 4px 10px; font-size: .75rem; font-weight: 600;
  border: 1.5px solid var(--gray-200); border-radius: 6px;
  background: #fff; color: var(--gray-600); cursor: pointer; transition: all .2s;
}
.scope-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.scope-btn:hover:not(.active) { border-color: var(--primary); color: var(--primary); }

/* ─── HOME SECTIONS ───────────────────────────────────────────────────── */
.home-shelf { margin-bottom: 28px; }
.shelf-title {
  font-size: .95rem; font-weight: 700; margin-bottom: 10px; color: var(--gray-800);
  display: flex; align-items: center; gap: 6px;
}
.shelf-scroll {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px;
  scrollbar-width: thin; scrollbar-color: var(--gray-200) transparent;
  -webkit-overflow-scrolling: touch;
}
.shelf-scroll::-webkit-scrollbar { height: 4px; }
.shelf-scroll::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 4px; }
.shelf-card {
  flex: 0 0 155px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; transition: transform .2s, box-shadow .2s; cursor: default;
  position: relative;
}
.shelf-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.shelf-img { width: 100%; height: 110px; object-fit: contain; background: var(--gray-50); padding: 6px; }
.shelf-placeholder {
  width: 100%; height: 110px; background: var(--gray-100);
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem;
}
.shelf-card-body { padding: 8px 10px 10px; }
.shelf-name {
  font-size: .76rem; font-weight: 600; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2em; margin-bottom: 3px; color: var(--gray-800);
}
.shelf-sku { font-size: .68rem; color: var(--gray-400); margin-bottom: 5px; }
.shelf-price { font-size: .88rem; font-weight: 700; color: var(--primary); margin-bottom: 8px; }
.shelf-btn-cart {
  width: 100%; padding: 6px 4px; background: var(--primary); color: #fff;
  border: none; border-radius: 6px; cursor: pointer; font-size: .75rem; font-weight: 600;
  transition: background .2s;
}
.shelf-btn-cart:hover { background: var(--primary-dark); }
.shelf-btn-cart:disabled { background: var(--gray-400); cursor: not-allowed; }

.shelf-badge-wrap { position: absolute; top: 6px; left: 6px; z-index: 2; }
.shelf-badge {
  display: inline-block; font-size: .62rem; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; white-space: nowrap;
}
.shelf-badge-overdue { background: #fee2e2; color: #991b1b; }
.shelf-badge-today   { background: #fef3c7; color: #92400e; }
.shelf-badge-soon    { background: #d1fae5; color: #065f46; }

/* ─── HISTORY DATE FILTER ─────────────────────────────────────────────── */
.history-date-filter { display:flex; align-items:center; gap:6px; flex-wrap:wrap; }
.history-date-filter label { font-size:.82rem; color:#6b7280; white-space:nowrap; }
.history-date-filter input[type=date] {
  border:1.5px solid #e5e7eb; border-radius:8px; padding:5px 8px;
  font-size:.82rem; color:#374151; cursor:pointer; outline:none; }
.history-date-filter input[type=date]:focus { border-color:#2563eb; }
.btn-primary { background:#2563eb; color:#fff; border:none; }
.btn-primary:hover { background:#1d4ed8; }

/* ─── CHAT PRODUCT TABLE — compact ───────────────────────────────────── */
.cpt-wrap { margin-top:8px; border-radius:8px; overflow:hidden;
  border:1px solid #e5e7eb; background:#fff; }
.cpt-title { padding:5px 10px; background:#eff6ff; font-weight:600;
  font-size:.76rem; color:#1d4ed8; border-bottom:1px solid #dbeafe; }
.cpt-scroll { overflow-x:auto; }
.cpt-table { width:100%; border-collapse:collapse; min-width:360px; }
.cpt-table thead { background:#f9fafb; }
.cpt-table th { padding:4px 7px; text-align:left; font-size:.71rem;
  color:#9ca3af; font-weight:600; border-bottom:1px solid #e5e7eb; white-space:nowrap; }
.cpt-table td { padding:4px 7px; border-bottom:1px solid #f3f4f6; vertical-align:middle; }
.cpt-table tr:last-child td { border-bottom:none; }
.cpt-table tr:hover td { background:#fafafa; }
/* Mã hàng nhỏ gọn */
.cpt-sku { font-size:.68rem; color:#9ca3af; font-family:monospace; display:block; }
/* Tên SP */
.cpt-name { font-size:.78rem; font-weight:500; color:#111827; max-width:150px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.cpt-price { font-size:.76rem; font-weight:600; color:#2563eb; white-space:nowrap; }
/* Status badges — nhỏ gọn */
.cpt-note { display:inline-block; font-size:.66rem; padding:1px 5px;
  border-radius:8px; font-weight:700; white-space:nowrap; }
.cpt-overdue { background:#fee2e2; color:#dc2626; }
.cpt-today   { background:#fef3c7; color:#b45309; }
.cpt-soon    { background:#dbeafe; color:#1d4ed8; }
.cpt-out     { background:#f3f4f6; color:#9ca3af; }
/* Qty control — nhỏ gọn */
.cpt-qty-wrap { display:flex; align-items:center; gap:2px; }
.cpt-qty-btn { width:20px; height:20px; border:1px solid #e5e7eb;
  border-radius:4px; background:#f9fafb; cursor:pointer; font-size:.85rem;
  line-height:1; display:flex; align-items:center; justify-content:center;
  color:#374151; transition:background .12s; padding:0; }
.cpt-qty-btn:hover { background:#e5e7eb; }
.cpt-qty-input { width:32px; height:20px; border:1px solid #e5e7eb;
  border-radius:4px; text-align:center; font-size:.76rem; outline:none; padding:0; }
.cpt-qty-input:focus { border-color:#2563eb; }
/* Add button */
.cpt-add-btn { background:#2563eb; color:#fff; border:none; border-radius:5px;
  padding:3px 8px; font-size:.72rem; cursor:pointer; font-weight:600;
  white-space:nowrap; transition:background .12s; }
.cpt-add-btn:hover { background:#1d4ed8; }
.cpt-add-btn:disabled { background:#bfdbfe; cursor:default; }
/* Add all button */
.cpt-add-all-btn { display:block; width:100%; padding:6px 10px; background:#1d4ed8;
  color:#fff; border:none; font-size:.76rem; font-weight:600; cursor:pointer;
  transition:background .12s; letter-spacing:.01em; }
.cpt-add-all-btn:hover { background:#1e40af; }

/* ─── RESPONSIVE ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .overview-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .main-content { padding: 14px 10px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .cart-drawer { width: 100%; }
  .chat-window { width: calc(100vw - 32px); right: 16px; }
  .shelf-card { flex: 0 0 140px; }
  .shelf-img, .shelf-placeholder { height: 95px; }
  .app-tab-btn { font-size: .78rem; padding: 12px 4px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-card { padding: 12px; }
  .kpi-value { font-size: 1.2rem; }
  .hist-name { max-width: 140px; }
  .hist-table th:nth-child(4),
  .hist-table td:nth-child(4) { display: none; }
}
