:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 220px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  font-size: 14px;
}

/* ===== LOGIN ===== */
.login-wrap {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px;
  width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card h1 { font-size: 24px; text-align: center; margin-bottom: 8px; color: var(--gray-800); }
.login-card .subtitle { text-align: center; color: var(--gray-500); margin-bottom: 28px; font-size: 13px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card label { display: block; font-size: 13px; color: var(--gray-600); margin-bottom: 6px; font-weight: 500; }
.login-card input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--gray-300);
  border-radius: var(--radius); font-size: 14px; transition: border-color .2s;
}
.login-card input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.login-card .btn-login {
  width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .2s; margin-top: 8px;
}
.login-card .btn-login:hover { background: var(--primary-dark); }
.login-card .hint { text-align: center; margin-top: 20px; font-size: 12px; color: var(--gray-400); }
.login-card .hint p { margin: 4px 0; }

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

.sidebar {
  width: var(--sidebar-w); background: var(--gray-900); color: #fff;
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-header {
  padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-header h2 { font-size: 17px; font-weight: 700; }
.sidebar-header .version { font-size: 11px; color: var(--gray-400); }
.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  color: var(--gray-300); border-radius: var(--radius); cursor: pointer;
  transition: all .15s; margin-bottom: 2px; font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item .icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); }
.user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px;
}
.user-detail { flex: 1; }
.user-detail .name { color: #fff; font-weight: 500; }
.user-detail .role { color: var(--gray-400); font-size: 11px; }
.btn-logout { color: var(--gray-400); cursor: pointer; font-size: 12px; background: none; border: none; }
.btn-logout:hover { color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-w); padding: 20px 24px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.topbar h1 { font-size: 22px; font-weight: 700; color: var(--gray-800); }
.topbar .actions { display: flex; gap: 8px; align-items: center; }
.online-badge {
  display: flex; align-items: center; gap: 6px; font-size: 12px;
  color: var(--gray-500); background: var(--gray-100); padding: 6px 12px; border-radius: 20px;
}
.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* ===== CARDS ===== */
.card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--gray-700); margin-bottom: 12px; }

/* ===== KPI CARDS ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi-card {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px; position: relative; overflow: hidden;
}
.kpi-card .kpi-label { font-size: 12px; color: var(--gray-500); margin-bottom: 8px; }
.kpi-card .kpi-value { font-size: 28px; font-weight: 700; color: var(--gray-800); }
.kpi-card .kpi-icon {
  position: absolute; top: 16px; right: 16px; font-size: 28px; opacity: .15;
}
.kpi-card.blue .kpi-value { color: var(--primary); }
.kpi-card.green .kpi-value { color: var(--success); }
.kpi-card.orange .kpi-value { color: var(--warning); }
.kpi-card.red .kpi-value { color: var(--danger); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600;
  color: var(--gray-500); text-transform: uppercase; border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
tr:hover td { background: var(--gray-50); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-400); }

/* ===== BADGE ===== */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

/* ===== FORM ===== */
.form-row { display: flex; gap: 12px; margin-bottom: 12px; }
.form-group { flex: 1; }
.form-group label { display: block; font-size: 12px; color: var(--gray-600); margin-bottom: 4px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-300);
  border-radius: 6px; font-size: 13px; background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light);
}

/* ===== BUTTONS ===== */
.btn {
  padding: 8px 16px; border: none; border-radius: 6px; font-size: 13px;
  font-weight: 500; cursor: pointer; transition: all .15s; display: inline-flex;
  align-items: center; gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-outline { background: #fff; color: var(--gray-600); border: 1px solid var(--gray-300); }
.btn-outline:hover { background: var(--gray-50); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ===== SEARCH BAR ===== */
.search-bar {
  display: flex; gap: 8px; margin-bottom: 16px; align-items: center;
}
.search-bar input {
  flex: 1; padding: 8px 14px; border: 1px solid var(--gray-300);
  border-radius: 6px; font-size: 13px;
}
.search-bar input:focus { outline: none; border-color: var(--primary); }
.search-bar select {
  padding: 8px 14px; border: 1px solid var(--gray-300);
  border-radius: 6px; font-size: 13px; background: #fff;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 200; display: flex;
  align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; max-width: 700px; width: 100%;
  max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
  display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { font-size: 22px; cursor: pointer; color: var(--gray-400); background: none; border: none; }
.modal-close:hover { color: var(--gray-800); }

/* ===== PAGINATION ===== */
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; font-size: 13px; }
.pagination .page-info { color: var(--gray-500); }
.pagination .page-btns { display: flex; gap: 4px; }

/* ===== ACTIVITY FEED ===== */
.activity-feed { max-height: 400px; overflow-y: auto; }
.activity-item {
  display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--gray-100);
}
.activity-item .act-time { font-size: 11px; color: var(--gray-400); }
.activity-item .act-text { font-size: 13px; }
.activity-item .act-user { font-weight: 600; color: var(--primary); }

/* ===== AI IMPORT ===== */
.ai-import {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.ai-textarea {
  width: 100%; min-height: 300px; padding: 14px; border: 1px solid var(--gray-300);
  border-radius: 8px; font-size: 13px; font-family: 'Courier New', monospace;
  resize: vertical; line-height: 1.6;
}
.ai-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.ai-result { background: var(--gray-50); border-radius: 8px; padding: 16px; min-height: 300px; }
.ai-result .result-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
.confidence-bar { height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.confidence-fill { height: 100%; border-radius: 3px; transition: width .5s; }

/* ===== TWO COLUMN ===== */
.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* ===== STOCK INDICATOR ===== */
.stock-bar { display: inline-flex; align-items: center; gap: 4px; }
.stock-dot { width: 8px; height: 8px; border-radius: 50%; }
.stock-green { background: var(--success); }
.stock-yellow { background: var(--warning); }
.stock-red { background: var(--danger); }
.stock-gray { background: var(--gray-400); }

/* ===== TOAST ===== */
.toast {
  position: fixed; top: 20px; right: 20px; z-index: 300;
  background: var(--gray-800); color: #fff; padding: 12px 20px;
  border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 14px;
  animation: slideIn .3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ===== LANGUAGE SWITCH ===== */
.lang-btn {
  padding: 4px 12px; border: 1px solid var(--gray-300); border-radius: 20px;
  background: #fff; color: var(--gray-600); font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all .15s;
}
.lang-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.login-card .lang-btn { position: absolute; top: 16px; right: 16px; }

/* ===== SHOP / MALL ===== */
.shop-filter-bar {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 20px; margin-bottom: 16px;
}
.shop-filter-level {
  display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px;
}
.shop-filter-level:last-child { margin-bottom: 0; }
.shop-filter-label {
  font-size: 13px; font-weight: 600; color: var(--gray-600);
  min-width: 70px; padding-top: 6px; flex-shrink: 0;
}
.shop-filter-opts {
  display: flex; flex-wrap: wrap; gap: 6px; flex: 1;
}
.shop-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.shop-card {
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  overflow: hidden; cursor: pointer; transition: all .2s; border: 1px solid var(--gray-200);
}
.shop-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--primary); }
.shop-card-img {
  width: 100%; height: 200px; object-fit: cover; background: var(--gray-100);
  display: flex; align-items: center; justify-content: center;
}
.shop-card-img img { width: 100%; height: 100%; object-fit: cover; }
.shop-card-body { padding: 12px 14px; }
.shop-card-name { font-size: 14px; font-weight: 600; color: var(--gray-800); margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-card-meta { display: flex; justify-content: space-between; align-items: center; }
.shop-card-price { font-size: 16px; font-weight: 700; color: var(--danger); }
.shop-card-stock { font-size: 12px; }

/* ===== PRODUCT DETAIL MODAL (Taobao style) ===== */
.pd-modal { max-width: 800px; }
.pd-layout { display: flex; gap: 24px; }
.pd-image { width: 300px; flex-shrink: 0; }
.pd-image img { width: 100%; border-radius: 8px; }
.pd-info { flex: 1; }
.pd-title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.pd-price { font-size: 28px; color: var(--danger); font-weight: 700; margin-bottom: 16px; }
.pd-section { margin-bottom: 16px; }
.pd-section-label { font-size: 13px; color: var(--gray-500); margin-bottom: 8px; }
.pd-options { display: flex; flex-wrap: wrap; gap: 8px; }
.pd-option {
  padding: 6px 16px; border: 2px solid var(--gray-200); border-radius: 6px;
  font-size: 13px; cursor: pointer; transition: all .15s; background: #fff;
}
.pd-option:hover { border-color: var(--primary); }
.pd-option.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.pd-option.disabled { opacity: .4; cursor: not-allowed; text-decoration: line-through; }
.pd-stock-info { display: flex; gap: 16px; font-size: 13px; color: var(--gray-600); margin-bottom: 16px; }
.pd-stock-info .stock-num { font-weight: 700; }
.pd-actions { display: flex; gap: 12px; margin-top: 20px; }
.pd-qty { display: flex; align-items: center; gap: 8px; }
.pd-qty button {
  width: 32px; height: 32px; border: 1px solid var(--gray-300); border-radius: 6px;
  background: #fff; cursor: pointer; font-size: 16px; font-weight: 600;
}
.pd-qty input { width: 60px; text-align: center; padding: 6px; border: 1px solid var(--gray-300); border-radius: 6px; font-size: 14px; }

/* ===== FAB (Floating Action Button) ===== */
.fab {
  display: none; position: fixed; bottom: 24px; right: 24px;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; font-size: 28px; font-weight: 300;
  border: none; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.25);
  z-index: 50; transition: all .2s; align-items: center; justify-content: center;
}
.fab:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.fab:active { transform: scale(0.95); }

.fab-cart {
  background: var(--danger); font-size: 24px;
}
.fab-cart:hover { background: #c0392b; }

.cart-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 22px; height: 22px; border-radius: 11px;
  background: #fff; color: var(--danger); font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--danger); padding: 0 4px;
}

/* ===== AI BANNER ===== */
.ai-banner {
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: 12px; padding: 16px 20px; margin-bottom: 16px;
}
.ai-banner-title {
  color: #fff; font-size: 16px; font-weight: 700; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.ai-banner-items { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-item {
  background: rgba(255,255,255,0.1); border-radius: 8px;
  padding: 6px 12px; font-size: 13px; color: #e2e8f0;
  display: flex; align-items: center; gap: 6px;
}
.ai-positive { border-left: 3px solid #22c55e; }
.ai-warning { border-left: 3px solid #f59e0b; }
.ai-danger { border-left: 3px solid #ef4444; }
.ai-info { border-left: 3px solid #3b82f6; }
.ai-icon { font-size: 16px; }

/* ===== SEARCH DROPDOWN ===== */
.search-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; margin-top: 4px;
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15);
  max-height: 400px; overflow-y: auto; z-index: 100; min-width: 320px;
}
.search-group { border-bottom: 1px solid var(--gray-100); }
.search-group:last-child { border-bottom: none; }
.search-group-title {
  font-size: 11px; font-weight: 700; color: var(--gray-500);
  padding: 6px 12px; background: var(--gray-50);
  text-transform: uppercase;
}
.search-item {
  padding: 8px 12px; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid var(--gray-50);
}
.search-item:hover { background: var(--gray-50); }

@media (max-width: 768px) {
  .global-search { display: none; }
}
.file-upload-zone {
  border: 2px dashed var(--gray-300); border-radius: 12px;
  padding: 28px 20px; text-align: center; cursor: pointer;
  transition: all .2s; background: var(--gray-50);
}
.file-upload-zone:hover {
  border-color: var(--primary); background: #eff6ff;
}
.file-upload-icon { font-size: 36px; margin-bottom: 4px; }

/* ===== PRODUCT IMAGE UPLOAD ===== */
.img-upload-area {
  margin-bottom: 16px; text-align: center;
}
.img-preview {
  width: 150px; height: 150px; margin: 0 auto; border-radius: 8px;
  border: 2px dashed var(--gray-300); background: var(--gray-50);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer; transition: border-color .15s;
}
.img-preview:hover { border-color: var(--primary); }
.img-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.img-placeholder { text-align: center; color: var(--gray-400); }
.img-placeholder span { font-size: 32px; display: block; margin-bottom: 4px; }
.img-placeholder p { font-size: 13px; margin: 0; }
.img-placeholder .hint-text { font-size: 11px; color: var(--gray-400); }

/* ===== PRODUCT THUMBNAIL IN TABLE ===== */
.prod-thumb {
  width: 40px; height: 40px; border-radius: 6px; overflow: hidden; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--gray-100); transition: transform .15s;
}
.prod-thumb:hover { transform: scale(1.1); }
.prod-thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-thumb span { font-size: 18px; }

/* ===== MOBILE: SHOW FAB ===== */
@media (max-width: 768px) {
  .fab { display: flex; bottom: 20px; right: 20px; }
  .img-preview { width: 120px; height: 120px; }
  .prod-thumb { width: 36px; height: 36px; }
}
.menu-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 36px; height: 36px; padding: 0; background: none; border: none; cursor: pointer;
}
.menu-toggle span {
  display: block; width: 22px; height: 2px; background: var(--gray-700);
  border-radius: 2px; transition: all .3s;
}

/* ===== SIDEBAR BACKDROP ===== */
.sidebar-backdrop {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.5); z-index: 99; opacity: 0; transition: opacity .3s;
}
.sidebar-backdrop.show { display: block; opacity: 1; }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
  /* --- Layout --- */
  .sidebar {
    transform: translateX(-100%); transition: transform .3s ease;
    box-shadow: 2px 0 20px rgba(0,0,0,.2);
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 12px 14px; padding-bottom: 80px; }

  /* --- Hamburger visible --- */
  .menu-toggle { display: flex; }

  /* --- Topbar --- */
  .topbar { margin-bottom: 12px; gap: 8px; }
  .topbar h1 { font-size: 17px; flex: 1; }
  .topbar .actions { gap: 6px; }
  .online-badge { font-size: 11px; padding: 4px 8px; }
  .online-suffix { display: none; }

  /* --- Login --- */
  .login-card { width: calc(100vw - 32px); max-width: 380px; padding: 28px 20px; border-radius: 12px; }
  .login-card h1 { font-size: 20px; }
  .login-card .subtitle { font-size: 12px; margin-bottom: 20px; }

  /* --- KPI Cards --- */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
  .kpi-card { padding: 14px; }
  .kpi-card .kpi-value { font-size: 22px; }
  .kpi-card .kpi-label { font-size: 11px; }
  .kpi-card .kpi-icon { font-size: 22px; }

  /* --- Cards --- */
  .card { padding: 14px; margin-bottom: 12px; }
  .card-title { font-size: 14px; margin-bottom: 10px; }

  /* --- Tables: horizontal scroll + compact --- */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 600px; }
  th { padding: 8px 8px; font-size: 11px; }
  td { padding: 8px 8px; font-size: 12px; }

  /* --- Search bar --- */
  .search-bar { flex-direction: column; gap: 8px; }
  .search-bar input, .search-bar select { width: 100%; }
  .search-bar .btn { width: 100%; justify-content: center; }

  /* --- Two column --- */
  .two-col { grid-template-columns: 1fr; gap: 12px; }

  /* --- Form rows --- */
  .form-row { flex-direction: column; gap: 10px; }

  /* --- Buttons: bigger touch targets --- */
  .btn { padding: 10px 16px; font-size: 14px; }
  .btn-sm { padding: 6px 12px; font-size: 12px; }

  /* --- Modal --- */
  .modal-overlay { padding: 0; }
  .modal {
    max-width: 100%; width: 100%; min-height: 100vh; max-height: 100vh;
    border-radius: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .modal-header { padding: 14px 16px; position: sticky; top: 0; background: #fff; z-index: 10; }
  .modal-header h3 { font-size: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; position: sticky; bottom: 0; background: #fff; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; justify-content: center; }

  /* --- Shop grid: 2 columns on phone, 1 on very small --- */
  .shop-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .shop-card-img { height: 130px; }
  .shop-card-body { padding: 8px 10px; }
  .shop-card-name { font-size: 12px; }
  .shop-card-price { font-size: 14px; }

  /* --- Shop filter bar --- */
  .shop-filter-bar { padding: 10px 12px; }
  .shop-filter-level { flex-direction: column; gap: 6px; margin-bottom: 10px; }
  .shop-filter-label { min-width: 0; padding-top: 0; font-size: 12px; }
  .shop-filter-opts { gap: 4px; }
  .pd-option { padding: 4px 10px; font-size: 11px; }

  /* --- Product detail modal --- */
  .pd-layout { flex-direction: column; gap: 16px; }
  .pd-image { width: 100%; }
  .pd-image img { max-height: 250px; object-fit: cover; }
  .pd-title { font-size: 16px; }
  .pd-price { font-size: 22px; }
  .pd-qty button { width: 36px; height: 36px; }
  .pd-qty input { width: 70px; height: 36px; }
  .pd-actions { flex-direction: column; gap: 8px; }
  .pd-actions .btn { width: 100%; justify-content: center; padding: 12px; }

  /* --- AI import --- */
  .ai-import { grid-template-columns: 1fr; }
  .ai-textarea { min-height: 200px; }

  /* --- Pagination --- */
  .pagination { flex-direction: column; gap: 8px; align-items: stretch; }
  .pagination .page-btns { justify-content: center; }

  /* --- Toast --- */
  .toast { top: 10px; right: 10px; left: 10px; text-align: center; font-size: 13px; padding: 10px 16px; }

  /* --- User info sidebar --- */
  .user-info { flex-wrap: wrap; }
  .btn-logout { margin-left: auto; }

  /* --- Activity feed --- */
  .activity-feed { max-height: 250px; }
}

@media (max-width: 380px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .shop-grid { grid-template-columns: 1fr; }
  .shop-card-img { height: 160px; }
  .login-card { padding: 24px 16px; }
  .login-card h1 { font-size: 18px; }
}

/* ===== SAFE AREA (notch) ===== */
@supports (padding: max(env(safe-area-inset-top), 0px)) {
  .topbar { padding-top: max(0px, env(safe-area-inset-top)); }
  .sidebar-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .modal-footer { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .toast { top: max(10px, env(safe-area-inset-top)); }
}
