:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --ink: #17202a;
  --muted: #68737d;
  --border: #dce2e7;
  --border-strong: #c7d0d7;
  --green: #167a5b;
  --green-soft: #e8f5ef;
  --blue: #2563a8;
  --blue-soft: #eaf2fb;
  --cyan: #168fa0;
  --cyan-soft: #e7f6f8;
  --coral: #d96350;
  --coral-soft: #fff0ed;
  --amber: #a4610a;
  --amber-soft: #fff3dc;
  --red: #b53a3a;
  --red-soft: #fcebec;
  --shadow: 0 8px 24px rgba(23, 32, 42, 0.06);
  font-family: Inter, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }

.app-header {
  min-height: 80px;
  padding: 14px 24px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  overflow: hidden;
}
.app-header::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background: url("/assets/revenue-flow-v1.png") center 48% / cover no-repeat;
  opacity: 0.23;
  pointer-events: none;
}
.app-header > * { position: relative; z-index: 1; }

.brand-block { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.9);
  color: var(--cyan);
  border: 1px solid #a9d3da;
  border-radius: 6px;
  box-shadow: 0 5px 16px rgba(22, 143, 160, 0.12);
}
.brand-mark svg { width: 22px; height: 22px; }

h1, h2, h3, p { margin: 0; }
h1 { font-size: 17px; line-height: 1.3; font-weight: 720; }
h2 { font-size: 18px; line-height: 1.35; font-weight: 700; }
h3 { font-size: 15px; line-height: 1.4; font-weight: 700; }
.brand-block p { margin-top: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-block > div:last-child { min-width: 0; }

.header-status { display: flex; align-items: center; gap: 8px; }
.status-pill, .risk-pill, .decision-pill, .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.status-pill.simulation { background: var(--blue-soft); color: var(--blue); }
.status-pill.objective { background: #eef3ff; color: #3459a4; }
.status-pill.readonly { background: var(--cyan-soft); color: #0f7481; }
.status-pill.live, .status-pill.approved { background: var(--green-soft); color: var(--green); }
.status-pill.paused, .status-pill.pending { background: var(--amber-soft); color: var(--amber); }
.status-pill.rejected, .status-pill.failed { background: var(--red-soft); color: var(--red); }
.status-pill.peak { background: var(--coral-soft); color: #ae4938; }
.status-pill.peak svg { width: 14px; height: 14px; margin-right: 5px; }

.header-actions { display: flex; gap: 6px; }
.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
  border-radius: 5px;
}
.icon-button:hover { background: var(--surface-soft); border-color: var(--border); }
.icon-button svg { width: 18px; height: 18px; }
.icon-button.danger-quiet { color: var(--red); }
.icon-button.is-syncing svg { animation: spin 1.1s linear infinite; }

.signal-strip {
  min-height: 58px;
  padding: 0 24px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.signal-orbit {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: #c8e8eb;
}
.signal-orbit span {
  position: absolute;
  top: -2px;
  left: 0;
  width: 7px;
  height: 5px;
  background: var(--cyan);
  animation: signal-run 5.5s linear infinite;
}
.signal-lead { display: flex; align-items: center; gap: 8px; color: #52616c; font-size: 10px; letter-spacing: 0; white-space: nowrap; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(22, 122, 91, 0.11); }
.live-dot.syncing { background: var(--cyan); animation: pulse 1.2s ease-in-out infinite; }
.signal-items { display: grid; grid-template-columns: repeat(7, minmax(96px, 1fr)); min-width: 0; }
.signal-item { min-height: 42px; padding: 0 14px; display: flex; align-items: center; gap: 9px; border-left: 1px solid #edf1f3; min-width: 0; }
.signal-item svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--muted); }
.signal-item.cyan svg { color: var(--cyan); }
.signal-item.green svg { color: var(--green); }
.signal-item.coral svg { color: var(--coral); }
.signal-item small, .signal-item b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signal-item small { color: var(--muted); font-size: 10px; }
.signal-item b { margin-top: 2px; font-size: 12px; }

.tab-bar {
  height: 48px;
  padding: 0 24px;
  display: flex;
  align-items: stretch;
  gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tab-button {
  min-width: 132px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: transparent;
  color: var(--muted);
  border: 0;
  border-bottom: 2px solid transparent;
}
.tab-button svg { width: 16px; height: 16px; }
.tab-button:hover { color: var(--ink); }
.tab-button.active { color: var(--ink); border-bottom-color: var(--green); font-weight: 700; }
.tab-link { text-decoration: none; }
.tab-count { min-width: 20px; min-height: 20px; padding: 1px 5px; background: var(--red-soft); color: var(--red); }

main { max-width: 1600px; margin: 0 auto; padding: 22px 24px 40px; }
.tab-view { display: none; }
.tab-view.active { display: block; }

.kpi-band {
  display: grid;
  grid-template-columns: repeat(8, minmax(132px, 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.kpi-item { min-height: 102px; padding: 16px 18px; border-right: 1px solid var(--border); }
.kpi-item:last-child { border-right: 0; }
.kpi-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--muted); font-size: 12px; }
.kpi-label svg { width: 15px; height: 15px; }
.kpi-item:nth-child(3n + 1) .kpi-label svg { color: var(--cyan); }
.kpi-item:nth-child(3n + 2) .kpi-label svg { color: var(--green); }
.kpi-item:nth-child(3n) .kpi-label svg { color: var(--coral); }
.kpi-value { margin-top: 10px; font-size: 24px; line-height: 1; font-weight: 760; font-variant-numeric: tabular-nums; }
.kpi-foot { margin-top: 9px; color: var(--muted); font-size: 11px; }

.future3-watch { margin-top: 18px; padding: 17px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); }
.future3-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.future3-total { color: var(--muted); font-size: 12px; }
.future3-total b { margin-left: 6px; color: var(--ink); font-size: 18px; }
.future3-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.future3-day { min-width: 0; padding: 14px 16px; border-right: 1px solid var(--border); }
.future3-day:last-child { border-right: 0; }
.future3-day-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; font-weight: 700; }
.future3-day-head b { color: var(--green); font-size: 18px; font-variant-numeric: tabular-nums; }
.future3-day.behind .future3-day-head b { color: var(--coral); }
.future3-progress { height: 5px; margin-top: 10px; overflow: hidden; background: #edf1f3; border-radius: 3px; }
.future3-progress span { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.future3-day.behind .future3-progress span { background: var(--coral); }
.future3-metrics { margin-top: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.future3-metrics span { min-width: 0; color: var(--muted); font-size: 9px; }
.future3-metrics b { display: block; margin-top: 3px; color: var(--ink); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.future3-day p { margin-top: 10px; color: var(--muted); font-size: 10px; }
.base2-watch { margin-top: 18px; padding: 18px; background: var(--surface); border: 1px solid #e3c7b7; border-left: 4px solid var(--coral); border-radius: 6px; box-shadow: var(--shadow); }
.base2-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.base2-summary { margin-top: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.base2-summary span { min-width: 0; padding: 10px 12px; color: var(--muted); font-size: 10px; border-right: 1px solid var(--border); }
.base2-summary span:last-child { border-right: 0; }
.base2-summary b { display: block; margin-top: 4px; color: var(--ink); font-size: 15px; font-variant-numeric: tabular-nums; }
.base2-rule { margin-top: 12px; display: flex; align-items: flex-start; gap: 7px; color: #75412d; background: #fff7f2; padding: 9px 11px; border-radius: 5px; font-size: 11px; line-height: 1.5; }
.base2-rule svg { width: 15px; height: 15px; flex: 0 0 auto; margin-top: 1px; }
.base2-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.base2-card { min-width: 0; padding: 13px; border: 1px solid var(--border); border-left: 3px solid var(--green); border-radius: 5px; background: #fbfdfc; }
.base2-card.lower { border-left-color: var(--red); background: #fffafa; }
.base2-card.raise { border-left-color: var(--blue); background: #f8fbff; }
.base2-card.audit { border-left-color: var(--amber); background: #fffdfa; }
.base2-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.base2-card-head span { color: var(--muted); font-size: 10px; }
.base2-card-head h3 { margin-top: 3px; font-size: 13px; }
.base2-action { max-width: 132px; color: var(--amber); font-size: 11px; text-align: right; line-height: 1.35; }
.base2-card.lower .base2-action { color: var(--red); }
.base2-card.raise .base2-action { color: var(--blue); }
.base2-card-metrics { margin-top: 10px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
.base2-card-metrics span { min-width: 0; color: var(--muted); font-size: 9px; }
.base2-card-metrics b { display: block; margin-top: 3px; color: var(--ink); font-size: 11px; white-space: nowrap; }
.base2-card p { margin-top: 10px; color: #46545c; font-size: 11px; line-height: 1.5; }
.base2-card small { display: block; margin-top: 8px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.floor-exception-confirm { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0; padding: 12px 14px; border: 1px solid #e0a98c; border-radius: 6px; background: #fff6f1; color: #71391e; }
.floor-exception-confirm[hidden] { display: none; }
.floor-exception-confirm input { width: 18px; height: 18px; margin-top: 2px; accent-color: #c7592b; }
.floor-exception-confirm span { display: grid; gap: 3px; min-width: 0; }
.floor-exception-confirm b { font-size: 12px; }
.floor-exception-confirm small { color: #86553e; font-size: 10px; line-height: 1.55; }
.floor-approval-steps { margin-top: 14px; min-height: 42px; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.floor-approval-steps[hidden] { display: none; }
.floor-approval-steps > span { min-height: 36px; padding: 8px 12px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 5px; background: var(--surface); font-size: 11px; font-weight: 700; }
.floor-approval-steps > span b { width: 19px; height: 19px; display: grid; place-items: center; border-radius: 50%; background: #e9edf0; color: var(--muted); font-size: 10px; }
.floor-approval-steps > span.active { border-color: #d9825a; background: #fff7f2; color: #71391e; }
.floor-approval-steps > span.active b { background: #c7592b; color: #fff; }
.floor-approval-steps > span.complete { border-color: #8ab7a4; background: #f2faf6; color: #256647; }
.floor-approval-steps > span.complete b { background: #2d7b58; color: #fff; }
.floor-approval-steps > svg { width: 16px; height: 16px; }

.peak-watch { margin-top: 18px; padding: 15px 18px; background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.peak-watch.empty { min-height: 72px; }
.peak-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.peak-alert-list { margin-top: 14px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.peak-alert { min-height: 190px; padding: 13px; border: 1px solid var(--border); border-left: 3px solid #d48a1f; border-radius: 5px; background: #fffdfa; }
.peak-alert.high { border-left-color: var(--coral); background: #fffafa; }
.peak-alert-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.peak-alert-title svg { width: 19px; height: 19px; color: #d48a1f; }
.peak-alert.high .peak-alert-title svg { color: var(--coral); }
.peak-level { color: var(--amber); font-size: 10px; font-weight: 760; }
.peak-alert.high .peak-level { color: var(--coral); }
.peak-alert h3 { margin-top: 3px; }
.peak-metrics { margin-top: 11px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.peak-metrics span { color: var(--muted); font-size: 9px; }
.peak-metrics b { display: block; margin-top: 3px; color: var(--ink); font-size: 12px; }
.peak-alert p { margin-top: 11px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.peak-alert strong { display: block; margin-top: 8px; color: #384750; font-size: 11px; line-height: 1.5; }

.workspace-grid { margin-top: 18px; display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 18px; align-items: start; }
.data-region, .decision-rail, .execution-band, .simulation-band {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.workspace-grid > *, .data-region, .execution-band, .simulation-band { min-width: 0; }
.data-region { width: 100%; padding: 18px; overflow: hidden; }
.data-region.wide { margin-top: 16px; }
.section-heading, .page-heading { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.section-heading.compact { padding: 18px 18px 0; }
.page-heading { margin-bottom: 16px; }
.page-heading > .secondary-button { flex: 0 0 auto; white-space: nowrap; }
.eyebrow { margin-bottom: 3px; color: var(--green); font-size: 11px; font-weight: 760; text-transform: uppercase; }
.muted, .source-stamp { color: var(--muted); font-size: 12px; }

.legend { display: flex; gap: 12px; color: var(--muted); font-size: 11px; }
.legend span { display: flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--green); }
.dot.amber { background: #d48a1f; }
.dot.red { background: var(--red); }

.table-shell { margin-top: 14px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { height: 38px; padding: 0 10px; text-align: left; color: var(--muted); font-size: 11px; font-weight: 680; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { height: 58px; padding: 8px 10px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcfd; }
.date-name { font-weight: 680; white-space: nowrap; }
.date-type { margin-top: 3px; color: var(--muted); font-size: 11px; }
.metric-strong { font-weight: 720; }
.metric-sub { color: var(--muted); font-size: 11px; margin-top: 3px; }

.progress-track { width: 128px; height: 7px; margin-top: 7px; background: #e9edf0; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 3px; transition: width 420ms ease; }
.progress-fill.warn { background: #d48a1f; }
.progress-fill.risk { background: var(--red); }

.decision-pill.hold { background: var(--green-soft); color: var(--green); }
.decision-pill.watch { background: var(--amber-soft); color: var(--amber); }
.decision-pill.lower { background: var(--red-soft); color: var(--red); }
.decision-pill.verify { background: var(--blue-soft); color: var(--blue); }

.decision-rail { overflow: hidden; }
.rail-section { padding: 17px; border-bottom: 1px solid var(--border); }
.rail-section:last-child { border-bottom: 0; }
.rail-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.policy-grid, .proposal-metrics { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.policy-metric, .proposal-metric { min-height: 58px; padding: 9px 10px; background: var(--surface-soft); border: 1px solid #edf0f2; border-radius: 5px; }
.policy-metric span, .proposal-metric span { color: var(--muted); font-size: 11px; }
.policy-metric b, .proposal-metric b { display: block; margin-top: 5px; font-size: 14px; }
.scope-line { margin-top: 12px; color: var(--muted); font-size: 12px; line-height: 1.65; }
.button-row { margin-top: 15px; display: flex; gap: 8px; flex-wrap: wrap; }
.primary-button, .secondary-button, .danger-button {
  min-height: 36px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-radius: 5px;
  font-weight: 680;
}
.primary-button { color: white; background: var(--green); border: 1px solid var(--green); }
.primary-button:hover { background: #11684d; }
.primary-button.floor-override-button { background: #a94725; border-color: #a94725; }
.primary-button.floor-override-button:hover { background: #923b1f; border-color: #923b1f; }
.secondary-button { color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); }
.secondary-button:hover { background: var(--surface-soft); }
.danger-button { color: var(--red); background: var(--surface); border: 1px solid #e6b8ba; }
.primary-button svg, .secondary-button svg, .danger-button svg { width: 16px; height: 16px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.proposal-copy { margin-top: 11px; color: var(--ink); font-size: 13px; line-height: 1.55; }
.countdown { color: var(--amber); font-size: 11px; }
.risk-pill.green { background: var(--green-soft); color: var(--green); }
.risk-pill.yellow { background: var(--amber-soft); color: var(--amber); }
.risk-pill.red { background: var(--red-soft); color: var(--red); }
.delta-positive { color: var(--green); }
.delta-negative { color: var(--red); }

.execution-band { margin-top: 18px; overflow: hidden; }
.empty-state { min-height: 150px; padding: 24px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-state svg { width: 28px; height: 28px; margin-bottom: 8px; }
.execution-list { padding: 14px 18px 18px; display: grid; gap: 12px; }
.execution-item { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; padding: 14px; border: 1px solid var(--border); border-radius: 6px; }
.execution-summary p { margin-top: 6px; color: var(--muted); font-size: 12px; }
.execution-archive { min-height: 82px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--border); border-radius: 6px; }
.execution-archive svg { width: 20px; height: 20px; flex: 0 0 auto; color: var(--cyan); }
.execution-archive b, .execution-archive span { display: block; }
.execution-archive b { color: var(--ink); font-size: 12px; }
.execution-archive span { margin-top: 4px; font-size: 11px; line-height: 1.45; }
.step-line { display: grid; grid-template-columns: repeat(5, minmax(90px, 1fr)); gap: 8px; position: relative; }
.step-line::before { content: ""; position: absolute; left: 4%; right: 4%; top: 50%; border-top: 1px dashed #b8dce1; z-index: 0; }
.step-line::after { content: ""; position: absolute; top: calc(50% - 3px); left: 4%; width: 6px; height: 6px; background: var(--cyan); animation: execution-run 4.8s linear infinite; z-index: 1; }
.step { position: relative; min-height: 66px; padding: 9px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 5px; }
.step { z-index: 2; }
.step.complete { border-color: #9fd2bd; background: var(--green-soft); }
.step.pending { color: var(--muted); }
.step.failed { border-color: #e6b8ba; background: var(--red-soft); color: var(--red); }
.step.manual { border-color: #e0c68d; background: var(--amber-soft); color: var(--amber); }
.step b { display: block; font-size: 12px; }
.step span { display: block; margin-top: 5px; font-size: 10px; line-height: 1.35; }

.simulation-band { margin-top: 18px; min-height: 90px; padding: 15px 18px; display: grid; grid-template-columns: minmax(220px, 1fr) 210px 170px auto; gap: 14px; align-items: end; }
.simulation-band label, .form-field { display: grid; gap: 6px; color: var(--muted); font-size: 11px; }
select, input { width: 100%; height: 36px; padding: 0 10px; color: var(--ink); background: white; border: 1px solid var(--border-strong); border-radius: 5px; outline: none; }
select:focus, input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(37, 99, 168, 0.12); }

.channel-table td, .price-table td { height: 52px; }
.channel-name { font-weight: 720; }
.channel-status { color: var(--muted); font-size: 11px; }
.price-section { margin-top: 18px; }
.price-heading { align-items: end; }
.price-filters { display: flex; gap: 10px; align-items: end; }
.price-filters label { display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.price-filters select { min-width: 148px; height: 34px; }
.matrix-note { margin-top: 13px; padding: 9px 10px; display: flex; align-items: center; gap: 7px; color: #53616b; background: #f1f8f9; border-left: 3px solid var(--cyan); font-size: 11px; line-height: 1.45; }
.matrix-note svg { width: 15px; height: 15px; flex: 0 0 auto; color: var(--cyan); }
.matrix-note.warning { background: var(--amber-soft); border-left-color: var(--amber); color: #735018; }
.matrix-note.warning svg { color: var(--amber); }
.confidence { display: inline-flex; padding: 4px 7px; border-radius: 4px; background: var(--surface-soft); color: var(--muted); font-size: 11px; }
.confidence.risk { background: var(--red-soft); color: var(--red); }

.horizon-grid { margin-top: 18px; display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 18px; align-items: start; }
.horizon-summary { margin-top: 16px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.horizon-metric { min-height: 86px; padding: 13px 14px; border-right: 1px solid var(--border); }
.horizon-metric:last-child { border-right: 0; }
.horizon-metric span, .horizon-metric small { display: block; color: var(--muted); font-size: 10px; }
.horizon-metric b { display: block; margin: 8px 0 6px; font-size: 20px; font-variant-numeric: tabular-nums; }
.horizon-table td { height: 46px; }
.horizon-table { min-width: 720px; }
.horizon-table.compact { font-size: 12px; }
.event-grid { margin-top: 15px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.event-card { min-height: 138px; padding: 13px; border: 1px solid var(--border); border-left: 3px solid var(--blue); border-radius: 6px; background: var(--surface-soft); }
.event-card.confirmed { border-left-color: var(--coral); background: #fffafa; }
.event-card.recurring { border-left-color: var(--green); }
.event-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.event-title span { color: var(--muted); font-size: 10px; }
.event-title h3 { margin-top: 4px; }
.event-title b { flex: 0 0 auto; color: var(--coral); font-size: 13px; }
.event-card p { margin-top: 10px; color: var(--muted); font-size: 11px; }
.event-card strong { display: block; margin-top: 8px; color: #3d4a53; font-size: 11px; line-height: 1.5; }

.approval-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 18px; align-items: start; }
.approval-list { display: grid; gap: 12px; }
.approval-card { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; }
.approval-card.status-completed, .approval-card.status-rejected, .approval-card.status-superseded { opacity: 0.68; }
.approval-card .proposal-metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.audit-grid { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 18px; }
.log-list { margin-top: 12px; display: grid; }
.log-item { min-height: 62px; padding: 10px 0 10px 22px; position: relative; border-bottom: 1px solid #edf0f2; }
.log-item:last-child { border-bottom: 0; }
.log-item::before { content: ""; position: absolute; left: 2px; top: 17px; width: 8px; height: 8px; border-radius: 50%; background: var(--blue); }
.log-item.success::before { background: var(--green); }
.log-item.warning::before { background: #d48a1f; }
.log-item h3 { font-size: 13px; }
.log-item p { margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.45; }

dialog { width: min(520px, calc(100vw - 28px)); padding: 0; border: 0; border-radius: 6px; box-shadow: 0 24px 70px rgba(23, 32, 42, 0.22); }
.approval-dialog { width: min(980px, calc(100vw - 28px)); }
dialog::backdrop { background: rgba(23, 32, 42, 0.4); }
dialog form { padding: 20px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog-header + .form-field { margin-top: 18px; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 36px; }
.input-suffix b { position: absolute; right: 12px; top: 9px; color: var(--muted); }
fieldset { margin: 18px 0 0; padding: 0; border: 0; }
legend { margin-bottom: 8px; color: var(--muted); font-size: 11px; }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.check-option { min-height: 38px; padding: 8px 10px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); border-radius: 5px; }
.check-option input { width: 16px; height: 16px; }
.dialog-actions { margin-top: 22px; display: flex; justify-content: flex-end; gap: 8px; }
.approval-summary { margin-top: 18px; padding: 12px 14px; display: flex; gap: 24px; flex-wrap: wrap; background: var(--surface-soft); border-left: 3px solid var(--green); }
.approval-summary span { color: var(--muted); font-size: 11px; }
.approval-summary b { display: block; margin-top: 4px; color: var(--ink); font-size: 15px; }
.approval-warning:empty { display: none; }
.approval-warning { margin-top: 12px; padding: 10px 12px; color: var(--amber); background: var(--amber-soft); font-size: 12px; line-height: 1.55; }
.approval-preview-table { max-height: min(48vh, 440px); overflow: auto; border: 1px solid var(--border); }
.approval-preview-table table { min-width: 800px; }
.approval-preview-table td { height: 48px; }
.approval-preview-table .price-after { color: var(--red); font-weight: 760; }
.approval-footnote { margin-top: 13px; display: flex; align-items: flex-start; gap: 8px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.approval-footnote svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--green); }

.tab-count.ai-count { background: var(--blue-soft); color: var(--blue); }
.ai-command-band {
  min-height: 132px;
  padding: 20px 22px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 18px;
  background: #f7fbfc;
  border-top: 1px solid #cfe3e6;
  border-bottom: 1px solid #cfe3e6;
}
.ai-orbit {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  color: var(--cyan);
  background: white;
  border: 1px solid #a9d3da;
  border-radius: 7px;
  box-shadow: 0 8px 20px rgba(22, 143, 160, 0.1);
}
.ai-orbit svg { width: 27px; height: 27px; }
.ai-orbit.running svg { animation: pulse 1.2s ease-in-out infinite; }
.ai-command-copy { min-width: 0; }
.ai-command-copy h3 { margin-top: 5px; font-size: 17px; overflow-wrap: anywhere; }
.ai-command-copy > p:last-child { margin-top: 8px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.ai-runtime { min-width: 170px; padding-left: 18px; border-left: 1px solid #d9e7e9; }
.ai-runtime span, .ai-runtime small { display: block; color: var(--muted); font-size: 10px; }
.ai-runtime b { display: inline-flex; margin: 6px 0; font-size: 12px; }
.ai-workspace { margin-top: 18px; display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 18px; align-items: start; }
.ai-diagnosis-list, .ai-action-list { margin-top: 12px; display: grid; }
.ai-diagnosis-row { padding: 13px 0; border-bottom: 1px solid #edf0f2; }
.ai-diagnosis-row:last-child { border-bottom: 0; }
.ai-diagnosis-row p { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.ai-diagnosis-row strong { display: block; margin-top: 6px; color: #3f4d56; font-size: 11px; line-height: 1.45; }
.ai-action-row { min-height: 98px; padding: 13px 0; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; border-bottom: 1px solid #edf0f2; }
.ai-action-row:last-child { border-bottom: 0; }
.ai-action-row.eligible { border-left: 3px solid var(--green); padding-left: 10px; }
.ai-action-row.blocked { border-left: 3px solid var(--red); padding-left: 10px; }
.ai-action-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); border-radius: 5px; }
.ai-action-icon svg { width: 17px; height: 17px; }
.ai-action-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ai-action-row p { margin-top: 6px; color: #3f4d56; font-size: 12px; line-height: 1.5; }
.ai-action-row small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.ai-action-row strong { display: block; margin-top: 5px; color: var(--green); font-size: 10px; line-height: 1.45; }
.ai-action-row.blocked strong { color: var(--red); }
.ai-action-row.advisory strong { color: var(--amber); }
.ai-risk-band { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.ai-risk-band > div { min-height: 82px; padding: 13px 15px; }
.ai-risk-band > div + div { border-left: 1px solid var(--border); }
.ai-risk-band span { display: block; color: var(--muted); font-size: 10px; }
.ai-risk-band strong { display: block; margin-top: 7px; font-size: 12px; line-height: 1.5; }
.ai-audit-columns { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.ai-audit-columns h3 { font-size: 12px; }
.ai-audit-columns ul { margin: 9px 0 0; padding-left: 18px; color: var(--muted); font-size: 11px; line-height: 1.65; }
.guardrail-flow { margin-top: 16px; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.guardrail-flow span { padding: 8px 10px; color: #3d4a53; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 5px; font-size: 11px; }
.guardrail-flow svg { width: 15px; height: 15px; color: var(--cyan); }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: 380px; padding: 12px 14px; color: white; background: var(--ink); border-radius: 5px; box-shadow: var(--shadow); transform: translateY(20px); opacity: 0; pointer-events: none; transition: 180ms ease; z-index: 50; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: var(--red); }

@keyframes signal-run {
  from { transform: translateX(-8px); }
  to { transform: translateX(100vw); }
}

@keyframes execution-run {
  from { left: 4%; }
  to { left: 95%; }
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.72); opacity: 0.55; }
}

@media (max-width: 1100px) {
  .app-header { grid-template-columns: 1fr auto; }
  .header-status { grid-column: 1 / -1; grid-row: 2; }
  .kpi-band { grid-template-columns: repeat(4, 1fr); }
  .kpi-item:nth-child(4n) { border-right: 0; }
  .kpi-item:nth-child(-n + 4) { border-bottom: 1px solid var(--border); }
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .decision-rail { display: grid; grid-template-columns: 1fr 1fr; }
  .rail-section { border-bottom: 0; border-right: 1px solid var(--border); }
  .rail-section:last-child { border-right: 0; }
  .simulation-band { grid-template-columns: 1fr 1fr; }
  .simulation-band > div { grid-column: 1 / -1; }
  .execution-item { grid-template-columns: 1fr; }
  .approval-layout, .audit-grid { grid-template-columns: 1fr; }
  .ai-workspace { grid-template-columns: 1fr; }
  .horizon-grid { grid-template-columns: 1fr; }
  .event-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .peak-alert-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .future3-grid { grid-template-columns: 1fr; }
  .future3-day { border-right: 0; border-bottom: 1px solid var(--border); }
  .future3-day:last-child { border-bottom: 0; }
  .base2-grid { grid-template-columns: 1fr; }
  .signal-strip { grid-template-columns: 1fr; gap: 0; padding: 8px 18px; }
  .signal-items { grid-template-columns: repeat(3, 1fr); }
  .signal-item:nth-child(n + 4) { border-top: 1px solid #edf1f3; }
}

@media (max-width: 720px) {
  .app-header { padding: 10px 14px; gap: 10px; }
  .brand-mark { width: 38px; height: 38px; }
  h1 { max-width: 190px; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-actions { gap: 2px; }
  .header-actions .icon-button:nth-child(n + 4) { display: none; }
  .header-status { overflow-x: auto; }
  .tab-bar { padding: 0 8px; overflow-x: auto; }
  .tab-button { min-width: 52px; padding: 0 11px; }
  .tab-button span:not(.tab-count) { display: none; }
  main { padding: 14px 12px 28px; }
  .kpi-band { grid-template-columns: repeat(2, 1fr); }
  .kpi-item { min-height: 92px; padding: 14px; border-bottom: 1px solid var(--border); }
  .kpi-item:nth-child(2n) { border-right: 0; }
  .kpi-item:nth-last-child(-n + 2) { border-bottom: 0; }
  .kpi-value { font-size: 21px; }
  .data-region { padding: 14px; }
  .legend { display: none; }
  .decision-rail { grid-template-columns: 1fr; }
  .rail-section { border-right: 0; border-bottom: 1px solid var(--border); }
  .step-line { grid-template-columns: 1fr 1fr; }
  .step-line .step:first-child { grid-column: 1 / -1; }
  .simulation-band { grid-template-columns: 1fr; align-items: stretch; }
  .simulation-band > div { grid-column: auto; }
  .simulation-band .secondary-button { width: 100%; }
  .approval-card .proposal-metrics { grid-template-columns: repeat(2, 1fr); }
  .page-heading { align-items: flex-start; }
  .source-stamp { display: none; }
  .check-grid { grid-template-columns: repeat(2, 1fr); }
  .signal-strip { min-height: 54px; padding: 7px 12px; display: block; }
  .signal-lead { margin-bottom: 7px; }
  .signal-items { display: flex; overflow-x: auto; scrollbar-width: none; }
  .signal-items::-webkit-scrollbar { display: none; }
  .signal-item { min-width: 124px; min-height: 34px; padding: 0 10px; border-top: 0 !important; }
  .price-heading { align-items: flex-start; flex-direction: column; }
  .price-filters { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .price-filters select { min-width: 0; }
  .step-line::before, .step-line::after { display: none; }
  .peak-watch { padding: 14px 12px; }
  .base2-watch { padding: 14px 12px; }
  .base2-heading { flex-direction: column; }
  .base2-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .base2-summary span:nth-child(2n) { border-right: 0; }
  .base2-summary span:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
  .base2-card-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .peak-heading { align-items: flex-start; }
  .peak-alert-list { grid-template-columns: 1fr; }
  .horizon-summary { grid-template-columns: repeat(2, 1fr); }
  .horizon-metric:nth-child(2) { border-right: 0; }
  .horizon-metric:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
  .event-grid { grid-template-columns: 1fr; }
  .peak-alert { min-height: 0; }
  .ai-command-band { grid-template-columns: 46px minmax(0, 1fr); padding: 16px 14px; }
  .ai-orbit { width: 44px; height: 44px; }
  .ai-runtime { grid-column: 1 / -1; padding: 12px 0 0; border-left: 0; border-top: 1px solid #d9e7e9; }
  .ai-risk-band, .ai-audit-columns { grid-template-columns: 1fr; }
  .ai-risk-band > div + div { border-left: 0; border-top: 1px solid var(--border); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: 1ms !important; }
}
