:root {
  color-scheme: light;
  --bg: #f2f5f2;
  --surface: #ffffff;
  --surface-alt: #edf1ee;
  --ink: #11181c;
  --muted: #626e73;
  --line: #d8ded9;
  --accent: #255f55;
  --accent-strong: #173f39;
  --blue: #245f9f;
  --violet: #684a98;
  --amber: #9a6100;
  --red: #a93f32;
  --green-soft: #e4f3ec;
  --amber-soft: #fff4dc;
  --red-soft: #fde9e5;
  --shadow: 0 16px 38px rgba(17, 24, 28, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(249, 250, 247, 0.96);
  backdrop-filter: blur(14px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.brand-link {
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid #b8d8cf;
  border-radius: 8px;
  background: #e7f2ed;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 900;
}

.brand-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 25px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 12px;
  font-size: 20px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-alt);
}

.tab,
.button,
.ghost-button,
.event-row {
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
}

.tab {
  min-height: 36px;
  padding: 0 14px;
  color: var(--muted);
  font-weight: 700;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.tab.is-active {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(23, 32, 38, 0.07);
}

#app {
  padding: 24px 28px 36px;
}

.brief-shell {
  display: grid;
  grid-template-columns: minmax(320px, 1.35fr) repeat(3, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.brief-copy,
.brief-card,
.brief-map,
.filter-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brief-copy {
  min-height: 214px;
  padding: 20px;
  background: #14201f;
  color: #f7fbf7;
}

.brief-copy .eyebrow {
  color: #a9d8c6;
}

.brief-copy h2 {
  max-width: 720px;
  margin-bottom: 12px;
  font-size: 30px;
  line-height: 1.08;
}

.brief-copy p {
  max-width: 720px;
  margin-bottom: 16px;
  color: #d6e2dc;
  line-height: 1.55;
}

.brief-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.brief-actions span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid rgba(214, 226, 220, 0.3);
  border-radius: 999px;
  color: #f3faf6;
  font-size: 12px;
  font-weight: 800;
}

.brief-card {
  min-height: 214px;
  padding: 16px;
  background: var(--surface);
}

.brief-card strong {
  display: block;
  margin-bottom: 10px;
  font-size: 18px;
  line-height: 1.22;
}

.brief-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.primary-brief-card {
  border-color: #badbd3;
  background: #f7fcf9;
}

.brief-map {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 72px minmax(150px, 1fr) 72px minmax(150px, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  background: #fbfcfb;
}

.map-node {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.map-node span,
.map-node small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.map-node strong {
  display: block;
  margin: 4px 0 3px;
  font-size: 26px;
  line-height: 1;
}

.map-rail {
  position: relative;
  height: 2px;
  background: var(--line);
}

.map-rail span {
  position: absolute;
  right: 0;
  top: -4px;
  width: 10px;
  height: 10px;
  border-top: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  transform: rotate(45deg);
}

.pulse-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) repeat(3, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.pulse-panel {
  min-height: 112px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.pulse-primary {
  border-color: #b8dbd4;
  background: #f1fbf8;
}

.pulse-panel strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.2;
}

.pulse-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.source-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.source-chip {
  display: inline-grid;
  grid-template-columns: auto auto auto;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.source-chip strong {
  color: var(--ink);
  font-size: 15px;
}

.source-chip small {
  color: var(--muted);
  font-size: 12px;
}

.readiness-band {
  display: grid;
  grid-template-columns: minmax(240px, 0.85fr) minmax(320px, 1.15fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.readiness-band.is-ready {
  border-color: #b8d8cf;
  background: #f7fcfa;
}

.readiness-band.is-blocked {
  border-color: #f7d18e;
  background: var(--amber-soft);
}

.readiness-summary strong {
  display: block;
  margin: 4px 0 6px;
  font-size: 18px;
}

.readiness-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.readiness-checks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.readiness-check {
  min-height: 54px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.readiness-check.pass {
  border-color: #b8d8cf;
}

.readiness-check.fail {
  border-color: #e4a84f;
}

.readiness-check small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.view-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 240px) minmax(180px, 240px) auto auto auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.view-summary strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.view-summary p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.loading {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  min-height: 84px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  font-size: 26px;
  line-height: 1.1;
}

.toolbar {
  display: grid;
  grid-template-columns:
    minmax(220px, 1.2fr)
    repeat(3, minmax(150px, 0.72fr))
    minmax(190px, 0.9fr)
    minmax(140px, 0.64fr);
  gap: 10px;
  margin-bottom: 0;
}

.filter-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.92);
}

.filter-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 14px;
}

.filter-intro strong {
  display: block;
  font-size: 16px;
  line-height: 1.25;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  padding: 9px 10px;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(37, 95, 85, 0.14);
}

.textarea {
  min-height: 76px;
  resize: vertical;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.86fr) minmax(380px, 1.34fr);
  gap: 16px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-body {
  padding: 14px 16px;
}

.event-list {
  display: grid;
  gap: 8px;
}

.event-row {
  width: 100%;
  min-height: 136px;
  padding: 12px;
  border-color: var(--line);
  background: #ffffff;
  text-align: left;
}

.event-row:hover,
.event-row.is-selected {
  border-color: var(--accent);
  background: #f1fbf8;
}

.event-row:focus-visible,
.button:focus-visible,
.ghost-button:focus-visible,
.tab:focus-visible {
  outline: 3px solid rgba(37, 95, 85, 0.18);
  outline-offset: 2px;
}

.row-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.event-title {
  margin: 0 0 10px;
  font-weight: 800;
  line-height: 1.3;
}

.event-summary {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.event-footer {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.meta {
  font-size: 13px;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fafb;
  color: #33434a;
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
}

.pill.high {
  border-color: #f5b2aa;
  background: var(--red-soft);
  color: var(--red);
}

.pill.watch {
  border-color: #f7d18e;
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.fixture {
  border-color: #b8dbd4;
  background: var(--green-soft);
  color: var(--accent-strong);
}

.pill.live {
  border-color: #aec9f2;
  background: #eaf2ff;
  color: var(--blue);
}

.pill.fda {
  border-color: #d7b4f3;
  background: #f4ecff;
  color: var(--violet);
}

.pill.clinical {
  border-color: #aec9f2;
  background: #eaf2ff;
  color: var(--blue);
}

.detail-title {
  margin-bottom: 8px;
  font-size: 22px;
  line-height: 1.2;
}

.answer-card {
  margin-bottom: 12px;
  padding: 16px;
  border: 1px solid #b8d8cf;
  border-radius: 8px;
  background: #f7fcf9;
}

.answer-card p {
  margin: 0;
  color: #314148;
  line-height: 1.55;
}

.next-step-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.next-step-grid > div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.next-step-grid p {
  margin: 0;
  color: #314148;
  font-size: 13px;
  line-height: 1.48;
}

.compact-notice {
  margin-bottom: 12px;
}

.summary-list {
  display: grid;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.summary-list li {
  padding-left: 12px;
  border-left: 3px solid var(--accent);
}

.source-link {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.source-record {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid #b8dbd4;
  border-radius: 8px;
  background: #f3faf8;
}

.source-page {
  display: grid;
  gap: 16px;
  width: min(1040px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.source-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.source-record h3 {
  margin: 0;
}

.source-metadata {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.source-metadata div {
  min-width: 0;
}

.source-metadata dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.source-metadata dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.source-record blockquote {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  color: #33434a;
}

.source-disclaimer {
  margin: 0 0 12px;
  color: #563100;
  font-size: 13px;
  line-height: 1.45;
}

.source-actions:empty {
  display: none;
}

.source-placeholder {
  display: block;
  margin-top: 4px;
}

.document-viewer {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.document-viewer h3 {
  margin: 0;
}

.document-viewer pre {
  max-height: 360px;
  margin: 12px 0 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: #223037;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.match-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.match-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.score {
  display: inline-flex;
  align-items: center;
  min-width: 52px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.compact-score {
  min-width: 40px;
  padding: 4px 7px;
  background: #243a3f;
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 13px;
  line-height: 1.15;
  text-align: center;
  font-weight: 800;
}

a.button,
a.ghost-button {
  text-decoration: none;
}

.button {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button:hover {
  background: var(--accent-strong);
}

.button:disabled,
.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ghost-button {
  border-color: var(--line);
  background: var(--surface);
}

.ghost-button:hover {
  border-color: var(--accent);
}

.debug-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.debug-table th,
.debug-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
  text-align: left;
  vertical-align: top;
}

.debug-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border: 1px solid #f7d18e;
  border-radius: 8px;
  background: var(--amber-soft);
  color: #563100;
}

.admin-access {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.admin-access p {
  margin: 0 0 10px;
}

.admin-token-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 8px;
}

.two-column {
  display: grid;
  grid-template-columns: minmax(280px, 0.75fr) minmax(320px, 1.25fr);
  gap: 16px;
  align-items: start;
}

.monitor-pack-panel {
  margin-top: 16px;
}

.recipient-panel {
  margin-top: 16px;
}

.alert-digest-panel {
  margin-top: 16px;
}

.monitor-pack-grid,
.recipient-grid {
  display: grid;
  grid-template-columns: minmax(260px, 0.75fr) minmax(320px, 1.25fr);
  gap: 16px;
  align-items: start;
}

.recipient-grid > div {
  min-width: 0;
}

.recipient-grid > div:first-child {
  overflow-x: auto;
}

.recipient-table {
  min-width: 640px;
}

.recipient-table .input,
.recipient-table .select {
  width: 100%;
  min-width: 0;
}

.recipient-table td:last-child {
  width: 1%;
  white-space: nowrap;
}

.recipient-form {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(120px, 0.7fr) minmax(180px, 1.3fr) auto;
  gap: 8px;
  margin-top: 12px;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.server-pack-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 8px;
  margin: 10px 0;
}

.file-button {
  cursor: pointer;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.digest-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.digest-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.digest-item h3 {
  margin-top: 8px;
}

.digest-item p {
  color: #33434a;
  font-size: 13px;
  line-height: 1.45;
}

.digest-textarea {
  margin-top: 12px;
  min-height: 220px;
}

.delivery-log {
  margin-top: 16px;
}

.delivery-log h3 {
  margin: 0;
}

.delivery-provider-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0;
}

.delivery-provider-summary span {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7fafb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 840px) {
  .topbar {
    position: static;
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
  }

  #app {
    padding: 16px;
  }

  .tabs,
  .toolbar,
  .readiness-band,
  .view-bar,
  .dashboard-grid,
  .two-column,
  .monitor-pack-grid,
  .recipient-grid,
  .admin-token-row,
  .recipient-form,
  .server-pack-row,
  .form-grid,
  .source-metadata,
  .pulse-grid,
  .metric-grid,
  .brief-shell,
  .brief-map,
  .filter-card,
  .next-step-grid {
    grid-template-columns: 1fr;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .metric-grid {
    display: grid;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .brief-copy {
    min-height: 0;
  }

  .brief-copy h2 {
    font-size: 24px;
  }

  .brief-card {
    min-height: 0;
  }

  .map-rail {
    display: none;
  }

  .event-footer {
    display: grid;
  }

  .actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  }

  .admin-token-row .input,
  .admin-token-row .ghost-button,
  .server-pack-row .input,
  .server-pack-row .ghost-button {
    min-width: 0;
    width: 100%;
  }

  .debug-table th,
  .debug-table td {
    padding: 9px 6px;
  }
}
