/* ===== Reset & Base ===== */
*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{font-size:13px;-webkit-text-size-adjust:100%;scroll-behavior:smooth}
body{font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,'Helvetica Neue',Arial,'Noto Sans SC',sans-serif;
  color:#1e293b;background:#f1f5f9;line-height:1.5;min-height:100vh}
a{color:inherit;text-decoration:none}
button{cursor:pointer;border:none;background:none;font:inherit}
input,select,textarea{font:inherit;border:1px solid #cbd5e1;border-radius:6px;padding:6px 10px;width:100%;outline:none;transition:border .2s}
input:focus,select:focus,textarea:focus{border-color:#3b82f6;box-shadow:0 0 0 2px rgba(59,130,246,.12)}
img{max-width:100%;display:block}
::-webkit-scrollbar{width:5px;height:5px}
::-webkit-scrollbar-thumb{background:#cbd5e1;border-radius:3px}

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

/* ===== Sidebar ===== */
.sidebar{width:220px;background:#fff;border-right:1px solid #e2e8f0;display:flex;flex-direction:column;position:fixed;top:0;left:0;bottom:0;z-index:50;overflow-y:auto;transition:transform .25s}
.sidebar-header{padding:12px 14px;border-bottom:1px solid #e2e8f0;display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;background:#fff;z-index:2}
.sidebar-logo{display:flex;align-items:center;gap:6px;font-size:14px;font-weight:700;color:#0f172a}
.sidebar-logo svg{width:20px;height:20px;color:#3b82f6}
.sidebar-close{display:none;width:28px;height:28px;align-items:center;justify-content:center;border-radius:6px;color:#94a3b8}
.sidebar-close:hover{background:#f1f5f9}
.sidebar-nav{padding:8px 0;flex:1}
.nav-group{margin-bottom:2px}
.nav-group-title{padding:6px 14px 3px;font-size:10px;font-weight:600;color:#94a3b8;text-transform:uppercase;letter-spacing:.5px}
.nav-item{display:flex;align-items:center;gap:8px;padding:7px 14px;font-size:12px;color:#475569;cursor:pointer;transition:all .15s;border-left:3px solid transparent}
.nav-item:hover{background:#f8fafc;color:#1e293b}
.nav-item.active{background:#eff6ff;color:#2563eb;border-left-color:#3b82f6;font-weight:600}
.nav-item svg{width:15px;height:15px;flex-shrink:0;opacity:.7}
.nav-item.active svg{opacity:1}
.nav-item .badge{margin-left:auto;font-size:10px;background:#e2e8f0;color:#64748b;padding:1px 6px;border-radius:8px;font-weight:500}
.nav-item.active .badge{background:#dbeafe;color:#2563eb}
.sidebar-footer{padding:10px 14px;border-top:1px solid #e2e8f0;font-size:11px;color:#94a3b8;text-align:center}
.sidebar-footer a{color:#3b82f6}

/* ===== Main Area ===== */
.main{flex:1;margin-left:220px;display:flex;flex-direction:column;min-height:100vh}

/* ===== Top Bar ===== */
.topbar{background:#fff;border-bottom:1px solid #e2e8f0;padding:0 20px;height:44px;display:flex;align-items:center;justify-content:space-between;position:sticky;top:0;z-index:40}
.topbar-left{display:flex;align-items:center;gap:10px}
.menu-toggle{display:none;width:32px;height:32px;align-items:center;justify-content:center;border-radius:6px;color:#475569}
.menu-toggle:hover{background:#f1f5f9}
.topbar-title{font-size:13px;font-weight:600;color:#0f172a}
.topbar-right{display:flex;align-items:center;gap:10px}
.lang-btn{font-size:11px;color:#64748b;padding:3px 10px;border:1px solid #e2e8f0;border-radius:4px;transition:all .15s;cursor:pointer}
.lang-btn:hover{border-color:#3b82f6;color:#3b82f6}

/* ===== Info Banner ===== */
.info-banner{background:#eff6ff;border:1px solid #bfdbfe;border-radius:8px;padding:10px 14px;margin:12px 20px 0;font-size:11px;color:#1e40af;line-height:1.5}
.info-banner b{font-weight:600}

/* ===== Search Bar ===== */
.search-section{padding:10px 20px 0}
.search-bar{position:relative}
.search-bar input{padding-left:32px;font-size:12px;background:#fff;height:36px}
.search-bar svg{position:absolute;left:10px;top:50%;transform:translateY(-50%);width:14px;height:14px;color:#94a3b8}

/* ===== Sub Tabs (二级分类) ===== */
.sub-tabs{display:flex;gap:6px;padding:10px 20px 0;overflow-x:auto;-webkit-overflow-scrolling:touch;scrollbar-width:none;flex-wrap:wrap}
.sub-tabs::-webkit-scrollbar{display:none}
.sub-tab{flex-shrink:0;padding:4px 12px;font-size:11px;font-weight:500;border-radius:14px;border:1px solid #e2e8f0;color:#64748b;transition:all .15s;white-space:nowrap;cursor:pointer}
.sub-tab:hover{border-color:#93c5fd;color:#3b82f6}
.sub-tab.active{background:#3b82f6;color:#fff;border-color:#3b82f6}

/* ===== Product List ===== */
.product-section{padding:10px 20px 20px;flex:1}
.product-list{background:#fff;border:1px solid #e2e8f0;border-radius:8px;overflow:hidden}
.product-list-header{display:grid;grid-template-columns:1fr 90px 90px 90px;padding:8px 14px;background:#f8fafc;border-bottom:1px solid #e2e8f0;font-size:10px;font-weight:600;color:#94a3b8;text-transform:uppercase;letter-spacing:.3px}
.product-row{display:grid;grid-template-columns:1fr 90px 90px 90px;padding:9px 14px;border-bottom:1px solid #f1f5f9;align-items:center;transition:background .1s;font-size:12px}
.product-row:last-child{border-bottom:none}
.product-row:hover{background:#f8fafc}
.product-name{display:flex;align-items:center;gap:8px;min-width:0}
.product-flag{flex-shrink:0;width:26px;height:26px;border-radius:50%;background:#e2e8f0;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;color:#475569;letter-spacing:-.5px}
.product-info{min-width:0}
.product-title{font-weight:500;color:#1e293b;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.product-desc{font-size:10px;color:#94a3b8;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.product-stock{font-size:11px;color:#475569;text-align:center}
.stock-num{font-weight:600}
.stock-ok{color:#16a34a}
.stock-low{color:#f59e0b}
.stock-out{color:#ef4444}
.product-price{font-size:12px;font-weight:700;color:#0f172a;text-align:center}
.product-price .unit{font-size:9px;font-weight:400;color:#94a3b8}
.product-action{text-align:center}
.btn-buy{display:inline-flex;align-items:center;gap:4px;padding:5px 14px;background:#3b82f6;color:#fff;font-size:11px;font-weight:600;border-radius:5px;transition:background .15s;white-space:nowrap}
.btn-buy:hover{background:#2563eb}
.btn-buy:disabled,.btn-buy.disabled{background:#e2e8f0;color:#94a3b8;cursor:not-allowed}
.btn-buy svg{width:12px;height:12px}

/* Badge in product name */
.p-badge{font-size:9px;padding:1px 5px;border-radius:3px;font-weight:600;flex-shrink:0;margin-left:4px}
.p-badge-hot{background:#fef2f2;color:#ef4444}
.p-badge-new{background:#eff6ff;color:#3b82f6}
.p-badge-sale{background:#f0fdf4;color:#16a34a}

/* ===== Empty State ===== */
.empty-state{text-align:center;padding:40px 20px;color:#94a3b8;font-size:12px}

/* ===== Order Modal ===== */
.modal-overlay{position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:200;display:flex;align-items:center;justify-content:center;padding:16px;opacity:0;pointer-events:none;transition:opacity .2s}
.modal-overlay.show{opacity:1;pointer-events:auto}
.modal-box{background:#fff;border-radius:10px;width:100%;max-width:420px;max-height:90vh;overflow-y:auto;transform:translateY(16px);transition:transform .2s}
.modal-overlay.show .modal-box{transform:translateY(0)}
.modal-header{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid #f1f5f9}
.modal-header h3{font-size:14px;font-weight:700;color:#0f172a}
.modal-close{width:28px;height:28px;display:flex;align-items:center;justify-content:center;border-radius:6px;color:#94a3b8;transition:background .15s}
.modal-close:hover{background:#f1f5f9;color:#475569}
.modal-body{padding:14px 16px}
.form-group{margin-bottom:10px}
.form-group label{display:block;font-size:11px;font-weight:600;color:#475569;margin-bottom:3px}
.form-group .req{color:#ef4444}
.form-group input,.form-group select,.form-group textarea{font-size:12px}
.form-group textarea{resize:vertical;min-height:44px}
.form-hint{font-size:10px;color:#94a3b8;margin-top:2px}
.order-summary{background:#f8fafc;border:1px solid #e2e8f0;border-radius:6px;padding:10px 12px;margin-bottom:10px}
.order-summary .row{display:flex;justify-content:space-between;font-size:11px;color:#475569;padding:2px 0}
.order-summary .row.total{font-weight:700;color:#0f172a;font-size:12px;border-top:1px solid #e2e8f0;margin-top:4px;padding-top:6px}
.contact-method{display:flex;gap:6px;margin-bottom:4px;flex-wrap:wrap}
.contact-method label{display:inline-flex;align-items:center;gap:4px;font-size:11px;color:#475569;cursor:pointer;padding:3px 8px;border:1px solid #e2e8f0;border-radius:4px;transition:all .15s}
.contact-method label:hover{border-color:#93c5fd}
.contact-method input[type=radio]{display:none}
.contact-method input[type=radio]:checked+label{background:#eff6ff;border-color:#3b82f6;color:#2563eb;font-weight:600}
.qty-row{display:flex;align-items:center;gap:8px}
.qty-stepper{display:flex;align-items:center;border:1px solid #cbd5e1;border-radius:5px;overflow:hidden}
.qty-stepper button{width:28px;height:28px;display:flex;align-items:center;justify-content:center;font-size:13px;color:#475569;background:#f8fafc;transition:background .1s}
.qty-stepper button:hover{background:#e2e8f0}
.qty-stepper input{width:36px;text-align:center;border:none;border-left:1px solid #cbd5e1;border-right:1px solid #cbd5e1;border-radius:0;padding:3px 0;font-size:12px}
.qty-stepper input:focus{box-shadow:none}
.form-agree{display:flex;align-items:flex-start;gap:6px;font-size:11px;color:#64748b;margin:10px 0}
.form-agree input[type=checkbox]{width:auto;margin-top:1px;accent-color:#3b82f6}
.btn-submit{width:100%;padding:9px 0;background:#3b82f6;color:#fff;font-size:12px;font-weight:600;border-radius:6px;transition:background .15s}
.btn-submit:hover{background:#2563eb}
.btn-submit:disabled{background:#cbd5e1;color:#94a3b8;cursor:not-allowed}

/* ===== Toast ===== */
.toast{position:fixed;top:52px;left:50%;transform:translateX(-50%) translateY(-16px);background:#1e293b;color:#fff;font-size:11px;padding:7px 16px;border-radius:6px;z-index:300;opacity:0;transition:all .25s;pointer-events:none;white-space:nowrap}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0)}
.toast.error{background:#ef4444}
.toast.success{background:#16a34a}

/* ===== Footer ===== */
.app-footer{text-align:center;padding:12px 20px;font-size:10px;color:#94a3b8;border-top:1px solid #e2e8f0;background:#fff;margin-top:auto}

/* ===== Mobile ===== */
@media(max-width:768px){
  .sidebar{transform:translateX(-100%)}
  .sidebar.open{transform:translateX(0)}
  .sidebar-close{display:flex}
  .main{margin-left:0}
  .menu-toggle{display:flex}
  .product-list-header{grid-template-columns:1fr 60px 70px 70px;padding:6px 10px;font-size:9px}
  .product-row{grid-template-columns:1fr 60px 70px 70px;padding:7px 10px;font-size:11px}
  .product-flag{font-size:13px;width:18px}
  .product-price{font-size:11px}
  .btn-buy{padding:4px 10px;font-size:10px}
  .btn-buy span.buy-text{display:none}
  .info-banner{margin:8px 12px 0}
  .search-section{padding:8px 12px 0}
  .sub-tabs{padding:8px 12px 0}
  .product-section{padding:8px 12px 12px}
  .topbar{padding:0 12px}
}
@media(max-width:480px){
  .product-list-header{grid-template-columns:1fr 70px 60px}
  .product-row{grid-template-columns:1fr 70px 60px}
  .product-list-header .hide-xs,.product-row .product-stock{display:none}
}

/* ===== Overlay (mobile sidebar bg) ===== */
.sidebar-overlay{position:fixed;inset:0;background:rgba(0,0,0,.3);z-index:45;opacity:0;pointer-events:none;transition:opacity .2s}
.sidebar-overlay.show{opacity:1;pointer-events:auto}

/* ===== Animations ===== */
@keyframes fadeIn{from{opacity:0}to{opacity:1}}
.product-row{animation:fadeIn .2s ease both}

/* ===== 后台可选模板风格 =====
   同一套经过测试的页面渲染所有模板，避免“后台建了模板但服务器没目录”的断链；
   只通过 data-template-style 改视觉，不复制 JS、不产生多套业务逻辑。 */
html[data-template-style="dark"] { color-scheme: dark; }
html[data-template-style="dark"] body { color:#e2e8f0; background:#0f172a; }
html[data-template-style="dark"] .sidebar,
html[data-template-style="dark"] .sidebar-header,
html[data-template-style="dark"] .topbar,
html[data-template-style="dark"] .product-list,
html[data-template-style="dark"] .modal-box,
html[data-template-style="dark"] .app-footer { background:#1e293b; border-color:#334155; }
html[data-template-style="dark"] .sidebar-logo,
html[data-template-style="dark"] .topbar-title,
html[data-template-style="dark"] .product-title,
html[data-template-style="dark"] .product-price,
html[data-template-style="dark"] .modal-header h3,
html[data-template-style="dark"] .order-summary .row.total { color:#f8fafc; }
html[data-template-style="dark"] .nav-item,
html[data-template-style="dark"] .product-stock,
html[data-template-style="dark"] .form-group label,
html[data-template-style="dark"] .order-summary .row,
html[data-template-style="dark"] .contact-method label,
html[data-template-style="dark"] .form-agree { color:#cbd5e1; }
html[data-template-style="dark"] .nav-item:hover,
html[data-template-style="dark"] .product-row:hover,
html[data-template-style="dark"] .product-list-header,
html[data-template-style="dark"] .order-summary,
html[data-template-style="dark"] .qty-stepper button { background:#0f172a; }
html[data-template-style="dark"] .nav-item.active,
html[data-template-style="dark"] .contact-method input[type=radio]:checked+label,
html[data-template-style="dark"] .info-banner { background:#172554; border-color:#1d4ed8; color:#bfdbfe; }
html[data-template-style="dark"] .product-row,
html[data-template-style="dark"] .product-list-header,
html[data-template-style="dark"] .modal-header,
html[data-template-style="dark"] .order-summary,
html[data-template-style="dark"] .app-footer,
html[data-template-style="dark"] .sidebar-footer { border-color:#334155; }
html[data-template-style="dark"] input,
html[data-template-style="dark"] select,
html[data-template-style="dark"] textarea,
html[data-template-style="dark"] .search-bar input { background:#0f172a; border-color:#475569; color:#f8fafc; }
html[data-template-style="dark"] .modal-overlay { background:rgba(2,6,23,.78); }

/* 极简：隐藏非核心装饰，内容居中；商品与下单流程完全不变。 */
html[data-template-style="minimal"] body { background:#fff; }
html[data-template-style="minimal"] .sidebar,
html[data-template-style="minimal"] .sidebar-overlay,
html[data-template-style="minimal"] .info-banner,
html[data-template-style="minimal"] .app-footer { display:none; }
html[data-template-style="minimal"] .main { margin-left:0; max-width:960px; width:100%; margin-right:auto; }
html[data-template-style="minimal"] .menu-toggle { display:none; }
html[data-template-style="minimal"] .topbar { position:static; box-shadow:none; }
html[data-template-style="minimal"] .product-list { border-radius:12px; box-shadow:0 4px 18px rgba(15,23,42,.06); }
