:root {
  --c-orange: #E1A36F;
  --c-gold: #DEC484;
  --c-pale: #E2D8A5;
  --c-teal: #6F9F9C;
  --c-slate: #577E89;
  --bg: #F6EEE2;
  --panel: #FFFDF8;
  --panel2: #F3EADA;
  --border: #E7DAC5;
  --text: #463E33;
  --muted: #94886F;
  --accent: #E1A36F;
  --safe: #6F9F9C;
  --info: #577E89;
  --warn: #C79A3B;
  --danger: #E1A36F;
  --breach: #C25A3C;
  --shadow: 0 1px 3px rgba(120, 95, 60, .10), 0 6px 18px rgba(120, 95, 60, .07);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans TC", -apple-system, "Segoe UI", "Microsoft JhengHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a {
  color: var(--c-slate);
}

header.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 30px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow);
}

header.top h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 900;
  letter-spacing: .3px;
}

header.top .sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 22px;
}

.kpi {
  text-align: right;
}

.kpi .v {
  font-size: 17px;
  font-weight: 900;
  color: var(--c-slate);
}

.kpi .l {
  color: var(--muted);
  font-size: 11px;
}

button.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 10px 18px;
  border-radius: 9px;
  font-weight: 700;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(225, 163, 111, .45);
  font-family: inherit;
}

button.btn:hover {
  filter: brightness(1.04);
}

button.btn:disabled {
  opacity: .6;
  cursor: wait;
}

/* ===== 分頁導覽 ===== */
.tab-nav {
  display: flex;
  gap: 2px;
  padding: 0 30px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 57px;
  z-index: 15;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 11px 22px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-section {
  margin-bottom: 22px;
}

.tab-section-hd {
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-section-hd::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 3px;
  background: var(--accent);
  display: inline-block;
}

.tab-desc {
  font-size: 12px;
  color: var(--muted);
  margin: -6px 0 14px;
}

main {
  padding: 20px 30px 60px;
  max-width: 1680px;
  margin: 0 auto;
}

.grid {
  display: grid;
  gap: 16px;
}

.cols-2 {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 900px) {
  .cols-2 {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.panel h2 {
  font-size: 12px;
  margin: 0 0 12px;
  letter-spacing: .6px;
  color: var(--muted);
  font-weight: 700;
}

.section-title {
  font-size: 15px;
  font-weight: 900;
  margin: 22px 0 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::before {
  content: "";
  width: 5px;
  height: 18px;
  border-radius: 3px;
  background: var(--accent);
}

/* ===== 第一列:總覽合併 + 小行事曆 ===== */
.row1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 1000px) {
  .row1 {
    grid-template-columns: 1fr;
  }
}

.merged-grid {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 18px;
}

@media (max-width: 760px) {
  .merged-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== 風險總覽 — 三卡片 + Chip 展開 ===== */
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}

.dot.safe {
  background: var(--safe)
}

.dot.info {
  background: var(--info)
}

.dot.warn {
  background: var(--warn)
}

.dot.danger {
  background: var(--danger)
}

.dot.breach {
  background: var(--breach)
}

.txt-safe {
  color: var(--safe)
}

.txt-info {
  color: var(--info)
}

.txt-warn {
  color: var(--warn)
}

.txt-danger {
  color: var(--danger)
}

.txt-breach {
  color: var(--breach)
}

/* 風險總覽面板：與右側行事曆等高 */
.row1>.risk-panel {
  display: flex;
  flex-direction: column;
}

.risk-panel h2 {
  flex-shrink: 0;
}

.sev-row {
  display: flex;
  gap: 10px;
  flex: 1;
}

@media (max-width:760px) {
  .sev-row {
    flex-direction: column;
  }
}

.sev-cat {
  border-radius: 10px;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

.sev-cat-breach {
  border-color: rgba(194, 90, 60, .35);
}

.sev-cat-danger {
  border-color: rgba(199, 154, 59, .35);
}

.sev-cat-safe {
  border-color: rgba(111, 159, 156, .35);
}

.sev-cat-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sev-cat-n {
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  min-width: 28px;
  text-align: center;
}

.sev-cat-breach .sev-cat-n {
  color: var(--breach);
}

.sev-cat-danger .sev-cat-n {
  color: var(--warn);
}

.sev-cat-safe .sev-cat-n {
  color: var(--safe);
}

.sev-cat-lbl {
  font-size: 12px;
  font-weight: 900;
}

.sev-cat-body {
  flex: 1;
  padding: 10px 12px;
}

.sev-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-content: flex-start;
}

.sev-empty {
  font-size: 11px;
  color: var(--muted);
}

.sev-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 30px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
  user-select: none;
  letter-spacing: .3px;
  transition: filter .1s, transform .1s;
}

.sev-chip:hover {
  filter: brightness(.88);
  transform: translateY(-1px);
}

.sev-chip:active {
  transform: translateY(0);
}

.sev-chip-breach {
  background: rgba(194, 90, 60, .15);
  color: var(--breach);
}

.sev-chip-danger {
  background: rgba(199, 154, 59, .15);
  color: #9a720a;
}

.sev-chip-safe {
  background: rgba(111, 159, 156, .18);
  color: #317572;
}

.sev-ko-note {
  font-size: 10.5px;
  color: var(--muted);
  margin: 8px 0 0;
  padding: 0;
}

/* FCN card highlight on jump */
@keyframes nc-flash {

  0%,
  20% {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
  }

  100% {
    outline: 3px solid transparent;
    outline-offset: 4px;
  }
}

.nc-highlight {
  animation: nc-flash 1.8s ease-out;
}

.badge {
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  display: inline-block;
}

.badge.safe {
  background: rgba(111, 159, 156, .18);
  color: #4f817d
}

.badge.info {
  background: rgba(87, 126, 137, .18);
  color: #456773
}

.badge.warn {
  background: rgba(199, 154, 59, .20);
  color: #9c7822
}

.badge.danger {
  background: rgba(225, 163, 111, .24);
  color: #bb7338
}

.badge.breach {
  background: rgba(194, 90, 60, .20);
  color: #b04b2d
}

.alert-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

@media (max-width: 1400px) {
  .alert-list {
    grid-template-columns: 1fr;
  }
}

.alert {
  display: grid;
  grid-template-columns: 5px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 11px;
  border-radius: 9px;
  background: var(--panel2);
  border: 1px solid var(--border);
}

.alert .bar {
  width: 5px;
  align-self: stretch;
  min-height: 30px;
  border-radius: 3px;
}

.alert .who b {
  display: block;
}

.alert .who small {
  color: var(--muted);
}

.alert .metric {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.alert .metric small {
  color: var(--muted);
}

.legend-inline {
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 12px;
  align-items: center;
}

.legend-inline b {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  margin-right: 5px;
}

/* ===== cards (一列四個) ===== */
.cards4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

@media (max-width: 1400px) {
  .cards4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .cards4 {
    grid-template-columns: 1fr;
  }
}

.note-card {
  padding: 0;
  overflow: hidden;
}

.nc-top {
  padding: 14px 16px;
  border-left: 5px solid var(--accent);
}

.note-card.sev-safe .nc-top {
  border-left-color: var(--safe)
}

.note-card.sev-info .nc-top {
  border-left-color: var(--info)
}

.note-card.sev-warn .nc-top {
  border-left-color: var(--warn)
}

.note-card.sev-danger .nc-top {
  border-left-color: var(--danger)
}

.note-card.sev-breach .nc-top {
  border-left-color: var(--breach)
}

.nc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.nc-issuer {
  font-size: 15px;
  font-weight: 900;
}

.nc-sub {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 2px;
}

.nc-worst {
  text-align: right;
  white-space: nowrap;
}

.nc-worst .l {
  color: var(--muted);
  font-size: 10.5px;
}

.nc-worst .v {
  font-weight: 900;
  font-size: 14px;
}

.note-kv {
  margin-top: 10px;
}

.nkv-row {
  display: flex;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.nk-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 5px 8px;
  border-right: 1px solid var(--border);
}

.nk-item:last-child {
  border-right: none;
}

.nk-item span {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.nk-item b {
  font-size: 12px;
  font-weight: 700;
}

.nkv-dates {
  display: flex;
  gap: 7px;
  align-items: center;
  margin-top: 7px;
  font-size: 11px;
}

.nkv-dates span {
  color: var(--muted);
  font-size: 10px;
}

.nkv-dates i {
  color: var(--border);
  font-style: normal;
  font-size: 13px;
}

table.und {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
}

table.und th {
  text-align: right;
  font-size: 10.5px;
  color: var(--muted);
  padding: 5px 7px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

table.und th:first-child,
table.und td:first-child {
  text-align: left;
}

table.und td {
  padding: 6px 7px;
  border-bottom: 1px solid var(--border);
}

table.und tbody tr:last-child td {
  border-bottom: none;
}

table.und tr:hover td {
  background: rgba(225, 163, 111, .07);
}

table.und td:first-child {
  width: 55px;
}

.tick {
  font-weight: 900;
}

.muted {
  color: var(--muted);
}

.usub {
  color: var(--muted);
  font-size: 10.5px;
}

/* labeled ladder: 現價標於上方,障礙價標於下方 */
.ladder2 {
  position: relative;
  height: 42px;
  margin: 6px 6px 2px;
}

.ladder2 .track {
  position: absolute;
  left: 0;
  right: 0;
  top: 19px;
  height: 7px;
  border-radius: 5px;
  background: linear-gradient(90deg, rgba(194, 90, 60, .30) 0%, rgba(199, 154, 59, .20) 40%, rgba(111, 159, 156, .24) 100%);
  border: 1px solid var(--border);
}

.ladder2 .lvl {
  position: absolute;
  top: 14px;
  width: 2px;
  height: 17px;
}

.ladder2 .lvl.barrier {
  background: var(--breach);
}

.ladder2 .lvl.strike {
  background: var(--warn);
}

.ladder2 .lvl.ko {
  background: var(--safe);
}

.ladder2 .spot {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 9.5px;
  font-weight: 900;
  color: var(--c-slate);
  white-space: nowrap;
  z-index: 2;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.ladder2 .spot::after {
  content: '';
  width: 10px;
  height: 9px;
  flex-shrink: 0;
  background: var(--c-slate);
  clip-path: polygon(50% 100%, 0% 0%, 100% 0%);
  margin-top: 1px;
}

.lad-lab {
  position: absolute;
  transform: translateX(-50%);
  font-size: 9.5px;
  font-weight: 700;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.lad-lab.below {
  top: 32px;
}

.lad-lab.above {
  top: 0;
}

.lad-lab.barrier {
  color: var(--breach);
}

.lad-lab.strike {
  color: #9c7822;
}

.lad-lab.ko {
  color: #4f817d;
}


/* 曝險:圓餅圖並排 + 個股表全寬 */
.exp-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width:760px) {
  .exp-charts {
    grid-template-columns: 1fr;
  }
}

/* exposure table */
table.exp {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.exp th {
  text-align: center;
  font-size: 10.5px;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

table.exp td {
  text-align: center;
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
}

table.exp tbody tr:last-child td {
  border-bottom: none;
}

.exp-bar {
  height: 7px;
  border-radius: 4px;
  background: var(--accent);
}

.exp-bar-track {
  background: var(--panel2);
  border-radius: 4px;
  width: 100%;
  min-width: 60px;
}

.note-foot {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
}

/* ===== 可切換月份小日曆 ===== */
.dot-coupon {
  background: var(--c-teal);
}

.dot-maturity {
  background: var(--breach);
}

.cal-legend {
  display: flex;
  gap: 12px;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--muted);
}

.cal-legend i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 3px;
}

.mini-cal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.cal-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  font-family: inherit;
}

.cal-nav-btn:hover {
  background: var(--panel2);
  color: var(--text);
}

.cal-nav-title {
  font-weight: 700;
  font-size: 14px;
}

#calendar {
  max-width: none;
}

.mc-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mc-dow {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  padding: 4px 0;
}

.mc-day {
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border-radius: 5px;
  color: var(--text);
}

.mc-day.out {
  color: var(--border);
}

.mc-day.today {
  background: var(--panel2);
  box-shadow: inset 0 0 0 1.5px var(--accent);
  font-weight: 900;
}

.mc-day.has-ev {
  font-weight: 700;
}

.mc-dots {
  display: flex;
  gap: 2px;
  margin-top: 1px;
  min-height: 5px;
}

.mc-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
}

.hist-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 12px;
  flex-wrap: wrap;
}

select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-family: inherit;
}

.chart-wrap {
  position: relative;
  height: 300px;
}

.empty-line {
  color: var(--muted);
  font-size: 13px;
  padding: 6px 2px;
}

/* ===== 生命週期時間軸 ===== */
.tl-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
  align-items: center;
}

.tl-sw {
  display: inline-block;
  width: 22px;
  height: 8px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 4px;
}

.tl-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1.5px solid #6F9F9C;
  background: white;
  vertical-align: middle;
  margin-right: 4px;
}

.tl-tri {
  font-style: normal;
  color: #DEC484;
  margin-right: 4px;
}

.tl-today-line {
  display: inline-block;
  width: 2px;
  height: 12px;
  background: #E1A36F;
  vertical-align: middle;
  margin-right: 4px;
}

/* ===== KO 觀察進度 ===== */
.ko-obs {
  margin-top: 9px;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 11px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.ko-obs-pending {
  background: rgba(199, 154, 59, .10);
  border: 1px solid rgba(199, 154, 59, .28);
}

.ko-obs-active {
  background: rgba(111, 159, 156, .10);
  border: 1px solid rgba(111, 159, 156, .28);
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
}

.ko-obs-lbl {
  font-weight: 700;
}

.ko-obs-pending .ko-obs-lbl {
  color: #9c7822;
}

.ko-obs-active .ko-obs-lbl {
  color: #4f817d;
}

.ko-obs-count b {
  font-size: 13px;
}

.ko-obs-meta {
  color: var(--muted);
  font-size: 10.5px;
}

.ko-obs-hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ko-obs-track {
  height: 6px;
  background: var(--panel2);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.ko-obs-fill {
  height: 100%;
  background: var(--safe);
  border-radius: 4px;
}

.ko-paid {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 1px;
}

.ko-paid b {
  color: var(--text);
}

/* ===== 情境試算 ===== */
.scen-top {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scen-quick {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.scen-btn {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  color: var(--text);
}

.scen-btn:hover {
  background: var(--border);
}

.scen-reset {
  color: var(--muted);
}

.scen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 7px;
}

.scen-row {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

.scen-row .tick {
  width: 46px;
  flex-shrink: 0;
}

.scen-cur {
  font-size: 11px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.scen-inp {
  width: 50px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 12px;
  font-family: inherit;
  background: var(--panel);
  color: var(--text);
  text-align: right;
}

.scen-inp:focus {
  outline: none;
  border-color: var(--accent);
}

.scen-pct {
  font-size: 11px;
  color: var(--muted);
}

.scen-sim {
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  width: 62px;
  text-align: right;
  white-space: nowrap;
}

.scen-summary {
  display: flex;
  gap: 0;
  margin: 16px 0 14px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.scen-kpi {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 8px;
  border-right: 1px solid var(--border);
}

.scen-kpi:last-child {
  border-right: none;
}

.scen-kpi span {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
}

.scen-kpi b {
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}

.scen-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.scen-card {
  border-radius: 10px;
  border: 1px solid var(--border);
  overflow: hidden;
  background: var(--panel);
}

.scen-card-head {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  border-left: 5px solid var(--border);
}

.scen-card-head.breach {
  border-left-color: var(--breach);
  background: rgba(194, 90, 60, .05);
}

.scen-card-head.strike {
  border-left-color: var(--warn);
  background: rgba(199, 154, 59, .05);
}

.scen-card-head.safe {
  border-left-color: var(--safe);
}

.scen-card-issuer {
  font-weight: 900;
  font-size: 13px;
}

.scen-card-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.scen-obligation {
  color: var(--breach);
  font-weight: 700;
}

.scen-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.scen-card th {
  text-align: left;
  font-size: 10px;
  color: var(--muted);
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
}

.scen-card td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.scen-card tbody tr:last-child td {
  border-bottom: none;
}

.scen-badge {
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.scen-badge.breach {
  background: rgba(194, 90, 60, .18);
  color: #b04b2d;
}

.scen-badge.strike {
  background: rgba(199, 154, 59, .18);
  color: #9c7822;
}

.scen-badge.safe {
  background: rgba(111, 159, 156, .14);
  color: #4f817d;
}

.scen-badge.ko {
  background: rgba(87, 126, 137, .18);
  color: #456773;
}

.scen-delta {
  font-size: 10.5px;
  font-weight: 700;
}

.scen-delta.down {
  color: var(--breach);
}

.scen-delta.up {
  color: var(--safe);
}

.toast {
  position: fixed;
  bottom: 22px;
  right: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 13px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 50;
  font-weight: 700;
}

/* ===== AI 資料助理 側邊欄 ===== */
.ai-launcher {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 22px; line-height: 1;
  box-shadow: 0 4px 14px rgba(225,163,111,.5); transition: transform .15s, filter .15s;
}
.ai-launcher:hover { filter: brightness(1.05); transform: translateY(-2px); }
.ai-launcher-ico { display: block; }

.ai-panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: var(--ai-w, 420px);
  background: var(--panel); border-left: 1px solid var(--border);
  box-shadow: -6px 0 24px rgba(120,95,60,.12); z-index: 70;
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .22s ease;
}
.ai-panel.open { transform: translateX(0); }
body.ai-resizing { user-select: none; cursor: col-resize; }

.ai-resize {
  position: absolute; left: -4px; top: 0; width: 8px; height: 100%;
  cursor: col-resize; z-index: 2;
}
.ai-resize:hover { background: linear-gradient(90deg, transparent, rgba(225,163,111,.35)); }

.ai-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--panel2);
}
.ai-title { font-weight: 900; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.ai-live { width: 8px; height: 8px; border-radius: 50%; background: var(--safe);
  box-shadow: 0 0 0 0 rgba(111,159,156,.5); animation: ai-pulse 2s infinite; }
@keyframes ai-pulse {
  0% { box-shadow: 0 0 0 0 rgba(111,159,156,.5); }
  70% { box-shadow: 0 0 0 7px rgba(111,159,156,0); }
  100% { box-shadow: 0 0 0 0 rgba(111,159,156,0); }
}
.ai-head-btns { display: flex; gap: 4px; }
.ai-icon-btn {
  background: none; border: none; cursor: pointer; font-size: 15px;
  width: 30px; height: 30px; border-radius: 7px; color: var(--muted); font-family: inherit;
}
.ai-icon-btn:hover { background: rgba(225,163,111,.14); color: var(--text); }

.ai-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 12px; }
.ai-msg { max-width: 88%; padding: 10px 13px; border-radius: 13px; font-size: 13.5px;
  line-height: 1.55; word-break: break-word; }
.ai-msg code { background: var(--panel2); padding: 1px 5px; border-radius: 4px;
  font-size: 12px; font-family: ui-monospace, "SF Mono", Consolas, monospace; }
.ai-user { align-self: flex-end; background: var(--accent); color: #fff;
  border-bottom-right-radius: 4px; }
.ai-user code { background: rgba(255,255,255,.22); color: #fff; }
.ai-assistant { align-self: flex-start; background: var(--panel2);
  border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-err { background: rgba(194,90,60,.12); border-color: rgba(194,90,60,.3); }
.ai-intro { max-width: 100%; }
.ai-eg { display: block; margin-top: 7px; padding: 7px 10px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-size: 12.5px;
  color: var(--c-slate); }
.ai-eg:hover { background: rgba(225,163,111,.1); }

.ai-sql { margin-top: 8px; font-size: 11.5px; }
.ai-sql summary { cursor: pointer; color: var(--muted); }
.ai-sql pre { margin: 6px 0 0; padding: 8px 10px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 7px; overflow-x: auto;
  font-size: 11px; font-family: ui-monospace, Consolas, monospace; white-space: pre-wrap; }

.ai-dots { display: inline-flex; gap: 4px; }
.ai-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: ai-bounce 1.2s infinite; }
.ai-dots i:nth-child(2) { animation-delay: .2s; }
.ai-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes ai-bounce { 0%,60%,100% { opacity: .3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); } }

.ai-input-bar { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border);
  align-items: flex-end; background: var(--panel); }
.ai-input-bar textarea {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px; font-family: inherit; font-size: 13.5px; line-height: 1.4;
  background: var(--panel2); color: var(--text); overflow-y: hidden; }
.ai-input-bar textarea:focus { outline: none; border-color: var(--accent); }
.ai-send { flex: none; width: 38px; height: 38px; border-radius: 10px; border: none;
  background: var(--accent); color: #fff; font-size: 18px; cursor: pointer; font-weight: 700; }
.ai-send:hover { filter: brightness(1.05); }
.ai-send:disabled { opacity: .5; cursor: wait; }

@media (max-width: 560px) {
  .ai-panel { width: 100vw !important; }
  .ai-resize { display: none; }
}