/* ============================================================
   安全生产事故调查报告数据库 · 共享样式（前台 + 后台）
   v3：主题色对齐 hse.zone（青蓝 #37606a + 珊瑚橙 #f85a40）
       修复手机端列表溢出（长词断行 + flex 收缩 + 横向裁切兜底）
   ============================================================ */

:root {
    /* 主题色（对齐 hse.zone） */
    --primary: #37606a;        /* 主色：青蓝 */
    --primary-dark: #2c4d55;
    --primary-deep: #24424a;
    --primary-light: #53919f;  /* 亮青：hover/渐变收尾 */
    --accent: #f85a40;         /* 强调色：珊瑚橙（CTA/高亮数字） */

    --bg: #f2f4f8;
    --card: #ffffff;
    --line: #e8ecf1;
    --text: #232a31;
    --text-sub: #6b7684;
    --text-dim: #98a1ac;
    --green: #2e7d32;
    --link: #2f6b8f;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-lg: 0 8px 24px rgba(16, 24, 40, .12);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
    background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
    /* 手机端防横向溢出兜底：clip 不产生滚动容器（不影响 sticky 顶栏），旧浏览器回退 hidden */
    overflow-x: hidden;
    overflow-x: clip;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; min-width: 0; }
a { color: var(--link); text-decoration: none; overflow-wrap: anywhere; }
a:hover { text-decoration: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ---------- 顶栏 ---------- */
.topbar {
    position: sticky; top: 0; z-index: 100;
    background: linear-gradient(135deg, var(--primary-deep) 0%, var(--primary) 55%, var(--primary-light) 100%);
    color: #fff; padding: 16px 0 13px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
}
.topbar h1 { font-size: 21px; letter-spacing: .5px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.topbar h1 a { color: inherit; overflow-wrap: break-word; }
/* hse.zone logo（白色透明底，点击回首页） */
.brand { display: inline-flex; align-items: center; flex: 0 0 auto; }
.brand img { height: 30px; width: auto; display: block; }
.topbar h1 > a:first-child + a { margin-left: 2px; }
.topbar .sub { font-size: 12px; opacity: .92; margin-top: 5px; }
.daemon.on { color: #b8f5c4; font-weight: bold; }

/* 顶栏右侧导航 */
.top-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; }
.top-actions a {
    display: inline-block; padding: 5px 14px; border-radius: 999px;
    background: rgba(255, 255, 255, .16); color: #fff; font-size: 13px; font-weight: 500;
    backdrop-filter: blur(4px); transition: background .15s;
}
.top-actions a:hover { background: rgba(255, 255, 255, .3); }

/* ---------- 筛选 ---------- */
.filter {
    background: var(--card); border-radius: var(--radius); padding: 14px 16px;
    margin: 18px 0 16px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.filter-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter input.kw {
    flex: 1 1 260px; min-width: 0; padding: 9px 14px; border: 1px solid #d5dbe2; border-radius: 8px;
    font-size: 14px; background: #fafbfc; transition: border-color .15s, box-shadow .15s;
}
.filter input.kw:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(55, 96, 106, .14); outline: none; background: #fff; }
.filter select {
    padding: 9px 8px; border: 1px solid #d5dbe2; border-radius: 8px; background: #fff;
    max-width: 230px; font-size: 13px; color: var(--text); min-width: 0;
}
.filter button {
    padding: 9px 26px; background: var(--accent); color: #fff; border: none; border-radius: 8px;
    cursor: pointer; font-size: 14px; font-weight: 500;
    transition: background .15s, transform .1s;
}
.filter button:hover { background: #e14e35; }
.filter button:active { transform: scale(.97); }
.filter .reset { color: var(--text-sub); font-size: 13px; margin-left: 4px; }
.filter .reset:hover { color: var(--accent); text-decoration: underline; }

/* ---------- 列表 ---------- */
.list {
    background: var(--card); border-radius: var(--radius); padding: 12px 16px 18px;
    box-shadow: var(--shadow); border: 1px solid var(--line);
    min-width: 0; max-width: 100%;
}
.list-head { padding: 6px 2px 10px; color: var(--text-sub); font-size: 13px; border-bottom: 1px solid var(--line); }
.list-head b { color: var(--accent); }

table { width: 100%; border-collapse: collapse; }
th {
    font-size: 12px; color: var(--text-sub); text-align: left; padding: 10px 8px 6px;
    border-bottom: 2px solid var(--line); white-space: nowrap; font-weight: 600;
}
td { padding: 12px 8px; border-bottom: 1px solid #f1f3f6; vertical-align: top; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: none; }
td.t a { font-weight: 600; color: var(--text); line-height: 1.5; overflow-wrap: anywhere; word-break: break-word; }
td.t a:hover { color: var(--accent); }
td .sum {
    font-size: 12px; color: var(--text-dim); margin-top: 3px; max-width: 560px;
    overflow-wrap: anywhere; word-break: break-word;
}
td.c { text-align: center; white-space: nowrap; font-size: 13px; color: #55606c; }
td.src { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 44px 16px; text-align: center; color: var(--text-dim); overflow-wrap: anywhere; }
.empty code { background: #f3f5f8; padding: 2px 6px; border-radius: 4px; }

/* ---------- 标签（等级语义色，保持不变） ---------- */
.tag { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; color: #fff; }
.lv-特别重大 { background: #b62b2b; }
.lv-重大 { background: #e2640c; }
.lv-较大 { background: #d9a400; }
.lv-一般 { background: #3f8f29; }

/* ---------- 下载按钮 ---------- */
.files .btn { display: inline-block; margin: 1px 3px 1px 0; padding: 3px 10px; border-radius: 6px; font-size: 12px; color: #fff; transition: opacity .15s, transform .1s; }
.btn.pdf { background: #c0392b; }
.btn.doc { background: #2b5797; }
.btn.att { background: var(--primary); }
.btn.raw { background: #8a94a1; }
.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { transform: scale(.96); }

/* ---------- 分页 ---------- */
.pager { margin-top: 18px; text-align: center; color: var(--text-sub); display: flex; justify-content: center; align-items: center; gap: 12px; flex-wrap: wrap; }
.pager a {
    display: inline-block; padding: 7px 18px; background: #f3f5f8; border-radius: 8px;
    font-size: 13px; transition: background .15s;
}
.pager a:hover { background: #e6eaef; text-decoration: none; }

/* ---------- 详情页 ---------- */
.crumb { margin: 16px 0; font-size: 13px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.crumb a { color: var(--text-sub); }
.crumb a:hover { color: var(--accent); }
.crumb > * { overflow-wrap: anywhere; }
.detail {
    background: var(--card); border-radius: var(--radius); padding: 28px 32px;
    box-shadow: var(--shadow); border: 1px solid var(--line); min-width: 0;
}
.detail .dt { font-size: 22px; line-height: 1.5; color: #1f2730; overflow-wrap: anywhere; word-break: break-word; }
.detail .meta { margin: 14px 0 4px; color: var(--text-sub); font-size: 13px; display: flex; flex-wrap: wrap; gap: 6px 20px; min-width: 0; }
.detail .meta span { overflow-wrap: anywhere; }
.detail .ops { margin: 16px 0 8px; padding: 14px; background: #f8fafc; border-radius: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.detail .ops .btn {
    display: inline-block; padding: 8px 16px; border-radius: 8px; color: #fff;
    font-size: 13px; font-weight: 500; transition: opacity .15s, transform .1s;
}
.pdfview { width: 100%; height: 76vh; min-height: 480px; border: 1px solid var(--line); border-radius: 10px; margin-top: 16px; }
.bodytext { margin-top: 20px; border-top: 1px dashed var(--line); padding-top: 16px; }
.bodytext h3 { font-size: 15px; color: #55606c; margin-bottom: 10px; }
.bodytext pre { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; font-family: inherit; font-size: 14px; color: #3a434d; line-height: 1.9; }

footer { margin: 22px 0 34px; text-align: center; color: #a5adb6; font-size: 12px; overflow-wrap: anywhere; }
footer a { color: var(--text-dim); word-break: break-all; }
/* 底部数据概览（最简样式：一行浅灰文字） */
.foot-stat { margin-bottom: 8px; color: var(--text-dim); letter-spacing: .3px; }

/* ============================================================
   后台组件
   ============================================================ */
.adm-grid { display: flex; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.adm-card {
    background: var(--card); border-radius: var(--radius); padding: 16px 18px;
    box-shadow: var(--shadow); border: 1px solid var(--line); flex: 1;
    margin-bottom: 16px; min-width: 0;
}
.adm-card h3 { font-size: 15px; margin-bottom: 10px; color: var(--primary); display: flex; align-items: center; gap: 6px; }
.adm-card h3::before { content: ""; display: inline-block; width: 4px; height: 15px; border-radius: 2px; background: var(--primary); flex: 0 0 auto; }
.adm-card:last-child { margin-bottom: 0; }

table.adm { width: 100%; border-collapse: collapse; font-size: 13px; }
.adm th { background: #f8fafc; padding: 9px 7px; border-bottom: 2px solid var(--line); text-align: left; white-space: nowrap; }
.adm td { padding: 8px 7px; border-bottom: 1px solid #f1f3f6; }
.adm tbody tr:hover { background: #fafbfd; }

/* 后台操作按钮 */
.adm .btn, .btn-run, .btn-test, .btn-off, .btn-del, .btn-edit, .btn-daemon, .btn-view, .btn-rename, .btn-cancel {
    display: inline-block; padding: 4px 12px; margin: 1px 2px; border-radius: 6px;
    font-size: 12px; color: #fff; border: none; cursor: pointer; text-decoration: none;
    transition: opacity .15s, transform .1s; vertical-align: middle;
}
.adm .btn:hover, .btn-run:hover, .btn-test:hover, .btn-off:hover, .btn-del:hover,
.btn-edit:hover, .btn-daemon:hover, .btn-view:hover, .btn-rename:hover, .btn-cancel:hover { opacity: .85; text-decoration: none; }
.btn-run { background: #2e7d32; }
.btn-test { background: #0277bd; }
.btn-off { background: #90a4ae; }
.btn-del { background: #c62828; }
.btn-edit { background: var(--primary); }
.btn-daemon { background: #e65100; }
.btn-view { background: #0277bd; }
.btn-rename { background: #e08600; }
.btn-cancel { background: #9aa3ad; }
.adm .btn:disabled, .btn-run:disabled, .btn-daemon:disabled { opacity: .5; cursor: not-allowed; }

/* 表单网格（数据源编辑） */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.form-grid label { font-size: 12px; color: #55606c; display: block; margin-bottom: 4px; }
.form-grid input, .form-grid select, .form-grid textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #d5dbe2; border-radius: 8px;
    font-size: 13px; box-sizing: border-box; background: #fafbfc; transition: border-color .15s, box-shadow .15s;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus {
    border-color: var(--primary); box-shadow: 0 0 0 3px rgba(55, 96, 106, .12); outline: none; background: #fff;
}
.form-grid .full { grid-column: 1 / -1; }

.state-on { color: var(--green); font-weight: bold; }
.state-off { color: var(--accent); font-weight: bold; }

.msg { background: #fff8e1; border: 1px solid #ffe082; border-radius: 10px; padding: 11px 15px; margin-bottom: 14px; color: #795548; }
.adm-banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 13px; }
.adm-banner.ok { background: #e7f6ec; color: var(--green); border: 1px solid #b7dfc4; }
.adm-banner.err { background: #fdeee9; color: #c23a24; border: 1px solid #f2c9bd; }

/* 后台表格横向滚动容器（手机端不挤压布局） */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.table-wrap .adm { min-width: 760px; }
.table-wrap table { min-width: 760px; }

code { background: #f3f5f8; padding: 1px 6px; border-radius: 5px; font-size: 12px; overflow-wrap: anywhere; }

/* ============================================================
   移动端适配
   ============================================================ */
@media (max-width: 860px) {
    .adm-grid { flex-direction: column; }
    .adm-grid .adm-card { min-width: 0; }

    /* 顶栏 */
    .topbar { padding: 12px 0 10px; }
    .topbar h1 { font-size: 17px; }
    .brand img { height: 24px; }
    .top-actions { margin-left: 0; width: 100%; }
    .top-actions a { padding: 4px 12px; font-size: 12px; }

    /* 详情页 */
    .detail { padding: 20px 16px; }
    .detail .dt { font-size: 18px; }
    .detail .meta { gap: 4px 14px; }
    .detail .ops .btn { padding: 9px 14px; }     /* 加大触控目标 */
    .pdfview { height: 64vh; min-height: 380px; }

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

@media (max-width: 760px) {
    /* ---- 前台报告列表：表格 → 卡片 ---- */
    .list { padding: 10px 12px 14px; }
    .list table, .list tbody, .list tr, .list td { display: block; width: 100%; max-width: 100%; }
    .list thead { display: none; }
    .list tbody tr {
        border: 1px solid var(--line); border-radius: 10px; padding: 12px 12px 8px;
        margin-bottom: 10px; background: #fff;
    }
    .list tbody tr:hover { background: #fff; }
    .list td {
        border-bottom: none; padding: 4px 0;
        display: flex; align-items: baseline; gap: 10px;
        min-width: 0; overflow-wrap: anywhere; word-break: break-word;
    }
    .list td > * { min-width: 0; max-width: 100%; }   /* flex 子项允许收缩，杜绝撑出屏幕 */
    .list td.t { display: block; }
    .list td .sum { margin: 4px 0 2px; }
    .list td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 4.2em; font-size: 12px; color: var(--text-dim);
        overflow-wrap: normal; word-break: keep-all;
    }
    .list td.files { flex-wrap: wrap; gap: 2px; }
    .list td.files .btn { padding: 6px 14px; font-size: 13px; margin: 2px 4px 2px 0; }  /* 加大触控目标 */

    /* 手机端后台表格统一横向滚动兜底 */
    .table-wrap { margin: 0 -16px; padding: 0 16px; }

    .filter select { max-width: none; }
    .filter-form > * { width: 100%; }
    .filter-form .kw { flex: 1 1 100%; }
    .filter .reset { text-align: center; display: block; margin: 2px auto 0; }

    .wrap { padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
    html { scroll-behavior: auto; }
}
