/* ============================================================
   MS4 Stream Assessment dashboard
   Rebuilt 2026-09-29 on the Terrain360 site design (redesign.css):
   #0c0d10 ground, #121319 cards with a uniform 1px line and 16px radius,
   Archivo 800 display type, Space Mono labels, #3d8ed6 accent.
   House rules: no coloured rail on a rounded card, no gradient tiles,
   status colour lives in the number or the text, never in a border stripe.
   Class names that analysis-dashboard.js builds are kept as they were.
   ============================================================ */

.ms4-dash {
  --d-card: #121319;
  --d-inset: #0f1014;
  --d-line: rgba(255, 255, 255, .1);
  --d-line-2: rgba(255, 255, 255, .16);
  --d-ink: #eef1ec;
  --d-ink-2: #aab4ac;
  --d-ink-3: #8f998f;
  --d-accent: #3d8ed6;
  --d-accent-lt: #9fc6e8;
  --d-mono: 'Space Mono', ui-monospace, monospace;
  color: var(--d-ink);
  font-family: 'Archivo', system-ui, sans-serif;
}

.ms4-dash .d-kicker {
  font-family: var(--d-mono);
  font-size: 11.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--d-accent);
}

/* --- 1. Header --- */

.dashboard-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px 32px;
  align-items: end;
  padding: 8px 0 28px;
}

.dashboard-header-left h1 {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: clamp(32px, 4.6vw, 54px);
  line-height: 1.04;
  letter-spacing: -.03em;
  color: var(--d-ink);
  margin: 12px 0 0;
  text-wrap: balance;
}

.dashboard-header-meta {
  margin-top: 14px;
  font-size: 16px;
  color: var(--d-ink-2);
  line-height: 1.5;
}

.dashboard-header-method {
  margin-top: 6px;
  font-family: var(--d-mono);
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--d-ink-3);
}

.dashboard-export-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.dashboard-export-buttons .t360-btn {
  font-size: 14px;
  padding: 12px 18px;
}

/* --- 2. Caveat --- */

.ms4-caveat {
  margin: 16px 0 0;
  padding: 14px 18px;
  border: 1px solid rgba(159, 198, 232, .24);
  background: rgba(61, 142, 214, .07);
  border-radius: 12px;
  font-size: 14.5px;
  line-height: 1.55;
  color: #c4cdc6;
}

.ms4-caveat strong {
  color: var(--d-ink);
  font-weight: 700;
}

/* --- 3. Summary cards --- */

.summary-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.summary-card {
  background: var(--d-card);
  border: 1px solid var(--d-line);
  border-radius: 16px;
  padding: 20px 20px 18px;
}

.summary-card-label {
  font-family: var(--d-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--d-ink-3);
}

.summary-card-value {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 40px;
  line-height: 1;
  letter-spacing: -.02em;
  margin: 12px 0 8px;
}

.summary-card-sub {
  font-size: 13.5px;
  color: var(--d-ink-2);
}

/* --- 4. Map --- */

.dashboard-map-wrap {
  position: relative;
  margin-top: 28px;
  border: 1px solid var(--d-line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--d-inset);
}

.dashboard-map {
  width: 100%;
  height: 440px;
  border: none;
  position: relative;
}

.dashboard-map-legend {
  position: absolute;
  bottom: 14px;
  right: 14px;
  background: rgba(12, 13, 16, .86);
  border: 1px solid var(--d-line);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 12px;
  z-index: 2;
}

.dashboard-map-legend-title {
  font-family: var(--d-mono);
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--d-ink-3);
  margin-bottom: 6px;
}

.dashboard-map-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  color: var(--d-ink-2);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-diamond {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  transform: rotate(45deg);
  display: inline-block;
}

.dashboard-map-toggles {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(12, 13, 16, .86);
  border: 1px solid var(--d-line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
}

.dashboard-map-toggles label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin-bottom: 4px;
  color: var(--d-ink-2);
}

/* --- 5. Tabs --- */

.dashboard-tabs {
  display: flex;
  gap: 4px;
  margin-top: 28px;
  border-bottom: 1px solid var(--d-line);
  overflow-x: auto;
  scrollbar-width: none;
}

.dashboard-tabs::-webkit-scrollbar { display: none; }

.dashboard-tab {
  padding: 12px 14px;
  color: var(--d-ink-3);
  font-family: 'Archivo', sans-serif;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s;
}

.dashboard-tab:hover {
  color: var(--d-ink);
}

.dashboard-tab.active {
  color: var(--d-ink);
  border-bottom-color: var(--d-accent);
}

/* --- 6. Tab content --- */

.dashboard-tab-content {
  padding: 22px 0 8px;
}

.tab-grid-2col {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 16px;
}

.tab-panel {
  background: var(--d-card);
  border: 1px solid var(--d-line);
  border-radius: 16px;
  padding: 20px 22px;
  min-width: 0;
}

.tab-panel-title {
  font-family: var(--d-mono);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--d-ink-3);
  margin-bottom: 14px;
}

/* --- 7. Component bars --- */

.component-bar {
  margin-bottom: 14px;
}

.component-bar-header {
  display: flex;
  justify-content: space-between;
  font-size: 14.5px;
  color: var(--d-ink);
  margin-bottom: 6px;
}

.component-bar-header span:last-child {
  font-family: var(--d-mono);
  font-size: 12.5px;
  color: var(--d-ink-2);
}

.component-bar-track {
  height: 6px;
  background: rgba(255, 255, 255, .08);
  border-radius: 999px;
  overflow: hidden;
}

.component-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .4s;
}

/* --- 8. Priority list --- */

.priority-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--d-line);
  font-size: 14px;
}

.priority-item:first-of-type { padding-top: 0; }
.priority-item:last-child { border-bottom: none; padding-bottom: 0; }

.priority-scene {
  color: var(--d-accent-lt);
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.priority-scene:hover {
  color: var(--d-ink);
  text-decoration: underline;
}

.priority-issue {
  color: var(--d-ink-2);
  flex: 1;
  min-width: 0;
  line-height: 1.5;
}

/* Rich item: scene + urgency row, stressors, clamped scene note */
.priority-item--rich {
  display: block;
}

.priority-item--rich .priority-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.priority-item--rich .priority-score {
  font-family: var(--d-mono);
  font-size: 12px;
  color: var(--d-ink-3);
  margin-left: 10px;
}

.priority-stressors {
  margin-top: 6px;
  font-family: var(--d-mono);
  font-size: 12px;
  color: var(--d-ink-3);
}

.priority-item--rich .priority-issue {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 6px;
  font-size: 14px;
}

.urgency-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-family: var(--d-mono);
  font-size: 11px;
  letter-spacing: .04em;
  white-space: nowrap;
  border: 1px solid var(--d-line-2);
  color: var(--d-ink-2);
}

.urgency-immediate,
.urgency-urgent {
  border-color: rgba(232, 125, 125, .45);
  color: #f0a3a3;
}

.urgency-soon {
  border-color: rgba(224, 160, 90, .45);
  color: #ecc08f;
}

.urgency-routine {
  color: var(--d-ink-2);
}

/* --- 9. Outfall table --- */

.outfall-table {
  width: 100%;
  font-size: 13.5px;
  border-collapse: collapse;
}

.outfall-table th {
  padding: 8px;
  border-bottom: 1px solid var(--d-line);
  color: var(--d-ink-3);
  font-family: var(--d-mono);
  font-size: 10.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: left;
  font-weight: 400;
}

.outfall-table td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .05);
  color: var(--d-ink);
}

.outfall-table a {
  color: var(--d-accent-lt);
  text-decoration: none;
}

.outfall-table a:hover {
  text-decoration: underline;
}

.illicit-badge {
  border: 1px solid rgba(232, 125, 125, .45);
  color: #f0a3a3;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

/* --- 10. SCM cards (uniform border; status is the text colour) --- */

.scm-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  font-size: 13.5px;
}

.scm-card {
  padding: 12px 14px;
  background: var(--d-inset);
  border: 1px solid var(--d-line);
  border-radius: 10px;
}

.scm-card.present {
  border-color: rgba(95, 174, 126, .35);
}

.scm-card.degraded {
  border-color: rgba(224, 160, 90, .35);
}

.scm-card-name {
  color: var(--d-ink-2);
}

.scm-card-status {
  font-weight: 600;
  margin-top: 4px;
}

/* --- 11. Colour utilities (data encodings, shared with the map) --- */

.color-good { color: #22c55e; }
.color-fair { color: #f59e0b; }
.color-poor { color: #ef4444; }
.color-unknown { color: var(--d-ink-3); font-size: 14px; }

/* --- 12. Responsive --- */

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

  .dashboard-export-buttons {
    justify-content: flex-start;
  }

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

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

@media (max-width: 560px) {
  .summary-cards {
    gap: 10px;
  }

  .summary-card {
    padding: 16px 14px 14px;
  }

  .summary-card-value {
    font-size: 32px;
  }

  .scm-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-map {
    height: 300px;
  }

  .dashboard-export-buttons .t360-btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .tab-panel {
    padding: 18px 16px;
  }
}
