/* ============ 小礼品申领系统 · 商务简约 (工业制造业) ============ */
:root {
  --steel-900: #1b2a3a;
  --steel-800: #22364a;
  --steel-700: #2d475f;
  --accent: #1f5f8b;      /* 钢蓝主色 */
  --accent-dark: #17496b;
  --accent-soft: #e8f0f6;
  --ink: #1f2933;
  --ink-2: #52606d;
  --ink-3: #7b8794;
  --line: #e1e7ec;
  --line-2: #eef2f5;
  --bg: #f4f6f8;
  --card: #ffffff;
  --ok: #2f855a;
  --warn: #b7791f;
  --danger: #c0392b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(16,42,67,.08), 0 1px 2px rgba(16,42,67,.06);
  --shadow-lg: 0 8px 28px rgba(16,42,67,.16);
  --font: "Segoe UI", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 14px; line-height: 1.5; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
  font-size: 14px; font-family: inherit; padding: 9px 16px; transition: all .15s;
  white-space: nowrap; font-weight: 500;
}
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-outline { background: #fff; border-color: var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line); }
.btn-ghost:hover { background: var(--line-2); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e6b7b1; }
.btn-danger:hover { background: #fdecea; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  font-size: 14px; font-family: inherit; color: var(--ink); background: #fff; transition: border .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31,95,139,.12); }
.input-sm { padding: 6px 10px; font-size: 13px; }
.dim-inputs { display: flex; gap: 6px; align-items: center; }
.dim-inputs .input { flex: 1; min-width: 80px; }
.dim-inputs .dim-sep { color: var(--ink-3); font-weight: 500; font-size: 14px; }
.dim-inputs .dim-unit { flex: 0 0 72px; }
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 5px; font-weight: 500; }
.req-star { color: var(--danger); }
.hint-inline { color: var(--ink-3); font-weight: 400; font-size: 11px; margin-left: 4px; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--steel-900), var(--accent-dark));
  padding: 20px;
}
.login-card { background: #fff; border-radius: 12px; padding: 40px 36px; width: 100%; max-width: 380px; box-shadow: var(--shadow-lg); }
.login-brand { text-align: center; margin-bottom: 28px; }
.login-logo {
  display: inline-block; background: var(--accent); color: #fff; font-weight: 700; letter-spacing: 2px;
  padding: 10px 16px; border-radius: 8px; font-size: 18px; margin-bottom: 16px;
}
.login-brand h1 { font-size: 20px; color: var(--ink); }
.login-sub { color: var(--ink-3); font-size: 12px; margin-top: 4px; letter-spacing: .5px; }
#loginForm label { margin-top: 4px; }
#loginForm .btn { margin-top: 18px; }
.login-err { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; min-height: 18px; }
.login-foot { text-align: center; color: var(--ink-3); font-size: 12px; margin-top: 24px; }

/* ---------- 顶栏 ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  background: var(--steel-900); color: #fff; display: flex; align-items: center;
  padding: 0 20px; height: 56px; gap: 20px; position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.brand-mark { background: var(--accent); font-weight: 700; letter-spacing: 1px; padding: 4px 9px; border-radius: 5px; font-size: 13px; }
.brand-title { font-size: 15px; font-weight: 600; white-space: nowrap; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.tab {
  background: transparent; border: none; color: #c7d3de; padding: 8px 14px; cursor: pointer;
  font-size: 14px; font-family: inherit; border-radius: 6px; white-space: nowrap; transition: all .15s;
}
.tab:hover { color: #fff; background: rgba(255,255,255,.08); }
.tab.active { color: #fff; background: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.role-badge { font-size: 12px; background: rgba(255,255,255,.12); padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.topbar .btn-ghost { color: #c7d3de; border-color: rgba(255,255,255,.2); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ---------- 内容区 ---------- */
.content { flex: 1; padding: 24px; max-width: 1280px; width: 100%; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .2s; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.panel-head h2 { font-size: 18px; color: var(--ink); font-weight: 600; }
.head-tools { display: flex; gap: 8px; align-items: center; }
.head-tools .input { width: 220px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.empty-hint { text-align: center; color: var(--ink-3); padding: 40px 20px; }

/* ---------- 礼品展示卡片 ---------- */
.gift-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.gift-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: box-shadow .15s, transform .15s; }
.gift-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.gift-img { width: 100%; height: 160px; object-fit: cover; background: var(--line-2); display: block; }
.gift-img.placeholder { display: flex; align-items: center; justify-content: center; color: var(--ink-3); font-size: 13px; }
.gift-body { padding: 14px; }
.gift-name { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.gift-meta { font-size: 12px; color: var(--ink-3); margin-bottom: 3px; }
.gift-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.gift-price { color: var(--accent); font-weight: 600; }
.stock-badge { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600; }
.stock-ok { background: #e6f4ec; color: var(--ok); }
.stock-low { background: #fdf3e2; color: var(--warn); }
.stock-out { background: #fdecea; color: var(--danger); }

/* ---------- 领用登记 ---------- */
.req-form-card { max-width: 720px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-field { margin-bottom: 14px; }
.form-row .form-field { margin-bottom: 0; }
.items-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.items-list { display: flex; flex-direction: column; gap: 10px; }
.item-row { display: grid; grid-template-columns: 1fr 110px auto; gap: 10px; align-items: center; background: var(--line-2); padding: 10px; border-radius: var(--radius); }
.item-row .stock-tip { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.item-row .stock-tip.warn { color: var(--danger); }
.item-remove { background: #fff; border: 1px solid var(--line); color: var(--danger); border-radius: 6px; width: 34px; height: 34px; cursor: pointer; font-size: 18px; }
.item-remove:hover { background: #fdecea; }
.req-summary { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin: 16px 0 8px; font-size: 15px; }
.req-summary strong { color: var(--accent); font-size: 18px; }

/* ---------- 筛选 ---------- */
.filter-card { padding: 14px 18px; }
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filter-row .input { width: auto; min-width: 130px; flex: 0 1 auto; }
.filter-row #fKeyword { min-width: 200px; }
.filter-label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.filter-sep { color: var(--ink-3); }

/* ---------- 表格 ---------- */
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: var(--accent-soft); color: var(--steel-800); text-align: left; padding: 11px 14px; font-weight: 600; white-space: nowrap; border-bottom: 2px solid var(--line); }
.data-table td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.data-table tbody tr:hover { background: #fafcfd; }
.data-table .num { text-align: right; }
.data-table td.num { font-variant-numeric: tabular-nums; }
.record-no { font-family: "Consolas", monospace; color: var(--accent); font-size: 12px; }
.gift-detail-line { white-space: nowrap; }
.gift-detail-line + .gift-detail-line { margin-top: 2px; }
.tag-qty { color: var(--ink-3); }

/* ---------- 礼品领用排行进度条 ---------- */
.bar-wrap { display: flex; align-items: center; gap: 10px; }
.bar { flex: 1; min-width: 90px; background: var(--bg); border-radius: 5px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-dark)); border-radius: 5px; transition: width .35s ease; }
.bar-pct { font-size: 12px; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- KPI ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-card { background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.kpi-value { font-size: 22px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi-card.warn { border-left-color: var(--warn); }
.kpi-card.warn .kpi-value { color: var(--warn); }

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; background: rgba(16,42,67,.5); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-box { background: #fff; border-radius: 10px; width: 100%; max-width: 640px; box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column; }
.modal-sm { max-width: 400px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; color: var(--ink); }
.modal-close { background: none; border: none; font-size: 24px; color: var(--ink-3); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.restock-name { font-size: 15px; font-weight: 600; margin-bottom: 16px; color: var(--ink); }

/* 图片上传 */
.upload-area { display: flex; align-items: center; gap: 14px; }
.img-preview { width: 90px; height: 90px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.upload-btn { display: inline-flex; align-items: center; padding: 8px 16px; background: var(--accent-soft); color: var(--accent); border-radius: var(--radius); cursor: pointer; font-size: 13px; font-weight: 500; margin: 0; }
.upload-btn:hover { background: #d9e6f0; }

/* Toast */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--steel-900); color: #fff; padding: 12px 22px; border-radius: 8px; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: all .25s; z-index: 200; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.toast.warn { background: var(--warn); }

/* 隐藏管理员元素 */
body:not(.is-admin) .admin-only { display: none !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .tabs { order: 3; width: 100%; }
  .content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .item-row { grid-template-columns: 1fr; }
  .head-tools .input { width: 100%; }
  .filter-row .input { flex: 1 1 100%; }
}
