/* 資安情資管制台。世界：捷運路網與月台資訊。只借用字體、配色、密度和一個招牌設計（路網圖），
   導覽與控制項維持標準網頁元件。狀態色都附形狀與文字，不只靠顏色。 */
:root {
  --ink: #13202b;
  --ink-2: #2b3a47;
  --muted: #4a5864;
  --ground: #e8eef4;        /* 清單與時間軸底：帶藍的淺灰 */
  --surface: #ffffff;
  --line: #c5cfd8;
  --line-soft: #e1e7ec;
  --sign: #14202b;          /* 站名牌：頂列底色 */
  --accent: #0f4c81;
  --focus: #0f62b0;

  --amber-bg: #fdebc8; --amber-fg: #6a3f00; --amber-mk: #a85a00;
  --red-bg: #fde3e3;   --red-fg: #8c0a1f;   --red-mk: #c8102e;
  --blue-bg: #dbe9f8;  --blue-fg: #0b4378;  --blue-mk: #0f62b0;
  --green-bg: #d9f0e2; --green-fg: #115430; --green-mk: #1b7a45;
  --brown-bg: #f3e4cf; --brown-fg: #5a3609; --brown-mk: #a8691b;
  --gray-bg: #e6eaee;  --gray-fg: #36434e;  --gray-mk: #5d6b76;

  --font: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 8px;
  --shadow: 0 1px 2px rgba(19, 32, 43, .10), 0 3px 10px rgba(19, 32, 43, .06);
}

* { box-sizing: border-box; }
html { font-size: 17px; }
body {
  margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font); line-height: 1.55;
  height: 100vh; display: flex; flex-direction: column; overflow: hidden; font-weight: 400;
}
::selection { background: #b9d4ee; color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
* { scrollbar-width: thin; scrollbar-color: #8fa0ae transparent; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--accent); color: #fff; padding: 8px 12px; z-index: 10; border-radius: var(--r); }
.skip:focus { top: 8px; }
h1, h2, h3, h4, p { margin: 0; }
h2 { font-size: 1.15rem; line-height: 1.3; font-weight: 800; letter-spacing: .02em; }
h3 { font-size: 1.08rem; margin-bottom: .35rem; font-weight: 800; }
h4 { font-size: .9rem; margin: .8rem 0 .3rem; color: var(--muted); font-weight: 700; letter-spacing: .03em; }
ul { margin: .3rem 0; padding-left: 1.2rem; }
li { margin: .15rem 0; }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
.muted { color: var(--muted); font-size: .9rem; }
.small { font-size: .88rem; color: var(--muted); margin-top: .2rem; }
.empty { color: var(--muted); padding: 1rem 0; }
.empty.big { font-size: 1.1rem; padding: 3rem 1rem; text-align: center; }
.err { background: var(--red-bg); color: var(--red-fg); padding: .7rem .9rem; border-radius: var(--r); margin: .5rem; }

/* 頂列：站名牌 */
.top { position: relative; display: flex; align-items: center; gap: 1.1rem; padding: .7rem 1.2rem .85rem; background: var(--sign); color: #fff; flex: none; }
.brand { display: flex; align-items: baseline; gap: 1rem; min-width: 0; }
.brand strong { font-size: 1.45rem; font-weight: 800; letter-spacing: .06em; }
.brand-sub { color: #b8c6d2; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ds { padding: .22rem .75rem; border-radius: 999px; font-weight: 800; font-size: .92rem; white-space: nowrap; }
.ds-fixture { background: #ffd66b; color: #3d2600; }
.ds-real { background: #8fe0b0; color: #06361c; }
.ctl { margin-left: auto; display: flex; gap: 1rem; }
.ctl label { display: flex; align-items: center; gap: .45rem; font-size: .9rem; color: #b8c6d2; }
.ctl input, .ctl select { background: #fff; border: 0; border-radius: 6px; padding: .25rem .5rem; color: var(--ink); }
.stripe { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; display: flex; }
.stripe i { flex: 1; }
.stripe i:nth-child(1) { background: #a8691b; }
.stripe i:nth-child(2) { background: #c8102e; }
.stripe i:nth-child(3) { background: #1b7a45; }
.stripe i:nth-child(4) { background: #f2a516; }
.stripe i:nth-child(5) { background: #0f62b0; }

/* 總覽：全案路網 */
.summary { flex: none; background: var(--surface); border-bottom: 1px solid var(--line); padding: .4rem 1.2rem .5rem; }
.sumgrid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 1.4rem; align-items: center; }
.net { min-width: 0; }
.route { width: 100%; height: auto; display: block; overflow: visible; }
.route-n { max-height: 252px; }
.rt { font-family: var(--font); font-size: 15px; font-weight: 500; fill: var(--ink-2); }
.rt-b { font-weight: 800; font-size: 16px; }
.rt-m { fill: #5d6b76; }
.rt-s { font-size: 14px; font-weight: 800; fill: var(--ink); }
.rt-n { font-size: 15px; font-weight: 800; font-family: var(--mono); }
.rt-t { fill: #fff; font-weight: 800; font-size: 15px; }
.rt-cap { fill: #fff; font-weight: 800; font-size: 15px; font-family: var(--mono); }
.rt-od { fill: #fff; font-weight: 800; font-size: 12px; }
.rt-warn { fill: var(--red-fg); font-weight: 800; font-size: 13px; }
.cap { cursor: pointer; }
.cap:hover rect { stroke: var(--ink); stroke-width: 3; }
.cap:focus-visible { outline: none; }
.cap:focus-visible rect { stroke: var(--focus); stroke-width: 4; }
.stn { cursor: pointer; }
.stn:hover text.rt-b, .stn.on text.rt-b { text-decoration: underline; text-underline-offset: 3px; }
.stn.on rect { fill: #dbe9f8; }
.stn:focus-visible { outline: none; }
.stn:focus-visible rect { stroke: var(--focus); stroke-width: 3; }
.sumside { font-size: .95rem; }
.sumside p { margin: 0 0 .45rem; }
.sum-h { font-size: 1.5rem; font-weight: 800; line-height: 1.2; }
.facts strong { font-family: var(--mono); }
.legend { display: flex; flex-wrap: wrap; gap: .4rem .6rem; margin: .2rem 0 .1rem; font-size: .85rem; }
.facts { list-style: none; padding: 0; margin: .3rem 0 .6rem; }
.facts li { margin: .2rem 0; }
.facts strong { margin-right: .5rem; font-variant-numeric: tabular-nums; }
.facts .warn, .warn { color: var(--red-fg); }
.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; font-weight: 700; }
.link[aria-pressed="true"] { color: var(--ink); background: var(--amber-bg); padding: 0 .3rem; border-radius: 3px; }

/* 三欄 */
.work { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr) 400px; }
.col { overflow-y: auto; padding: .8rem 1rem 2rem; min-height: 0; }
.list { background: var(--ground); padding: .8rem .75rem 2rem; }
.dossier { background: var(--surface); border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.timeline { background: #f1f5f8; }
.col-h { display: flex; align-items: baseline; justify-content: space-between; margin: 0 .3rem .6rem; }

/* 案件清單 */
.cases { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.cases li { margin: 0; }
.case { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: .6rem .75rem .65rem; display: grid; gap: .12rem; box-shadow: var(--shadow); }
.case:hover { border-color: var(--ink-2); }
.case[aria-current="true"] { border-color: var(--ink); box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--ink); }
.case-id { font-size: .85rem; color: var(--muted); font-family: var(--mono); letter-spacing: .02em; }
.case-t { font-weight: 800; overflow-wrap: anywhere; }
.case-s { font-size: .85rem; color: var(--muted); }
.case-m { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .35rem; }
.mr { display: flex; gap: 3px; margin: .4rem 0 .1rem; align-items: center; }
.mr i { flex: 1; height: 7px; border-radius: 4px; background: #d3dbe2; }
.mr i.g { height: 11px; }
.mr i.d { background: var(--c); }
.mr i.c { background: #fff; box-shadow: 0 0 0 3px var(--c); height: 11px; }
.mr i.sp { flex: 0 0 18px; height: 11px; border-radius: 3px; background: var(--c); }
.mr.tone-amber { --c: var(--amber-mk); }
.mr.tone-red { --c: var(--red-mk); }
.mr.tone-blue { --c: var(--blue-mk); }
.mr.tone-green { --c: var(--green-mk); }
.mr.tone-brown { --c: var(--brown-mk); }
.mr.tone-gray { --c: var(--gray-mk); }
.mr i.sp.tone-red { --c: var(--red-mk); background: var(--red-mk); }
.mr i.sp.tone-gray { --c: var(--gray-mk); background: var(--gray-mk); }

/* 標籤與形狀標記 */
.tag { display: inline-flex; align-items: center; gap: .35rem; padding: .08rem .6rem; border-radius: 999px; font-size: .84rem; font-weight: 700; white-space: nowrap; }
.tag.tone-amber, .tone-amber:not(.mr):not(.mk):not(.sp) { background: var(--amber-bg); color: var(--amber-fg); }
.tag.tone-red, .tone-red:not(.mr):not(.mk):not(.sp) { background: var(--red-bg); color: var(--red-fg); }
.tag.tone-blue, .tone-blue:not(.mr):not(.mk):not(.sp) { background: var(--blue-bg); color: var(--blue-fg); }
.tag.tone-green, .tone-green:not(.mr):not(.mk):not(.sp) { background: var(--green-bg); color: var(--green-fg); }
.tag.tone-brown, .tone-brown:not(.mr):not(.mk):not(.sp) { background: var(--brown-bg); color: var(--brown-fg); }
.tag.tone-gray, .tone-gray:not(.mr):not(.mk):not(.sp) { background: var(--gray-bg); color: var(--gray-fg); }
.mk { display: inline-block; width: 11px; height: 11px; flex: none; }
.mk.tone-amber { --c: var(--amber-mk); }
.mk.tone-red { --c: var(--red-mk); }
.mk.tone-blue { --c: var(--blue-mk); }
.mk.tone-green { --c: var(--green-mk); }
.mk.tone-brown { --c: var(--brown-mk); }
.mk.tone-gray { --c: var(--gray-mk); }
.mk-disc { background: var(--c); border-radius: 50%; }
.mk-ring { border: 2px solid var(--c); border-radius: 50%; background: transparent; }
.mk-square { background: var(--c); }
.mk-diamond { background: var(--c); transform: rotate(45deg) scale(.82); }
.mk-triangle { background: var(--c); clip-path: polygon(50% 0, 100% 100%, 0 100%); }

/* 卷宗 */
.dh { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; padding-bottom: .5rem; }
.dh h2 { font-size: 1.6rem; overflow-wrap: anywhere; letter-spacing: .01em; }
.dh-r { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.warns { display: flex; flex-wrap: wrap; gap: .35rem; margin: .2rem 0 .3rem; }
.routebox { margin: .4rem 0 .2rem; padding: .3rem .4rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line-soft); }
.routebox .route { max-height: 190px; }
.gate { margin: .9rem 0; padding: .95rem 1.1rem; border-radius: var(--r); background: var(--gray-bg); border: 1px solid var(--line); }
.gate-open { background: var(--amber-bg); border: 2px solid var(--amber-mk); }
.gate .ai { margin-bottom: .6rem; }
.opts { display: flex; flex-wrap: wrap; gap: .55rem; margin: .5rem 0; }
.opt { background: #fff; border: 2px solid var(--ink); border-radius: 999px; padding: .5rem 1.2rem; font-weight: 800; display: inline-flex; gap: .5rem; align-items: center; }
.opt:hover { background: var(--ink); color: #fff; }
.opt.rec { border-color: var(--accent); }
.opt-t { font-size: .85rem; background: var(--accent); color: #fff; padding: .02rem .45rem; border-radius: 999px; }
.opt-t.warn { background: var(--red-mk); color: #fff; }
.gate input[type="text"] { width: 100%; margin: .3rem 0; padding: .4rem .6rem; border: 1px solid var(--line); border-radius: var(--r); background: #fff; }
.plain { list-style: none; padding: 0; margin: .5rem 0 0; }
.gate-detail { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: .5rem .8rem; margin: .5rem 0; }
.gate-detail .adj { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-top: .4rem; }
.gate-detail label { display: inline-flex; gap: .4rem; align-items: center; font-size: .9rem; }
.gate-detail select, .gate-detail .days { padding: .2rem .4rem; border: 1px solid var(--line); border-radius: var(--r); background: #fff; width: auto; }
.gate-detail .days { width: 4.5rem; margin: 0; }

.sec { margin: 1rem 0; border-top: 1px solid var(--line); padding-top: .5rem; }
.sec > summary { cursor: pointer; display: flex; justify-content: space-between; align-items: baseline; padding: .2rem 0; list-style: none; }
.sec > summary::-webkit-details-marker { display: none; }
.sec > summary::before { content: ""; width: 8px; height: 10px; background: var(--muted); clip-path: polygon(0 0, 100% 50%, 0 100%); margin-right: .55rem; transition: transform .15s ease-out; flex: none; align-self: center; }
.sec[open] > summary::before { transform: rotate(90deg); }
.sec-t { font-weight: 800; font-size: 1.08rem; flex: 1; }
.sec-aside { color: var(--muted); font-size: .85rem; }
.sec-red > summary .sec-t { color: var(--red-fg); }
.sec-b { padding: .4rem 0 .2rem 1.1rem; }
.kv { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: .25rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .92rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.tbl-wrap { overflow-x: auto; margin: .5rem 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tbl th, .tbl td { padding: .45rem .55rem; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
.tbl thead th { background: var(--gray-bg); color: var(--ink); font-size: .85rem; font-weight: 800; border-bottom: 2px solid var(--ink-2); white-space: nowrap; }
.tbl tbody th { font-weight: 700; white-space: nowrap; }
.tbl tr.diff td, .tbl tr.diff th { background: #fff1ee; }
.tbl tr.partial td, .tbl tr.partial th { background: #fff9e8; }
.note-box { background: var(--gray-bg); border-radius: var(--r); padding: .6rem .8rem; margin: .6rem 0; }
.note-box h4 { margin-top: 0; }
.note-box.stop { background: var(--red-bg); color: var(--red-fg); font-weight: 700; }
.rawbox { margin-top: .6rem; }
.rawbox > summary { cursor: pointer; color: var(--accent); font-size: .9rem; font-weight: 700; }
.raw { font-family: var(--mono); font-size: .82rem; background: #f4f7fa; border: 1px solid var(--line-soft); border-radius: var(--r); padding: .6rem .7rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: .3rem 0; max-height: 22rem; overflow: auto; }
code { font-family: var(--mono); font-size: .85rem; background: #eef2f6; padding: .05rem .3rem; border-radius: 3px; overflow-wrap: anywhere; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.lead { margin-bottom: .5rem; }
.ev { margin: .5rem 0; }
.ev img { max-width: 100%; border: 1px solid var(--line); border-radius: var(--r); display: block; }
.ev figcaption { font-size: .82rem; color: var(--muted); margin-top: .2rem; }

/* 同一事件：多管道 */
.evgroup { border: 2px solid var(--red-mk); border-radius: var(--r); padding: .4rem; background: #fff7f5; }
.evgroup .cases { gap: .35rem; }
.evgroup .case { box-shadow: none; }
.evh { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: 0 .2rem .4rem; }
.tbl.event td.cur { background: #e7f0fa; }
.tbl.event thead th.cur { background: #dbe9f8; }
.tbl.event thead th { vertical-align: top; }
.tbl.event thead th .small { color: var(--muted); white-space: normal; }
.chlines { display: grid; gap: .1rem; margin: .4rem 0 .6rem; }
.chline { display: grid; grid-template-columns: 5.5rem minmax(0, 12rem) minmax(0, 1fr) auto; align-items: center; gap: .6rem; border-bottom: 1px solid var(--line-soft); padding: .1rem 0; }
.chline .route { max-height: 52px; }

/* 時間軸 */
.tl { list-style: none; margin: 0; padding: 0 0 0 1.8rem; position: relative; display: grid; gap: .35rem; }
.tl::before { content: ""; position: absolute; left: 5px; top: 8px; bottom: 8px; width: 4px; border-radius: 2px; background: var(--ink-2); }
.tl li { margin: 0; padding: .15rem 0; position: relative; }
.tl li::before { content: ""; position: absolute; left: -1.8rem; top: .55rem; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--ink-2); }
.tl li.gate::before { left: calc(-1.8rem - 3px); top: .45rem; width: 20px; height: 20px; border-width: 6px; border-color: var(--amber-mk); }
.tl li.stop::before { background: var(--red-mk); border-color: var(--red-mk); border-radius: 3px; }
.tl summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .45rem; font-size: .9rem; }
.tl-ts { color: var(--muted); font-size: .82rem; min-width: 2rem; font-family: var(--mono); }
.tl-act { font-weight: 800; }
.tl-sum { flex-basis: 100%; color: var(--ink); }
.tl-body { padding: .3rem 0 .4rem .3rem; }
.tl li.demo { background: var(--amber-bg); border-radius: var(--r); padding: .25rem .4rem; }

@media (max-width: 1180px) {
  body { height: auto; overflow: auto; }
  .work { grid-template-columns: 1fr; }
  .col { overflow: visible; }
  .sumgrid { grid-template-columns: 1fr; }
  .chline { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
