/* 法规库后台样式 */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f5f6f8;
    color: #333;
    line-height: 1.6;
}

/* 左侧导航布局 */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 154px; /* 原 220px 缩窄 30% */
    flex-shrink: 0;
    background: #1a3a5c;
    color: #fff;
    padding: 20px 0;
    position: sticky;
    top: 0;
    height: 100vh;
    box-sizing: border-box;
    overflow-y: auto;
}

.site-title {
    display: block;
    color: #fff;
    text-decoration: none;
    font-size: 19px;
    font-weight: 600;
    padding: 4px 24px 18px;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.side-nav a {
    color: #c8d8e8;
    text-decoration: none;
    font-size: 15px;
    padding: 10px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.side-nav a:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.side-footer {
    margin-top: auto;
    padding: 16px 20px 4px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar {
    display: flex;
    flex-direction: column;
}

.side-user {
    color: #c8d8e8;
    font-size: 13px;
}

.logout-btn {
    background: none;
    border: 1px solid #3d5a7a;
    color: #c8d8e8;
    font-size: 12px;
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
}

.logout-btn:hover {
    color: #fff;
    border-color: #c8d8e8;
}

/* 登录页 */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #1a3a5c;
}

.login-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    padding: 36px 40px;
    width: 340px;
    box-sizing: border-box;
}

.login-title {
    text-align: center;
    color: #1a3a5c;
    font-size: 22px;
    margin: 0 0 24px;
}

.login-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 14px;
    margin-bottom: 16px;
    text-align: center;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.login-field label {
    font-size: 14px;
    color: #475569;
}

.login-field input {
    box-sizing: border-box;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 15px;
}

.login-field input:focus {
    outline: none;
    border-color: #1a6fb0;
}

.login-submit {
    width: 100%;
    margin-top: 8px;
    padding: 11px;
    font-size: 15px;
}

/* MCP调试页 */
.mcp-desc {
    color: #64748b;
    font-size: 14px;
    margin: 4px 0 16px;
}

.mcp-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: none; /* 按语义定宽（模板内联 width），不拉伸占满 */
    min-width: 0;
}

/* 适用地域等：输入框与「包含全国性」勾选同排 */
.mcp-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* 返回条数：下拉选项 10~50（不用 filter-select，其 min-width:140px 会钳制小宽度）；
   padding/字号对齐 mcp-input 保证同行高度一致 */
.mcp-limit {
    padding: 8px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 15px;
    background: #fff;
    width: 70px;
    height: 39px; /* 与同行 mcp-input 渲染高度一致（select 盒模型天然多 2px） */
}

/* MCP 调试页「调用结果」标题：与耗时元信息合并一行、同小字体（12px 灰） */
.mcp-result-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 12px;
}

#mcp-result-title {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 600;
}

.mcp-field-label {
    font-size: 13px;
    color: #475569;
    white-space: nowrap;
}

.mcp-raw {
    display: flex;
    gap: 16px;
    margin-top: 16px;
}

.mcp-raw .mcp-field {
    flex: 1;
}

.mcp-textarea {
    box-sizing: border-box;
    width: 100%;
    background: #0f172a;
    color: #e2e8f0;
    border: none;
    border-radius: 6px;
    padding: 12px;
    font-size: 12px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    line-height: 1.5;
    resize: vertical;
}

.mcp-tool-label {
    font-size: 14px;
    color: #475569;
    white-space: nowrap;
    align-self: center;
}

.mcp-date-sep {
    color: #64748b;
    align-self: center;
}

.mcp-json {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 16px;
    font-size: 13px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    overflow-x: auto;
    max-height: 640px;
    overflow-y: auto;
    white-space: pre;
    margin: 0;
}

.mcp-json-error {
    color: #f87171;
}

/* MCP 日志页 */
.log-records {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.log-record {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 12px;
}

.log-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    color: #64748b;
}

.log-time {
    font-family: "SF Mono", Menlo, Consolas, monospace;
}

.log-level {
    padding: 1px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
}

.log-level-DEBUG {
    background: #f1f5f9;
    color: #475569;
}

.log-level-INFO {
    background: #e0f2fe;
    color: #0369a1;
}

.log-level-WARNING {
    background: #fef3c7;
    color: #b45309;
}

.log-level-ERROR,
.log-level-CRITICAL {
    background: #fee2e2;
    color: #b91c1c;
}

.log-req {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    color: #2563eb;
}

.log-msg {
    margin: 6px 0 0;
    background: #0f172a;
    color: #e2e8f0;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-msg-short {
    color: #94a3b8;
}

/* 含 JSON 段的消息：文本与折叠树混排 */
.log-msg-rich .log-text {
    white-space: pre-wrap;
    word-break: break-all;
}

.log-msg-rich .json-node {
    display: block;
    margin: 2px 0;
    border: 1px solid #334155;
    border-radius: 6px;
    background: #1e293b;
}

.log-msg-rich .json-node > summary {
    cursor: pointer;
    padding: 2px 10px;
    color: #7dd3fc;
    font-size: 12px;
    user-select: none;
    /* 折叠摘要单行显示：内容预览溢出省略 */
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 隐藏浏览器默认三角，改用自定义折叠图标（▸ / 展开时旋转为 ▾） */
.log-msg-rich .json-node > summary::-webkit-details-marker {
    display: none;
}

.log-msg-rich .json-node > summary::before {
    content: "▸";
    display: inline-block;
    width: 14px;
    color: #7dd3fc;
    transition: transform 0.15s;
}

.log-msg-rich .json-node[open] > summary::before {
    transform: rotate(90deg);
}

.log-msg-rich .json-preview {
    color: #94a3b8;
    margin-left: 6px;
}

.log-msg-rich .json-body {
    padding: 4px 10px 6px;
    border-top: 1px solid #334155;
}

.log-msg-rich .json-item {
    margin: 2px 0;
    font-size: 12px;
}

.log-msg-rich .json-key {
    color: #fbbf24;
    margin-right: 4px;
}

.log-msg-rich .json-scalar {
    color: #e2e8f0;
    word-break: break-all;
}

.log-toggle {
    margin-top: 6px;
    border: none;
    background: none;
    color: #2563eb;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

/* 日志记录「复制」按钮：头部行末右对齐，复制该条完整消息体 */
.log-copy {
    margin-left: auto;
    border: none;
    background: none;
    color: #2563eb;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

.log-copy:hover {
    text-decoration: underline;
}

.container {
    flex: 1;
    min-width: 0;
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 24px;
}

/* 数据库信息栏 */
.db-info {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 32px;
    background: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    font-size: 13px;
    color: #475569;
}

.db-info-item {
    white-space: nowrap;
}

.db-info-item strong {
    color: #64748b;
    font-weight: 600;
    margin-right: 8px;
}

.db-info-item strong::after {
    content: "：";
    margin-right: 0;
}

.db-info-error {
    color: #b91c1c;
}

/* 搜索表单 */
.search-form {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.search-input {
    /* 弹性基准宽：按含义在各自 class 上覆写 */
    flex: 1 1 220px;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
}

/* 法规ID：8 位数字宽度 */
.search-input.q-lid {
    flex: 0 1 100px;
}

/* 文号：12 个汉字宽度 */
.search-input.q-doc-no {
    flex: 0 1 210px;
}

/* 法规名：占第一行剩余宽度 */
.search-input.q-title {
    flex: 1 1 220px;
}

/* 正文内容：第二行全宽 */
.search-input.q-content {
    flex: 1 1 100%;
    width: 100%;
}

.search-input:focus {
    border-color: #1a6fb0;
}

/* ─── MCP 调试页表单（mcp.html，与查询页 search-* 解耦） ─── */
.mcp-form {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.mcp-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end; /* 调用按钮与字段底部对齐 */
    margin-bottom: 10px;
}

.mcp-input {
    flex: none;
    width: 260px;
    padding: 10px 14px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 15px;
    outline: none;
}

.mcp-input:focus {
    border-color: #1a6fb0;
}

/* ─── 结果卡片（mcp.html 调试结果列表） ─── */
.semantic-results {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.semantic-card {
    background: #fff;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-left: 3px solid #1a6fb0;
}

.semantic-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

/* 结果卡片排名序号徽标（检索命中顺序，1 起） */
.semantic-rank {
    flex-shrink: 0;
    min-width: 22px;
    height: 22px;
    line-height: 22px;
    padding: 0 5px;
    text-align: center;
    border-radius: 4px;
    background: #1a6fb0;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

.semantic-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a3a5c;
    text-decoration: none;
}

.semantic-title:hover {
    color: #1a6fb0;
}

.semantic-label {
    font-size: 13px;
    color: #475569;
    margin-bottom: 8px;
    font-weight: 500;
}

/* 法条内容截断容器：链接绝对定位到第三行行末 */
.semantic-text-wrap {
    position: relative;
}

.semantic-text {
    font-size: 14px;
    color: #333;
    line-height: 1.7;
    margin-bottom: 8px;
    /* 默认限 3 行（渲染后 JS 检测溢出才显示「更多」链接） */
    max-height: calc(1.7em * 3);
    overflow: hidden;
}

/* 点击「更多」后展开完整内容 */
.semantic-text.expanded {
    max-height: none;
}

/* 「更多/收起」链接：悬浮第三行行末，左侧渐白避免盖字；
   仅对内容超过 3 行的卡片显示 */
.semantic-more {
    display: none;
    font-size: 12px;
    color: #3b82f6;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

.semantic-more.show {
    display: inline;
    position: absolute;
    right: 0;
    bottom: 0;
    line-height: 24px; /* ≈ 14px × 1.7，与第三行文本基线对齐 */
    padding-left: 36px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 40%);
}

.semantic-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 12px;
    color: #94a3b8;
}

.btn-primary {
    padding: 10px 24px;
    background: #1a6fb0;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 15px;
    cursor: pointer;
}

.btn-primary:hover {
    background: #155a92;
}

.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* 排序行（独立于筛选行） */
.sort-row {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 12px;
}

.sort-row .filter-select {
    min-width: 160px;
}

.sort-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    background: #fff;
    color: #1a6fb0;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
}

.sort-toggle:hover {
    border-color: #1a6fb0;
    background: #eef5fb;
}

.btn-reload {
    padding: 8px 20px;
    background: #fff;
    color: #1a6fb0;
    border: 1px solid #1a6fb0;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
}

.btn-reload:hover {
    background: #eef5fb;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    min-width: 140px;
}

/* 作用域下拉固定宽度约 10 个汉字（14px 字号） */
.scope-select {
    width: 170px;
    min-width: 0;
}

/* 正文字节数比较符下拉与 KB 输入框 */
.content-op-select {
    width: 91px;
    min-width: 0;
}

.filter-input {
    padding: 8px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    width: 80px;
}

/* 结果摘要 */
.result-summary {
    margin-bottom: 12px;
    color: #666;
    font-size: 14px;
}

/* 关键字查询结果卡片 */
.result-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.result-card {
    background: #fff;
    padding: 14px 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.result-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* 卡片第一行：ID、法规名、时效性、删除 */
.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.card-lid {
    color: #94a3b8;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a3a5c;
    text-decoration: none;
    word-break: break-all;
}

.card-title:hover {
    color: #1a6fb0;
}

.card-del {
    margin-left: auto;
    flex-shrink: 0;
}

/* 卡片第二行：其余元数据 */
.card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 20px;
    font-size: 13px;
    color: #64748b;
}

.empty {
    text-align: center;
    color: #999;
    padding: 40px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 状态标签 */
.status-tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    white-space: nowrap;
}

.status-现行有效 {
    background: #e6f7ed;
    color: #1a7d3a;
}

.status-废止或失效 {
    background: #fde8e8;
    color: #b91c1c;
}

.status-已被修改 {
    background: #fff4e6;
    color: #b45309;
}

.status-部分废止或失效 {
    background: #fff4e6;
    color: #b45309;
}

.status-尚未施行 {
    background: #e8eef7;
    color: #3b5b92;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.page-btn {
    display: inline-block;
    min-width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    padding: 0 10px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    background: #fff;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
}

.page-btn:hover {
    border-color: #1a6fb0;
    color: #1a6fb0;
}

.page-btn.current {
    background: #1a6fb0;
    color: #fff;
    border-color: #1a6fb0;
}

.page-ellipsis {
    display: inline-block;
    min-width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

/* 跳页表单 */
.page-jump {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
}

.page-jump-input {
    width: 64px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.page-jump-input:focus {
    outline: none;
    border-color: #1a6fb0;
}

.page-jump-total {
    color: #94a3b8;
    font-size: 13px;
    white-space: nowrap;
}

/* 详情页 */
.detail-header {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.back-link {
    color: #1a6fb0;
    text-decoration: none;
    font-size: 14px;
    display: inline-block;
    margin-bottom: 12px;
}

/* 详情页头部链接组：返回 + 页内定位到法规正文 */
.header-links {
    display: inline-flex;
    gap: 16px;
    align-items: baseline;
}

.back-link:hover {
    text-decoration: underline;
}

.detail-header h1 {
    font-size: 22px;
    color: #1a3a5c;
    margin-bottom: 8px;
}

.detail-sub {
    display: flex;
    gap: 12px;
    align-items: center;
    color: #666;
    font-size: 14px;
}

.meta-table {
    width: 100%;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-collapse: collapse;
    margin-bottom: 20px;
}

.meta-table th,
.meta-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #eef0f3;
    font-size: 14px;
    text-align: left;
}

.meta-table th {
    background: #f0f4f8;
    color: #475569;
    font-weight: 600;
    width: 110px;
    white-space: nowrap;
}

.content-title {
    font-size: 18px;
    color: #1a3a5c;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 标题旁的正文字节数 */
.content-size {
    font-size: 12px;
    font-weight: normal;
    color: #999;
}

/* 原文 / Markdown预览 视图切换按钮组 */
.view-switch {
    display: flex;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    overflow: hidden;
}

.view-btn {
    padding: 4px 14px;
    border: none;
    background: #fff;
    color: #666;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.view-btn + .view-btn {
    border-left: 1px solid #d0d5dd;
}

.view-btn.active {
    background: #1a3a5c;
    color: #fff;
}

.content-body {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.content-body pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: "PingFang SC", "Microsoft YaHei", monospace;
    font-size: 15px;
    line-height: 1.8;
    color: #333;
}

/* 删除按钮 */
.btn-delete {
    padding: 4px 12px;
    background: #fff;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.btn-delete:hover {
    background: #fef2f2;
}

/* 可编辑表单 */
.edit-table select,
.edit-input,
.edit-textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.edit-select {
    padding: 6px 10px;
    border: 1px solid #d0d5dd;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
}

.edit-textarea {
    resize: vertical;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    cursor: pointer;
}

.content-textarea {
    width: 100%;
    min-height: 400px;
    padding: 16px;
    padding-left: 64px;  /* 左侧留白给行号栏覆盖 */
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-family: "PingFang SC", "Microsoft YaHei", monospace;
    font-size: 15px;
    line-height: 1.8;
    resize: vertical;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* 行号栏：覆盖于正文文本框左侧留白（.content-editor 为定位基准），
   overflow 裁剪 + transform 随文本框滚动同步；数字由 JS 按逻辑行行首
   排版位置绝对定位，软换行延续行不另编号 */
.line-gutter {
    position: absolute;
    top: 1px;
    bottom: 1px;
    left: 1px;
    width: 52px;
    z-index: 1;  /* 必须高于同为定位元素且 DOM 序靠后的 .md-preview，否则被其白底遮住 */
    overflow: hidden;
    border-right: 1px solid #eef1f5;
    border-radius: 8px 0 0 8px;
    background: #fafbfc;
    pointer-events: none;
    user-select: none;
}

.line-gutter[hidden] {
    display: none;
}

/* 内层承接滚动位移（transform 移动带 overflow 的容器会把裁剪窗口一起移走） */
.line-gutter-inner {
    position: absolute;
    inset: 0;
}

.line-num {
    position: absolute;
    right: 10px;
    font-family: "PingFang SC", "Microsoft YaHei", monospace;
    font-size: 12px;
    line-height: 1.8;
    color: #98a2b3;
    white-space: nowrap;
}

/* 法规正文：目录 + 文本框双栏布局（无目录时仅文本框占满） */
.content-layout {
    display: flex;
    gap: 16px;
    align-items: stretch;
}

.content-layout.with-toc .content-textarea {
    min-height: 70vh;
}

/* Markdown 预览容器：与文本框同尺寸自滚动；position:relative 使块级
   offsetTop 以预览容器为基准，供目录按 data-offset 定位 */
.md-preview {
    position: relative;
    min-height: 400px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 16px;
    padding-left: 64px;  /* 左侧留白给行号栏覆盖（与正文文本框一致） */
    background: #fff;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    font-size: 15px;
    line-height: 1.8;
    color: #333;
}

.content-layout.with-toc .md-preview {
    min-height: 70vh;
}

.md-preview p {
    margin: 0 0 12px;
}

.md-preview h1, .md-preview h2, .md-preview h3,
.md-preview h4, .md-preview h5, .md-preview h6 {
    margin: 18px 0 10px;
    color: #1a3a5c;
}

.md-preview h1 { font-size: 20px; }
.md-preview h2 { font-size: 18px; }
.md-preview h3 { font-size: 16px; }
.md-preview h4, .md-preview h5, .md-preview h6 { font-size: 15px; }

/* 表格（MinerU 产出的 HTML 表格与 markdown 管道表格共用样式；
   th 默认居中对齐 colspan/rowspan 表头） */
.md-preview table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
}

.md-preview th,
.md-preview td {
    border: 1px solid #d0d5dd;
    padding: 6px 10px;
    font-size: 14px;
    text-align: center;
}

.md-preview th {
    background: #f0f4f8;
    font-weight: 600;
}

/* HTML 表格单元格内嵌 <p> 去边距，保持单元格紧凑 */
.md-preview table p {
    margin: 0;
}

.md-preview ul,
.md-preview ol {
    margin: 0 0 12px;
    padding-left: 2em;
}

.md-preview li {
    margin: 2px 0;
}

.md-preview blockquote {
    border-left: 3px solid #cbd5e1;
    padding-left: 12px;
    color: #64748b;
    margin: 0 0 12px;
}

.md-preview pre {
    background: #f5f6f8;
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
}

.md-preview code {
    background: #f0f4f8;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 13px;
}

.md-preview pre code {
    background: none;
    padding: 0;
}

.md-preview hr {
    border: none;
    border-top: 1px solid #d0d5dd;
    margin: 16px 0;
}

.md-preview a {
    color: #2563eb;
}

.content-editor {
    flex: 1;
    min-width: 0;
    position: relative;  /* 行号栏绝对定位基准 */
}

/* 目录模块（law_tree 层级树，可折叠展开） */
.toc-panel {
    width: 260px;
    flex-shrink: 0;
    background: #fff;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    max-height: 70vh;
    overflow: hidden;
}

.toc-header {
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #1a3a5c;
    border-bottom: 1px solid #e5e9f0;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 全部折叠/全部展开二态按钮（图标 ⊞/⊟ 随状态切换） */
.toc-toggle-all {
    padding: 2px 6px;
    border: 1px solid #d0d5dd;
    background: #fff;
    color: #475569;
    border-radius: 4px;
    font-size: 12px;
    line-height: 1.2;
    cursor: pointer;
}

.toc-toggle-all:hover {
    background: #f0f4f8;
    color: #1a3a5c;
}

.toc-list {
    overflow-y: auto;
    padding: 6px 4px;
}

/* 单个树节点：标签行 + 子节点容器 */
.toc-row {
    display: flex;
    align-items: center;
}

/* 折叠箭头 / 叶子占位：固定宽度保证各层级标签对齐 */
.toc-toggle,
.toc-spacer {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.toc-toggle {
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    color: #94a3b8;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    transition: transform 0.15s ease;
}

.toc-toggle:hover {
    color: #1a3a5c;
}

/* 折叠状态：箭头转向（▾→▸）、子节点隐藏 */
.toc-node.collapsed > .toc-row > .toc-toggle {
    transform: rotate(-90deg);
}

.toc-node.collapsed > .toc-children {
    display: none;
}

/* 子节点容器：缩进 + 竖向引导线构成树形层级（任意深度自动缩进） */
.toc-children {
    margin-left: 9px;
    padding-left: 8px;
    border-left: 1px solid #e5e9f0;
}

.toc-item {
    flex: 1;
    min-width: 0;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #475569;
    line-height: 1.6;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.toc-item:hover {
    background: #f0f4f8;
    color: #1a3a5c;
}

.toc-item.active {
    background: #e8f0fe;
    color: #1a3a5c;
    font-weight: 600;
}

/* 容器类节点（编/章/节/附件）加粗，条节点常规字重 */
.toc-part, .toc-chapter, .toc-section, .toc-annex {
    font-weight: 600;
    color: #1a3a5c;
}

.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
}

.btn-cancel {
    padding: 10px 24px;
    background: #fff;
    color: #666;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    font-size: 15px;
    text-decoration: none;
    display: inline-block;
    line-height: 1.5;
}

.btn-cancel:hover {
    background: #f5f6f8;
}

/* 导入页面 */
.import-page h1 {
    font-size: 22px;
    color: #1a3a5c;
    margin-bottom: 20px;
}

.import-form {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #475569;
    font-size: 14px;
    font-weight: 600;
}

.form-group input[type="file"] {
    font-size: 14px;
}

.log-container {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.log-container h2 {
    font-size: 18px;
    color: #1a3a5c;
    margin-bottom: 12px;
}

.log-output {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 6px;
    font-family: "SF Mono", "Menlo", monospace;
    font-size: 13px;
    line-height: 1.6;
    max-height: 400px;
    overflow-y: auto;
}

.log-line {
    padding: 2px 0;
}

.log-success {
    color: #4ade80;
    font-weight: 600;
    padding: 4px 0;
}

.log-error {
    color: #f87171;
    font-weight: 600;
    padding: 4px 0;
}

.log-warn {
    color: #fbbf24;
    font-weight: 600;
    padding: 4px 0;
}

.result-actions {
    margin-top: 16px;
}

#import-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 其他功能页 */
.other-page h1 {
    font-size: 22px;
    color: #1a3a5c;
    margin-bottom: 20px;
}

.other-panel {
    background: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    max-width: 560px;
}

.other-panel h2 {
    font-size: 18px;
    color: #1a3a5c;
    margin-bottom: 8px;
}

.other-desc {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 16px;
}
/* ===== 模态弹窗（保存进度 / 结果提示） ===== */
.modal-mask {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-mask[hidden] {
    display: none;
}

.modal-card {
    background: #fff;
    border-radius: 12px;
    padding: 32px 36px;
    width: 420px;
    max-width: 90vw;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.modal-progress {
    width: 480px;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 16px 0 12px;
}

.text-success { color: #16a34a; }
.text-error { color: #dc2626; }

.modal-message {
    font-size: 14px;
    color: #475569;
    line-height: 1.7;
    margin-bottom: 20px;
    word-break: break-all;
    white-space: pre-line;
    text-align: left;
}

.modal-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    color: #64748b;
    margin: 12px 0;
    flex-wrap: wrap;
}

.step-arrow { color: #cbd5e1; }

.modal-hint {
    font-size: 13px;
    color: #94a3b8;
    margin-top: 8px;
}

.modal-actions {
    display: flex;
    justify-content: center;
}

.modal-actions .btn-primary {
    min-width: 96px;
}

.spinner {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 2px solid #f59e0b;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-lg {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border-width: 3px;
    border-color: #f59e0b;
    border-top-color: transparent;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 错误页 */
.error-page {
    max-width: 560px;
    margin: 60px auto;
    text-align: center;
}

.error-page h1 {
    margin-bottom: 16px;
}

.error-message {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
    line-height: 1.6;
}

/* ───────────── 法条页（articles 分块卡片） ───────────── */

/* 查询列表卡片上的「查看法条」入口 */
.card-link {
    font-size: 13px;
    color: #1a6fb0;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.card-link:hover {
    text-decoration: underline;
}

.article-card {
    border-left: 3px solid #1a6fb0;
}

.article-no {
    font-size: 15px;
    font-weight: 600;
    color: #1a3a5c;
}

.article-no-chapter {
    font-weight: 500;
    color: #475569;
}

.article-chapter {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 6px;
}

/* 分块正文：保留原分段换行，不限高（法条需完整阅读） */
.article-text {
    font-size: 15px;
    color: #1f2937;
    line-height: 1.9;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 10px;
}

.summary-link {
    color: #1a6fb0;
    text-decoration: none;
}

.summary-link:hover {
    text-decoration: underline;
}

/* ───────────── 仪表盘（统计卡片 + 纯 CSS 柱状图） ───────────── */

.stat-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    text-decoration: none;
}

a.stat-card:hover {
    border-color: #1a6fb0;
}

.stat-num {
    font-size: 28px;
    font-weight: 700;
    color: #1a3a5c;
    line-height: 1.2;
}

.stat-label {
    font-size: 13px;
    color: #64748b;
}

.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 18px 20px;
    min-width: 0;
}

.panel-wide {
    grid-column: 1 / -1;
}

.panel h2 {
    font-size: 15px;
    font-weight: 600;
    color: #1a3a5c;
    margin: 0 0 16px;
}

/* 柱状图：列弹性均分，柱体高度由模板按相对峰值百分比内联指定 */
.chart {
    display: flex;
    align-items: stretch;
    gap: 6px;
    height: 220px;
}

.chart-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chart-value {
    font-size: 11px;
    color: #475569;
    line-height: 1.4;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-bar-wrap {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.chart-bar {
    width: 68%;
    max-width: 40px;
    min-height: 1px;
    background: linear-gradient(180deg, #3b82f6, #1d4ed8);
    border-radius: 4px 4px 0 0;
}

.chart-label {
    margin-top: 6px;
    font-size: 11px;
    color: #64748b;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    height: 16px;
}

/* 每日新增 30 根柱：数值与标签缩小，标签由 app 层稀疏标记 */
.chart-compact {
    height: 240px;
}

.chart-compact .chart-value {
    font-size: 10px;
    color: #94a3b8;
}

.chart-compact .chart-label {
    font-size: 10px;
}

/* 最近入库列表 */
.recent-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.recent-list li {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    min-width: 0;
}

.recent-list li:last-child {
    border-bottom: none;
}

.recent-lid {
    font-size: 12px;
    color: #94a3b8;
    flex-shrink: 0;
    min-width: 44px;
}

.recent-title {
    color: #1a3a5c;
    text-decoration: none;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-title:hover {
    color: #1a6fb0;
    text-decoration: underline;
}

.recent-time {
    margin-left: auto;
    font-size: 12px;
    color: #94a3b8;
    flex-shrink: 0;
}

@media (max-width: 900px) {
    .stat-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }
}

/* ───────────── 移动端适配（≤768px，2026-09-29）─────────────
   侧边栏转抽屉（汉堡按钮开合）+ 表单流式换行。
   模板内联 width（mcp.html 等）在本断点内以 !important 收编为流式，
   桌面端保持原样；布局规则只加不改，桌面零影响。 */
.topbar {
    display: none;
}

@media (max-width: 768px) {
    /* 顶栏：仅移动端显示，汉堡按钮开合抽屉 */
    .topbar {
        display: flex;
        align-items: center;
        gap: 10px;
        position: sticky;
        top: 0;
        z-index: 40;
        background: #1a3a5c;
        color: #fff;
        padding: 10px 14px;
    }

    .menu-btn {
        background: none;
        border: 0;
        color: #fff;
        font-size: 22px;
        line-height: 1;
        padding: 2px 8px;
        cursor: pointer;
    }

    .topbar-title {
        font-size: 16px;
        font-weight: 600;
    }

    /* 侧边栏转屏外抽屉：body.sidebar-open 时滑入；点遮罩/导航后收起 */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 200px;
        height: 100%;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.25);
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 55;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    .container {
        margin: 12px 10px;
        padding: 0 12px;
    }

    /* 表单行可换行，控件流式占满；!important 收编模板内联 width */
    .mcp-row,
    .filter-row {
        flex-wrap: wrap;
    }

    .mcp-field {
        flex: 1 1 45%;
    }

    .mcp-field-label {
        white-space: normal;
    }

    .mcp-input,
    .mcp-limit,
    .filter-select,
    .scope-select {
        width: 100% !important;
        max-width: 100%;
    }

    .filter-row .filter-select {
        flex: 1 1 44%;
    }

    /* 详情页：目录树与正文纵向堆叠（正文在前，目录移至正文下方） */
    .content-layout {
        flex-direction: column-reverse;
    }

    .toc-panel {
        width: 100%;
    }

    /* 元数据编辑表：整表横向滚动，不挤压表单控件 */
    .meta-table {
        display: block;
        overflow-x: auto;
    }
}

/* 结果卡头部窄屏换行：标题独占一行，避免 break-all 压成一字一行 */
@media (max-width: 768px) {
    .card-head {
        flex-wrap: wrap;
    }

    .card-head .card-title {
        flex: 1 1 100%;
        word-break: break-word;
    }
}

/* 行内组合（输入+勾选标签）：勾选标签不被 100% 输入框挤出屏 */
@media (max-width: 768px) {
    .mcp-inline {
        flex-wrap: wrap;
    }

    .mcp-inline .mcp-input {
        flex: 1 1 120px;
    }
}

/* 元数据表：窄屏保持可读宽度，整表横向滑动（外层 block 滚动，
   tbody 以 table 格式持最小宽——min-width 直接放滚动容器自身会撑破页面） */
@media (max-width: 768px) {
    .meta-table {
        display: block;
        overflow-x: auto;
    }

    .meta-table tbody {
        display: table;
        width: auto;
        min-width: 560px;
    }
}
