/* ============================================================
   产品管理系统 - 公共样式（移动端 + PC 响应式）
   ============================================================ */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --text-2: #64748b;
  --border: #e2e8f0;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
}

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

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 500;
  transition: all .15s ease; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- 表单 ---------- */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 13px; color: var(--text-2);
  margin-bottom: 6px; font-weight: 500;
}
.form-group label .req { color: var(--danger); }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: #fff; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.textarea { resize: vertical; min-height: 72px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--text-2); margin-top: 4px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 17px; font-weight: 600; margin-bottom: 16px; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; height: 60px;
}
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; }
.topbar .brand .logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.topbar .user-area { display: flex; align-items: center; gap: 10px; }
.topbar .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}

/* ---------- 布局 ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 20px; }
.page-wide { max-width: 1280px; margin: 0 auto; padding: 20px; }

/* ---------- 登录页 ---------- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: linear-gradient(160deg, #eff6ff 0%, #dbeafe 55%, #bfdbfe 100%);
}
.auth-card {
  width: 100%; max-width: 400px; background: #fff;
  border-radius: 16px; box-shadow: 0 12px 40px rgba(37,99,235,.14);
  border: 1px solid #dbeafe; padding: 32px 30px;
}
.auth-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.auth-card .brand .logo {
  width: 42px; height: 42px; border-radius: 11px;
  background: #2563eb;
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.auth-card h1 { font-size: 20px; font-weight: 700; color: #1e3a8a; }
.auth-card .subtitle { color: #64748b; font-size: 13px; margin-bottom: 22px; }
.auth-tabs { display: flex; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.auth-tabs button {
  flex: 1; padding: 10px; background: none; border: none;
  border-bottom: 2px solid transparent; font-size: 14px; color: var(--text-2); font-weight: 500;
}
.auth-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- 提示 ---------- */
.alert {
  padding: 11px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* ---------- 统计卡片 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.stat-card .num { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-card .lbl { color: var(--text-2); font-size: 13px; }
.stat-card.accent-1 { border-top: 3px solid var(--primary); }
.stat-card.accent-2 { border-top: 3px solid var(--success); }
.stat-card.accent-3 { border-top: 3px solid var(--warning); }
.stat-card.accent-4 { border-top: 3px solid #0891b2; }

/* ---------- 工具栏 ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 16px; margin-bottom: 16px;
}
.toolbar .input, .toolbar .select { width: auto; flex: 0 0 auto; }
.toolbar .search { flex: 1 1 200px; min-width: 160px; }
.toolbar .spacer { flex: 1; }

/* ---------- 客户筛选标签 ---------- */
.customer-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.customer-tabs .chip {
  padding: 6px 14px; border-radius: 999px; font-size: 13px;
  background: #fff; border: 1px solid var(--border); color: var(--text-2);
  cursor: pointer; transition: all .15s;
}
.customer-tabs .chip:hover { border-color: var(--primary); color: var(--primary); }
.customer-tabs .chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- 产品网格（紧凑小方块） ---------- */
.product-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.product-card {
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  overflow: hidden; cursor: pointer; position: relative;
  border: 1px solid var(--border);
  transition: transform .12s, box-shadow .12s;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.product-card .thumb-wrap {
  position: relative; width: 100%; padding-top: 100%;
  background: #f8fafc; overflow: hidden;
}
.product-card .thumb {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #f8fafc;
}
.product-card .thumb.placeholder {
  display: flex; align-items: center; justify-content: center; color: #cbd5e1;
}
.product-card .color-dots {
  position: absolute; left: 6px; bottom: 6px; display: flex; gap: 3px;
}
.color-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.9); box-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.product-card .body { padding: 8px 10px 6px; }
.product-card .code { font-size: 11px; color: var(--primary); font-weight: 600; }
.product-card .name {
  font-size: 13px; font-weight: 600; margin: 3px 0 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-card .price { color: var(--danger); font-weight: 700; font-size: 15px; }
.product-card .cust {
  font-size: 11px; color: var(--success); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-card .actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 4px;
  opacity: 0; transition: opacity .12s;
}
.product-card:hover .actions, .product-card:focus-within .actions { opacity: 1; }
@media (hover: none) { .product-card .actions { opacity: 1; } }
.icon-btn {
  width: 28px; height: 28px; border-radius: 8px; border: none;
  background: rgba(255,255,255,.92); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.15); cursor: pointer;
}
.icon-btn:hover { color: var(--primary); }
.icon-btn.danger:hover { color: var(--danger); background: #fef2f2; }
.icon-btn .ic { width: 15px; height: 15px; }

/* ---------- 色系编辑 ---------- */
.color-editor { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.color-editor input[type="color"] {
  width: 46px; height: 40px; border: 1px solid var(--border);
  border-radius: 8px; padding: 2px; cursor: pointer; background: #fff;
}
.color-editor .rgb-inputs { display: flex; gap: 6px; }
.color-editor .rgb-inputs .input { width: 62px; text-align: center; }
.color-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.color-item {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f1f5f9; border-radius: 8px; padding: 4px 6px 4px 4px;
  font-size: 12px; color: var(--text-2);
}
.color-item .color-dot { width: 16px; height: 16px; }
.color-item .rm { border: none; background: none; color: var(--text-2); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.color-item .rm:hover { color: var(--danger); }

/* ---------- 色谱点选 ---------- */
.hue-bar {
  width: 100%; height: 16px; border-radius: 8px; cursor: pointer; margin-bottom: 10px;
  background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  border: 1px solid var(--border);
}
.color-map {
  width: 100%; height: 150px; border-radius: 10px; border: 1px solid var(--border);
  cursor: crosshair; touch-action: none; display: block; background: #fff;
}
.color-map-current { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.color-map-current .dot { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); flex-shrink: 0; background: rgb(255,0,0); }
.auth-card .btn-primary { background: #2563eb; border-color: #2563eb; }
.auth-card .btn-primary:hover { background: #1d4ed8; }
.auth-tabs button.active { color: #2563eb; border-bottom-color: #2563eb; }

/* ---------- 产品详情弹窗 ---------- */
.view-modal-img {
  width: 100%; max-height: 440px; object-fit: contain;
  border-radius: 12px; background: #f8fafc; border: 1px solid var(--border);
  cursor: zoom-in;
}
.view-modal-img-link { display: block; text-align: center; font-size: 12px; color: var(--text-2); margin-top: 6px; }
.pv-field { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.pv-field .k { color: var(--text-2); flex: 0 0 88px; }
.pv-field .v { flex: 1; }
.pv-colors { display: flex; flex-wrap: wrap; gap: 8px; }
.pv-color { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 640px; font-size: 14px; }
thead th {
  text-align: left; padding: 12px 16px; font-size: 12px; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .03em; border-bottom: 1px solid var(--border);
  background: #f8fafc; white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 6px; }

/* ---------- 列表（员工/明细） ---------- */
.list-item {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; }
.list-item .sub { color: var(--text-2); font-size: 13px; }

/* ---------- 明细卡片（员工端） ---------- */
.record-item {
  background: #fff; border-radius: 12px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px;
  display: flex; gap: 12px; align-items: flex-start;
}
.record-item .date-badge {
  background: var(--primary-light); color: var(--primary);
  border-radius: 10px; padding: 6px 10px; text-align: center; min-width: 64px;
  font-size: 13px; font-weight: 600;
}
.record-item .date-badge .d { display: block; font-size: 16px; }
.record-item .grow { flex: 1; }
.record-item .wage { color: var(--danger); font-weight: 700; font-size: 16px; white-space: nowrap; }

/* ---------- 空状态 ---------- */
.empty {
  text-align: center; color: var(--text-2); padding: 48px 20px;
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
}
.empty .icon { font-size: 44px; margin-bottom: 10px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .45);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; padding: 24px;
  animation: pop .18s ease;
}
.modal.wide { max-width: 720px; }
@keyframes pop { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 18px; margin-bottom: 18px; }
.modal .modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- 侧边栏（管理端） ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: #111827; color: #e5e7eb;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { padding: 20px; display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.sidebar .nav { padding: 8px 12px; flex: 1; overflow-y: auto; }
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 11px 14px; border-radius: 10px; color: #cbd5e1;
  background: none; border: none; font-size: 14px; font-weight: 500;
  margin-bottom: 4px; transition: background .15s;
}
.sidebar .nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar .nav-item.active { background: var(--primary); color: #fff; }
.sidebar .nav-item .ic { width: 20px; text-align: center; }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-content { padding: 24px; flex: 1; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 18px; }

/* 移动端顶栏 + 抽屉 */
.mobile-topbar {
  display: none; align-items: center; gap: 12px;
  background: #111827; color: #fff; padding: 12px 16px; position: sticky; top: 0; z-index: 60;
}
.mobile-topbar .burger { background: none; border: none; color: #fff; font-size: 22px; }
.mobile-topbar .ttl { font-weight: 600; flex: 1; }
.sidebar-mask { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 65; }

/* ---------- 分页 ---------- */
.pagination { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.pagination .pg-info { color: var(--text-2); font-size: 13px; margin-right: 8px; }

/* ---------- 徽标 ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge-green { background: #f0fdf4; color: var(--success); }
.badge-gray { background: #f1f5f9; color: var(--text-2); }
.badge-red { background: #fef2f2; color: var(--danger); }
.badge-blue { background: var(--primary-light); color: var(--primary); }

/* ---------- 图片预览 ---------- */
.img-preview {
  width: 88px; height: 88px; border-radius: 10px; object-fit: cover;
  border: 1px solid var(--border); background: #f8fafc; display: block;
}

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .sidebar { display: none; position: fixed; left: 0; top: 0; z-index: 70; width: 240px; }
  .sidebar.open { display: flex; }
  .sidebar-mask.show { display: block; }
  .mobile-topbar { display: flex; }
  .admin-content { padding: 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .product-card .thumb { height: 140px; }
  .page, .page-wide { padding: 14px; }
}

/* ---------- 其他 ---------- */
.spinner {
  width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 线条简约图标 ---------- */
.ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1em; height: 1em; vertical-align: -0.15em; flex-shrink: 0;
}
.ic svg { width: 100%; height: 100%; }
.spin { animation: spin .8s linear infinite; }
.sidebar .nav-item .ic { width: 18px; height: 18px; margin-right: 10px; }
.mobile-topbar .burger .ic, .mobile-topbar .ic { width: 22px; height: 22px; }
.mobile-topbar .burger { background: none; border: none; color: #fff; padding: 4px; line-height: 0; }
.btn .ic { font-size: 15px; }
.btn-sm .ic { font-size: 13px; }
.product-card .actions .btn .ic { font-size: 14px; }
.process-chip .ic { width: 12px; height: 12px; vertical-align: -1px; margin-right: 3px; }
.product-card .customer .ic { width: 12px; height: 12px; vertical-align: -1px; margin-right: 2px; }
.product-card .thumb.placeholder { display: flex; align-items: center; justify-content: center; }
.product-card .thumb.placeholder .ic { width: 40px; height: 40px; color: #cbd5e1; }
.empty .icon { font-size: 40px; color: #cbd5e1; }
.empty .icon .ic { width: 1em; height: 1em; }
.empty .icon { display: flex; align-items: center; justify-content: center; }
.topbar .brand .logo, .auth-card .brand .logo { display: inline-flex; align-items: center; justify-content: center; }
.topbar .brand .logo .ic, .auth-card .brand .logo .ic { width: 20px; height: 20px; }
.sidebar .brand .ic { width: 20px; height: 20px; }
.muted { color: var(--text-2); }
.text-danger { color: var(--danger); }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.text-center { text-align: center; }
