:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --text: #16202c;
  --text-dim: #5b6b7b;
  --border: #d9e1ea;
  --primary: #0f4c81;
  --primary-soft: #e4eef7;
  --danger: #d12b2b;
  --danger-soft: #fdeaea;
  --ok: #1f8a4c;
  --shadow: 0 2px 10px rgba(15, 38, 64, .08);
  --radius: 14px;
  --cat-接发列车: #2563eb;
  --cat-乘客组织: #0891b2;
  --cat-设备操作: #7c3aed;
  --cat-安全卡控: #d12b2b;
  --cat-应急处置: #ea580c;
}

[data-theme="dark"] {
  --bg: #0e1620;
  --surface: #16212e;
  --surface-2: #1d2a3a;
  --text: #e8eef5;
  --text-dim: #9fb0c2;
  --border: #2a3a4d;
  --primary: #4f9fe0;
  --primary-soft: #16314a;
  --danger: #ff6b6b;
  --danger-soft: #3a1c1c;
  --ok: #54d98c;
  --shadow: 0 2px 10px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 76px;
  -webkit-font-smoothing: antialiased;
}

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--primary); color: #fff; box-shadow: var(--shadow);
}
.topbar-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { font-size: 26px; }
.app-name { font-weight: 700; font-size: 16px; line-height: 1.1; }
.app-sub { font-size: 11px; opacity: .85; line-height: 1.2; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.line-select {
  background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.3);
  border-radius: 10px; padding: 7px 10px; font-size: 13px; max-width: 42vw;
}
.line-select option { color: #16202c; }
.icon-btn {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.3);
  color: #fff; border-radius: 10px; width: 38px; height: 38px; font-size: 17px; cursor: pointer;
}

/* View */
.view { padding: 14px; max-width: 760px; margin: 0 auto; }

/* Search */
.search {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 15px; margin-bottom: 12px;
}

/* Station grid */
.station-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px;
}
.station-chip {
  position: relative; padding: 12px 8px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 13px; text-align: center; cursor: pointer;
  box-shadow: var(--shadow); transition: transform .08s, border-color .15s;
  display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 56px; justify-content: center;
}
.station-chip:active { transform: scale(.96); }
.station-chip.selected { border-color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.station-chip .cnt {
  font-size: 10px; padding: 1px 6px; border-radius: 999px; background: var(--surface-2); color: var(--text-dim);
}
.station-chip.has-data .cnt { background: var(--primary); color: #fff; }
.station-chip .empty-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }

/* Section headers */
.section-h { font-size: 13px; color: var(--text-dim); margin: 18px 2px 8px; font-weight: 600; }
.station-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.station-head .name { font-size: 19px; font-weight: 700; }
.station-head .meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.btn-row { display: flex; gap: 8px; }
.mini-btn {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 9px; padding: 7px 10px; font-size: 12px; cursor: pointer;
}

/* Operation point cards */
.cat-group { margin-bottom: 14px; }
.cat-title {
  display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; margin: 4px 2px 8px;
}
.cat-dot { width: 10px; height: 10px; border-radius: 3px; }
.cat-count { font-size: 11px; color: var(--text-dim); font-weight: 400; }

.op-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 9px; box-shadow: var(--shadow);
}
.op-card.critical { border-left-color: var(--danger); background: var(--danger-soft); }
.op-top { display: flex; align-items: flex-start; gap: 10px; }
.op-check {
  appearance: none; -webkit-appearance: none; flex: 0 0 auto; width: 22px; height: 22px; margin-top: 1px;
  border: 2px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; position: relative;
}
.op-check:checked { background: var(--ok); border-color: var(--ok); }
.op-check:checked::after { content: "✓"; color: #fff; font-size: 15px; position: absolute; left: 3px; top: -1px; }
.op-main { flex: 1; min-width: 0; }
.op-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.op-star { color: var(--danger); font-weight: 700; }
.op-detail { font-size: 13.5px; color: var(--text); margin-top: 5px; line-height: 1.5; white-space: pre-wrap; }
.op-risk {
  font-size: 12px; color: var(--danger); margin-top: 6px; padding: 6px 9px; background: var(--danger-soft);
  border-radius: 8px; line-height: 1.45;
}
[data-theme="dark"] .op-risk { background: rgba(255,107,107,.12); }
.op-done .op-title, .op-done .op-detail { opacity: .5; text-decoration: line-through; }
.op-edit { background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer; padding: 2px 4px; }

.empty-hint {
  text-align: center; color: var(--text-dim); padding: 30px 16px; font-size: 14px; line-height: 1.6;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}

/* Forms / edit */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 5px; font-weight: 600; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 70px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 6px 0; }
.primary-btn {
  width: 100%; padding: 13px; border: none; border-radius: 12px; background: var(--primary); color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 6px;
}
.ghost-btn {
  width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text); font-size: 14px; cursor: pointer; margin-top: 8px;
}
.danger-btn {
  width: 100%; padding: 12px; border: 1px solid var(--danger); border-radius: 12px; background: transparent;
  color: var(--danger); font-size: 14px; cursor: pointer; margin-top: 8px;
}
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px;
  margin-bottom: 8px; box-shadow: var(--shadow);
}
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { font-size: 14px; font-weight: 600; }
.list-item .li-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.li-actions { display: flex; gap: 6px; }
.li-btn { border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 6px 9px; font-size: 12px; cursor: pointer; }

/* Data view */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-size: 15px; }
.card p { margin: 6px 0; font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.code {
  background: var(--surface-2); border-radius: 9px; padding: 10px; font-size: 11.5px; line-height: 1.5;
  overflow-x: auto; color: var(--text-dim); font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* Tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; border: none; background: none; color: var(--text-dim); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 0; font-size: 11px;
}
.tab .tab-ico { font-size: 19px; }
.tab.active { color: var(--primary); font-weight: 700; }

/* Modal */
.modal-mask {
  position: fixed; inset: 0; z-index: 50; background: rgba(8, 18, 30, .5);
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--bg); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { font-size: 17px; margin: 0; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-dim); cursor: pointer; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 60;
  background: #16202c; color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); max-width: 80vw; text-align: center;
}
[data-theme="dark"] .toast { background: #e8eef5; color: #16202c; }

/* ---- 提醒视图：控制条 ---- */
.ctrl { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.ctrl-item { flex: 1 1 150px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ctrl-item label { font-size: 12px; color: var(--text-dim); font-weight: 600; }
.ctl-sel {
  width: 100%; padding: 10px 11px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit;
  appearance: none; -webkit-appearance: none;
}

/* ---- 模拟时间 ---- */
.sim {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; background: var(--surface-2); border-radius: 10px; margin-bottom: 12px; font-size: 13px;
}
.sim-lbl { display: flex; align-items: center; gap: 6px; cursor: pointer; font-weight: 600; }
.sim input[type="time"] {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit;
}
.sim-hint { color: var(--text-dim); font-size: 12px; }

/* ---- 节点摘要 ---- */
.nodes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.nodes span {
  font-size: 12.5px; color: var(--text-dim); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; box-shadow: var(--shadow);
}
.nodes b { color: var(--text); }
.warn-inline { color: var(--danger); background: var(--danger-soft) !important; }

/* ---- 时间轴头部 ---- */
.tl-head-bar { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin: 6px 2px 12px; }
.tl-title-main { font-size: 15px; font-weight: 700; }
.tl-count { font-size: 12px; color: var(--text-dim); }

/* ---- 时间轴卡片 ---- */
.timeline { display: flex; flex-direction: column; }
.tl-card {
  display: flex; align-items: stretch; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 9px; box-shadow: var(--shadow);
}
.tl-card.critical { border-left-color: var(--danger); background: var(--danger-soft); }
.tl-card.cd-near { border-left-color: #f59e0b; }
.tl-card.cd-now { border-left-color: var(--danger); background: var(--danger-soft); }
.tl-card.tl-pending { border-left-color: var(--text-dim); border-left-style: dashed; }
.tl-card.tl-done { opacity: .55; }
.tl-card.tl-done .tl-title { text-decoration: line-through; }

.tl-time {
  flex: 0 0 auto; min-width: 60px; font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums; color: var(--primary);
  display: flex; align-items: flex-start; padding-top: 2px; line-height: 1.3;
}
.tl-body { flex: 1; min-width: 0; }
.tl-head { display: flex; align-items: center; gap: 7px; }
.tl-title { font-size: 15px; font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tl-roles { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.role-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
}
.role-tag.all { background: var(--surface-2); color: var(--text-dim); }

.tl-side {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between;
  gap: 8px; min-width: 88px;
}
.tl-cd {
  font-size: 19px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums;
  text-align: right; letter-spacing: .3px; line-height: 1.2;
}
.tl-conf { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 5px; cursor: pointer; }
.tl-conf .op-check { width: 18px; height: 18px; margin: 0; }

.tl-note {
  font-size: 11.5px; color: #b45309; margin-top: 6px; padding: 4px 8px;
  background: #fff7ed; border-radius: 7px; line-height: 1.4;
}
[data-theme="dark"] .tl-note { background: rgba(245,158,11,.12); color: #fbbf24; }

/* ---- 本站补充要点 ---- */
.supplement { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 12px; }
.supp-h { font-size: 13px; color: var(--text-dim); font-weight: 600; margin-bottom: 8px; }

/* ---- 顶栏实时时钟 ---- */
.clock {
  font-size: 11px; color: rgba(255,255,255,.92); margin-top: 3px;
  font-variant-numeric: tabular-nums; letter-spacing: .3px; line-height: 1.2;
}

/* ---- 岗位 Tab 切换栏 ---- */
.role-tabs {
  display: flex; gap: 0; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.role-tab {
  flex: 1; border: none; background: none; color: var(--text-dim);
  cursor: pointer; display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 12px 6px; font-size: 13px; font-weight: 600;
  transition: background .15s, color .15s; position: relative;
  border-right: 1px solid var(--border);
}
.role-tab:last-child { border-right: none; }
.role-tab:hover { background: var(--surface-2); }
.role-tab.active {
  background: var(--primary-soft); color: var(--primary);
  box-shadow: inset 0 -3px 0 var(--primary);
}
.role-tab .rt-icon { font-size: 20px; line-height: 1; }
.role-tab .rt-label { font-size: 13px; font-weight: 700; }
.role-tab .rt-sub { font-size: 10px; color: var(--text-dim); font-weight: 400; }
.role-tab.active .rt-sub { color: var(--primary); opacity: .7; }
.role-tab .rt-count {
  position: absolute; top: 6px; right: 8px;
  font-size: 10px; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 999px; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}
.role-tab:not(.active) .rt-count {
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
}

/* ---- 当前岗位时间轴区域 ---- */
.role-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 13px; box-shadow: var(--shadow);
}
.rp-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 8px;
  margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--primary);
}
.rp-title { font-size: 15px; font-weight: 700; }
.rp-title .col-sub { font-size: 11px; color: var(--text-dim); font-weight: 500; }
.rp-count { font-size: 12px; color: var(--text-dim); }

/* ---- 新增提醒按钮 ---- */
.add-rem-btn {
  width: 100%; padding: 11px; margin-bottom: 12px;
  border: 1.5px dashed var(--primary); border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.add-rem-btn:active { transform: scale(.99); }

/* ---- 实时运营状态面板 ---- */
.live-status {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--text-dim);
  border-radius: var(--radius); padding: 13px 15px; margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.live-status.phase-running { border-left-color: var(--ok); background: rgba(31,138,76,.07); }
.live-status.phase-idle { border-left-color: var(--text-dim); }
.live-status.phase-none { border-left-color: #d12b2b; }
[data-theme="dark"] .live-status.phase-running { background: rgba(84,217,140,.10); }
.ls-main { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ls-phase { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.ls-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--text-dim); display: inline-block; }
.live-status.phase-running .ls-dot { background: var(--ok); box-shadow: 0 0 0 4px rgba(31,138,76,.18); animation: pulse 1.6s infinite; }
.live-status.phase-idle .ls-dot { background: var(--text-dim); }
.live-status.phase-none .ls-dot { background: #d12b2b; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(31,138,76,.35);} 70%{box-shadow:0 0 0 7px rgba(31,138,76,0);} 100%{box-shadow:0 0 0 0 rgba(31,138,76,0);} }
.ls-cd { font-size: 14px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.ls-cd b { color: var(--text); font-size: 16px; font-weight: 800; }
.ls-nodes { display: flex; flex-wrap: wrap; gap: 8px; }
.ls-nodes span {
  font-size: 12px; color: var(--text-dim); background: var(--surface-2);
  border-radius: 999px; padding: 5px 11px;
}
.ls-nodes b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ---- 提醒卡片：标签 + 操作 ---- */
.type-tag, .freq-tag {
  font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600;
}
.type-tag { background: var(--primary-soft); color: var(--primary); }
.freq-tag { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border); }
.tl-cd.muted { color: var(--text-dim); font-size: 14px; font-weight: 600; }
.card-acts { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mini-act {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer;
}
.mini-act.del { color: var(--danger); border-color: var(--danger); }
.mini-act:active { opacity: .7; }
.tl-conf { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 4px; cursor: pointer; }
.tl-conf .op-check { width: 16px; height: 16px; margin: 0; }

/* ---- 分段选择 / 偏移输入 ---- */
.seg { display: flex; gap: 8px; }
.seg-opt {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; font-size: 14px; cursor: pointer;
  background: var(--surface); color: var(--text);
}
.seg-opt input { accent-color: var(--primary); }
.offset-row {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--text-dim);
}
.offset-row input { width: 78px; padding: 8px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-family: inherit; }

