/* ==========================================================
   入厂报备调试台
   信息密度优先：颜色只用来标记状态，不用来装饰
   数字 / 日期 / ID 一律等宽对齐，危险操作描边不实心
   ========================================================== */

:root {
    --canvas: #f6f7f9;
    --paper: #ffffff;
    --ink: #111418;
    --ink-2: #3f4650;
    --muted: #6b7280;
    --faint: #9aa1ab;
    --rule: #e7e9ee;
    --rule-2: #d6dae2;
    --accent: #1d4ed8;
    --accent-soft: #edf1fe;
    --ok: #0b6b4f;
    --ok-soft: #e9f7f1;
    --warn: #8a5003;
    --warn-soft: #fdf4e0;
    --bad: #a51c1c;
    --bad-soft: #fdeeee;
    --code-bg: #0f141b;
    --code-fg: #c8d3e4;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --radius: 10px;
}

body.bg-light {
    background: var(--canvas) !important;
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}
.container { max-width: 1120px; padding-left: 16px; padding-right: 16px; }

/* ---------- 页头 ---------- */
.page-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 2px 0 18px;
}
.page-title {
    margin: 0;
    border: 0;
    padding: 0;
    font-size: 1.12rem;
    font-weight: 650;
    letter-spacing: .1px;
    color: var(--ink);
}
.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 650;
    white-space: nowrap;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: #bfe7d8; }
.pill.bad { color: var(--bad); background: var(--bad-soft); border-color: #f4c7c7; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: #f0dcb0; }

/* ---------- 厂区切换：小分段控件，不再铺满整行 ---------- */
.tabs {
    display: flex;
    gap: 6px;
    margin: 0 0 18px;
    padding: 0;
    position: static;
    background: none;
}
.tab {
    flex: 0 0 auto;
    min-width: 96px;
    padding: 7px 14px;
    border: 1px solid var(--rule-2);
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink-2);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.tab:hover { background: #f2f4f7; }
.tab.active { background: var(--accent-soft); border-color: #bfcdf7; color: var(--accent); box-shadow: none; }
.loc-content { display: none; }
.loc-content.active { display: block; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------- 面板 ---------- */
.panel {
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 14px;
    box-shadow: none;
}
.panel > h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: .84rem;
    font-weight: 650;
    color: var(--ink);
    letter-spacing: .2px;
    flex-wrap: wrap;
}
.panel > h2 > span:first-child { flex: 0 0 auto; }
.panel > h2 .meta { margin-left: auto; font-family: var(--mono); font-size: .72rem; font-weight: 400; color: var(--faint); }
.panel-desc { margin: 0 0 12px; font-size: .78rem; line-height: 1.65; color: var(--muted); }
.panel-desc code { font-family: var(--mono); font-size: .74rem; color: var(--ink-2); background: #f2f4f7; padding: 1px 5px; border-radius: 4px; }
.panel.is-warn { border-color: #eee2c6; }

/* ---------- 指标 ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    margin: 0 0 16px;
    padding: 0;
    border: 1px solid var(--rule);
    border-radius: 8px;
    overflow: hidden;
    background: none;
}
.stat-item {
    padding: 9px 12px;
    border-left: 1px solid var(--rule);
    font-size: .7rem;
    color: var(--muted);
    text-align: left;
}
.stat-item:first-child { border-left: 0; }
.stat-val {
    font-family: var(--mono);
    font-size: 1.02rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}
.stat-val.ok { color: var(--ok); }
.stat-val.bad { color: var(--bad); }

/* ---------- 人员表 ---------- */
.table-wrapper { border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; margin-bottom: 18px; }
table { width: 100%; border-collapse: collapse; min-width: 0; }
th {
    background: #fafbfc;
    color: var(--muted);
    font-size: .7rem;
    font-weight: 600;
    text-align: left;
    padding: 8px 12px;
    border-bottom: 1px solid var(--rule);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--rule); font-size: .82rem; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfcfd; }
.person-table th:first-child, .person-table td:first-child { width: 150px; }
.person-table strong { font-weight: 650; font-size: .84rem; }
.id-mask {
    display: inline-block;
    margin-top: 2px;
    font-family: var(--mono);
    font-size: .66rem;
    color: var(--faint);
    max-width: 132px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 一人多接待人：每个轨迹一行 */
.track-line { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; padding: 1px 0; }
.track-line + .track-line { border-top: 1px dashed #f0f2f5; margin-top: 5px; padding-top: 6px; }
.track-rec {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 1px 7px;
    border: 1px solid var(--rule);
    border-radius: 5px;
    background: #f2f5f9;
    color: var(--ink-2);
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.track-rec::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: #94a3b8; }
.track-date { font-family: var(--mono); font-size: .74rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.track-rule { font-size: .7rem; color: var(--faint); }

/* 状态：一个点 + 一个词，不再用糖果色块 */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 0;
    border-radius: 0;
    background: none;
    font-size: .72rem;
    font-weight: 600;
    white-space: nowrap;
}
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.expired { color: var(--bad); }
.warning { color: #b45309; }
.success { color: var(--ok); }

/* ---------- 队列 ---------- */
.queue-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; }
.queue-head h3 { margin: 0; font-size: .8rem; font-weight: 650; color: var(--ink); }
.queue-head .count { font-family: var(--mono); font-size: .72rem; color: var(--faint); }
.empty-state {
    padding: 18px;
    border: 1px dashed var(--rule-2);
    border-radius: 8px;
    text-align: center;
    font-size: .78rem;
    color: var(--faint);
}
.empty-state.ok { border-color: #cfe8dd; background: #f7fcf9; color: var(--ok); }

/* ---------- 请求包 ---------- */
.request-item { border: 1px solid var(--rule); border-radius: 8px; margin-bottom: 8px; background: var(--paper); overflow: hidden; }
.req-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
    user-select: none;
    list-style: none;
    transition: background .15s;
}
.req-header::-webkit-details-marker { display: none; }
.req-header:hover { background: #f8fafc; }
details[open] > .req-header { background: #fafbfc; border-bottom: 1px solid var(--rule); }
.req-header::after {
    content: '';
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--faint);
    border-bottom: 1.5px solid var(--faint);
    transform: rotate(45deg);
    transition: transform .15s;
    flex: 0 0 auto;
}
details[open] > .req-header::after { transform: rotate(-135deg); }
.req-date { font-family: var(--mono); font-size: .78rem; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.req-people { font-size: .76rem; color: var(--muted); }

/* ---------- 报文代码块 ---------- */
.code-section { background: var(--paper); }
.code-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 6px 10px;
    background: #fafbfc;
    border-bottom: 1px solid var(--rule);
}
.code-tabs { display: flex; gap: 2px; }
.tab-btn {
    border: 0;
    background: none;
    color: var(--muted);
    font-size: .72rem;
    padding: 4px 9px;
    border-radius: 6px;
    cursor: pointer;
    transition: background .15s, color .15s;
}
.tab-btn:hover { background: #eef1f5; color: var(--ink); }
.tab-btn.active { background: #e9edf4; color: var(--ink); font-weight: 650; }

.send-btn {
    margin-left: auto;
    border: 1px solid #efc4c4;
    background: var(--paper);
    color: var(--bad);
    font-size: .74rem;
    font-weight: 650;
    padding: 4px 11px;
    border-radius: 7px;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.send-btn:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.send-btn:disabled { background: #f3f4f6; border-color: var(--rule-2); color: var(--faint); cursor: not-allowed; }
.send-btn:active { transform: none; }

.code-content { display: none; position: relative; }
.code-content.active { display: block; }
pre {
    margin: 0;
    padding: 12px 76px 12px 14px;
    background: var(--code-bg);
    color: var(--code-fg);
    font-family: var(--mono);
    font-size: .71rem;
    line-height: 1.62;
    overflow-x: auto;
    max-height: 320px;
}
pre.code-json { color: #a8c7fa; }
pre.code-body { color: #e2b47a; white-space: pre-wrap; word-break: break-all; }
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    background: rgba(255, 255, 255, .12);
    border: 1px solid rgba(255, 255, 255, .22);
    color: #e5eaf3;
    font-size: .68rem;
    padding: 2px 8px;
    border-radius: 5px;
    cursor: pointer;
}
.copy-btn:hover { background: rgba(255, 255, 255, .22); }

/* ---------- 自定义报文生成器 ---------- */
.gen-form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.form-label { font-size: .74rem; color: var(--muted); flex: 0 0 auto; }
.form-sep { font-size: .74rem; color: var(--faint); }
.form-row input[type="date"] {
    flex: 1 1 132px;
    min-width: 0;
    padding: 6px 9px;
    border: 1px solid var(--rule-2);
    border-radius: 7px;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--mono);
    font-size: .78rem;
}
.form-row input[type="date"]:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.person-field { display: flex; flex-direction: column; gap: 8px; }
.person-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px;
    background: #fafbfc;
    border: 1px solid var(--rule);
    border-radius: 8px;
}
.person-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px 3px 8px;
    border: 1px solid var(--rule-2);
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink-2);
    font-size: .76rem;
    cursor: pointer;
    user-select: none;
    transition: background .12s, border-color .12s, color .12s;
}
.person-chip input { width: 13px; height: 13px; margin: 0; accent-color: var(--accent); }
.person-chip:has(input:checked) { border-color: #bfcdf7; background: var(--accent-soft); color: var(--accent); }
.person-chip.off { opacity: .55; }
.person-chip .star { color: #c2830b; font-size: .68rem; line-height: 1; }
.person-chip .off-tag { font-size: .64rem; color: var(--faint); }

.primary-btn {
    border: 0;
    background: var(--ink);
    color: #fff;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: .78rem;
    font-weight: 650;
    cursor: pointer;
    transition: background .15s;
}
.primary-btn:hover { background: #000; }
.primary-btn:disabled { background: #c8cdd6; cursor: default; }
.ghost-btn {
    border: 1px solid var(--rule-2);
    background: var(--paper);
    color: var(--ink-2);
    padding: 3px 10px;
    border-radius: 7px;
    font-size: .72rem;
    cursor: pointer;
    transition: background .15s;
}
.ghost-btn:hover { background: #f2f4f7; }
.ghost-btn.is-open { background: #eef1f5; border-color: var(--rule-2); color: var(--ink); }
.custom-result { margin-top: 14px; }
.batch-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 12px;
    margin-bottom: 10px;
    background: #f7f9fc;
    border: 1px solid var(--rule);
    border-radius: 8px;
}
.batch-text { display: flex; align-items: baseline; gap: 8px; font-size: .78rem; color: var(--ink-2); }
.batch-text b { color: var(--ink); font-weight: 650; }
.batch-row { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.note {
    padding: 8px 11px;
    margin-bottom: 10px;
    background: var(--warn-soft);
    border: 1px solid #f0dcb0;
    border-radius: 7px;
    font-size: .74rem;
    color: var(--warn);
}

/* ---------- 智能拼车 ---------- */
.notice { padding: 11px 13px; background: var(--warn-soft); border: 1px solid #f0dcb0; border-radius: 8px; margin-bottom: 12px; }
.notice-line { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .78rem; color: var(--warn); }
.notice-line b { font-family: var(--mono); font-size: .84rem; }
.notice-line .ghost-btn { margin-left: auto; color: var(--warn); border-color: #e6cfa0; background: #fffdf7; }
.notice-line .ghost-btn:hover { background: #fdf3dd; }
.pending-box { margin-top: 2px; }

/* ---------- 折叠 / 空态 / 熔断 ---------- */
.sim-box > summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    list-style: none;
    cursor: pointer;
    font-size: .84rem;
    font-weight: 650;
    color: var(--ink);
}
.sim-box > summary::-webkit-details-marker { display: none; }
.sim-box > summary::after {
    content: '';
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--faint);
    border-bottom: 1.5px solid var(--faint);
    transform: rotate(45deg);
    transition: transform .15s;
}
.sim-box[open] > summary::after { transform: rotate(-135deg); }
.sim-count { font-family: var(--mono); font-size: .72rem; font-weight: 400; color: var(--faint); }
.sim-box > p { margin: 12px 0; }

.error-banner {
    padding: 11px 13px;
    margin-bottom: 14px;
    background: var(--bad-soft);
    border: 1px solid #f3c6c6;
    border-radius: 8px;
    color: #8f1d1d;
    font-size: .78rem;
    font-weight: 600;
}
.blocked-overlay {
    padding: 26px 18px;
    background: #fbfbfc;
    border: 1px dashed var(--rule-2);
    border-radius: 10px;
    text-align: center;
}
.blocked-title { font-size: .92rem; font-weight: 650; color: var(--bad); margin-bottom: 6px; }
.blocked-sub { font-size: .76rem; line-height: 1.65; color: var(--muted); }

.loading-box { padding: 46px 18px; text-align: center; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius); }
.loading-dot {
    width: 10px;
    height: 10px;
    margin: 0 auto 14px;
    border-radius: 50%;
    background: var(--accent);
    animation: pulse 1.4s ease-in-out infinite;
}
.loading-title { font-size: .88rem; font-weight: 600; color: var(--ink-2); }
.loading-sub { margin-top: 5px; font-size: .74rem; color: var(--faint); }

/* ==========================================================
   窄屏：表格拆成卡片，工具条折行
   ========================================================== */
@media (max-width: 720px) {
    .container { padding-left: 12px; padding-right: 12px; }
    .page-title { font-size: 1rem; }
    .page-head { margin-bottom: 14px; }
    .tabs { margin-bottom: 14px; }
    .tab { min-width: 0; flex: 1 1 0; padding: 8px 10px; }
    .panel { padding: 13px 13px 14px; border-radius: 9px; }
    .panel > h2 { font-size: .8rem; }
    .panel > h2 .meta { width: 100%; margin-left: 0; }

    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-item { border-left: 1px solid var(--rule); border-top: 1px solid var(--rule); }
    .stat-item:nth-child(2n+1) { border-left: 0; }
    .stat-item:nth-child(-n+2) { border-top: 0; }
    .stat-val { font-size: .96rem; }

    /* 表格 → 卡片 */
    .table-wrapper { border: 0; border-radius: 0; margin-bottom: 14px; }
    .person-table, .person-table tbody { display: block; min-width: 0; }
    .person-table thead { display: none; }
    .person-table tr { display: block; border: 1px solid var(--rule); border-radius: 9px; margin-bottom: 8px; padding: 10px 11px; }
    .person-table td, .person-table td:first-child { display: block; width: auto; border: 0; padding: 0; }
    .person-table td:first-child { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 7px; }
    .person-table td:first-child br { display: none; }
    .person-table .id-mask { margin: 0 0 0 auto; font-size: .62rem; }
    tbody tr:hover td { background: transparent; }
    .track-line { gap: 7px; padding: 3px 0; }
    .track-line + .track-line { margin-top: 4px; padding-top: 6px; }

    .req-header { padding: 9px 11px; }
    .code-toolbar { padding: 7px 8px; }
    .send-btn { margin-left: 0; flex: 1 1 100%; text-align: center; padding: 7px 11px; }
    pre { font-size: .68rem; max-height: 260px; padding: 11px 54px 11px 11px; }
    .copy-btn { top: 6px; right: 6px; font-size: .62rem; padding: 1px 6px; }
    .form-row input[type="date"] { flex: 1 1 110px; }
    /* 日期区间：标签独占一行，两个日期并排；16px 防止 iOS 聚焦放大 */
    .date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
    .date-row .form-label { grid-column: 1 / -1; }
    .date-row .form-sep { display: none; }
    .date-row input[type="date"] { width: 100%; flex: none; font-size: 16px; padding: 7px 4px 7px 8px; }
    .person-chip { font-size: .74rem; }
    .notice-line .ghost-btn { margin-left: 0; width: 100%; padding: 7px 10px; }
    .batch-bar { align-items: stretch; }
}

@media (prefers-reduced-motion: reduce) {
    .loc-content.active { animation: none; }
    .loading-dot { animation: none; }
}
