/* ═══════════════════════════════════════════════════════════════
   AVA HEALTH — CORPORATE HEALTH DASHBOARD
   Design System: Clean Editorial & Clinical Analytics
   ═══════════════════════════════════════════════════════════════ */

.corp-dashboard {
  --cd-ink: #102c54;
  --cd-ink-deep: #0a2342;
  --cd-muted: #52657b;
  --cd-green: #00865a;
  --cd-green-dark: #006c59;
  --cd-blue: #2676cc;
  --cd-teal: #0891a5;
  --cd-rose: #d94055;
  --cd-border: #e2ebf3;
  --cd-bg: #f8fafc;
  
  color: var(--cd-ink);
  background: #ffffff;
  padding: 28px 32px 36px;
  border-radius: 16px;
  border: 1px solid var(--cd-border);
  box-shadow: 0 1px 4px rgba(16, 44, 84, 0.04);
  font-family: 'Outfit', 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  margin-bottom: 24px;
}

.corp-dashboard * {
  box-sizing: border-box;
}

.corp-dashboard h2,
.corp-dashboard h3,
.corp-dashboard p {
  margin: 0;
}

/* ── Header Row ──────────────────────────────────────────────── */
.cd-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.cd-eyebrow {
  display: inline-block;
  font-size: 11px !important;
  letter-spacing: 1.5px;
  font-weight: 800;
  color: var(--cd-green);
  text-transform: uppercase;
  margin-bottom: 8px !important;
}

.corp-dashboard h2 {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.6px;
  color: var(--cd-ink);
}

.cd-subtitle {
  font-size: 13px;
  color: var(--cd-muted);
  line-height: 1.6;
  margin-top: 6px !important;
}

.cd-note {
  font-size: 11.5px;
  color: var(--cd-muted);
  line-height: 1.55;
  margin-top: 6px !important;
}

.cd-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.corp-dashboard button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  min-height: 38px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 16px;
  background: #ffffff;
  color: var(--cd-ink);
  cursor: pointer;
  transition: all 0.18s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.corp-dashboard button:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
}
.corp-dashboard button:focus-visible {
  outline: 2px solid #0284c7;
  outline-offset: 2px;
}
.corp-dashboard button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.corp-dashboard .cd-primary {
  background: var(--cd-ink);
  color: #ffffff;
  border-color: var(--cd-ink);
  box-shadow: 0 2px 8px rgba(16, 44, 84, 0.18);
}
.corp-dashboard .cd-primary:hover {
  background: var(--cd-ink-deep);
  border-color: var(--cd-ink-deep);
  box-shadow: 0 4px 14px rgba(16, 44, 84, 0.28);
  transform: translateY(-1px);
}
.corp-dashboard .cd-primary:active {
  transform: translateY(0);
}

/* ── Filters Bar ─────────────────────────────────────────────── */
.cd-filters {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}

.cd-filters label,
.cd-program {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--cd-ink);
  min-width: 0;
}

.cd-filters input,
.cd-filters select,
.cd-program select {
  width: 100%;
  min-width: 0;
  font: inherit;
  font-size: 13px;
  min-height: 40px;
  height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 12px;
  background: #ffffff;
  color: var(--cd-ink);
  outline: 0;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.cd-filters select,
.cd-program select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2352657b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.cd-filters input:focus,
.cd-filters select:focus,
.cd-program select:focus {
  border-color: #0284c7;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* ── KPI Cards Grid ──────────────────────────────────────────── */
.cd-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
  margin-bottom: 20px;
}

.cd-card {
  min-width: 0;
  background: #ffffff;
  border: 1px solid var(--cd-border);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 2px 10px rgba(16, 44, 84, 0.03);
  position: relative;
  overflow: hidden;
}

.cd-card h3 {
  font-size: 15px;
  font-weight: 750;
  color: var(--cd-ink);
  margin-bottom: 14px;
}

.cd-kpi {
  border-width: 1.5px;
  border-style: solid;
  display: flex;
  flex-direction: column;
}
.cd-kpi:nth-child(1) { border-color: #2676cc; }
.cd-kpi:nth-child(2) { border-color: var(--cd-green); }
.cd-kpi:nth-child(3) { border-color: var(--cd-teal); }
.cd-kpi:nth-child(4) { border-color: var(--cd-rose); }

.cd-kpi span {
  font-size: 12px;
  font-weight: 700;
  color: var(--cd-ink);
  letter-spacing: 0.01em;
}

.cd-kpi strong {
  display: block;
  font-size: 32px;
  line-height: 1.15;
  margin: 10px 0 4px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--cd-ink);
}

.cd-kpi .cd-note {
  margin-top: auto !important;
  padding-top: 4px;
}

/* ── Middle Grid (Status, Trend, Department) ─────────────────── */
.cd-grid {
  display: grid;
  grid-template-columns: 1fr 1.45fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* Donut Chart */
.cd-donut {
  display: block;
  width: 170px;
  height: 170px;
  margin: 4px auto 18px;
}

.cd-legend {
  display: grid;
  gap: 10px;
  font-size: 12px;
}
.cd-legend div {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--cd-ink);
}
.cd-legend b {
  margin-left: auto;
  white-space: nowrap;
  font-weight: 700;
}
.cd-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Trend Chart */
.cd-chart {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 8px;
}

.corp-dashboard details {
  margin-top: 12px;
}
.corp-dashboard summary {
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--cd-blue);
  padding: 6px 0;
  user-select: none;
  list-style: none;
}
.corp-dashboard summary::-webkit-details-marker {
  display: none;
}
.corp-dashboard summary:hover {
  text-decoration: underline;
}

.corp-dashboard table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.corp-dashboard th,
.corp-dashboard td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--cd-border);
  color: var(--cd-ink);
}
.corp-dashboard th {
  background: #f1f6fa;
  font-weight: 700;
}

/* Department & Progress Bars */
.cd-bar {
  margin: 14px 0;
  font-size: 12px;
}
.cd-bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--cd-ink);
}
.cd-bar-label b {
  font-weight: 750;
}

.cd-track {
  height: 8px;
  background: #edf2f6;
  border-radius: 6px;
  overflow: hidden;
}
.cd-track span {
  display: block;
  height: 100%;
  background: var(--cd-blue);
  border-radius: 6px;
  transition: width 0.3s ease;
}

/* ── Bottom Grid (Risk Profile & Next Steps) ─────────────────── */
.cd-bottom {
  grid-template-columns: 1fr 1fr;
}

.cd-program {
  margin-bottom: 16px;
}

/* Action Links Buttons */
.cd-links {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.cd-links button {
  text-align: left;
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: all 0.18s ease;
}
.cd-links button:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(16, 44, 84, 0.05);
}
.cd-links small {
  display: block;
  font-weight: 400;
  margin-top: 4px;
  line-height: 1.5;
  color: var(--cd-muted);
  font-size: 11.5px;
}

/* ── Status & Meta ───────────────────────────────────────────── */
.cd-empty {
  padding: 28px 0;
  color: var(--cd-muted);
  font-size: 13px;
  line-height: 1.7;
  text-align: center;
}

.cd-warning {
  padding: 12px 16px;
  background: #fffbe8;
  border: 1px solid #e8d085;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 12.5px;
  color: #7a5410;
}

.cd-state {
  padding: 48px 0;
  text-align: center;
  color: var(--cd-muted);
  font-size: 13.5px;
}

.cd-meta {
  font-size: 11px;
  color: var(--cd-muted);
  margin-top: 20px !important;
}

/* ── Responsive Rules ────────────────────────────────────────── */
@media (max-width: 1200px) {
  .cd-grid {
    grid-template-columns: 1fr 1fr;
  }
  .cd-grid > .cd-card:last-child {
    grid-column: 1 / -1;
  }
  .cd-bottom > .cd-card:last-child {
    grid-column: auto;
  }
  .cd-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .cd-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .corp-dashboard {
    padding: 18px 16px;
    border-radius: 14px;
  }
  .cd-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .cd-filters {
    grid-template-columns: 1fr 1fr;
  }
  .cd-filters label:last-child {
    grid-column: 1 / -1;
  }
  .cd-grid,
  .cd-bottom {
    grid-template-columns: 1fr;
  }
  .cd-card {
    padding: 16px;
  }
  .cd-kpi strong {
    font-size: 26px;
  }
  .cd-kpis {
    gap: 10px;
  }
  .cd-grid > .cd-card:last-child {
    grid-column: auto;
  }
}
