:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --surface: #ffffff;
  --bg: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --green: #059669;
  --green-light: #d1fae5;
  --red: #dc2626;
  --red-light: #fee2e2;
  --orange: #d97706;
  --orange-light: #fef3c7;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

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

.hidden { display: none !important; }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-container {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 48px 40px;
  width: 400px;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0,0,0,0.5);
}
.login-logo { font-size: 56px; margin-bottom: 12px; animation: bounce 2s infinite; display:flex; justify-content:center; align-items:center; }
.login-logo img { animation: bounce 2s infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.login-title { font-size: 24px; font-weight: 800; color: white; margin-bottom: 4px; }
.login-subtitle { color: rgba(255,255,255,0.5); font-size: 12px; margin-bottom: 28px; }
.login-role-tabs { display: flex; gap: 8px; margin-bottom: 28px; }
.role-tab {
  flex: 1; padding: 10px 8px; border: 1px solid rgba(255,255,255,0.2);
  background: transparent; color: rgba(255,255,255,0.6);
  border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 600; transition: all 0.2s;
}
.role-tab.active { background: var(--primary); border-color: var(--primary); color: white; }
.role-tab:hover:not(.active) { background: rgba(255,255,255,0.1); color: white; }
.pin-label { color: rgba(255,255,255,0.6); font-size: 12px; margin-bottom: 12px; }
.pin-display {
  font-size: 32px; letter-spacing: 12px; color: white; margin-bottom: 24px;
  font-weight: 700; min-height: 44px;
}
/* Placeholder state — no letter-spacing so Chinese/text renders normally */
.pin-display.pin-empty {
  font-size: 14px; letter-spacing: 0.5px; color: rgba(255,255,255,0.4);
  font-weight: 400; font-style: italic;
}
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.pin-btn {
  padding: 16px; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px; color: white; font-size: 20px; font-weight: 600; cursor: pointer; transition: all 0.15s;
}
.pin-btn:hover { background: rgba(255,255,255,0.2); transform: scale(1.05); }
.pin-btn:active { transform: scale(0.95); }
.pin-clear { color: #f87171; }
.pin-enter { background: var(--primary) !important; border-color: var(--primary) !important; color: white; }
.pin-enter:hover { background: var(--primary-dark) !important; }
.login-hint { color: rgba(255,255,255,0.35); font-size: 11px; margin-top: 8px; }

/* ===== APP LAYOUT ===== */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
  width: 240px; background: var(--sidebar-bg); display: flex; flex-direction: column;
  flex-shrink: 0; transition: width 0.3s; overflow: hidden; z-index: 50;
}
.sidebar.collapsed { width: 64px; }
.sidebar-header {
  padding: 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08); min-height: 64px;
}
.sidebar-logo { font-size: 28px; flex-shrink: 0; }
.sidebar-info { flex: 1; overflow: hidden; }
.sidebar-title { color: white; font-weight: 700; font-size: 14px; white-space: nowrap; }
.sidebar-user { color: var(--sidebar-text); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-toggle { background: none; border: none; color: var(--sidebar-text); cursor: pointer; font-size: 18px; flex-shrink: 0; padding: 4px; }
.sidebar.collapsed .sidebar-info { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 16px 8px; }
.sidebar.collapsed .sidebar-logo { display: none; }
.sidebar.collapsed .sidebar-toggle { font-size: 20px; opacity: 0.8; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; overflow-x: hidden; }
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.nav-section-label {
  color: rgba(255,255,255,0.3); font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; padding: 8px 8px 4px; white-space: nowrap; overflow: hidden;
}
.sidebar.collapsed .nav-section-label { display: none; }

.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 8px; cursor: pointer; transition: all 0.15s; margin-bottom: 2px;
  color: var(--sidebar-text); white-space: nowrap; overflow: hidden; text-decoration: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: white; }
.nav-item.active { background: var(--sidebar-active); color: white; }
.nav-item .nav-icon { font-size: 18px; flex-shrink: 0; }
.nav-item .nav-label { font-size: 13px; font-weight: 500; flex: 1; }
.nav-item .nav-badge {
  background: var(--red); color: white; border-radius: 10px;
  font-size: 10px; font-weight: 700; padding: 1px 6px; min-width: 18px; text-align: center;
}
.sidebar.collapsed .nav-label, .sidebar.collapsed .nav-badge { display: none; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-logout {
  width: 100%; padding: 10px 12px; background: none; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; color: var(--sidebar-text); cursor: pointer; font-size: 13px; transition: all 0.2s;
  white-space: nowrap; overflow: hidden; text-align: left; display: flex; align-items: center; gap: 8px;
}
.sidebar-logout:hover { background: rgba(220,38,38,0.2); color: #f87171; border-color: #f87171; }
.sidebar.collapsed .sidebar-logout span { display: none; }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  flex-shrink: 0; box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-badge {
  background: var(--primary-light); color: var(--primary); border-radius: 12px;
  padding: 2px 10px; font-size: 11px; font-weight: 700;
}
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-time { color: var(--text-muted); font-size: 13px; }
.topbar-user { font-size: 13px; font-weight: 600; background: var(--primary-light); color: var(--primary); padding: 6px 12px; border-radius: 20px; }

.content-area { flex: 1; overflow-y: auto; padding: 24px; }
.content-area::-webkit-scrollbar { width: 6px; }
.content-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== CARDS ===== */
.card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-actions { display: flex; gap: 8px; }

/* ===== KPI CARDS ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
@media(max-width:1200px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } }
.kpi-card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); padding: 20px; display: flex; align-items: flex-start; gap: 16px;
}
.kpi-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.kpi-data .kpi-value { font-size: 26px; font-weight: 800; line-height: 1; }
.kpi-data .kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.kpi-data .kpi-change { font-size: 12px; font-weight: 600; margin-top: 6px; }
.kpi-change.up { color: var(--green); }
.kpi-change.down { color: var(--red); }

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
@media(max-width:900px) { .grid-2,.grid-3,.grid-4 { grid-template-columns:1fr; } }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: 8px; border: none; cursor: pointer; font-size: 13px; font-weight: 600;
  transition: all 0.15s; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #047857; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--orange); color: white; }
.btn-warning:hover { background: #b45309; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== TABLES ===== */
.table-container { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead th { background: #f8fafc; padding: 12px 16px; text-align: left; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; }
tbody td { padding: 12px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:first-child td { border-top: none; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-green { background: var(--green-light); color: #065f46; }
.badge-red { background: var(--red-light); color: #991b1b; }
.badge-orange { background: var(--orange-light); color: #92400e; }
.badge-blue { background: var(--primary-light); color: var(--primary-dark); }
.badge-purple { background: var(--purple-light); color: #5b21b6; }
.badge-gray { background: #f1f5f9; color: var(--text-muted); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.3px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; color: var(--text); background: var(--surface); transition: border-color 0.2s;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-control option { color: var(--text); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

/* ===== POS SPECIFIC ===== */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: 16px; height: calc(100vh - 160px); }
.pos-products { display: flex; flex-direction: column; overflow: hidden; }
.pos-cart { display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); overflow: hidden; }

.category-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.cat-tab { padding: 6px 14px; border-radius: 20px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-muted); transition: all 0.15s; }
.cat-tab:hover { border-color: var(--primary); color: var(--primary); }
.cat-tab.active { background: var(--primary); border-color: var(--primary); color: white; }

.product-search { position: relative; margin-bottom: 14px; }
.product-search input { width: 100%; padding: 9px 12px 9px 36px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; }
.product-search input:focus { outline: none; border-color: var(--primary); }
.product-search .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

.products-grid { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; align-content: start; }
.products-grid::-webkit-scrollbar { width: 4px; }
.products-grid::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.product-card {
  background: var(--surface); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 14px 10px; text-align: center; cursor: pointer; transition: all 0.15s;
  position: relative;
}
.product-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(37,99,235,0.15); transform: translateY(-2px); }
.product-card:active { transform: scale(0.97); }
.product-card .p-emoji { font-size: 32px; margin-bottom: 6px; }
.product-card .p-name { font-size: 11px; font-weight: 600; color: var(--text); line-height: 1.3; margin-bottom: 4px; }
.product-card .p-price { font-size: 14px; font-weight: 800; color: var(--primary); }
.product-card .p-stock { position: absolute; top: 6px; right: 6px; background: var(--bg); border-radius: 4px; padding: 1px 5px; font-size: 10px; color: var(--text-muted); }
.product-card.out-of-stock { opacity: 0.4; cursor: not-allowed; }
.product-card.low-stock .p-stock { background: var(--orange-light); color: var(--orange); }

.cart-header { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.cart-header h3 { font-size: 15px; font-weight: 700; }
.cart-items { flex: 1; overflow-y: auto; padding: 12px; }
.cart-items::-webkit-scrollbar { width: 3px; }
.cart-item { display: flex; align-items: center; gap: 10px; padding: 10px; background: var(--bg); border-radius: 8px; margin-bottom: 8px; }
.cart-item-emoji { font-size: 20px; flex-shrink: 0; }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cart-item-price { font-size: 12px; color: var(--text-muted); }
.cart-item-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qty-btn { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.qty-btn:hover { background: var(--primary); color: white; border-color: var(--primary); }
.qty-display { font-size: 13px; font-weight: 700; min-width: 20px; text-align: center; }
.cart-item-total { font-size: 13px; font-weight: 700; color: var(--primary); min-width: 52px; text-align: right; flex-shrink: 0; }

.cart-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-muted); padding: 40px; }
.cart-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }

.cart-footer { padding: 14px 18px; border-top: 1px solid var(--border); }
.cart-discount-row { display: flex; gap: 8px; margin-bottom: 12px; }
.cart-discount-row input { flex: 1; padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.cart-summary { background: var(--bg); border-radius: 8px; padding: 12px; margin-bottom: 12px; }
.cart-summary-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.cart-summary-row.total { font-weight: 800; font-size: 18px; color: var(--text); margin-top: 8px; padding-top: 8px; border-top: 1.5px solid var(--border); margin-bottom: 0; }
.payment-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.pay-method { padding: 8px; border: 1.5px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 11px; font-weight: 600; text-align: center; transition: all 0.15s; }
.pay-method:hover { border-color: var(--primary); color: var(--primary); }
.pay-method.active { background: var(--primary); border-color: var(--primary); color: white; }

/* ===== INVENTORY ===== */
.stock-indicator { display: flex; align-items: center; gap: 8px; }
.stock-bar-wrap { flex: 1; height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.stock-bar { height: 100%; border-radius: 3px; transition: width 0.3s; }
.stock-ok .stock-bar { background: var(--green); }
.stock-low .stock-bar { background: var(--orange); }
.stock-out .stock-bar { background: var(--red); }

/* ===== DASHBOARD ===== */
.chart-container { position: relative; height: 240px; }

/* ===== MODAL ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-lg { max-width: 740px; }
.modal-xl { max-width: 980px; }

/* ===== TOAST ===== */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1e293b; color: white; padding: 12px 18px; border-radius: 10px;
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 10px; min-width: 260px; max-width: 360px;
  animation: slideIn 0.3s ease; border-left: 4px solid var(--primary);
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.warning { border-color: var(--orange); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== MISC ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-title { font-size: 18px; font-weight: 700; }
.section-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.font-bold { font-weight: 700; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-primary { color: var(--primary); }
.text-orange { color: var(--orange); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 16px; font-weight: 700; margin-bottom: 6px; }

.search-bar { display: flex; gap: 10px; margin-bottom: 16px; }
.search-bar input { flex: 1; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; }
.search-bar input:focus { outline: none; border-color: var(--primary); }
.search-bar select { padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--surface); color: var(--text); }

.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.avatar-sm { width: 28px; height: 28px; font-size: 14px; }

.progress-bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 4px; background: var(--primary); }

/* Payment modal specific */
.payment-numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.numpad-btn { padding: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; font-size: 18px; font-weight: 600; cursor: pointer; text-align: center; transition: all 0.15s; }
.numpad-btn:hover { background: var(--primary-light); color: var(--primary); }
.amount-display { background: var(--sidebar-bg); color: white; padding: 16px; border-radius: 8px; font-size: 28px; font-weight: 800; text-align: right; margin-bottom: 12px; letter-spacing: 1px; }

.receipt-modal { font-family: 'Courier New', monospace; }
.receipt-header { text-align: center; border-bottom: 2px dashed var(--border); padding-bottom: 16px; margin-bottom: 16px; }
.receipt-items { margin-bottom: 12px; }
.receipt-item { display: flex; justify-content: space-between; font-size: 13px; padding: 3px 0; }
.receipt-total { border-top: 2px dashed var(--border); padding-top: 12px; display: flex; justify-content: space-between; font-size: 16px; font-weight: 700; }
.receipt-footer { text-align: center; margin-top: 16px; font-size: 12px; color: var(--text-muted); }

.stat-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border-bottom: none; }
.stat-label { font-size: 13px; color: var(--text-muted); }
.stat-value { font-size: 14px; font-weight: 700; }

/* Top products list */
.top-product-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.top-product-item:last-child { border-bottom: none; }
.top-product-rank { width: 24px; height: 24px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.top-product-rank.gold { background: #fef3c7; color: #92400e; }
.top-product-rank.silver { background: #f1f5f9; color: var(--text-muted); }
.top-product-rank.bronze { background: #fff7ed; color: #9a3412; }
.top-product-info { flex: 1; }
.top-product-name { font-size: 13px; font-weight: 600; }
.top-product-qty { font-size: 11px; color: var(--text-muted); }
.top-product-revenue { font-size: 14px; font-weight: 700; color: var(--primary); }

/* Booking calendar */
.booking-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 10px; display: flex; gap: 14px; border-left: 4px solid var(--primary); }
.booking-card.coaching { border-color: var(--purple); }
.booking-card.sparring { border-color: var(--green); }
.booking-card.cancelled { border-color: var(--border); opacity: 0.6; }
.booking-time { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.booking-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.booking-detail { font-size: 12px; color: var(--text-muted); }

/* Alerts */
.alert { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; display: flex; align-items: flex-start; gap: 10px; }
.alert-warning { background: var(--orange-light); color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #bfdbfe; }
.alert-success { background: var(--green-light); color: #065f46; border: 1px solid #6ee7b7; }

/* ===== MUSIC PLAYER ===== */
#music-player {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9000;
  background: #0f172a; border-top: 1px solid #1e293b;
  display: flex; align-items: center; gap: 0;
  transition: transform 0.3s ease; height: 64px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
}
#music-player.minimized { transform: translateY(52px); }
#music-player.hidden-player { display: none; }

.mp-toggle { width: 64px; height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; background: #1e293b; border-right: 1px solid #334155; flex-shrink: 0; }
.mp-toggle .mp-icon { font-size: 20px; }
.mp-toggle .mp-label { font-size: 9px; color: #64748b; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }

.mp-track-info { flex: 1; padding: 0 20px; min-width: 0; }
.mp-track-title { font-size: 13px; font-weight: 600; color: #f1f5f9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-track-sub { font-size: 11px; color: #64748b; margin-top: 2px; }

.mp-controls { display: flex; align-items: center; gap: 8px; padding: 0 16px; flex-shrink: 0; }
.mp-btn { background: transparent; border: none; color: #94a3b8; cursor: pointer; font-size: 18px; width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.mp-btn:hover { background: #1e293b; color: #f1f5f9; }
.mp-btn.play-btn { background: #16a34a; color: white; font-size: 20px; }
.mp-btn.play-btn:hover { background: #15803d; transform: scale(1.05); }

.mp-progress { flex: 1; max-width: 300px; padding: 0 16px; display: flex; align-items: center; gap: 8px; }
.mp-bar { flex: 1; height: 4px; background: #1e293b; border-radius: 2px; cursor: pointer; position: relative; }
.mp-bar-fill { height: 100%; background: #16a34a; border-radius: 2px; transition: width 0.5s linear; pointer-events: none; }
.mp-time { font-size: 10px; color: #64748b; font-variant-numeric: tabular-nums; white-space: nowrap; }

.mp-volume { display: flex; align-items: center; gap: 8px; padding: 0 16px; flex-shrink: 0; }
.mp-vol-icon { font-size: 16px; color: #64748b; cursor: pointer; }
.mp-vol-slider { width: 80px; height: 4px; appearance: none; background: #1e293b; border-radius: 2px; cursor: pointer; }
.mp-vol-slider::-webkit-slider-thumb { appearance: none; width: 14px; height: 14px; border-radius: 50%; background: #16a34a; cursor: pointer; }

.mp-source-btns { display: flex; gap: 4px; padding: 0 12px; flex-shrink: 0; border-left: 1px solid #1e293b; }
.mp-source-btn { background: #1e293b; border: 1px solid #334155; color: #64748b; border-radius: 6px; padding: 4px 10px; font-size: 11px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.mp-source-btn.active { background: #16a34a; border-color: #16a34a; color: white; }

.mp-url-input { background: #1e293b; border: 1px solid #334155; color: #f1f5f9; border-radius: 6px; padding: 4px 10px; font-size: 12px; width: 220px; }
.mp-url-input::placeholder { color: #475569; }
#yt-iframe-container { display: none; position: fixed; bottom: 64px; right: 16px; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

/* Push page content up when player visible */
.app.has-music .content-area { padding-bottom: 80px; }

/* Rental card */
.rental-item { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 14px; }
.rental-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.rental-status-dot.active { background: var(--green); box-shadow: 0 0 0 3px var(--green-light); }
.rental-status-dot.overdue { background: var(--red); box-shadow: 0 0 0 3px var(--red-light); }
.rental-status-dot.returned { background: var(--text-muted); }

/* ═══════════════════════════════════════════════════════
   TOUCH / TABLET / MOBILE — Global overrides
   ═══════════════════════════════════════════════════════ */

/* ── Touch-friendly base ─────────────────────────────── */
@media (pointer: coarse), (max-width: 1024px) {
  body { font-size: 15px; }

  /* All buttons: bigger tap targets */
  .btn        { padding: 11px 20px; font-size: 14px; min-height: 44px; border-radius: 10px; }
  .btn-sm     { padding: 9px 14px;  font-size: 13px; min-height: 40px; }
  .btn-lg     { padding: 14px 28px; font-size: 16px; min-height: 52px; }

  /* Nav items: taller */
  .nav-item { padding: 13px 14px; margin-bottom: 4px; }
  .nav-item .nav-icon { font-size: 20px; }
  .nav-item .nav-label { font-size: 14px; }

  /* Inputs: bigger */
  .form-control { padding: 13px 14px; font-size: 15px; min-height: 48px; border-radius: 10px; }
  .search-bar input, .product-search input { padding: 12px 14px; font-size: 15px; min-height: 48px; }

  /* Table cells: bigger */
  thead th   { padding: 14px 14px; font-size: 13px; }
  tbody td   { padding: 14px 14px; font-size: 14px; }

  /* Cart qty buttons */
  .qty-btn { width: 36px; height: 36px; font-size: 18px; border-radius: 8px; }
  .qty-display { font-size: 15px; }

  /* Category tabs */
  .cat-tab { padding: 9px 18px; font-size: 13px; min-height: 40px; }

  /* Product cards: bigger emoji & tap area */
  .product-card { padding: 18px 12px; border-radius: 12px; }
  .product-card .p-emoji { font-size: 38px; margin-bottom: 8px; }
  .product-card .p-name  { font-size: 12px; }
  .product-card .p-price { font-size: 16px; }

  /* Content padding */
  .content-area { padding: 16px; }
  .topbar       { padding: 0 16px; }

  /* Modal */
  .modal { border-radius: 18px; }
  .modal-body { padding: 20px 18px; }

  /* KPI grid: 2 cols on tablet */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }

  /* Stat cards */
  .stat-card { padding: 18px; border-radius: 14px; }
}

/* ── Phone (narrow) ──────────────────────────────────── */
@media (max-width: 640px) {
  .kpi-grid  { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .topbar-time { display: none; }
  .page-header { flex-wrap: wrap; gap: 10px; }

  /* POS goes single column on phone */
  .pos-layout { grid-template-columns: 1fr; height: auto; }
  .pos-cart   { max-height: 420px; }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-bottom-left-radius: 0; border-bottom-right-radius: 0; max-height: 92vh; }
}

/* ── Sidebar: overlay on mobile/tablet ───────────────── */
/* Overlay backdrop */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  z-index: 40; backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
.sidebar-overlay.visible { display: block; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

@media (max-width: 1024px) {
  /* Sidebar slides over content rather than pushing it */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh;
    transform: translateX(0);
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    width: 260px !important; /* always full width when open */
    transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    width: 260px !important; /* don't collapse to 64px on mobile */
  }
  /* Always show all sidebar text on mobile (no icon-only mode) */
  .sidebar.collapsed .sidebar-info,
  .sidebar.collapsed .sidebar-logo,
  .sidebar.collapsed .sidebar-toggle,
  .sidebar.collapsed .nav-section-label,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-badge,
  .sidebar.collapsed .sidebar-logout span { display: unset !important; }
  .sidebar.collapsed .sidebar-header { justify-content: unset; padding: 16px; }

  /* Main content fills full width */
  .main-content { width: 100%; }

  /* Hamburger button in topbar */
  .mobile-menu-btn { display: flex !important; }
}

@media (min-width: 1025px) {
  .mobile-menu-btn { display: none !important; }
  .sidebar-overlay { display: none !important; }
}

/* Hamburger button (hidden on desktop) */
.mobile-menu-btn {
  display: none;
  align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
  cursor: pointer; font-size: 20px; color: var(--text);
  margin-right: 8px; flex-shrink: 0;
  transition: background 0.15s;
}
.mobile-menu-btn:hover { background: var(--border); }

/* ══════════════════════════════════════════════════════
   STOCK CHECK — Webapp card layout (moved from inline)
   ══════════════════════════════════════════════════════ */

.sc-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px; margin-top: 16px;
}
.sc-hist-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px; cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}
.sc-hist-card:hover  { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.sc-hist-card:active { transform: scale(0.98); }
.sc-hist-card .sc-hc-no   { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.sc-hist-card .sc-hc-date { font-size: 12px; color: var(--text-muted); }
.sc-hist-card .sc-hc-by   { font-size: 14px; font-weight: 600; margin: 8px 0 10px; }
.sc-hist-card .sc-hc-bar  { height: 6px; border-radius: 99px; background: var(--border); overflow: hidden; margin-bottom: 8px; }
.sc-hist-card .sc-hc-fill { height: 100%; border-radius: 99px; background: #22c55e; }
.sc-hist-card .sc-hc-stats { display: flex; gap: 8px; font-size: 12px; }
.sc-hist-card .sc-hc-disc  { color: #ef4444; font-weight: 700; }

.sc-start-banner {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border-radius: 16px; padding: 28px 24px; margin-bottom: 20px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
.sc-start-banner h2 { color: white; font-size: 20px; margin: 0 0 4px; font-weight: 800; }
.sc-start-banner p  { color: rgba(255,255,255,0.75); font-size: 13px; margin: 0; }
.sc-start-btn {
  background: white; color: #2563eb; font-weight: 700;
  padding: 12px 24px; border-radius: 12px; border: none; cursor: pointer;
  font-size: 15px; white-space: nowrap; min-height: 48px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.sc-start-btn:hover  { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.sc-start-btn:active { transform: scale(0.97); }

/* ─ Active check form ─ */
.sc-sticky-top {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg); padding: 12px 0 8px;
  border-bottom: 1px solid var(--border); margin-bottom: 16px;
}
.sc-progress-bar  { height: 10px; border-radius: 99px; background: var(--border); overflow: hidden; margin-top: 8px; }
.sc-progress-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #2563eb, #7c3aed); transition: width 0.3s; }

.sc-search-filter { display: flex; gap: 8px; margin-top: 10px; }
.sc-search-filter input {
  flex: 1; padding: 10px 14px; font-size: 14px;
  border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); min-height: 44px;
}
.sc-search-filter input:focus { outline: none; border-color: var(--primary); }

/* Product count cards grid */
.sc-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 cols on phone */
  gap: 12px;
  padding-bottom: 100px; /* room for FAB */
}
@media (min-width: 600px)  { .sc-cards-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px)  { .sc-cards-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .sc-cards-grid { grid-template-columns: repeat(5, 1fr); } }

.sc-item-card {
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px;
  padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color 0.2s, background 0.2s;
}
.sc-item-card.counted { border-color: #22c55e; background: rgba(34,197,94,0.05); }
.sc-item-card .sc-ic-emoji { font-size: 36px; }
.sc-item-card .sc-ic-name  { font-size: 13px; font-weight: 700; text-align: center; color: var(--text); line-height: 1.3; }
.sc-item-card .sc-ic-unit  { font-size: 11px; color: var(--text-muted); }

/* Stepper */
.sc-stepper { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.sc-stepper button {
  width: 36px; height: 36px; border: none; border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: 20px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s; user-select: none; touch-action: manipulation;
}
.sc-stepper button:hover  { background: var(--primary); color: white; }
.sc-stepper button:active { transform: scale(0.92); }
.sc-stepper input {
  width: 52px; text-align: center; font-size: 17px; font-weight: 800;
  padding: 4px 2px; border: 2px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); min-height: 36px;
}
.sc-stepper input:focus { border-color: var(--primary); outline: none; }

/* Floating submit button */
.sc-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 100;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: white; border: none; border-radius: 16px;
  padding: 16px 32px; font-size: 16px; font-weight: 700;
  cursor: pointer; box-shadow: 0 8px 24px rgba(37,99,235,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  touch-action: manipulation;
}
.sc-fab:hover  { box-shadow: 0 12px 32px rgba(37,99,235,0.5); }
.sc-fab:active { transform: scale(0.97); }

/* Result cards */
.sc-result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-top: 16px;
}
@media (min-width: 600px)  { .sc-result-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px)  { .sc-result-grid { grid-template-columns: repeat(4, 1fr); } }

.sc-res-card { border-radius: 14px; padding: 16px; border: 2px solid; }
.sc-res-card.ok   { border-color: #bbf7d0; background: #f0fdf4; }
.sc-res-card.low  { border-color: #fecaca; background: #fff5f5; }
.sc-res-card.high { border-color: #fed7aa; background: #fffbeb; }
.sc-res-card.skip { border-color: var(--border); background: var(--bg); opacity: 0.55; }
.sc-res-card .sc-rc-emoji { font-size: 30px; margin-bottom: 6px; }
.sc-res-card .sc-rc-name  { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 8px; line-height: 1.3; }
.sc-res-card .sc-rc-diff  { font-size: 22px; font-weight: 900; margin: 4px 0; }
.sc-res-card .sc-rc-nums  { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); flex-wrap: wrap; gap: 2px; }

/* ─ Supplier tap-to-check cards ─ */
.sup-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
@media (min-width: 600px)  { .sup-cards-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px)  { .sup-cards-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .sup-cards-grid { grid-template-columns: repeat(5, 1fr); } }

.sup-item-card {
  background: var(--surface); border: 2px solid var(--border); border-radius: 16px;
  padding: 22px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  cursor: pointer; transition: border-color 0.2s, background 0.2s, transform 0.1s;
  user-select: none; touch-action: manipulation;
}
.sup-item-card:active { transform: scale(0.96); }
.sup-item-card.checked { border-color: #22c55e; background: rgba(34,197,94,0.06); }
.sup-item-card .sup-ic-emoji { font-size: 40px; }
.sup-item-card .sup-ic-name  { font-size: 13px; font-weight: 700; text-align: center; line-height: 1.3; }
.sup-item-card .sup-ic-qty   { font-size: 26px; font-weight: 900; color: var(--primary); }
.sup-item-card .sup-ic-unit  { font-size: 11px; color: var(--text-muted); }
.sup-item-card .sup-ic-chk   { font-size: 28px; margin-top: 4px; }
