/* ============================================================
   车管通 SaaS · 参考系统（insurance-crm v5.2）主题层  v5.5
   加载顺序：assets/css/style.css  →  本文件（覆盖）
   原则：只改视觉，不改任何业务 HTML 行为；旧 class 全部映射。
   ============================================================ */

/* ---------- 1. 设计令牌（与参考系统一致） ---------- */
:root {
  --bg: #f4f6f9;
  --panel: #fff;
  --text: #1d2433;
  --muted: #6b7280;
  --line: #e5e8ee;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --danger: #dc2626;
  --warn: #d97706;
  --ok: #059669;
  --sidebar: #111827;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 6px 20px rgba(16,24,40,.08);
  --shadow-lg: 0 20px 50px rgba(15,23,42,.18);
  --ease: cubic-bezier(.2,.8,.2,1);
  /* 兼容旧页面使用的别名 */
  --primary-dark: var(--primary-d);
  --sidebar-hover: #1f2937;
  --border: var(--line);
  --warning: var(--warn);
  --success: var(--ok);
}

/* ---------- 2. 基础 ---------- */
* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- 3. 布局 + 侧栏 ---------- */
.layout.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--sidebar); color: #cbd5e1;
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
  overflow: visible; z-index: 20; transition: none;
}
.sidebar .logo.brand {
  height: 64px; display: flex; align-items: center; gap: 11px;
  padding: 0 18px; color: #fff; font-weight: 600; font-size: 16px;
  border-bottom: 1px solid #1f2937; white-space: nowrap;
}
.sidebar .brand-mark {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #60a5fa); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; box-shadow: 0 4px 12px rgba(37,99,235,.3);
}
.sidebar .brand-txt { overflow: hidden; text-overflow: ellipsis; }
.sidebar .tenant-meta {
  padding: 12px 16px; font-size: 12px; color: #94a3b8;
  border-bottom: 1px solid #1f2937; line-height: 1.6;
}
.sidebar .tenant-meta b { color: #cbd5e1; font-weight: 500; }
.sidebar nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 13px; border-radius: 9px; margin-bottom: 4px;
  color: #cbd5e1; border-left: 0; text-decoration: none; position: relative;
  transition: background .16s, color .16s;
}
.sidebar nav a:hover { background: #1f2937; color: #fff; }
.sidebar nav a.active {
  background: var(--primary); color: #fff; border-left-color: transparent;
  box-shadow: 0 4px 12px rgba(37,99,235,.28);
}
.sidebar nav a.active::before {
  content: ""; position: absolute; left: -12px; top: 11px; bottom: 11px;
  width: 3px; border-radius: 0 3px 3px 0; background: #93c5fd;
}
.sidebar nav a .nav-ico { width: 18px; height: 18px; flex: none; opacity: .9; }
.sidebar nav a .nav-txt { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .sidebar-foot {
  padding: 16px; border-top: 1px solid #1f2937; font-size: 13px; flex: none;
}
.sidebar .sidebar-foot #user-info {
  margin-bottom: 10px; color: #94a3b8; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.sidebar .btn.ghost {
  background: transparent; color: #cbd5e1; border-color: #374151; text-align: center;
}
.sidebar .btn.ghost:hover { background: #1f2937; color: #fff; border-color: #475569; }

/* ---------- 4. 主区 / 顶栏 / 内容 ---------- */
.main {
  flex: 1; margin-left: 220px; width: calc(100% - 220px);
  min-width: 0; padding: 0;
}
.main > .topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--line);
  border-radius: 0; margin-bottom: 0; padding: 0 28px; box-shadow: none;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.main > .topbar #page-title { font-size: 18px; font-weight: 600; white-space: nowrap; }
.main > .topbar #page-title b { font-size: inherit; font-weight: inherit; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  background: #eef2ff; color: #4338ca; border-radius: 20px;
  padding: 5px 12px; font-size: 12px; white-space: nowrap;
}
.pill.off { background: #fef2f2; color: #b91c1c; }
.topbar .who { color: var(--muted); }
.topbar .who b { color: var(--text); }
.menu-toggle { display: none; }
.content { padding: 24px 28px 40px; max-width: 1440px; }

/* ---------- 5. 按钮（保留旧语义：.btn 主色，.btn-gray 次色） ---------- */
.btn {
  display: inline-block; border: 1px solid var(--primary); background: var(--primary);
  color: #fff; padding: 8px 16px; border-radius: 8px; cursor: pointer;
  font-size: 14px; line-height: 1.5; white-space: nowrap; text-decoration: none;
  transition: background .16s, border-color .16s, color .16s, transform .12s, box-shadow .16s;
  box-shadow: 0 2px 8px rgba(37,99,235,.2);
}
.btn:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-sm, .btn.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-block, .btn.btn-block { width: 100%; padding: 12px; font-size: 16px; box-shadow: none; }
.btn-gray, .btn.ghost {
  background: #fff; color: var(--text); border-color: var(--line); box-shadow: none;
}
.btn-gray:hover, .btn.ghost:hover { background: #f9fafb; border-color: #c7cdd8; color: var(--text); }
.btn-primary, .btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover, .btn.primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn-danger, .btn.danger { background: #fff; color: var(--danger); border-color: #fecaca; box-shadow: none; }
.btn-danger:hover, .btn.danger:hover { background: #fef2f2; border-color: #fca5a5; color: var(--danger); }
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; box-shadow: none; }
.btn-success:hover { background: #047857; border-color: #047857; }
td .btn + .btn { margin-left: 6px; }

/* ---------- 6. 卡片 / 网格 / 统计块 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow-sm); overflow-x: auto;
}
.card h2, .card h3 {
  font-size: 15px; font-weight: 600; margin-bottom: 16px; padding-bottom: 0;
  border-bottom: 0; display: flex; align-items: center; gap: 8px;
}
.card h2::before, .card h3::before {
  content: ""; width: 3px; height: 15px; border-radius: 2px;
  background: var(--primary); flex: none;
}
.stat-grid, .grid.c4 {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.grid { display: grid; gap: 16px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c5 { grid-template-columns: repeat(5, 1fr); }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px 20px 24px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.stat::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--primary);
}
.stat:nth-child(3)::before { background: var(--ok); }
.stat:nth-child(4)::before, .stat:nth-child(5)::before { background: var(--danger); }
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat .lbl, .stat .label { color: var(--muted); font-size: 13px; }
.stat .num {
  font-size: 34px; font-weight: 700; line-height: 1.2; margin-top: 8px;
  letter-spacing: -.5px; font-variant-numeric: tabular-nums;
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}

/* ---------- 7. 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-item label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 13px; }
.form-item label .req { color: var(--danger); }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=email], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
  outline: none; transition: border-color .16s, box-shadow .16s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
textarea { resize: vertical; min-height: 70px; }

/* ---------- 8. 表格 ---------- */
table.tbl, .tbl-wrap table { width: 100%; border-collapse: collapse; background: #fff; }
table.tbl th, .tbl-wrap th, table th {
  padding: 12px; text-align: left; border-bottom: 1px solid var(--line);
  background: #fafbfc; color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap;
}
table.tbl td, .tbl-wrap td, table td {
  padding: 12px; text-align: left; border-bottom: 1px solid var(--line);
  font-size: 13px; vertical-align: middle;
}
table.tbl tr:hover td, .tbl-wrap tr:hover td, tbody tr:hover td { background: #f7f9ff; }
tbody tr:last-child td { border-bottom: none; }
.tbl-wrap { overflow-x: auto; }
.sum-row td { background: #f8fafc !important; font-weight: 700; }

/* ---------- 9. 标签（参考系统为纯文字色标签） ---------- */
.tag {
  display: inline-block; padding: 3px 9px; border-radius: 12px;
  background: #eef2ff; color: #4338ca; font-size: 11px; margin-right: 4px; line-height: 1.5;
}
.tag-red, .tag.danger, .tag.expired, .tag.due3 { background: transparent; color: #b91c1c; font-weight: 600; }
.tag-green, .tag.ok, .tag.done { background: transparent; color: #047857; font-weight: 600; }
.tag-orange, .tag.warn, .tag.amber, .tag.due7 { background: transparent; color: #b45309; font-weight: 600; }
.tag-blue, .tag.due30, .tag.kind-car { background: transparent; color: #1d4ed8; font-weight: 600; }
.tag-gray, .tag.none, .tag.scrapped { background: transparent; color: #6b7280; font-weight: 600; }
.tag.purple, .tag.lost, .tag.kind-noncar { background: transparent; color: #6d28d9; font-weight: 600; }
.tag.due20 { background: transparent; color: #0e7490; font-weight: 600; }

/* ---------- 10. 闪现消息 / 横幅 ---------- */
.flash {
  padding: 12px 16px; border-radius: 10px; margin-bottom: 16px;
  border: 1px solid var(--line); background: #fff; font-size: 13px;
}
.flash-success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.flash-warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.snippet { color: var(--muted); font-size: 12px; }
.card > p.snippet { margin-top: 12px; padding: 11px 14px; background: #f8fafc; border-left: 3px solid var(--primary); border-radius: 0 7px 7px 0; line-height: 1.7; }
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv > span { color: var(--muted); }
.kv > b { font-weight: 500; text-align: right; word-break: break-all; }
.link { color: var(--primary); cursor: pointer; font-weight: 500; }
.link:hover { text-decoration: underline; }
.empty {
  padding: 58px 20px 40px; text-align: center; color: var(--muted);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpath d='M14 2v6h6'/%3E%3Cpath d='M8 13h8M8 17h5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center 14px;
}
.empty::before { content: ""; display: block; height: 50px; }

/* ---------- 11. 工具栏 / 分页 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.toolbar form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar input, .toolbar select { width: auto; }
.pager { margin-top: 16px; display: flex; gap: 6px; flex-wrap: wrap; }
.pager a, .pager span {
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 7px;
  background: #fff; font-size: 13px;
}
.pager .cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.seg { display: inline-flex; gap: 2px; background: #f1f5f9; border: 1px solid var(--line); border-radius: 10px; padding: 3px; flex: none; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 14px; border-radius: 7px; cursor: pointer; font-size: 12px; }
.seg button.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 4px rgba(16,24,40,.12); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: #fff;
  border: 1px solid var(--line); border-radius: 20px; padding: 5px 10px;
  margin: 0 6px 6px 0; font-size: 12px;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 12. 弹层 / 上传区（供新页面复用） ---------- */
@keyframes maskIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%,10px); } to { opacity: 1; transform: translate(-50%,0); } }
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); display: flex;
  align-items: center; justify-content: center; z-index: 50; padding: 20px;
  animation: maskIn .16s ease; backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 14px; width: 640px; max-width: 100%;
  max-height: 88vh; overflow: auto; padding: 26px; box-shadow: var(--shadow-lg);
  animation: modalIn .2s var(--ease);
}
.modal h2 { font-size: 17px; font-weight: 600; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; }
.modal h2::before { content: ""; width: 3px; height: 17px; border-radius: 2px; background: var(--primary); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 12px 22px; border-radius: 10px;
  z-index: 100; box-shadow: var(--shadow-lg); animation: toastIn .2s var(--ease);
  max-width: 90vw; text-align: center;
}
.dropzone {
  border: 2px dashed #c7d2fe; border-radius: 12px; background: #f8faff;
  padding: 32px; text-align: center; color: #4338ca; cursor: pointer; transition: .2s;
}
.dropzone:hover { background: #eef2ff; border-color: #a5b4fc; }
.file-item { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.file-item .meta { color: var(--muted); font-size: 12px; }

/* ---------- 13. 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
  background: radial-gradient(circle at 12% 18%, rgba(255,255,255,.18), transparent 38%),
              radial-gradient(circle at 88% 82%, rgba(255,255,255,.12), transparent 35%),
              linear-gradient(135deg, #1e3a8a, #2563eb 60%, #3b82f6);
}
.login-wrap::before, .login-wrap::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255,255,255,.12); pointer-events: none; }
.login-wrap::before { width: 420px; height: 420px; top: -120px; right: -80px; }
.login-wrap::after { width: 300px; height: 300px; bottom: -100px; left: -60px; }
.login-box, .login-card {
  width: 380px; max-width: 100%; position: relative; z-index: 1; background: #fff;
  border-radius: 18px; padding: 38px 34px; box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 56px; height: 56px; border-radius: 15px;
  background: linear-gradient(135deg, var(--primary), #60a5fa); color: #fff;
  font-size: 27px; font-weight: 600; display: flex; align-items: center; justify-content: center;
  margin: 0 auto 18px; box-shadow: 0 8px 20px rgba(37,99,235,.28);
}
.login-box h1, .login-card h1 { text-align: center; font-size: 21px; font-weight: 600; margin-bottom: 24px; letter-spacing: .3px; }
.login-box .form-item { margin-bottom: 16px; }
.login-box .btn-block { height: 42px; margin-top: 8px; }

/* ---------- 14. 响应式（参考系统：窄屏收成图标栏） ---------- */
@media (max-width: 1200px) { .grid.c5 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 900px) {
  .sidebar { width: 64px; transform: none; }
  .menu-toggle { display: none; }
  .sidebar .logo.brand { padding: 0; justify-content: center; }
  .sidebar .brand-txt, .sidebar nav a .nav-txt { display: none; }
  .sidebar .tenant-meta, .sidebar .sidebar-foot #user-info { display: none; }
  .sidebar nav { padding: 12px 8px; }
  .sidebar nav a { justify-content: center; padding: 12px 0; }
  .sidebar nav a.active::before { left: -8px; top: 9px; bottom: 9px; }
  .sidebar nav a .nav-ico { width: 20px; height: 20px; }
  .sidebar .sidebar-foot { padding: 12px 8px; }
  .sidebar .sidebar-foot .btn { padding: 8px 2px; font-size: 11px; white-space: nowrap; letter-spacing: -.3px; }
  .main { margin-left: 64px; width: calc(100% - 64px); }
  .main > .topbar { padding: 0 18px; }
  .content { padding: 20px 18px 36px; }
  .grid.c4, .grid.c3, .grid.c5 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .grid.c4, .grid.c3, .grid.c2, .grid.c5 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .main > .topbar { height: auto; min-height: 64px; padding: 10px 14px; flex-wrap: wrap; }
  .content { padding: 16px 12px 30px; }
  .card { padding: 16px 12px; }
  .stat .num { font-size: 30px; }
  .modal { padding: 20px; }
  .row > .btn, .row > input, .row > select { flex: 1 1 auto; }
}

/* ---------- 15. 打印 ---------- */
@media print {
  .sidebar, .topbar, .toolbar, .no-print, .pager { display: none !important; }
  .main { margin: 0; width: 100%; }
  .content { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
}
