/* ============================================================
   CAD设计中心每日数据核对系统 —— 公共样式
   ============================================================ */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --text: #0f172a;
  --dim: #64748b;
  --primary: #0891b2;
  --indigo: #6366f1;
  --grad: linear-gradient(135deg, #06b6d4 0%, #6366f1 100%);
  --green: #059669;
  --amber: #d97706;
  --orange: #ea580c;
  --red: #e11d48;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  background: #fff; 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(8, 145, 178, .12); }
input:disabled { background: #f1f5f9; color: var(--dim); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 5px; justify-content: center;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 9px; padding: 7px 14px; font-size: 13.5px; font-weight: 600;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--grad); border: none; color: #fff; box-shadow: 0 4px 12px rgba(99, 102, 241, .25); }
.btn.primary:hover { filter: brightness(1.06); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--dim); }
.btn.ghost:hover { background: rgba(8, 145, 178, .08); color: var(--primary); }
.btn.danger { border-color: #fecdd3; color: var(--red); }
.btn.danger:hover { background: #fff1f2; border-color: var(--red); }
.btn.success { background: var(--green); border: none; color: #fff; }
.btn.mini { padding: 3px 9px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #f1f5f9; color: var(--dim); white-space: nowrap;
}
.badge.gray { background: #f1f5f9; color: #64748b; }
.badge.cyan { background: rgba(6, 182, 212, .12); color: #0e7490; }
.badge.indigo { background: rgba(99, 102, 241, .12); color: #4f46e5; }
.badge.amber { background: rgba(217, 119, 6, .12); color: #b45309; }
.badge.orange { background: rgba(234, 88, 12, .12); color: #c2410c; }
.badge.green { background: rgba(5, 150, 105, .12); color: #047857; }
.badge.red { background: rgba(225, 29, 72, .12); color: #be123c; }
.badge.grad { background: var(--grad); color: #fff; }

/* ---------- 卡片 / 布局 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(15, 23, 42, .04);
}
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title .sub { font-size: 12px; color: var(--dim); font-weight: 400; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; margin-bottom: 14px; }
/* 精简指标条：一行多指标（值+标签），替代大卡片，紧凑规范 */
.summary-bar {
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 26px; row-gap: 6px;
  background: #f8fafc; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 16px; margin-bottom: 12px;
}
.summary-item { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.summary-item .v { font-size: 17px; font-weight: 800; line-height: 1.2; }
.summary-item .l { font-size: 12px; color: var(--dim); }
.summary-item .sub { font-size: 11px; color: #94a3b8; margin-left: 2px; }
.summary-item .v.green { color: var(--green); }
.summary-item .v.amber { color: var(--amber); }
.summary-item .v.red { color: var(--red); }
.summary-item .v.cyan { color: var(--primary); }
.summary-item .v.indigo { color: var(--indigo); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 9px 10px; color: var(--dim); font-size: 12.5px; font-weight: 600;
  border-bottom: 1px solid var(--line); background: #f8fafc; white-space: nowrap;
}
.table td { padding: 9px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.table tfoot td { font-weight: 700; background: #f8fafc; border-top: 1px solid var(--line); white-space: nowrap; }
/* 仅确实很长的内容列允许换行 */
.table .wrap { white-space: normal; word-break: break-word; }
.wrap { white-space: normal; word-break: break-word; }
.table .mono { font-family: Consolas, monospace; font-weight: 600; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.proj-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.proj-chip {
  background: rgba(8, 145, 178, .08); color: #0e7490; border-radius: 6px;
  padding: 1px 8px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.teeth-line { font-size: 12px; color: var(--dim); margin-top: 2px; }
.empty { text-align: center; color: var(--dim); padding: 36px 0; font-size: 13px; }

/* ---------- 筛选卡片 / 页签 ---------- */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--dim);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; transition: all .15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.on { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 4px 10px rgba(99, 102, 241, .28); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; background: #f1f5f9; border-radius: 10px; padding: 4px; }
.tab {
  border: none; background: transparent; color: var(--dim); padding: 6px 14px;
  border-radius: 8px; font-size: 13px; font-weight: 600; transition: all .15s;
}
.tab.on { background: #fff; color: var(--primary); box-shadow: 0 1px 4px rgba(15, 23, 42, .1); }
.tab .n { display: inline-block; min-width: 16px; margin-left: 4px; padding: 0 5px; border-radius: 999px; background: rgba(225, 29, 72, .12); color: var(--red); font-size: 11px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px;
  animation: fadeIn .15s;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 640px;
  max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(15, 23, 42, .25);
  animation: popIn .18s;
}
.modal.small { max-width: 430px; }
.modal.wide { max-width: 920px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 15px; font-weight: 700;
}
.modal-x { cursor: pointer; color: var(--dim); font-size: 16px; padding: 2px 6px; border-radius: 6px; }
.modal-x:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { transform: scale(.96); opacity: 0; } }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.form-item { display: flex; flex-direction: column; gap: 5px; }
.form-item label { font-size: 12.5px; color: var(--dim); font-weight: 600; }
.form-item .req::after { content: ' *'; color: var(--red); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--primary); }
.hint { font-size: 12px; color: var(--dim); }
.note-box { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 12px; border-radius: 9px; font-size: 12.5px; margin-bottom: 10px; }

/* ---------- 提示 ---------- */
#toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 300; pointer-events: none; }
.toast-item {
  background: #0f172a; color: #fff; padding: 10px 20px; border-radius: 10px;
  font-size: 13.5px; box-shadow: 0 10px 30px rgba(15, 23, 42, .3); animation: popIn .2s; max-width: 80vw;
}
.toast-item.error { background: var(--red); }
.toast-item.success { background: var(--green); }

/* ---------- 牙位选择器（上下牙弓各一行，不换行） ---------- */
.tooth-modal-body { padding: 4px 2px; }
.arch-label { font-size: 12px; color: var(--dim); margin: 10px 0 6px; font-weight: 600; }
.tooth-row { display: grid; grid-template-columns: repeat(16, 1fr); gap: 4px; }
.tooth {
  width: auto; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: #f8fafc; font-size: 12px; font-weight: 700; color: var(--dim);
  display: flex; align-items: center; justify-content: center; transition: all .12s;
  padding: 0;
}
.tooth:hover { border-color: var(--primary); color: var(--primary); }
.tooth.on { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 3px 8px rgba(99, 102, 241, .3); }
.tooth.q { border-left: 2px solid #cbd5e1; }

/* ---------- 迷你牙位十字图（订单列表独立列显示） ---------- */
.tmap { display: inline-block; line-height: 1; }
.tmap-arch { font-size: 9px; color: var(--dim); margin: 3px 0 1px; font-weight: 600; }
.tmap-row { display: flex; gap: 2px; }
.tmap-t {
  width: 21px; height: 21px; border: 1px solid var(--line); border-radius: 3px;
  font-size: 9px; color: #94a3b8; display: inline-flex; align-items: center; justify-content: center;
  background: #f8fafc; position: relative; user-select: none; flex-shrink: 0;
}
.tmap-t.q { border-left-width: 2px; border-left-color: #cbd5e1; }
.tmap-t.on { background: var(--grad); border-color: transparent; }
/* 实际修复牙位：牙位数字字体增亮突出显示（不使用小十字图标） */
.tmap-t .n { position: relative; z-index: 1; color: inherit; }
.tmap-t.on .n {
  color: #ffffff; font-weight: 800; font-size: 10.5px;
  text-shadow: 0 0 4px rgba(255, 255, 255, .95), 0 0 2px rgba(15, 23, 42, .35);
}
.tooth-info {
  margin-top: 12px; padding: 9px 12px; background: rgba(8, 145, 178, .06);
  border: 1px dashed rgba(8, 145, 178, .35); border-radius: 9px; font-size: 13px; color: #0e7490;
}

/* ---------- 时间线 ---------- */
.tl { list-style: none; margin: 6px 0; }
.tl li { position: relative; padding: 0 0 12px 22px; border-left: 2px solid var(--line); margin-left: 6px; }
.tl li:last-child { border-left-color: transparent; }
.tl li::before {
  content: ''; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--grad); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--line);
}
.tl .t { font-size: 12px; color: var(--dim); }
.tl .b { font-size: 13.5px; font-weight: 600; }
.tl .n { font-size: 12px; color: var(--dim); }

/* ============================================================
   登录页（三个端共用）
   ============================================================ */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(1000px 500px at 10% -10%, rgba(6, 182, 212, .18), transparent 60%),
              radial-gradient(900px 500px at 100% 110%, rgba(99, 102, 241, .16), transparent 60%), var(--bg); }
.login-card { background: #fff; border-radius: 18px; box-shadow: var(--shadow); width: 400px; overflow: hidden; }
.login-brand { background: var(--grad); color: #fff; padding: 26px 28px; }
.login-brand h1 { font-size: 20px; margin: 4px 0 2px; }
.login-brand p { font-size: 12.5px; opacity: .85; }
.login-body { padding: 24px 28px 28px; }
.login-body .form-item { margin-bottom: 14px; }
.login-foot { text-align: center; margin-top: 6px; font-size: 12.5px; color: var(--dim); }
.login-foot a:hover { text-decoration: underline; }
.role-tip { margin-top: 14px; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; color: var(--dim); }

/* ============================================================
   设计中心端布局
   ============================================================ */
.center-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; flex-shrink: 0;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255, 255, 255, .07); }
.logo .mark {
  width: 38px; height: 38px; border-radius: 10px; background: var(--grad);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.logo b { display: block; color: #fff; font-size: 15px; line-height: 1.3; }
.logo span { font-size: 11px; color: #94a3b8; }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.side-nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px; color: #cbd5e1;
  font-size: 13.5px; font-weight: 600; border-left: 3px solid transparent; transition: all .15s;
}
.side-nav a:hover { background: rgba(255, 255, 255, .05); color: #fff; }
.side-nav a.on { background: rgba(6, 182, 212, .12); color: #22d3ee; border-left-color: #22d3ee; }
.side-nav a .ic { width: 20px; text-align: center; }
.side-nav a .n {
  margin-left: auto; min-width: 20px; text-align: center; background: var(--red); color: #fff;
  border-radius: 999px; font-size: 11px; padding: 1px 6px;
}
.side-foot { padding: 12px 16px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 12px; color: #94a3b8; }
.side-foot .who { color: #fff; font-weight: 700; font-size: 13px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--line); padding: 0 22px; height: 56px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 16.5px; font-weight: 800; }
.topbar .links { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar .links a { color: var(--dim); font-size: 13px; font-weight: 600; }
.topbar .links a:hover { color: var(--primary); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.content { padding: 18px 22px 30px; }

/* ============================================================
   客户端布局（顶部导航）
   ============================================================ */
.client-layout { min-height: 100vh; }
.client-top {
  background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50;
}
.client-top-in {
  max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 58px;
}
.client-logo { display: flex; align-items: center; gap: 10px; }
.client-logo .mark { width: 36px; height: 36px; border-radius: 9px; background: var(--grad); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.client-logo b { font-size: 15.5px; }
.client-logo span { font-size: 11px; color: var(--dim); display: block; line-height: 1.2; }
.client-nav { display: flex; gap: 2px; }
.client-nav a {
  padding: 8px 14px; border-radius: 9px; color: var(--dim); font-size: 13.5px; font-weight: 600;
}
.client-nav a.on { background: rgba(8, 145, 178, .09); color: var(--primary); }
.client-nav a .n { margin-left: 4px; color: var(--red); font-weight: 800; }
.client-top .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.client-content { max-width: 1240px; margin: 0 auto; padding: 18px 20px 40px; }

/* ============================================================
   手机 H5
   ============================================================ */
.h5-wrap { max-width: 480px; margin: 0 auto; min-height: 100vh; background: var(--bg); position: relative; }
.h5-top {
  background: var(--grad); color: #fff; padding: 14px 16px 40px;
  border-radius: 0 0 22px 22px; position: relative;
}
.h5-top h1 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.h5-top .sub { font-size: 12px; opacity: .85; margin-top: 2px; }
.h5-top .out { position: absolute; right: 14px; top: 14px; background: rgba(255, 255, 255, .18); color: #fff; border: none; border-radius: 8px; padding: 5px 12px; font-size: 12.5px; }
.h5-body { padding: 12px 14px 84px; margin-top: -26px; }
.h5-card { background: #fff; border-radius: 13px; padding: 14px; margin-bottom: 12px; box-shadow: 0 2px 8px rgba(15, 23, 42, .05); border: 1px solid var(--line); }
.h5-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.h5-stat { background: #fff; border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line); }
.h5-stat .v { font-size: 21px; font-weight: 800; }
.h5-stat .l { font-size: 11.5px; color: var(--dim); }
.h5-list-item {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  margin-bottom: 10px;
}
.h5-list-item .row1 { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.h5-list-item .row1 b { font-size: 14px; }
.h5-list-item .row2 { font-size: 12.5px; color: var(--dim); margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.h5-list-item .acts { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.h5-bottom {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px;
  background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 60;
  padding-bottom: env(safe-area-inset-bottom);
}
.h5-bottom a {
  flex: 1; text-align: center; padding: 8px 0 7px; color: var(--dim); font-size: 11px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.h5-bottom a .ic { font-size: 19px; }
.h5-bottom a.on { color: var(--primary); }
.h5-bottom a .n {
  position: absolute; transform: translate(12px, -4px); background: var(--red); color: #fff;
  border-radius: 999px; font-size: 10px; min-width: 15px; padding: 0 4px; line-height: 15px;
}
.h5-bottom a { position: relative; }
.h5-section-title { font-size: 13px; font-weight: 700; color: var(--dim); margin: 6px 2px 10px; }
.h5-float {
  position: fixed; bottom: 84px; right: calc(50% - 220px); width: 46px; height: 46px; border-radius: 50%;
  background: var(--grad); color: #fff; font-size: 22px; border: none; box-shadow: 0 8px 20px rgba(99, 102, 241, .4);
  z-index: 60;
}

/* ---------- 打印（客户端确认后打印账单） ---------- */
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: fixed; inset: 0; background: #fff; padding: 24px; overflow: visible; }
}

@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .sidebar .logo b, .sidebar .logo span, .side-nav a span.txt, .side-foot { display: none; }
  .side-nav a { justify-content: center; padding: 12px 0; }
  .topbar { padding: 0 12px; }
  .topbar .links a { display: none; }
  .content { padding: 14px 12px 30px; }
  .form-grid { grid-template-columns: 1fr; }
}
