/* ==========================================================================
   律师办系统 UI 主题 v3 —— 现代商务体系（全局视觉层）
   --------------------------------------------------------------------------
   ★ 设计原则（继承 v2，务必遵守）：
     1. 只改「视觉」：字体 / 圆角 / 阴影 / 边框色 / 焦点环 / 滚动条 / 少量内边距
        ✗ 不碰 display / position / width / height / flex → 零功能影响
     2. 通过 base.html 一行 <link> 引入 → 删除那一行即完全回滚
     3. 保留原有配色语义：★ 不覆盖任何按钮/标签的「背景色」，
        只统一形状（圆角）、质感（阴影/字重）、交互反馈（hover/active/focus）
     4. 主色与案件中心一致：#1B3A5C
   --------------------------------------------------------------------------
   v3 vs v2 的差别：
     · 圆角：沿用「编排-案件中心-定稿」的紧凑方正风格（小元素 4px / 按钮输入框 6px / 卡片 6px / 弹窗 8px）
     · 阴影 单层浅影 → 多层柔和（更有层次）
     · 覆盖 裸 <button>（v2 只覆盖 .btn 等类名，项目里大量是裸 button）
     · 覆盖 更多卡片类名（.panel/.box/.section-card/.form-card/.stat-card…）
     · 表格行高、卡片内边距、内容区间距 → 统一到「紧凑」尺度（用户要求：间距不要太大）
     · ⑫ 同层级标题字号统一成 5 档梯度（h1 22 / h2 18 / h3 16 / h4 15 / h5·h6 14）
   ========================================================================== */

:root {
    --ui-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    --ui-primary: #1B3A5C;
    --ui-primary-dark: #14283F;
    --ui-border: #D5E0EC;
    --ui-border-light: #E7EDF3;
    /* 圆角阶梯（★ 2026-09-19 用户定调：沿用「编排-案件中心-定稿」的紧凑方正风格，
       大圆角会破坏定稿观感 → 全部收小）
       小元素 4px / 按钮·输入框 6px / 卡片 6px / 弹窗 8px / 胶囊 999px */
    --ui-radius-xs: 4px;
    --ui-radius-sm: 6px;
    --ui-radius: 6px;
    --ui-radius-lg: 8px;
    --ui-radius-pill: 999px;
    /* 阴影阶梯（v3 更柔、多层） */
    --ui-shadow-btn: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
    --ui-shadow-btn-hover: 0 2px 4px rgba(15, 23, 42, .08), 0 4px 12px rgba(15, 23, 42, .10);
    --ui-shadow-card: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .06);
    --ui-shadow-modal: 0 16px 48px rgba(15, 23, 42, .24);
    /* 间距（留白）—— ★ 保持紧凑，不要撑开 */
    --ui-gap: 12px;
    --ui-pad-card: 16px;
}

/* ① 字体统一（中文优先 PingFang / 雅黑，避免系统默认宋体渲染） */
body, button, input, select, textarea, table, .btn, .d-btn {
    font-family: var(--ui-font) !important;
}
body { -webkit-font-smoothing: antialiased; }

/* ② 按钮：统一「凸起」质感
   ★ 不覆盖背景色 —— 各页原有的绿/蓝/红/橙语义一律保留；
   仅给「没有自定义背景色」的裸按钮补上中性底色 + 细边框（体积感）。 */
.btn, .d-btn, .action-btn, .btn-action, .btn-sm,
button, input[type="submit"], input[type="button"] {
    border-radius: var(--ui-radius-sm) !important;
    font-weight: 600 !important;
    box-shadow: var(--ui-shadow-btn) !important;
    transition: box-shadow .16s ease, transform .06s ease, background-color .16s ease,
                border-color .16s ease, color .16s ease, opacity .16s ease !important;
}
/* 无自定义背景的裸按钮 → 中性「凸起」底
   ★ 只命中「既没有 class、又没有内联背景色」的纯裸按钮，最大化避免误伤 */
button:not([class]):not([style*="background"]) {
    background: #F8FAFC !important;
    border: 1px solid #D5E0EC !important;
    color: #33445A !important;
}
button:not([class]):not([style*="background"]):hover { background: #F1F5F9 !important; border-color: #D5E0EC !important; }
:hover > .btn, .btn:hover, .d-btn:hover, .action-btn:hover, .btn-action:hover,
button:hover { box-shadow: var(--ui-shadow-btn-hover) !important; }
.btn:active, .d-btn:active, .action-btn:active, .btn-action:active,
button:active { transform: translateY(1px) !important; box-shadow: none !important; }
.btn:disabled, .d-btn:disabled, button:disabled { opacity: .5 !important; cursor: not-allowed !important; box-shadow: none !important; }

/* ③ 输入框：统一「凹陷」质感 + 焦点环（排除勾选框/单选，避免破坏原生外观） */
input[type="text"], input[type="password"], input[type="number"], input[type="email"],
input[type="date"], input[type="datetime-local"], input[type="search"], input[type="tel"],
input[type="url"], select, textarea, .form-control, .d-input {
    border: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius-sm) !important;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, .05) !important;
    transition: border-color .16s, box-shadow .16s !important;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, input[type="email"]:focus,
input[type="date"]:focus, input[type="datetime-local"]:focus, input[type="search"]:focus, input[type="tel"]:focus,
input[type="url"]:focus, select:focus, textarea:focus, .form-control:focus, .d-input:focus {
    outline: none !important;
    border-color: #7FA6C8 !important;
    box-shadow: inset 0 1px 2px rgba(15,23,42,.04), 0 0 0 4px rgba(27, 58, 92, .10) !important;
}
textarea { line-height: 1.6 !important; }

/* ④ 卡片 / 面板：统一圆角 + 柔和多层阴影（覆盖项目里各页用的各种卡片类名） */
.card, .d-card, .panel, .box, .section-card, .form-card, .stat-card,
.sandbox-box, .content-card, .info-card, .data-card {
    border-radius: var(--ui-radius) !important;
    box-shadow: var(--ui-shadow-card) !important;
    border-color: var(--ui-border-light) !important;
}
/* 卡片内边距更宽松（留白）——只加不减，避免压扁原有紧凑布局 */
.card, .d-card, .form-card { padding: var(--ui-pad-card) !important; }

/* ⑤ 弹窗：统一质感（遮罩轻微模糊，突出层级） */
.modal-content, .modal-box, .dialog { border-radius: var(--ui-radius-lg) !important; box-shadow: var(--ui-shadow-modal) !important; }
.modal-overlay { backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); }

/* ⑥ 标签 / 徽章 / 胶囊：统一 pill 圆角与字重 */
.badge, .f-chip, .tag { border-radius: var(--ui-radius-xs) !important; font-weight: 600 !important; letter-spacing: .2px; }
/* .pill 语义上就是胶囊，保留全圆角 */
.pill { border-radius: var(--ui-radius-pill) !important; font-weight: 600 !important; letter-spacing: .2px; }

/* ⑦ 表格：表头字重统一、行分隔线变淡（行高保持紧凑，只微调） */
table thead th { font-weight: 600 !important; letter-spacing: .2px; }
table tbody tr { border-color: var(--ui-border-light) !important; }
table tbody td { padding-top: 6px !important; padding-bottom: 6px !important; }

/* ⑧ 标签页按钮：统一圆角与字重 */
.tab-btn { border-radius: var(--ui-radius-sm) !important; font-weight: 600 !important; }

/* ⑨ 滚动条：细灰（提升整体质感，不改变功能） */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D5E0EC; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #D5E0EC; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ⑩ 内容区留白（★ 保持紧凑：原页多为 30px，这里不再加大） */
.content-area { padding: 22px !important; }
@media (max-width: 768px) { .content-area { padding: 14px !important; } }

/* ⑪ 收掉页面里零散的「偏大内边距」（用户要求：间距不要太大）
   全站扫描结果：padding 主流是 4–12px，但少数页面内联写了 20/24/25/30/40px。
   ★ 关键保护：`:not([style*="Npx "])` 用来排除「多值写法」（如 padding:20px 0
     —— 只设上下、左右为 0），这类若被整条覆盖会把左右也撑开、改变布局，
     故一律不碰（只处理单值 padding）。更大的 50/60/100/120px 多属空状态区，
     保持不动。删掉本段即完全恢复。 */
[style*="padding: 20px"]:not([style*="20px "]), [style*="padding:20px"]:not([style*="20px "]) { padding: 16px !important; }
[style*="padding: 25px"]:not([style*="25px "]), [style*="padding:25px"]:not([style*="25px "]) { padding: 16px !important; }
[style*="padding: 24px"]:not([style*="24px "]), [style*="padding:24px"]:not([style*="24px "]) { padding: 16px !important; }
[style*="padding: 30px"]:not([style*="30px "]), [style*="padding:30px"]:not([style*="30px "]) { padding: 18px !important; }
[style*="padding: 40px"]:not([style*="40px "]), [style*="padding:40px"]:not([style*="40px "]) { padding: 24px !important; }

/* ⑫ 标题层级统一（用户要求：字号统一，但间距保持紧凑）
   全站扫描结果：h1 有 20/22/24px 三档、h2/h3 各四档、.card-title 16/18px 不一，
   程序编辑页的 <h2> 甚至没写字号（用浏览器默认值）→ 同一层级在不同页观感不一致。
   这里收敛成 5 档梯度（紧凑商务尺度）。
   ★ 安全边界（务必保留）：
     · 只统一「字号 / 字重 / 行高」，不动 margin/padding/display —— 不搬位置、不改留白；
     · 用 :not([style*="font-size"]) 把「页面自己写死了字号」的标题整个排除在外
       （页面有意强调的标题、或把 <h4> 当 svg 图标容器用的地方），一个像素都不动；
     · .stat-value/.num/.price/.logo 等「数据大字」与 emoji/图标字号一律不碰；
     · h1 span 之类更深的子选择器仍按原样（本段只命中标题元素自身）。
   删除本段即完全恢复原状。 */
h1:not([style*="font-size"]) { font-size: 22px !important; }
h2:not([style*="font-size"]) { font-size: 18px !important; }
h3:not([style*="font-size"]), .card-title, .panel-title, .modal-title, .section-title { font-size: 16px !important; }
h4:not([style*="font-size"]) { font-size: 15px !important; }
h5:not([style*="font-size"]), h6:not([style*="font-size"]) { font-size: 14px !important; }
h1:not([style*="font-size"]), h2:not([style*="font-size"]), h3:not([style*="font-size"]),
h4:not([style*="font-size"]), h5:not([style*="font-size"]), h6:not([style*="font-size"]) {
    line-height: 1.4 !important; font-weight: 600 !important;
}
/* AI 工作台聊天气泡内的标题跟随正文（原 14.5px，别被上面的规则抬高） */
.ai-bub h1, .ai-bub h2, .ai-bub h3, .ai-bub h4, .ai-bub h5, .ai-bub h6 {
    font-size: 14.5px !important; font-weight: 600 !important; line-height: 1.55 !important;
}

/* ==========================================================================
   矢量图标全局尺寸（★关键★ 缺少此规则时 <svg class="nvi"> 会按浏览器默认
   渲染成 300×150 的巨幅色块）
   ========================================================================== */
.nvi {
    width: 1.05em !important;
    height: 1.05em !important;
    display: inline-block !important;
    vertical-align: -0.16em !important;
    flex: 0 0 auto !important;
    overflow: visible !important;
}
svg.nvi { max-width: 1.05em !important; max-height: 1.05em !important; }
button > .nvi, a > .nvi { margin-right: 3px; }
.icon-btn .nvi { width: 15px !important; height: 15px !important; margin: 0 !important; }
.nav-icon .nvi { width: 17px !important; height: 17px !important; }
.notif-bell .nvi { width: 19px !important; height: 19px !important; }

/* ==========================================================================
   ⑬ 容器头「默认浅色 → 悬停加深一档」（2026-09-20 用户拍板：同色系加深）
   --------------------------------------------------------------------------
   范围：浅色底的卡片头 / 分区头 / 折叠头。
   ★ 深色头一律不动（#0f172a / #1e293b：viewer-header / list-header /
     card-header / audit-header / dossier-head / m-header / fw-head / xray-header）。
   ★ 只改 background / transition，不动尺寸与布局。删本段即完全回滚。
   ========================================================================== */
.contract-header, .panel-header, .group-header, .folder-header, .action-header,
.proc-group-hd, .proc-set-hd, .m-cal-header, .rw-modal-header, .client-head-v2 {
    transition: background-color .18s cubic-bezier(.4,0,.2,1), box-shadow .18s ease !important;
}
.contract-header:hover { background: #F1F5F9 !important; }   /* 默认 #F8FAFC / #F8FAFC */
.client-head-v2:hover  { background: #F1F5F9 !important; }   /* 默认 #F8FAFC */
.proc-set-hd:hover     { background: #E7EDF3 !important; }   /* 默认 #F8FAFC */
.proc-group-hd:hover   { background: #E7EDF3 !important; }   /* 默认 #F1F5F9 */
.panel-header:hover    { background: #E7EDF3 !important; }   /* 默认 #f1f5f9 */
.group-header:hover, .folder-header:hover, .action-header:hover,
.m-cal-header:hover, .rw-modal-header:hover { background: #F1F5F9 !important; }  /* 默认 #f8fafc */

/* ==========================================================================
   ⑭ 卡片 / 列表行 hover 反馈（全站统一：描边加深 + 阴影抬起 + 行底色微深）
   ★ 只改 border-color / box-shadow / background，不动尺寸与位置。
     已有专属 hover 的页面（如案件中心 .client-card-row）优先。
   ========================================================================== */
.card:hover, .d-card:hover, .panel:hover, .content-card:hover, .info-card:hover,
.data-card:hover, .stage-card:hover, .proc-card:hover, .m-proc-card:hover,
.folder-card:hover, .file-card:hover, .review-card:hover, .ai-card:hover, .ov-card:hover {
    border-color: #D5E0EC !important;
    box-shadow: 0 4px 14px rgba(27,58,92,.08), 0 1px 3px rgba(27,58,92,.05) !important;
}
table tbody tr:hover > td, table tbody tr:hover > th { background: #F8FAFC !important; }

/* ==========================================================================
   ⑮ 按钮 hover 统一抬升与加深 + focus-visible 环（②③ 段的收尾）
   ★ 不改背景色（各页绿/蓝/红语义保留），只加上浮与微加深；
     focus-visible 仅键盘导航时触发，不干扰鼠标操作。
   ========================================================================== */
.btn:not(:disabled):hover, .d-btn:not(:disabled):hover, .action-btn:not(:disabled):hover,
.btn-action:not(:disabled):hover, .btn-sm:not(:disabled):hover, button:not(:disabled):hover {
    transform: translateY(-1px) !important;
    filter: brightness(.97);
}
.btn:focus-visible, .d-btn:focus-visible, .action-btn:focus-visible, button:focus-visible,
a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 2px solid #7FA6C8 !important; outline-offset: 2px !important;
}

/* ==========================================================================
   ⑯ 表头 th / 工具条统一（2026-09-20）
   --------------------------------------------------------------------------
   现状：各页表头底色有 6 种（#F8FAFC/#f1f5f9/#f8fafc/#fff/#F8FAFC）、
        字号 12/13/14px 混用、内边距 8–16px 不等。
   改法：统一为浅灰底 + 中性字色 + 12.5px + 紧凑内边距。
   ★ 只改底色/字号/内边距，不动表格布局。删本段即回滚。
   ========================================================================== */
table thead th, table > thead > tr > th {
    background: #F8FAFC !important;
    color: #475569 !important;
    font-weight: 600 !important;
    font-size: 12.5px !important;
    letter-spacing: .2px;
    border-bottom: 1px solid var(--ui-border) !important;
    padding: 9px 12px !important;
    white-space: nowrap;
}

/* ==========================================================================
   ⑰ 选项卡按钮 hover / active 统一（2026-09-20）
   --------------------------------------------------------------------------
   现状：各页 tab 配色有 4 套（#3b82f6 实心 / #eff6ff 浅蓝 /
        白底 / #4f46e5 紫）。改法：对齐「案件中心·定稿」的浅底深字。
   ★ 只改 background / color / border-bottom-color，不动尺寸与布局。删本段即回滚。
   ========================================================================== */
.tab-btn.active {
    background: #F8FAFC !important;
    color: #1B3A5C !important;
    border-bottom-color: #1B3A5C !important;
}
.tab-btn:not(.active):not(.step-done):hover {
    background: #F8FAFC !important;
    color: #25456B !important;
}

/* ==========================================================================
   ⑱ 空状态 / 加载中提示统一（2026-09-20）
   --------------------------------------------------------------------------
   现状：全站 23 个类名（.node-empty/.empty-state/.notif-empty/
        .ai-empty/.ws-empty/.m-*-empty 等）各写各的。
   ★ 只统一文字色（弱化灰），不动字号/padding/布局。
   ========================================================================== */
.empty-state, .empty, .empty-cell, .empty-hint, .notif-empty, .st-empty,
.ai-empty, .ai-empty-t, .ai-empty-s, .ov-empty, .ov-loading, .loading, .dossier-empty,
.m-app-empty, .m-notif-empty, .m-notif-loading, .m-tk-empty, .rw-empty, .rw-loading,
.rb-empty, .ws-empty, .tkd-empty {
    color: #94A3B8 !important;
}

/* ==========================================================================
   ⑲ 控件与浅紫块的「装饰性浅彩底」收敛（2026-09-20）
   --------------------------------------------------------------------------
   现状：部分页面把 input/select/textarea/按钮 的底色写成浅绿 #f0fdf4 /
        浅蓝 #f0f9ff / 浅靛 #eef2ff（如 manage_users 的输入框），视觉很花。
   ★ 为避免误伤语义色，本段只命中「控件本身」与「浅紫块」，
     不碰提示条 / 状态块（如「上传成功变绿」、「已结案绿」）。
   ★ 只改 background / border-color / color，不动尺寸布局。删本段即回滚。
   ========================================================================== */
/* 1) 表单控件的浅彩底 → 白底 + 标准边框 */
select[style*="#f0fdf4"], input[style*="#f0fdf4"], textarea[style*="#f0fdf4"],
select[style*="#f0f9ff"], input[style*="#f0f9ff"], textarea[style*="#f0f9ff"],
select[style*="#ecfdf5"], input[style*="#ecfdf5"], textarea[style*="#ecfdf5"],
select[style*="#eef2ff"], input[style*="#eef2ff"], textarea[style*="#eef2ff"] {
    background: #FFFFFF !important;
    border-color: #D5E0EC !important;
    color: #334155 !important;
}
/* 2) 按钮的浅彩底 → 中性次要档 */
button[style*="#f0f9ff"], input[type="button"][style*="#f0f9ff"], input[type="submit"][style*="#f0f9ff"],
button[style*="#f0fdf4"], input[type="button"][style*="#f0fdf4"], input[type="submit"][style*="#f0fdf4"],
button[style*="#eef2ff"], button[style*="#f5f3ff"], button[style*="#faf5ff"] {
    background: #F8FAFC !important;          /* 浅灰蓝：有色调但不刺眼 */
    border: 1px solid #D5E0EC !important;    /* 清晰描边：在灰白页面上不糊 */
    color: #1B3A5C !important;
    box-shadow: 0 1px 2px rgba(27,58,92,.06) !important;
}
/* 3) 浅紫块（最扎眼的一类）→ 中性浅灰 + 中性字色 */
[style*="background: #faf5ff"], [style*="background:#faf5ff"],
[style*="background: #f5f3ff"], [style*="background:#f5f3ff"] { background: #F8FAFC !important; }
[style*="color: #7e22ce"], [style*="color:#7e22ce"],
[style*="color: #9333ea"], [style*="color:#9333ea"],
[style*="color: #6b21a8"], [style*="color:#6b21a8"] { color: #334155 !important; }


/* ==========================================================================
   ⑭ 窄屏降级（2026-09-30）
   --------------------------------------------------------------------------
   多列 / 固定侧栏布局在平板与手机宽度下会挤压。这里只针对【页面特有的布局类名】降级，
   ★ 绝不覆盖 .container / .dashboard / .proc-details 这类多页共用的通用名字。
   删除本段即完全回滚。
   ========================================================================== */
@media (max-width: 1100px) {
    /* 程序编辑页：3fr 4fr → 单列 */
    .proc-layout { grid-template-columns: 1fr !important; }
    /* 文书中心：280px 侧栏 + 内容 → 单列 */
    .doc-layout { grid-template-columns: 1fr !important; }
    /* 审批台：横向 flex + calc(100vh) 固定高 + 子项 min-width 380px → 纵向、高度自适应 */
    .approval-layout { flex-direction: column !important; height: auto !important; min-height: 0 !important; }
    .approval-layout .file-list { min-width: 0 !important; max-width: none !important; }
}

@media (max-width: 768px) {
    /* 更窄时收窄列间距，避免内容被挤成一条 */
    .proc-layout, .doc-layout { gap: 12px !important; }
}
