/* ============================================================
 * styles.css —— 机车看板全部样式（原 index.html 内联 <style> 提取）
 * 与 js/ 各模块配套，classic <link> 引用，零依赖。
 * ============================================================ */
body { margin: 0; display: flex; justify-content: center; align-items: center; height: 100vh; overflow: hidden; background-color: #f0f0f0; font-family: Arial, sans-serif; user-select: none; }
#canvas { 
    width: 1715px; height: 922px; position: relative; 
    box-shadow: 0 0 10px rgba(0,0,0,0.1); overflow: visible; background-color: white;  /* visible：允许「运行故障」框贴在原提示框正上方时溢出画布顶显示 */
    -webkit-user-drag: none; 
}
.inspection-zone {
    position: absolute;
    left: 1px;     /* 最左侧，距画布左边缘 1px */
    bottom: 195px;   /* 兜底值；运行时由 JS 按「河西方向」行号计算顶边对齐线(第19行线)动态覆盖 */
    width: 419px;   /* 左距1px+419=420px(70×6) → 右缘压在单元格线上；相对原590px减少约2.5格(171px) */
    height: 280px;   /* 原255px增加3格后330px，现减2个单元格(2*BTN_HEIGHT=50px)=280px */
    border: 2px solid #222;
    background: #fff;
    z-index: 1;
    pointer-events: none;
    box-sizing: border-box;
}
.inspection-zone::before {
    content: '金泉机车统计系统';
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 13px;
    font-weight: bold;
    color: #444;
    pointer-events: none;
}
#inspection-body {
    position: absolute;
    top: 24px;
    left: 6px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
/* ✅ 提示框：位于机车统计系统框正上方，左空1格、宽12格、高6格；标题红/贴顶，内容居中，框为正常黑边白底 */
.stats-title-box {
    position: absolute;
    left: 1px;           /* 往右移 1px */
    top: 292px;          /* ✅ 在 287px 基础上下移 5px；故障框贴其正上方 top:231px */
    width: 330px;        /* 宽约 13.2 个单元格（原 280 + 50） */
    height: 150px;       /* 高 6 个单元格 */
    border: 2px solid #222;        /* 正常黑边框 */
    background: #fff;              /* 正常白底 */
    box-sizing: border-box;
    display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start;  /* 竖向排列、顶部对齐 */
    padding: 4px 6px 0;
    text-align: center;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;              /* 兜底：内容超出框时裁剪，避免溢出 */
}
.stats-title-box .tip-title { font-size: 14px; font-weight: bold; color: #333; }  /* 标题：黑、居中 */
.stats-title-box .tip-line { margin-top: 4px; }  /* 备用/第三趟 内容块容器 */
.stats-title-box .tip-row { display: flex; flex-wrap: wrap; gap: 2px 18px; margin-top: 2px; text-align: left; }  /* 每行最多排 2 台，字体允许时并排 */
.stats-title-box .tip-item { display: inline-flex; align-items: baseline; white-space: nowrap; font-size: 16px; font-weight: bold; color: #333; pointer-events: auto; }  /* 单台信息：靠左、加大、黑色；重新开启鼠标事件使右键可命中（框本体仍 pointer-events:none 不挡轨道） */
.stats-title-box .tip-item.fault { color: #c00; }  /* 运行故障整行红色 */
.stats-title-box .tip-tag { display: inline-block; margin-right: 8px; font-size: 14px; font-weight: bold; color: #333; }  /* 行首分组标签：备用/第三趟/运行故障 */
.stats-title-box .tip-tag.fault-tag { color: #c00; }
/* ✅ 独立「运行故障」提示框：位于主提示框正上方，高 2 格、长 4.5 格（1 格 = 25px，与提示框一致） */
.fault-box {
    position: absolute;
    left: 1px;              /* 向右移 1px */
    /* top 由 JS 动态设为「主提示框正上方」(=主提示框 offsetTop - 61)，保持原提示框位置不动 */
    width: 282.5px;          /* 长 4.5 个单元格 + 170px */
    height: 55px;           /* 高 2 个单元格 + 5px */
    border: 2px solid #c00;
    background: #fff;
    box-sizing: border-box;
    padding: 2px 4px 3px;
    z-index: 3;
    overflow: hidden;
    pointer-events: none;    /* 框本体不挡轨道，仅条目可点 */
    display: flex; flex-direction: column;
}
.fault-box .fb-title { flex: 0 0 auto; font-size: 12px; font-weight: bold; color: #c00; text-align: center; line-height: 14px; }
.fault-box .fb-body { flex: 1 1 auto; display: flex; flex-direction: row; align-items: stretch; overflow: visible; }
.fault-box .fb-item { flex: 1 1 0; min-width: 0; text-align: center; white-space: nowrap; overflow: visible; font-size: 14px; font-weight: bold; color: #c00; pointer-events: auto; cursor: pointer; line-height: 16px; }
.fault-box .fb-empty { font-size: 12px; color: #c00; opacity: .55; text-align: center; }
.stats-title-box .tip-item.overdue { color: #198754; }  /* 备用超 24 小时：字体变绿（※仍红） */
.stats-title-box .tip-mark { color: #d00; }  /* 行首 ※ 序号标记：红色 */
/* ✅ 修改时间 简易对话框（替代原生 prompt） */
.ts-edit-overlay { position: absolute; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,.25); display: flex; align-items: center; justify-content: center; z-index: 50; }
.ts-edit-box { background: #fff; border: 2px solid #222; border-radius: 6px; padding: 14px 16px; min-width: 220px; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
.ts-edit-title { font-size: 14px; font-weight: bold; color: #333; margin-bottom: 10px; text-align: center; }
.ts-edit-input { width: 100%; box-sizing: border-box; font-size: 14px; padding: 5px 6px; border: 1px solid #888; border-radius: 4px; }
.ts-edit-btns { display: flex; justify-content: space-between; margin-top: 12px; }
.ts-edit-btn { flex: 1; margin: 0 4px; padding: 6px 0; font-size: 13px; border: 1px solid #888; border-radius: 4px; background: #f3f3f3; cursor: pointer; }
.ts-edit-btn:hover { background: #e6e6e6; }
#inspection-formula {
    font-size: 16px;
    font-weight: bold;
    color: #000;
    white-space: normal;
    pointer-events: none;
}
.ins-num { color: #e60000; font-weight: bold; }
#inspection-bureau { font-size: 16px; font-weight: bold; color: #000; white-space: normal; pointer-events: none; }
#inspection-extra { font-size: 16px; font-weight: bold; color: #000; white-space: normal; line-height: 1.5; pointer-events: none; margin-top: 2px; display: flex; flex-direction: column; }
.loco-num { pointer-events: auto; cursor: context-menu; }
.loco-remark-mark { color: #e60000; font-weight: bold; }
#remark-bubble { position: fixed; display: none; max-width: 300px; box-sizing: border-box; background: #fff; border: 1px solid #e60000; color: #e60000; font-size: 19px; font-weight: bold; padding: 6px 10px; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,0.25); z-index: 99998; pointer-events: none; white-space: normal; line-height: 1.5; word-break: break-word; overflow-wrap: anywhere; text-align: left; }
.remark-menu { position: fixed; display: none; background: #fff; border: 1px solid #333; border-radius: 4px; box-shadow: 0 2px 10px rgba(0,0,0,0.25); padding: 4px 0; z-index: 99999; min-width: 120px; font-size: 13px; }
.remark-menu-item { padding: 7px 16px; cursor: pointer; color: #222; white-space: nowrap; }
.remark-menu-item:hover { background: #f0f4ff; }
/* ✅ 自定义「添加备注」居中弹窗（替代原生 prompt，保证屏幕正中） */
.remark-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 40000; display: none; align-items: center; justify-content: center; }
.remark-modal { background: #fff; border-radius: 8px; padding: 18px 20px; width: 320px; max-width: 90vw; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
.remark-modal h4 { margin: 0 0 10px; font-size: 15px; color: #333; text-align: center; }
.remark-modal textarea { width: 100%; box-sizing: border-box; min-height: 72px; font-size: 14px; padding: 8px; border: 1px solid #ccc; border-radius: 4px; resize: vertical; font-family: inherit; }
.remark-modal .rm-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.remark-modal button { font-size: 14px; padding: 6px 16px; border-radius: 4px; cursor: pointer; border: 1px solid #ccc; background: #fff; color: #333; }
.remark-modal button.rm-ok { background: #007bff; color: #fff; border-color: #007bff; }
.panel { display: none; position: absolute; background: rgba(255,255,255,0.98); border: 1px solid #ccc; padding: 10px 12px; border-radius: 6px; box-shadow: 0 3px 6px rgba(0,0,0,0.15); z-index: 1000; }
.panel h4 { margin: 0 0 6px 0; font-size: 14px; color: #555; text-align: center; }
.panel label { display: inline-block; width: 50px; font-size: 14px; }
.panel select, .panel input[type="text"] { width: 120px; padding: 4px; box-sizing: border-box; font-size: 14px; }
/* 局段下拉：居中显示；2字局段中间加全角空格，使其宽度与3字局段(二十局/十五局)一致、对齐 */
#btn-bureau-select, #btn-bureau-select option { text-align: center; }
.panel input.input-error { border: 2px solid #dc3545; outline: none; animation: shake 0.3s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-4px)} 75%{transform:translateX(4px)} }
.status-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 3px; margin-bottom: 4px; }
.status-option { padding: 4px 4px; border: 1px solid #ddd; border-radius: 3px; cursor: pointer; font-size: 12px; text-align: center; background: white; color: #333; line-height: 1.3; white-space: nowrap; transition: background-color 0.12s, border-color 0.12s; }
.status-option:hover { background: #eef3ff; border-color: #4a90e2; }
.status-divider { height: 1px; background: #eee; margin: 4px 0; }
.status-option.danger { color: #dc3545; border-color: #f5c6cb; background: #fff5f5; grid-column: 1 / -1; font-weight: bold; }
.status-option.danger:hover { background: #ffe0e0; }
.status-option.fault { color: #b8430b; border-color: #f0b27a; background: #fff3e6; grid-column: 1 / -1; font-weight: bold; }
.status-option.fault:hover { background: #ffe6cc; }

.loco-btn {
    position: absolute; width: 70px; height: 25px; border-radius: 3px; 
    cursor: grab; display: flex; overflow: hidden; box-sizing: border-box;
    border: 1px solid #000; transition: box-shadow 0.1s, border-radius 0.15s;
    will-change: left, top; z-index: 2;
    background-color: white;
}
.loco-btn:active { cursor: grabbing; }
/* ✅ 修复3: 拖拽时z-index提升至200，确保覆盖link-handle(60) */
.loco-btn.dragging { z-index: 200 !important; box-shadow: 0 4px 12px rgba(0,0,0,0.3); transition: none; }
.loco-bureau { width: 25%; height: 100%; flex-shrink: 0; color: white; font-size: 10px; font-weight: bold; line-height: 25px; text-align: center; pointer-events: none; }
.loco-bureau.light-bg { color: #333; }
.loco-status { 
    width: 75%; height: 100%; font-size: 22px; font-weight: bold; line-height: 25px; text-align: center; 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
    background-color: white; color: #333; position: relative; pointer-events: none; 
}
.loco-btn.grouped { border-radius: 0; }
.loco-btn.group-left { margin-left: -1px; border-top-left-radius: 0; border-bottom-left-radius: 0; z-index: 3; }
.loco-btn.group-top { margin-top: -1px; border-top-left-radius: 0; border-top-right-radius: 0; z-index: 3; }
.loco-btn.group-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.loco-btn.group-bottom { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
/* ✅ 机车被标记为「运行故障」时显示红色加粗边框；用 outline 绘制（不占布局、不挤压内容区），避免机车号被裁切 */
.loco-btn.fault-active {
    outline: 3px solid #c00 !important;
    outline-offset: -1px;
    box-shadow: 0 0 6px rgba(204,0,0,0.55);
}

.link-handle {
    position: absolute; width: 8px; height: 8px; background: #007bff; border: 1.5px solid white;
    border-radius: 50%; z-index: 60; cursor: grab; transform: translate(-50%, -50%);
    box-shadow: 0 1px 3px rgba(0,0,0,0.4); transition: background 0.15s;
}
.link-handle::after {
    content: ''; position: absolute; top: 50%; left: 50%;
    width: 15px; height: 15px; transform: translate(-50%, -50%);
    border-radius: 50%; background: transparent; pointer-events: auto; 
}
.link-handle:hover { background: #0056b3; transform: translate(-50%, -50%) scale(1.4); }
.link-handle:active { cursor: grabbing; transform: translate(-50%, -50%) scale(1.2); }

/* ============================================================
 * 验证模块（auth.js）：口令验证单元格 + 密码弹窗 + 提示气泡
 * ============================================================ */
.auth-cell {
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    writing-mode: horizontal-tb;
}
.auth-cell:hover { filter: brightness(0.96); }

/* 密码弹窗 */
.auth-modal-overlay {
    position: fixed; inset: 0; z-index: 4000;
    background: rgba(0, 0, 0, 0.3);
    display: none; align-items: center; justify-content: center;
    font-family: Arial, "Microsoft YaHei", sans-serif;
}
.auth-modal {
    background: #fff; border: 1px solid #ccc; border-radius: 8px;
    padding: 20px 22px; width: 280px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.auth-modal h4 { margin: 0 0 6px; font-size: 16px; color: #333; }
.auth-hint { margin: 0 0 12px; font-size: 12px; color: #888; }
.auth-input {
    width: 100%; box-sizing: border-box; padding: 8px 10px;
    font-size: 14px; border: 1px solid #ccc; border-radius: 4px; outline: none;
}
.auth-input:focus { border-color: #007bff; }
.auth-err { color: #dc3545; font-size: 12px; min-height: 16px; margin: 6px 0 0; }
.auth-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.auth-btns button {
    font-size: 14px; padding: 6px 16px; border-radius: 4px;
    cursor: pointer; border: 1px solid #ccc; background: #f5f5f5;
}
.auth-btns .auth-ok { background: #007bff; color: #fff; border-color: #007bff; }

/* 操作受限提示气泡 */
.auth-toast {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    z-index: 5000; color: #fff; padding: 14px 26px; border-radius: 10px;
    font-size: 16px; font-weight: bold; display: none; font-family: Arial, "Microsoft YaHei", sans-serif;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2); white-space: nowrap;
}
