/* ============================================================
   眼镜溯源系统 · 设计 Token 与组件（c2 前端设计规范实现）
   iOS 设计语言：系统灰底 / 毛玻璃 / 胶囊控件 / 发丝线 / 8pt 网格
   ============================================================ */
:root {
  --bg: #F5F5F7;
  --card: #FFFFFF;
  --text: #1D1D1F;
  --text2: #86868B;
  --text3: #C7C7CC;
  --line: rgba(0, 0, 0, .08);
  --accent: #007AFF;
  --accent-soft: rgba(0, 122, 255, .1);
  --green: #34C759;
  --green-soft: rgba(52, 199, 89, .12);
  --red: #FF3B30;
  --red-soft: rgba(255, 59, 48, .1);
  --orange: #FF9500;
  --orange-soft: rgba(255, 149, 0, .12);
  --purple: #5856D6;
  --cat-frame: #8E8E93;
  --cat-sun: #FF9F0A;
  --cat-fin: #5E5CE6;
  --cat-cl: #30B0C7;
  --radius: 16px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .06);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .06), 0 16px 48px rgba(0, 0, 0, .12);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; font-size: 14px; }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 9px 12px; outline: none; min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
a { color: var(--accent); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(0, 122, 255, .08), transparent 60%),
              radial-gradient(1000px 500px at 100% 110%, rgba(48, 176, 199, .1), transparent 60%), var(--bg);
}
.login-card {
  width: 380px; background: var(--card); border-radius: 20px; box-shadow: var(--shadow-lg);
  padding: 40px 36px; text-align: center;
}
.login-logo { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.login-logo span { color: var(--accent); }
.login-sub { color: var(--text2); font-size: 13px; margin: 6px 0 28px; }
.login-card input { width: 100%; margin-bottom: 12px; padding: 12px 14px; border-radius: 12px; }
.login-err { color: var(--red); font-size: 13px; min-height: 20px; margin-bottom: 8px; }
.login-hint { margin-top: 22px; font-size: 12px; color: var(--text3); line-height: 1.6; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: none; padding: 20px 12px; border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, .6); position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand-mark { font-size: 17px; font-weight: 700; padding: 8px 12px 18px; letter-spacing: -0.3px; }
.brand-mark span { color: var(--accent); }
.brand-mark small { display: block; font-size: 11px; color: var(--text2); font-weight: 400; margin-top: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 10px 12px; border-radius: var(--radius-s); color: var(--text);
  font-size: 14px; margin-bottom: 2px; transition: background .15s;
}
.nav-item:hover { background: rgba(0, 0, 0, .04); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-group { font-size: 11px; color: var(--text3); padding: 16px 12px 6px; font-weight: 600; letter-spacing: .5px; }

.main { flex: 1; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px 14px;
  background: rgba(245, 245, 247, .8); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.topbar h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.topbar .who { display: flex; align-items: center; gap: 10px; color: var(--text2); font-size: 13px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px;
}
.content { padding: 8px 32px 48px; max-width: 1200px; }

/* ---------- 卡片与看板 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 4px;
}
.stat .num { font-size: 32px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.stat .lbl { font-size: 12px; color: var(--text2); }
.stat.warn .num { color: var(--orange); }
.stat.danger .num { color: var(--red); }
.stat.good .num { color: var(--green); }

/* ---------- 工具条 / 筛选 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input, .toolbar select { min-width: 140px; }
.toolbar input.short { min-width: 110px; }
.seg {
  display: inline-flex; background: rgba(118, 118, 128, .12); border-radius: 10px; padding: 2px; gap: 2px;
}
.seg button {
  border-radius: 8px; padding: 6px 14px; font-size: 13px; color: var(--text2); transition: all .15s;
}
.seg button.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 12px; color: var(--text2); font-weight: 500; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: #F9F9FB; }
tbody tr.clickable { cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--text2); }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .2px; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px; white-space: nowrap;
}
.badge.gray { background: rgba(118, 118, 128, .12); color: #6d6d72; }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--green-soft); color: #248a3d; }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.orange { background: var(--orange-soft); color: #c77c00; }
.badge.cat-frame { background: rgba(142, 142, 147, .14); color: #6f6f74; }
.badge.cat-sun { background: rgba(255, 159, 10, .14); color: #b26a00; }
.badge.cat-fin { background: rgba(94, 92, 230, .12); color: var(--cat-fin); }
.badge.cat-cl { background: rgba(48, 176, 199, .14); color: #1d7f92; }
.badge.med { background: rgba(48, 176, 199, .14); color: #1d7f92; border: 1px solid rgba(48, 176, 199, .3); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px; border-radius: 99px; font-size: 14px; font-weight: 500; transition: all .15s;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #0066d6; }
.btn.ghost { background: var(--card); color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { border-color: var(--text3); }
.btn.danger { background: var(--red); color: #fff; }
.btn.sm { padding: 5px 12px; font-size: 12px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 弹层 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.modal {
  background: var(--card); border-radius: 20px; box-shadow: var(--shadow-lg);
  width: min(760px, 100%); max-height: 88vh; overflow-y: auto; padding: 26px;
}
.modal h2 { font-size: 19px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.3px; }
.modal .sub { color: var(--text2); font-size: 13px; margin-bottom: 18px; }
.modal-close { float: right; color: var(--text2); font-size: 20px; padding: 4px 8px; }

/* ---------- 时间轴 ---------- */
.timeline { list-style: none; }
.timeline li { position: relative; padding: 0 0 20px 26px; }
.timeline li::before {
  content: ''; position: absolute; left: 5px; top: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--text3);
}
.timeline li::after {
  content: ''; position: absolute; left: 8.5px; top: 18px; bottom: 2px; width: 1px; background: var(--line);
}
.timeline li:last-child::after { display: none; }
.timeline li.now::before { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.timeline .tl-head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.timeline .tl-time { color: var(--text2); font-size: 12px; font-weight: 400; white-space: nowrap; }
.timeline .tl-sub { color: var(--text2); font-size: 12px; margin-top: 2px; }

/* ---------- 详情信息块 ---------- */
.kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 20px; }
.kv .k { font-size: 12px; color: var(--text2); }
.kv .v { font-size: 14px; margin-top: 2px; word-break: break-all; }
.med-block {
  border-left: 3px solid var(--cat-cl); background: rgba(48, 176, 199, .06);
  border-radius: 10px; padding: 14px 16px; margin: 14px 0;
}

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.field label { display: block; font-size: 12px; color: var(--text2); margin-bottom: 5px; }
.field input, .field select, .field textarea { width: 100%; }
.field textarea { min-height: 84px; resize: vertical; font-family: var(--font); }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; gap: 12px; justify-content: flex-end; margin-top: 14px; color: var(--text2); font-size: 13px; }

/* ---------- 树 ---------- */
.tree-node { padding-left: 0; }
.tree-node .tn-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; }
.tree-node .tn-row:hover { background: rgba(0, 0, 0, .03); }
.tree-children { margin-left: 22px; border-left: 1px solid var(--line); padding-left: 8px; }
.tn-type { font-size: 10px; color: var(--text3); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; }

.empty { text-align: center; color: var(--text3); padding: 48px 0; font-size: 13px; }
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: var(--text); color: #fff; font-size: 13px; border-radius: 99px; padding: 10px 20px;
  box-shadow: var(--shadow-lg); max-width: 80vw;
}
.toast.err { background: var(--red); }

/* ---------- 通知角标 ---------- */
.bell-btn { position: relative; padding: 7px 10px; }
.bell-btn > span:last-child {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px;
  border-radius: 99px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; align-items: center; justify-content: center; padding: 0 4px;
}

/* ---------- H5（消费者页由独立文件实现，此处为复用基元） ---------- */
@media (max-width: 760px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 8px 16px 40px; }
  .topbar { padding: 14px 16px 10px; }
  .topbar h1 { font-size: 21px; }
}
