:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --border: #e6e8f0;
  --text: #1f2233;
  --muted: #8a8fa3;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --shadow: 0 1px 3px rgba(20, 20, 50, .06), 0 8px 24px rgba(20, 20, 50, .05);
  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ---------- 登录 ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #5b54ec 0%, #7c3aed 100%);
  padding: 20px;
}
.auth-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 36px 28px;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}
.auth-logo { font-size: 44px; margin-bottom: 8px; }
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.auth-card input {
  width: 100%; padding: 13px 14px; margin-bottom: 12px;
  border: 1px solid var(--border); border-radius: 10px; font-size: 15px;
  background: #fafbff;
}
.auth-card input:focus { outline: none; border-color: var(--primary); background: #fff; }

/* ---------- 顶栏 / 标签 ---------- */
.app { max-width: 1100px; margin: 0 auto; padding-bottom: 40px; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 17px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { color: var(--muted); font-size: 13px; }
.tabbar {
  display: flex; gap: 4px; padding: 8px 12px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 53px; z-index: 9;
  overflow-x: auto;
}
.tab {
  border: none; background: none; padding: 9px 16px; border-radius: 9px;
  font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; font-weight: 500;
}
.tab.active { background: var(--primary); color: #fff; }
.main { padding: 16px; }

/* ---------- 卡片 / 统计 ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 18px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.stat .label { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.stat .value { font-size: 26px; font-weight: 700; }
.stat .value.green { color: var(--green); }
.stat .value.amber { color: var(--amber); }
.stat .value.primary { color: var(--primary); }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.panel-head h2 { font-size: 16px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cell-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }

/* ---------- 表单控件 ---------- */
.btn {
  border: 1px solid transparent; border-radius: 9px; padding: 9px 14px;
  font-size: 14px; cursor: pointer; font-weight: 500; transition: .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 13px; font-size: 15px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 9px; background: #fafbff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: #fff; }
.search-input { width: 180px; }
.form-error { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 6px; text-align: left; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--border); background: #fafbfd; }
td { border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
.code-cell { font-family: ui-monospace, Menlo, Consolas, monospace; max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-available { background: #e7f6ec; color: var(--green); }
.badge-sold { background: #fdeaea; color: var(--red); }
.badge-admin { background: #ece9fd; color: var(--primary); }
.badge-staff { background: #eef0f5; color: var(--muted); }

/* ---------- 弹窗 ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,20,50,.45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
.modal {
  background: var(--surface); border-radius: 16px; width: 100%; max-width: 440px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 17px; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-body { padding: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field .req { color: var(--red); }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--border); }
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #1f2233; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; z-index: 200; box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
.toast.err { background: var(--red); }

/* ---------- 迷你柱状图 ---------- */
.chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding: 16px; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.chart .bar { width: 70%; max-width: 28px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; transition: .2s; }
.chart .bar-label { font-size: 10px; color: var(--muted); white-space: nowrap; }

@media (max-width: 600px) {
  .search-input { width: 130px; }
  .panel-head h2 { width: 100%; }
  .hide-sm { display: none; }
  .stat .value { font-size: 22px; }
}

/* ===== 员工申领 CDK ===== */
#claim-body { padding: 16px; }
.claim-tip {
  background: #fff8ed; border: 1px solid #fde9c8; color: #92600a;
  padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px;
}
.claim-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; background: #fafbff; }
.claim-field { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.claim-field:last-of-type { border-bottom: none; }
.claim-label { color: var(--muted); font-size: 13px; min-width: 48px; }
.claim-code {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 15px;
  background: #eef0fb; color: var(--primary-dark); padding: 6px 10px; border-radius: 8px;
  word-break: break-all; user-select: all;
}
.claim-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; justify-content: flex-end; }
.claim-prod-list { display: flex; flex-direction: column; gap: 10px; }
.claim-prod {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface);
}
.claim-prod-name { font-weight: 600; }
.claim-prod-count { font-size: 12px; margin-top: 2px; }
