:root {
  --page: #f3f4fa;
  --backdrop:
    radial-gradient(900px 520px at 8% -8%, #dfe3fb 0%, rgba(223,227,251,0) 70%),
    radial-gradient(760px 520px at 96% 4%, #e6e9fc 0%, rgba(230,233,252,0) 70%),
    #f3f4fa;
  --surface: #ffffff;
  --soft: #f7f8fc;
  --line: #e5e7ef;
  --line-strong: #d3d7e6;
  --ink: #0f1114;
  --ink-2: #262933;
  --ink-3: #454a59;
  --muted: #697082;
  --accent: #5e6ad2;
  --accent-hover: #4f5bc6;
  --accent-soft: #eef1ff;

  --s-ink: #b91c1c;
  --s-bg: #fef2f2;
  --s-border: #fecaca;

  --a-ink: #b45309;
  --a-bg: #fffbeb;
  --a-border: #fde68a;

  --b-ink: #4338ca;
  --b-bg: #eef2ff;
  --b-border: #c7d2fe;

  --pos-ink: #047857;
  --pos-bg: #ecfdf5;
  --pos-border: #a7f3d0;

  --neu-ink: #475569;
  --neu-bg: #f1f5f9;
  --neu-border: #cbd5e1;

  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 17, 20, .04), 0 1px 1px rgba(15, 17, 20, .02);
  --shadow-md: 0 6px 20px rgba(15, 17, 20, .06), 0 1px 3px rgba(15, 17, 20, .04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--backdrop);
  background-attachment: fixed;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  background: var(--soft);
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--line);
}

/* Header */
.ec-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.ec-header-bar {
  max-width: 1360px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.ec-brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.ec-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
}
.ec-brand-mark { width: 28px; height: 28px; flex: none; }
.ec-brand-text { display: inline-flex; align-items: center; gap: 8px; }
.ec-brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.ec-brand-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-hover);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.ec-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 3px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.22);
}

.ec-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.ec-nav-btn, .ec-nav-link {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s ease;
}
.ec-nav-btn:hover, .ec-nav-link:hover {
  background: var(--soft);
  color: var(--ink);
}
.ec-nav-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}
.ec-nav-link { color: var(--muted); margin-left: 4px; }

/* Main container */
.ec-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px 24px 56px;
}

/* Hero */
.odi-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.odi-eyebrow {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-hover);
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}
.odi-hero h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 2.6vw, 30px);
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.odi-lede {
  margin: 0;
  max-width: 760px;
  color: var(--ink-3);
  font-size: 14px;
}
.odi-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Buttons */
.ec-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all .15s ease;
}
.ec-btn:hover { background: var(--soft); border-color: #bcc3d8; }
.ec-btn.is-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.ec-btn.is-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.ec-btn.is-sm { padding: 5px 10px; font-size: 12px; }

/* KPI Strip */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin: 6px 0 4px;
  font-variant-numeric: tabular-nums;
}
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-bar {
  display: flex;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
  margin: 6px 0;
}
.kpi-bar-risk { background: #dc2626; }
.kpi-bar-pos { background: #10b981; }

/* Tabs */
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* Filter Bar */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-sm);
}
.filter-search { flex: 1 1 260px; }
.filter-search input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  outline: none;
  background: var(--soft);
  color: var(--ink);
}
.filter-search input:focus {
  background: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(94, 106, 210, .14);
}
.filter-pills { display: flex; gap: 5px; flex-wrap: wrap; }
.pill {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.pill.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.pill.is-s.is-active { background: #dc2626; border-color: #dc2626; }
.pill.is-a.is-active { background: #d97706; border-color: #d97706; }
.pill.is-b.is-active { background: var(--accent); border-color: var(--accent); }

.filter-selects { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-selects select {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink-2);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  outline: none;
}

/* Workspace Split */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: start;
}
.feed-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}
.event-list { display: flex; flex-direction: column; gap: 14px; }

/* Event Card */
.event-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .16s ease, border-color .16s ease;
}
.event-card:hover { box-shadow: var(--shadow-md); }
.event-card.grade-S { border-left-color: #dc2626; }
.event-card.grade-A { border-left-color: #d97706; }
.event-card.grade-B { border-left-color: #5e6ad2; }

.ev-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-S { background: var(--s-bg); color: var(--s-ink); border-color: var(--s-border); }
.badge-A { background: var(--a-bg); color: var(--a-ink); border-color: var(--a-border); }
.badge-B { background: var(--b-bg); color: var(--b-ink); border-color: var(--b-border); }
.badge-risk { background: var(--s-bg); color: var(--s-ink); }
.badge-pos { background: var(--pos-bg); color: var(--pos-ink); border-color: var(--pos-border); }
.badge-neu { background: var(--neu-bg); color: var(--neu-ink); border-color: var(--neu-border); }

.badge-l1 { background: #0f766e; color: #fff; }
.badge-l2m { background: #eef1ff; color: #3730a3; border-color: #c7d2fe; }
.badge-l2s { background: #fffbeb; color: #92400e; border: 1px dashed #f59e0b; }

.ev-date { color: var(--muted); font-variant-numeric: tabular-nums; margin-left: auto; font-weight: 500; }
.ev-title {
  margin: 0 0 8px;
  font-size: 17px;
  line-height: 1.38;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.ev-title:hover { color: var(--accent-hover); }

.ev-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.chip {
  font-size: 12px;
  color: var(--ink-3);
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 2px 8px;
  border-radius: 6px;
}
.chip-amount {
  font-weight: 600;
  color: var(--ink);
  background: #f0f2ff;
  border-color: #d6dcfa;
  font-variant-numeric: tabular-nums;
}

.ev-brief {
  background: #fafbfe;
  border: 1px solid #e9ecf6;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.ev-sec { font-size: 13.5px; line-height: 1.68; color: var(--ink-2); }
.ev-sec-label {
  font-weight: 700;
  color: var(--ink);
  margin-right: 4px;
}

.ev-foot {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
}
.ev-sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); }
.src-link {
  color: var(--accent-hover);
  text-decoration: none;
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
}
.src-link:hover { text-decoration: underline; }
.ev-actions { display: flex; align-items: center; gap: 8px; }
.char-pill {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Right Rail */
.ec-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.rail-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 68px;
}
.rail-card { padding: 16px; }
.rail-card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 700; }
.rail-sub { margin: 0 0 12px; font-size: 12px; color: var(--muted); }

.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-item {
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background .12s;
}
.bar-item:hover { background: var(--soft); }
.bar-row-top {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 4px;
}
.bar-track {
  height: 6px;
  background: #edf0f7;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.stage-box {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.stage-box-num { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stage-box-lbl { font-size: 11.5px; color: var(--muted); }

.telemetry-list {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  font-size: 12px;
}
.telemetry-list dt { color: var(--muted); }
.telemetry-list dd { margin: 0; text-align: right; font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* Tables */
.table-card { padding: 20px; }
.table-head-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.table-head-bar h2 { margin: 0 0 4px; font-size: 18px; }
.table-wrap { overflow-x: auto; }
.es-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.es-table th {
  text-align: left;
  padding: 10px 10px;
  background: var(--soft);
  border-bottom: 1px solid var(--line-strong);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.es-table td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.es-table tr:hover td { background: #fafbfe; }

/* Methodology */
.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.method-card { padding: 20px 22px; }
.ec-eyebrow {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-hover);
  display: block;
  margin-bottom: 6px;
}
.method-card h3 { margin: 0 0 10px; font-size: 16px; }
.method-card ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.method-card li { margin-bottom: 8px; }
.method-p { margin: 0; color: var(--ink-2); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 20, .48);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal-box {
  background: #fff;
  border-radius: 14px;
  max-width: 780px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .25);
}
.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.modal-close {
  border: 1px solid var(--line);
  background: var(--soft);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: all .2s ease;
  z-index: 100;
}
.toast.is-show { opacity: 1; transform: translateY(0); }

.ec-badge {
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent-hover);
  padding: 4px 10px;
  border-radius: 999px;
}
.empty-state {
  text-align: center;
  padding: 44px 20px;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
}

.ec-footer {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  margin-top: 24px;
}
.ec-footer-inner {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workspace-grid { grid-template-columns: 1fr; }
  .rail-col { position: static; }
  .method-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .ec-header-bar { padding: 10px 14px; }
  .ec-shell { padding: 16px 14px 40px; }
}

/* Print-ready Daily Decision Brief */
@media print {
  .ec-header, .odi-hero-actions, .filter-bar, .rail-col, .ev-actions, .ec-footer { display: none !important; }
  body { background: #fff; font-size: 11.5pt; }
  .workspace-grid { display: block; }
  .event-card { break-inside: avoid; box-shadow: none; border: 1px solid #cbd5e1; margin-bottom: 12px; }
}
