/* ==========================================================================
   律文管理系统 · 设计系统
   ========================================================================== */
:root {
  --bg: #f4f6fb;
  --bg-soft: #eef1f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #475569;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e6eaf2;
  --line-soft: #eef1f7;
  --primary: #3b5bff;
  --primary-2: #2c49e0;
  --primary-soft: #eef2ff;
  --navy: #0b1220;
  --green: #0ca678;
  --green-soft: #e4f7f0;
  --amber: #d97706;
  --amber-soft: #fdf1df;
  --red: #e03131;
  --red-soft: #fdeaea;
  --purple: #7048e8;
  --purple-soft: #f1ecfe;
  --cyan: #0b7285;
  --cyan-soft: #e2f4f7;
  --radius: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 14px 34px -18px rgba(15, 23, 42, .22);
  --shadow-lg: 0 34px 70px -26px rgba(15, 23, 42, .34);
  --sidebar: 248px;
  --topbar: 68px;
  --font: "Inter", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, figure { margin: 0; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(59, 91, 255, .18); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cfd6e4; border-radius: 10px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b7c0d3; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }
.icon-lg { width: 22px; height: 22px; }

.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.small { font-size: 12.5px; }
.mini { font-size: 11.5px; }
.strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.wrap { flex-wrap: wrap; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.clickable { cursor: pointer; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 38px;
  padding: 0 15px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  font-weight: 550;
  font-size: 13.5px;
  transition: all .18s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: #d4dbeb; background: #fbfcff; color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, #4a68ff, #3451ef);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 10px 22px -10px rgba(59, 91, 255, .75);
}
.btn-primary:hover { background: linear-gradient(135deg, #5573ff, #2f4be0); color: #fff; border-color: transparent; }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-2); box-shadow: none; }
.btn-soft:hover { background: #e3e9ff; color: var(--primary-2); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); border-color: transparent; }
.btn-danger { color: var(--red); border-color: #f6d5d5; background: #fff; }
.btn-danger:hover { background: var(--red-soft); border-color: #f3c1c1; color: var(--red); }
.btn-danger-solid { background: var(--red); border-color: transparent; color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 9px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 11.5px; border-radius: 8px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }
.btn-icon.btn-sm { width: 30px; height: 30px; }
.btn-block { width: 100%; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; gap: 4px; }
.field > label .req { color: var(--red); }
.input, .select, .textarea {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbfcfe;
  color: var(--ink);
  transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
  outline: none;
}
.textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:hover, .select:hover, .textarea:hover { border-color: #d5dceb; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3.5px rgba(59, 91, 255, .13);
  background: #fff;
}
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 15px;
  padding-right: 34px;
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group .icon { position: absolute; left: 12px; color: var(--muted-2); pointer-events: none; }
.input-group .input { padding-left: 38px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-section { padding-top: 6px; }
.form-section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted-2); margin: 6px 0 12px; display: flex; align-items: center; gap: 8px;
}
.form-section-title::after { content: ""; height: 1px; flex: 1; background: var(--line-soft); }
.hint { font-size: 12px; color: var(--muted-2); line-height: 1.5; }
.field-error { font-size: 12px; color: var(--red); }
.input-error { border-color: var(--red) !important; }

.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.switch input { display: none; }
.switch .track {
  width: 42px; height: 24px; border-radius: 999px; background: #d5dbe8; position: relative;
  transition: background .2s ease; flex: none;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(15, 23, 42, .2);
  transition: transform .2s ease;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(18px); }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
}
.card.tight { padding: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.card-head h3 { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card-head .sub { font-size: 12.5px; color: var(--muted-2); margin-top: 3px; }
.card-title-row { display: flex; align-items: center; gap: 9px; }
.card-title-row .badge-count {
  min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: var(--bg-soft);
  color: var(--muted); font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}

/* ---------- 徽标 / 胶囊 ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: 7px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--bg-soft); color: var(--ink-3);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--green-soft); color: #087f5b; }
.pill-amber { background: var(--amber-soft); color: #b45309; }
.pill-red { background: var(--red-soft); color: #c92a2a; }
.pill-blue { background: var(--primary-soft); color: var(--primary-2); }
.pill-purple { background: var(--purple-soft); color: #5f3dc4; }
.pill-cyan { background: var(--cyan-soft); color: #0b7285; }
.pill-gray { background: #f1f3f8; color: var(--muted); }
.pill-solid { background: var(--ink); color: #fff; }
.pill-lg { height: 28px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }

.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 6px; background: var(--bg-soft); color: var(--muted); font-size: 11.5px;
}

/* ---------- 表格 ---------- */
.table-wrap { width: 100%; overflow: auto; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 720px; }
.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #fafbfe;
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .04em;
  color: var(--muted-2);
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr { transition: background .14s ease; }
.table tbody tr:hover { background: #f9faff; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr.clickable:hover { background: #f5f7ff; }
.table .num { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .cell-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.table .cell-main .name { font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 6px; }
.table .cell-main .sub { font-size: 12px; color: var(--muted-2); margin-top: 1px; }

/* ---------- 头像 ---------- */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12.5px; font-weight: 650; letter-spacing: .02em;
  background: #64748b; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .18);
}
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 44px; height: 44px; font-size: 15px; }
.avatar-xl { width: 60px; height: 60px; font-size: 19px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid #fff; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- 进度 ---------- */
.bar { height: 6px; border-radius: 999px; background: #edf0f6; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5b7bff, #3b5bff); transition: width .5s ease; }
.bar.green > span { background: linear-gradient(90deg, #29c39a, #0ca678); }
.bar.amber > span { background: linear-gradient(90deg, #f5b041, #d97706); }
.bar.red > span { background: linear-gradient(90deg, #ff8787, #e03131); }
.bar.sm { height: 4px; }

/* ---------- 页签 ---------- */
.tabs { display: flex; align-items: center; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  position: relative; padding: 10px 14px 12px; color: var(--muted); font-weight: 550; font-size: 13.5px;
  border: none; background: none; transition: color .16s ease; display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); font-weight: 650; }
.tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2.5px;
  border-radius: 3px; background: var(--primary);
}
.tab .count { font-size: 11px; font-weight: 650; color: var(--muted-2); background: var(--bg-soft); border-radius: 6px; padding: 1px 6px; }
.tab.active .count { background: var(--primary-soft); color: var(--primary-2); }

.segmented { display: inline-flex; padding: 3px; background: var(--bg-soft); border-radius: 11px; gap: 2px; }
.segmented button {
  border: none; background: transparent; padding: 6px 13px; border-radius: 8px; font-size: 12.5px;
  color: var(--muted); font-weight: 550; transition: all .16s ease;
}
.segmented button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 650; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box .icon { position: absolute; left: 12px; color: var(--muted-2); width: 16px; height: 16px; }
.search-box input {
  height: 38px; width: 240px; padding: 0 12px 0 36px; border-radius: 11px;
  border: 1px solid var(--line); background: #fbfcfe; outline: none; transition: all .16s ease;
}
.search-box input:focus { border-color: var(--primary); box-shadow: 0 0 0 3.5px rgba(59, 91, 255, .12); background: #fff; width: 280px; }

/* ---------- 弹层 ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 90; background: rgba(15, 23, 42, .38);
  backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fadeIn .18s ease;
}
.modal {
  width: min(680px, 100%); max-height: calc(100vh - 48px); background: #fff;
  border-radius: 20px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: modalIn .22s cubic-bezier(.2, .8, .3, 1); overflow: hidden;
}
.modal.wide { width: min(860px, 100%); }
.modal.slim { width: min(480px, 100%); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 24px 0; }
.modal-head h3 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.modal-head .sub { font-size: 12.5px; color: var(--muted-2); margin-top: 3px; }
.modal-body { padding: 20px 24px; overflow: auto; }
.modal-foot {
  padding: 14px 24px 20px; display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--line-soft); background: #fdfdff;
}
.modal-foot .left { margin-right: auto; }

.drawer-wrap { position: fixed; inset: 0; z-index: 90; }
.drawer-overlay { position: absolute; inset: 0; background: rgba(15, 23, 42, .36); backdrop-filter: blur(2px); animation: fadeIn .18s ease; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(660px, 100%); background: #fff;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: drawerIn .26s cubic-bezier(.2, .8, .3, 1);
}
.drawer-head { padding: 20px 24px; border-bottom: 1px solid var(--line-soft); display: flex; gap: 14px; align-items: flex-start; }
.drawer-head h2 { font-size: 18px; font-weight: 650; letter-spacing: -.015em; }
.drawer-body { padding: 20px 24px 32px; overflow: auto; flex: 1; }
.drawer-foot { padding: 13px 24px; border-top: 1px solid var(--line-soft); display: flex; gap: 10px; justify-content: flex-end; background: #fdfdff; }

.close-btn {
  width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); display: inline-flex; align-items: center; justify-content: center;
  transition: all .16s ease; flex: none;
}
.close-btn:hover { background: var(--bg-soft); color: var(--ink); }

/* ---------- 提示 ---------- */
.toast-root { position: fixed; right: 22px; bottom: 22px; z-index: 120; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 240px; max-width: 380px;
  padding: 12px 15px; border-radius: 12px; background: #fff; border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 13px; color: var(--ink-2); animation: toastIn .22s cubic-bezier(.2, .8, .3, 1);
}
.toast .icon { flex: none; }
.toast.success .icon { color: var(--green); }
.toast.error .icon { color: var(--red); }
.toast.info .icon { color: var(--primary); }
.toast.leaving { animation: toastOut .2s ease forwards; }

/* ---------- 空状态 ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 20px; text-align: center; }
.empty .empty-icon {
  width: 54px; height: 54px; border-radius: 16px; background: var(--bg-soft); color: var(--muted-2);
  display: flex; align-items: center; justify-content: center; margin-bottom: 14px;
}
.empty .empty-icon .icon { width: 24px; height: 24px; }
.empty h4 { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.empty p { font-size: 12.5px; color: var(--muted-2); margin-top: 5px; max-width: 340px; }
.empty .btn { margin-top: 16px; }

/* ---------- 骨架屏 ---------- */
.skeleton { background: linear-gradient(90deg, #eef1f7 25%, #f7f9fc 37%, #eef1f7 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 8px; }

/* ---------- 其他 ---------- */
.divider { height: 1px; background: var(--line-soft); }
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 5px; border: 1px solid var(--line); background: #fff;
  font-size: 11px; color: var(--muted); box-shadow: 0 1px 0 var(--line);
}
.tooltip-host { position: relative; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes drawerIn { from { transform: translateX(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes pulseDot { 0%, 100% { box-shadow: 0 0 0 0 rgba(12, 166, 120, .45); } 50% { box-shadow: 0 0 0 5px rgba(12, 166, 120, 0); } }

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .search-box input { width: 170px; }
  .modal { border-radius: 16px; }
  .drawer { width: 100%; }
}
