/* 产品库存管理系统 - 响应式样式 */
:root{
  --primary:#2563eb; --primary-dark:#1d4ed8; --accent:#0891b2;
  --bg:#f8fafc; --card:#fff; --text:#1e293b; --muted:#64748b;
  --border:#e2e8f0; --success:#16a34a; --warning:#ea580c; --danger:#dc2626;
  --radius:10px; --shadow:0 1px 3px rgba(0,0,0,.06),0 1px 2px rgba(0,0,0,.04);
}
*{box-sizing:border-box;margin:0;padding:0}
body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif;background:var(--bg);color:var(--text);line-height:1.6;font-size:14px;-webkit-tap-highlight-color:transparent}
a{color:var(--primary);text-decoration:none}
button,input,select,textarea{font-family:inherit;font-size:14px}
button{cursor:pointer}

/* 布局 */
.app{display:flex;min-height:100vh}
.sidebar{width:232px;flex-shrink:0;background:#fff;border-right:1px solid var(--border);display:flex;flex-direction:column;position:sticky;top:0;height:100vh;z-index:30}
.brand{padding:20px 18px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:10px}
.brand .logo{width:34px;height:34px;border-radius:9px;background:linear-gradient(135deg,var(--primary),var(--accent));color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:17px}
.brand b{display:block;font-size:15px}
.brand small{color:var(--muted);font-size:11px}
.nav{flex:1;overflow:auto;padding:12px 10px}
.nav-group{font-size:11px;color:#94a3b8;padding:12px 10px 6px;font-weight:600;letter-spacing:.5px}
.nav a{display:flex;align-items:center;gap:10px;padding:10px 12px;border-radius:7px;color:var(--text);margin-bottom:2px;font-weight:500}
.nav a:hover{background:#f1f5f9}
.nav a.active{background:#eff6ff;color:var(--primary);font-weight:600}
.nav a .ico{width:20px;text-align:center;font-size:16px}
.sidebar-foot{padding:12px 16px;border-top:1px solid var(--border);font-size:12px;color:var(--muted)}
.main{flex:1;min-width:0;display:flex;flex-direction:column}
.topbar{height:60px;background:#fff;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:12px;padding:0 24px;position:sticky;top:0;z-index:20}
.topbar h1{font-size:17px;font-weight:600;flex:1}
.topbar .sub{color:var(--muted);font-size:12px}
.content{padding:22px 24px 60px;flex:1}
.mobile-nav{display:none}
.menu-btn{display:none;background:none;border:0;font-size:22px;padding:4px 8px}

/* 通用 */
.card{background:var(--card);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow);padding:20px;margin-bottom:18px}
.card h2{font-size:16px;margin-bottom:14px;display:flex;align-items:center;gap:8px}
.card h3{font-size:14px;margin:16px 0 10px;color:var(--primary-dark)}
.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;background:#fff;border:1px solid var(--border);border-radius:7px;padding:8px 14px;color:var(--text);font-weight:500;min-height:36px;white-space:nowrap}
.btn:hover{border-color:#cbd5e1;background:#f8fafc}
.btn.primary{background:var(--primary);border-color:var(--primary);color:#fff}
.btn.primary:hover{background:var(--primary-dark)}
.btn.danger{color:var(--danger);border-color:#fecaca}
.btn.danger:hover{background:#fef2f2}
.btn.ghost{border-color:transparent;background:transparent;color:var(--muted)}
.btn.sm{padding:5px 10px;min-height:30px;font-size:13px}
.btn.block{width:100%}
.btn:disabled{opacity:.5;cursor:not-allowed}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.row.end{justify-content:flex-end}
.spacer{flex:1}
.grid{display:grid;gap:16px}
.grid.cols-2{grid-template-columns:repeat(2,1fr)}
.grid.cols-3{grid-template-columns:repeat(3,1fr)}
.grid.cols-4{grid-template-columns:repeat(4,1fr)}
.field{display:flex;flex-direction:column;gap:6px;margin-bottom:14px}
.field label{font-size:13px;font-weight:600;color:#475569}
.field .hint{font-size:12px;color:var(--muted)}
input[type=text],input[type=number],input[type=date],input[type=datetime-local],input[type=email],input[type=tel],select,textarea{width:100%;padding:9px 11px;border:1px solid #cbd5e1;border-radius:7px;background:#fff;color:var(--text);outline:none;min-height:38px}
input:focus,select:focus,textarea:focus{border-color:var(--primary);box-shadow:0 0 0 3px rgba(37,99,235,.1)}
textarea{resize:vertical;min-height:76px}
.tag{display:inline-block;padding:2px 9px;border-radius:12px;font-size:12px;font-weight:500;background:#f1f5f9;color:#475569}
.tag.blue{background:#dbeafe;color:#1e40af}.tag.green{background:#dcfce7;color:#166534}
.tag.orange{background:#ffedd5;color:#9a3412}.tag.red{background:#fee2e2;color:#991b1b}
.tag.gray{background:#f1f5f9;color:#64748b}
.muted{color:var(--muted)}.small{font-size:12px}
.mono{font-family:Consolas,"Courier New",monospace}
.center{text-align:center}.right{text-align:right}
.empty{padding:44px 20px;text-align:center;color:var(--muted)}
.empty .big{font-size:34px;margin-bottom:8px;opacity:.5}
.divider{height:1px;background:var(--border);margin:16px 0}

/* 表格 */
.table-wrap{overflow:auto;border:1px solid var(--border);border-radius:8px}
table{width:100%;border-collapse:collapse;font-size:13px;background:#fff}
th{background:#f8fafc;text-align:left;padding:10px 12px;font-weight:600;color:#475569;border-bottom:1px solid var(--border);white-space:nowrap}
td{padding:10px 12px;border-bottom:1px solid #f1f5f9;vertical-align:middle}
tr:last-child td{border-bottom:0}
tbody tr:hover{background:#fafcff}

/* 筛选栏 */
.filters{display:flex;gap:10px;flex-wrap:wrap;align-items:center;margin-bottom:16px}
.filters input[type=text],.filters select{width:auto;min-width:150px}
.search{position:relative}
.search input{padding-left:32px}
.search::before{content:"🔍";position:absolute;left:10px;top:8px;font-size:13px;opacity:.6}

/* 统计卡 */
.stat{background:#fff;border:1px solid var(--border);border-radius:var(--radius);padding:18px;box-shadow:var(--shadow)}
.stat .label{font-size:12px;color:var(--muted)}
.stat .value{font-size:26px;font-weight:700;margin-top:4px;line-height:1.2}
.stat .ico{float:right;font-size:22px;opacity:.75}

/* 分类树 */
.tree-layout{display:grid;grid-template-columns:260px 1fr;gap:18px;align-items:start}
.tree{background:#fff;border:1px solid var(--border);border-radius:var(--radius);padding:12px;box-shadow:var(--shadow);position:sticky;top:82px}
.tree .node{display:flex;align-items:center;gap:4px;padding:5px 6px;border-radius:6px;cursor:pointer;font-size:13px}
.tree .node:hover{background:#f1f5f9}
.tree .node.selected{background:#eff6ff;color:var(--primary);font-weight:600}
.tree .node .tog{width:18px;text-align:center;color:var(--muted);flex-shrink:0}
.tree .node .name{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.tree .node .act{opacity:0;display:flex;gap:2px}
.tree .node:hover .act{opacity:1}
.tree .node .act button{border:0;background:none;color:var(--muted);padding:2px 4px;font-size:12px;border-radius:4px}
.tree .node .act button:hover{background:#e2e8f0;color:var(--primary)}
.tree .count{font-size:11px;color:var(--muted)}

/* 产品卡片 */
.product-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(225px,1fr));gap:14px}
.product-card{background:#fff;border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;box-shadow:var(--shadow);cursor:pointer;transition:transform .12s,box-shadow .12s}
.product-card:hover{transform:translateY(-2px);box-shadow:0 6px 16px rgba(0,0,0,.09);border-color:#bfdbfe}
.product-card .thumb{height:140px;background:#f1f5f9;display:flex;align-items:center;justify-content:center;overflow:hidden}
.product-card .thumb img{width:100%;height:100%;object-fit:cover}
.product-card .thumb .ph{font-size:38px;opacity:.35}
.product-card .body{padding:12px}
.product-card .name{font-weight:600;font-size:14px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.product-card .code{font-size:12px;color:var(--muted);font-family:Consolas,monospace}
.product-card .meta{display:flex;justify-content:space-between;align-items:center;margin-top:9px;font-size:12px;color:var(--muted)}
.product-card .stock{font-size:16px;font-weight:700;color:var(--text)}
.product-card .stock.low{color:var(--warning)}.product-card .stock.zero{color:#94a3b8}

/* 详情与画廊 */
.detail-grid{display:grid;grid-template-columns:minmax(320px,1.1fr) 1fr;gap:22px}
.gallery-main{background:#f1f5f9;border-radius:var(--radius);height:360px;display:flex;align-items:center;justify-content:center;position:relative;overflow:hidden}
.gallery-main img{max-width:100%;max-height:100%;object-fit:contain;cursor:zoom-in}
.gallery-main .ph{font-size:60px;opacity:.35}
.gallery-nav{position:absolute;top:50%;transform:translateY(-50%);background:rgba(255,255,255,.9);border:0;border-radius:50%;width:36px;height:36px;font-size:18px;box-shadow:var(--shadow)}
.gallery-nav.prev{left:10px}.gallery-nav.next{right:10px}
.thumbs{display:flex;gap:8px;overflow-x:auto;margin-top:10px;padding-bottom:4px}
.thumbs img{width:64px;height:64px;object-fit:cover;border-radius:7px;border:2px solid transparent;cursor:pointer;flex-shrink:0}
.thumbs img.active{border-color:var(--primary)}
.dots{display:none;justify-content:center;gap:6px;margin-top:8px}
.dots span{width:7px;height:7px;border-radius:50%;background:#cbd5e1;cursor:pointer}
.dots span.active{background:var(--primary)}
.info-group{background:#f8fafc;border-radius:8px;padding:14px;margin-bottom:12px}
.info-group h4{font-size:12px;color:var(--muted);letter-spacing:.5px;margin-bottom:10px;text-transform:uppercase}
.info-line{display:flex;padding:4px 0;font-size:13px;gap:12px}
.info-line .k{color:var(--muted);width:88px;flex-shrink:0}
.info-line .v{flex:1;word-break:break-all}
.tabs{display:flex;gap:4px;border-bottom:1px solid var(--border);margin-bottom:14px}
.tabs button{background:none;border:0;border-bottom:2px solid transparent;padding:8px 14px;color:var(--muted);font-weight:500}
.tabs button.active{color:var(--primary);border-color:var(--primary);font-weight:600}

/* 模态与提示 */
.modal-mask{position:fixed;inset:0;background:rgba(15,23,42,.48);display:flex;align-items:center;justify-content:center;z-index:100;padding:16px}
.modal{background:#fff;border-radius:12px;width:100%;max-width:560px;max-height:88vh;display:flex;flex-direction:column;box-shadow:0 20px 50px rgba(0,0,0,.2)}
.modal.wide{max-width:860px}
.modal-head{padding:16px 20px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between}
.modal-head h3{font-size:16px}
.modal-head button{background:none;border:0;font-size:20px;color:var(--muted)}
.modal-body{padding:20px;overflow:auto;flex:1}
.modal-foot{padding:14px 20px;border-top:1px solid var(--border);display:flex;justify-content:flex-end;gap:10px}
.toast-box{position:fixed;top:20px;right:20px;z-index:200;display:flex;flex-direction:column;gap:8px}
.toast{background:#1e293b;color:#fff;padding:11px 16px;border-radius:8px;box-shadow:0 4px 14px rgba(0,0,0,.2);max-width:380px;font-size:13px;animation:slidein .2s}
.toast.success{background:#15803d}.toast.error{background:#b91c1c}
@keyframes slidein{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:none}}
.lightbox{position:fixed;inset:0;background:rgba(0,0,0,.9);z-index:300;display:flex;align-items:center;justify-content:center}
.lightbox img{max-width:94vw;max-height:90vh;object-fit:contain}
.lightbox button{position:absolute;top:16px;right:20px;background:none;border:0;color:#fff;font-size:30px}

/* 明细行 */
.items-table td{padding:7px 8px}
.items-table input,.items-table select{padding:7px 8px;min-height:34px}
.item-picker{max-height:460px;overflow:auto;border:1px solid var(--border);border-radius:8px}
.item-picker .opt{padding:10px 12px;border-bottom:1px solid #f1f5f9;cursor:pointer;display:flex;justify-content:space-between;gap:10px}
.item-picker .opt:hover{background:#eff6ff}
.item-picker .opt b{font-weight:600}
.pagination{display:flex;justify-content:center;align-items:center;gap:6px;margin-top:16px}
.pagination button{min-width:32px;height:32px;border:1px solid var(--border);background:#fff;border-radius:6px;padding:0 8px}
.pagination button.active{background:var(--primary);color:#fff;border-color:var(--primary)}
.dirty-dot{display:inline-block;width:7px;height:7px;border-radius:50%;background:var(--warning);margin-left:6px}

/* 响应式 */
@media(max-width:1023px){
  .tree-layout{grid-template-columns:220px 1fr}
  .detail-grid{grid-template-columns:1fr}
  .gallery-main{height:320px}
}
@media(max-width:767px){
  .sidebar{position:fixed;left:0;top:0;transform:translateX(-100%);transition:transform .2s;width:250px;box-shadow:4px 0 20px rgba(0,0,0,.15)}
  .sidebar.open{transform:none}
  .menu-btn{display:block}
  .topbar{padding:0 14px;height:54px}
  .topbar .sub{display:none}
  .content{padding:14px 12px 90px}
  .card{padding:14px}
  .grid.cols-2,.grid.cols-3,.grid.cols-4{grid-template-columns:1fr}
  .tree-layout{grid-template-columns:1fr}
  .tree{position:static}
  .tree .node .act{opacity:1}
  .product-grid{grid-template-columns:repeat(2,1fr);gap:10px}
  .product-card .thumb{height:110px}
  .gallery-main{height:260px}
  .thumbs{display:none}
  .dots{display:flex}
  .mobile-nav{display:flex;position:fixed;bottom:0;left:0;right:0;height:58px;background:#fff;border-top:1px solid var(--border);z-index:25;justify-content:space-around;align-items:center;box-shadow:0 -2px 10px rgba(0,0,0,.04)}
  .mobile-nav a{display:flex;flex-direction:column;align-items:center;gap:2px;font-size:10px;color:var(--muted);flex:1;text-align:center}
  .mobile-nav a.active{color:var(--primary);font-weight:600}
  .mobile-nav a .ico{font-size:19px}
  .table-wrap{table-layout:fixed}
  .hide-mobile{display:none!important}
  .btn{min-height:40px}
  .filters input[type=text],.filters select{width:100%}
  .modal-foot .btn{flex:1}
  .info-line .k{width:72px}
  .toast-box{left:12px;right:12px;top:12px}
  .toast{max-width:none}
}
@media(max-width:400px){.product-grid{grid-template-columns:1fr}}
