* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif; background: #f5f5f5; color: #1a1a1a; font-size: 14px; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
button { cursor: pointer; }

/* ===== ADMIN LAYOUT ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 180px; background: #fff; border-right: 1px solid #eee; display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { padding: 16px 14px; font-weight: 600; font-size: 15px; color: #1D9E75; border-bottom: 1px solid #f0f0f0; }
.nav { display: flex; flex-direction: column; flex: 1; padding: 8px 0; }
.nav button { text-align: left; padding: 10px 14px; border: none; background: none; color: #444; font-size: 14px; border-left: 3px solid transparent; transition: all 0.15s; }
.nav button:hover { background: #f5f5f5; }
.nav button.active { background: #E1F5EE; color: #0F6E56; border-left-color: #1D9E75; font-weight: 500; }
.nav-logout { padding: 14px; border-top: 1px solid #f0f0f0; }
.nav-logout button { width: 100%; padding: 8px; border: 1px solid #ddd; border-radius: 6px; background: #fff; color: #666; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; background: #fff; border-bottom: 1px solid #eee; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.mobile-logout-btn, .mobile-admin-nav { display: none; }
.mobile-admin-nav { background: #fff; border-bottom: 1px solid #eee; padding: 8px 10px; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mobile-admin-nav::-webkit-scrollbar { display: none; }
.mobile-admin-nav button { flex: 0 0 auto; border: 1px solid #e8e8e8; border-radius: 999px; background: #fff; color: #444; padding: 7px 12px; font-size: 13px; white-space: nowrap; }
.mobile-admin-nav button.active { background: #1D9E75; border-color: #1D9E75; color: #fff; }
.mobile-admin-nav button.mobile-nav-logout { color: #E24B4A; border-color: #F3B5B5; background: #FFF7F7; }

.topbar h2 { font-size: 17px; font-weight: 600; }
.hint { color: #888; font-size: 12px; margin-top: 2px; }
.content { flex: 1; padding: 20px; overflow-y: auto; }
.card { background: #fff; border-radius: 8px; border: 1px solid #eee; padding: 16px; margin-bottom: 14px; }

/* ===== ADMIN COMPONENTS ===== */
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar-wrap { flex-wrap: wrap; }
.product-filters input { flex: 0 0 200px; width: 200px; }
.product-filters select { flex: 0 0 140px; width: 140px; }
button { padding: 7px 14px; border-radius: 6px; border: 1px solid #1D9E75; background: #1D9E75; color: #fff; font-weight: 500; transition: all 0.15s; }
button:hover { opacity: 0.88; }
button.secondary { background: #fff; color: #444; border-color: #ddd; font-weight: 400; }
button.secondary:hover { background: #f5f5f5; }
button.danger { background: #fff; color: #E24B4A; border-color: #E24B4A; }
button.danger:hover { background: #FFF0F0; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 6px; outline: none; background: #fff; transition: border-color 0.15s; }
input:focus, select:focus, textarea:focus { border-color: #1D9E75; }
label { display: block; font-size: 12px; color: #888; margin-bottom: 4px; }
.form-grid { display: flex; flex-direction: column; gap: 12px; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.stats { grid-template-columns: repeat(4, 1fr); }
.stat { text-align: center; }
.stat .num { font-size: 28px; font-weight: 700; color: #1D9E75; margin-top: 4px; }
.table-wrap { overflow-x: auto; border: 1px solid #eee; border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { background: #F8F8F8; }
th { padding: 10px 12px; text-align: left; font-weight: 500; color: #666; white-space: nowrap; }
td { padding: 10px 12px; border-top: 1px solid #f5f5f5; vertical-align: middle; }
.row-actions { display: flex; gap: 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; background: #E1F5EE; color: #0F6E56; }
.badge.warn { background: #FFF3EE; color: #C0392B; }
.badge.gray { background: #f0f0f0; color: #888; }
.error { color: #E24B4A; background: #FFF0F0; border: 1px solid #FDD; border-radius: 6px; padding: 10px 14px; margin-bottom: 12px; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin-bottom: 14px; font-size: 16px; }
.modal .toolbar { margin-top: 16px; justify-content: flex-end; }
.export-choice-list { display: grid; gap: 10px; }
.export-choice-list button { width: 100%; min-height: 68px; text-align: left; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; background: #fff; color: #1a1a1a; border-color: #dcdcdc; }
.export-choice-list button:hover:not(:disabled) { border-color: #1D9E75; background: #F2FBF7; opacity: 1; }
.export-choice-list span { font-size: 15px; font-weight: 600; }
.export-choice-list small { font-size: 12px; color: #888; }
.product-img { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; display: block; }
.product-avatar { width: 46px; height: 46px; border-radius: 8px; background: #1D9E75; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; flex-shrink: 0; }
.th-btn { background: none; border: none; color: #666; font-weight: 500; padding: 0; font-size: 13px; cursor: pointer; }
.order-builder { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-height: 360px; }
.product-list { overflow-y: auto; border: 1px solid #eee; border-radius: 6px; max-height: 300px; }
.product-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; border-bottom: 1px solid #f5f5f5; }
.cart-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f5f5f5; }
.login { display: flex; justify-content: center; align-items: center; min-height: 100vh; }
.login-card { max-width: 380px; width: 100%; text-align: center; }
.login-card h1 { font-size: 22px; color: #1D9E75; margin-bottom: 8px; }

/* ===== PURCHASE PANEL ===== */
.purchase-layout { display: flex; height: calc(100vh - 110px); gap: 0; background: #fff; border-radius: 8px; border: 1px solid #eee; overflow: hidden; }
.purchase-order-list { width: 280px; border-right: 1px solid #eee; overflow-y: auto; flex-shrink: 0; }
.purchase-order-item { padding: 12px 14px; border-bottom: 1px solid #f5f5f5; cursor: pointer; }
.purchase-order-item:hover { background: #f9f9f9; }
.purchase-order-item.active { background: #E1F5EE; }
.purchase-detail { flex: 1; overflow-y: auto; }
.purchase-detail-header { padding: 14px 16px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: flex-start; position: sticky; top: 0; background: #fff; z-index: 1; }
.purchase-item-row { display: flex; align-items: center; padding: 10px 16px; border-bottom: 1px solid #f5f5f5; gap: 10px; }
.purchase-selection-bar { padding: 10px 12px; font-size: 13px; color: #666; border-bottom: 1px solid #eee; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.purchase-selection-bar button { padding: 4px 8px; font-size: 12px; }
.purchase-selected-count { color: #1D9E75; font-weight: 600; margin-left: auto; }
.purchase-store-check { display: flex; align-items: center; gap: 7px; cursor: pointer; min-width: 0; }
.purchase-store-check input { width: 17px; height: 17px; accent-color: #1D9E75; flex-shrink: 0; }

/* ===== STORE MOBILE UI ===== */
.store-page { display: flex; flex-direction: column; height: 100vh; max-width: 480px; margin: 0 auto; background: #F5F5F5; position: relative; overflow: hidden; }
.store-header { background: #1D9E75; padding: 10px 14px 12px; flex-shrink: 0; }
.store-header-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.store-user-info { min-width: 0; color: #fff; }
.store-name-text { font-size: 15px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-user-name { margin-top: 2px; font-size: 12px; color: rgba(255,255,255,0.86); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-header-actions { display: flex; gap: 7px; align-items: center; }
.store-deadline { font-size: 12px; padding: 3px 8px; border-radius: 12px; color: #fff; background: rgba(255,255,255,0.18); }
.store-deadline.warn { background: rgba(220,60,20,0.35); }
.store-top-btn { background: rgba(255,255,255,0.2); border: none; color: #fff; border-radius: 7px; padding: 4px 10px; font-size: 12px; }
.store-search-bar { background: #fff; border-radius: 10px; display: flex; align-items: center; padding: 8px 12px; gap: 8px; }
.store-search-bar span { font-size: 16px; }
.store-search-input { flex: 1; border: none; outline: none; font-size: 14px; background: transparent; }
.store-clear-btn { background: none; border: none; color: #bbb; padding: 0; font-size: 14px; }
.store-clear-btn[hidden], .store-tabs[hidden] { display: none; }
.store-search-status { flex-shrink: 0; padding: 7px 14px; background: #F5F5F5; color: #777; font-size: 12px; border-bottom: 1px solid #eee; }
.store-tabs { display: flex; background: #fff; border-bottom: 1px solid #eee; flex-shrink: 0; }
.store-tab { flex: 1; text-align: center; padding: 11px 4px; font-size: 13px; color: #666; cursor: pointer; border-bottom: 2px solid transparent; border-radius: 0; background: none; }
.store-tab.active { color: #1D9E75; border-bottom-color: #1D9E75; font-weight: 500; }
.store-content { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.store-product-list { flex: 1; overflow-y: auto; background: #fff; }
.store-product-row { display: flex; align-items: center; padding: 11px 14px; border-bottom: 1px solid #F5F5F5; gap: 10px; background: #fff; }
.store-product-img { width: 46px; height: 46px; border-radius: 8px; background: #F5F5F5; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }
.store-product-img img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.store-product-avatar { width: 46px; height: 46px; border-radius: 8px; background: #1D9E75; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; }
.store-product-name { font-size: 14px; font-weight: 500; color: #1A1A1A; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.store-product-spec { font-size: 11px; color: #999; margin-top: 2px; }
.store-product-price { font-size: 14px; color: #D85A30; font-weight: 500; margin-top: 3px; }
.store-hot-badge { display: inline-block; margin-left: 6px; font-size: 10px; background: #FAEEDA; color: #854F0B; padding: 1px 5px; border-radius: 4px; }
.qty-ctrl { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.qty-btn { width: 28px; height: 28px; border-radius: 50%; border: 1.5px solid #1D9E75; background: transparent; color: #1D9E75; font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.qty-btn.add { background: #1D9E75; color: #fff; border: none; }
.qty-num { min-width: 22px; text-align: center; font-weight: 500; font-size: 15px; }
.bigcat-row { display: flex; overflow-x: auto; background: #fff; padding: 10px 8px; gap: 4px; flex-shrink: 0; border-bottom: 1px solid #f0f0f0; }
.bigcat-row::-webkit-scrollbar { display: none; }
.bigcat-item { display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; padding: 4px 6px; border-radius: 10px; flex-shrink: 0; min-width: 60px; }
.bigcat-item.active { background: #E1F5EE; }
.bigcat-icon { width: 44px; height: 44px; border-radius: 12px; background: #F0F0F0; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.bigcat-item.active .bigcat-icon { background: #1D9E75; }
.bigcat-label { font-size: 11px; color: #555; text-align: center; line-height: 1.2; }
.browse-area { display: flex; flex: 1; overflow: hidden; }
.smallcat-list { width: 80px; background: #F8F8F8; border-right: 1px solid #eee; flex-shrink: 0; overflow-y: auto; }
.smallcat-item { padding: 12px 6px; font-size: 12px; color: #666; cursor: pointer; text-align: center; line-height: 1.3; border-left: 3px solid transparent; }
.smallcat-item.active { background: #fff; color: #0F6E56; font-weight: 500; border-left-color: #1D9E75; }
.recent-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: #F8F8F8; font-size: 13px; color: #666; flex-shrink: 0; }
.reuse-btn { background: none; border: none; color: #1D9E75; font-size: 13px; font-weight: 500; padding: 0; }
.cart-bar { background: #fff; border-top: 1px solid #eee; padding: 10px 14px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.cart-icon-wrap { position: relative; width: 48px; height: 48px; background: #1D9E75; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; font-size: 22px; }
.cart-badge { position: absolute; top: -2px; right: -2px; background: #E24B4A; color: #fff; font-size: 10px; font-weight: 500; min-width: 18px; height: 18px; border-radius: 10px; display: flex; align-items: center; justify-content: center; padding: 0 3px; }
.cart-info { flex: 1; }
.cart-total-text { font-size: 17px; font-weight: 500; }
.cart-sub-text { font-size: 12px; color: #999; }
.cart-submit-btn { border-radius: 24px; padding: 12px 22px; font-size: 15px; border: none; background: #1D9E75; color: #fff; font-weight: 500; touch-action: manipulation; }
.cart-submit-btn:disabled { opacity: 0.5; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; display: flex; align-items: flex-end; }
.cart-sheet { width: 100%; max-width: 480px; margin: 0 auto; background: #fff; border-radius: 16px 16px 0 0; max-height: 75vh; display: flex; flex-direction: column; }
.cart-sheet-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid #eee; flex-shrink: 0; }
.cart-sheet-header span { font-weight: 500; }
.cart-clear-btn { background: none; border: none; color: #E24B4A; font-size: 13px; padding: 0; }
.cart-sheet-items { overflow-y: auto; flex: 1; }
.cart-sheet-item { display: flex; align-items: center; padding: 11px 16px; border-bottom: 1px solid #F5F5F5; gap: 10px; }
.cart-sheet-footer { padding: 12px 16px; border-top: 1px solid #eee; flex-shrink: 0; }
.cart-total-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: 14px; }
.cart-total-amount { font-weight: 600; color: #D85A30; font-size: 16px; }
.cart-btn-full { width: 100%; height: 48px; font-size: 16px; border-radius: 10px; border: none; background: #1D9E75; color: #fff; font-weight: 500; }
.store-history { display: flex; flex-direction: column; height: 100%; }
.store-history-header { background: #1D9E75; padding: 12px 14px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.store-back-btn { background: rgba(255,255,255,0.2); border: none; color: #fff; border-radius: 8px; padding: 5px 10px; font-size: 13px; }
.store-history-list { flex: 1; overflow-y: auto; background: #fff; }
.store-history-card { padding: 12px 16px; border-bottom: 1px solid #F5F5F5; cursor: pointer; }
.store-history-detail { flex: 1; overflow-y: auto; background: #fff; }
.pagination-controls { display: flex; gap: 8px; justify-content: center; align-items: center; padding: 14px; flex-wrap: wrap; color: #666; font-size: 13px; }
.page-jump-input, .pagination-controls input { width: 72px; padding: 7px 8px; text-align: center; }
.mobile-pagination { flex-shrink: 0; border-top: 1px solid #eee; background: #fff; padding: 10px; gap: 6px; }
.mobile-pagination button { min-height: 36px; }
.order-list-summary { margin-bottom: 12px; color: #666; font-size: 13px; }
.empty-state { padding: 48px 24px; text-align: center; color: #bbb; font-size: 14px; }
.spinner { width: 24px; height: 24px; border: 3px solid #eee; border-top-color: #1D9E75; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner-wrap { display: flex; justify-content: center; padding: 32px; }

@media (max-width: 760px) {
  .layout { flex-direction: column; min-height: 100vh; }
  .sidebar { display: none; }
  .main { min-height: 100vh; }
  .topbar { padding: 12px 14px; position: sticky; top: 0; z-index: 30; }
  .topbar h2 { font-size: 17px; margin: 0 0 2px; }
  .mobile-logout-btn { display: inline-flex; align-items: center; justify-content: center; padding: 7px 12px; border-radius: 999px; }
  .mobile-admin-nav { display: flex; position: sticky; top: 58px; z-index: 29; }
  .content { padding: 12px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .purchase-layout { flex-direction: column; height: auto; }
  .purchase-order-list { width: 100%; max-height: 200px; border-right: none; border-bottom: 1px solid #eee; }
}
