:root {
  --ink: #162126;
  --muted: #657179;
  --soft: #f4f7f6;
  --surface: #ffffff;
  --line: #d9e2e2;
  --blue: #246b8f;
  --teal: #158276;
  --green: #4d7c2f;
  --amber: #b86b12;
  --red: #b73535;
  --plum: #7b4d8f;
  --shadow: 0 18px 40px rgba(36, 57, 65, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.72)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' viewBox='0 0 180 180'%3E%3Cg fill='none' stroke='%23dce7e5' stroke-width='1'%3E%3Cpath d='M0 54c30-21 60-21 90 0s60 21 90 0'/%3E%3Cpath d='M0 90c30-21 60-21 90 0s60 21 90 0'/%3E%3Cpath d='M0 126c30-21 60-21 90 0s60 21 90 0'/%3E%3C/g%3E%3C/svg%3E");
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.dashboard-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.masthead {
  display: grid;
  grid-template-columns: 1fr 320px;
  align-items: end;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 12px;
  max-width: 820px;
  font-size: clamp(2.15rem, 5vw, 4.4rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.lede {
  max-width: 790px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.55;
}

.status-panel,
.kpi,
.control-strip,
.risk-panel,
.signals-panel,
.agent-panel,
.outreach-panel,
.briefing-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.status-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.status-panel div {
  display: grid;
  grid-template-columns: 14px 1fr;
  column-gap: 10px;
  align-items: center;
}

.status-panel small {
  grid-column: 2;
  color: var(--muted);
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(77, 124, 47, 0.16);
}

.status-panel button,
.message-tabs button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
}

.status-panel button {
  background: var(--blue);
  color: #fff;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.kpi {
  min-height: 104px;
  padding: 17px;
}

.kpi span {
  display: block;
  margin-bottom: 6px;
  font-size: 2.2rem;
  font-weight: 900;
}

.kpi small {
  color: var(--muted);
  font-weight: 750;
}

.control-strip {
  display: grid;
  grid-template-columns: 1.25fr 1fr 0.8fr 1.2fr;
  gap: 16px;
  margin-bottom: 12px;
  padding: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  min-height: 42px;
  border: 1px solid #cbd8d9;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

input[type="range"] {
  accent-color: var(--teal);
}

#thresholdLabel {
  color: var(--ink);
  font-size: 0.85rem;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.88fr) minmax(420px, 1.35fr) minmax(300px, 0.92fr);
  gap: 12px;
  align-items: start;
}

.risk-panel,
.signals-panel,
.agent-panel,
.outreach-panel,
.briefing-panel {
  padding: 16px;
}

.signals-panel {
  grid-row: span 2;
}

.briefing-panel {
  grid-column: 2 / 4;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

#selectedBadge {
  border-radius: 999px;
  background: #e7f1ef;
  color: var(--teal);
  padding: 7px 10px;
  font-size: 0.78rem;
  font-weight: 850;
  white-space: nowrap;
}

.risk-list,
.action-list,
.signal-grid {
  display: grid;
  gap: 10px;
}

.risk-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.risk-row.active {
  border-color: var(--blue);
  box-shadow: inset 4px 0 0 var(--blue);
}

.risk-row button {
  all: unset;
  cursor: pointer;
}

.risk-row strong,
.action-card strong,
.signal-card strong {
  display: block;
  margin-bottom: 5px;
}

.risk-row small,
.action-card small,
.signal-card small,
.timeline small {
  color: var(--muted);
  line-height: 1.45;
}

.risk-score {
  min-width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
}

.risk-high {
  background: var(--red);
}

.risk-watch {
  background: var(--amber);
}

.risk-steady {
  background: var(--green);
}

.signal-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.signal-card,
.action-card,
.message-draft {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.signal-card {
  min-height: 128px;
  padding: 14px;
}

.signal-value {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 10px;
}

.signal-value span {
  font-size: 1.65rem;
  font-weight: 900;
}

.signal-value em {
  color: var(--muted);
  font-style: normal;
  font-weight: 750;
}

.signal-meter {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7ecec;
}

.signal-meter div {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.timeline {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.bars {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 9px;
  align-items: end;
  min-height: 180px;
}

.bar {
  display: grid;
  align-content: end;
  gap: 8px;
  min-width: 0;
}

.bar-fill {
  min-height: 28px;
  border-radius: 7px 7px 3px 3px;
  background: linear-gradient(180deg, var(--plum), var(--blue));
}

.bar span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-align: center;
}

.action-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 12px;
}

.action-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #eaf3f4;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 900;
}

.message-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(94px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.message-tabs button.active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

.message-draft {
  min-height: 178px;
  padding: 14px;
}

.message-draft p,
.briefing-panel p {
  margin-bottom: 0;
  color: #304047;
  line-height: 1.58;
}

@media (max-width: 1120px) {
  .masthead,
  .main-grid,
  .briefing-panel {
    grid-template-columns: 1fr;
    grid-column: auto;
  }

  .signals-panel {
    grid-row: auto;
  }
}

@media (max-width: 780px) {
  .dashboard-shell {
    width: min(100% - 20px, 1380px);
    padding: 18px 0;
  }

  .kpi-grid,
  .control-strip,
  .signal-grid {
    grid-template-columns: 1fr;
  }

  .timeline-head {
    display: grid;
  }
}

@media (max-width: 520px) {
  .bars {
    grid-template-columns: repeat(3, 1fr);
  }

  .message-tabs {
    grid-template-columns: 1fr;
  }
}
