/* ─── Layout ─── */
.dashboard-body {
  background: var(--cream);
  font-family: 'Plus Jakarta Sans', sans-serif;
}

/* Top bar */
.dash-topbar {
  height: 56px;
  background: var(--navy);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 24px;
  position: sticky;
  top: 0;
  z-index: 200;
}

.dash-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
}

.dash-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

.breadcrumb-label {
  color: rgba(255,255,255,0.4);
}

.breadcrumb-sep {
  color: rgba(255,255,255,0.2);
}

.breadcrumb-current {
  color: rgba(255,255,255,0.7);
}

.dash-meta {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 200, 150, 0.2);
  animation: pulse 2s infinite;
}

.live-label {
  font-size: 0.75rem;
  color: var(--teal);
  font-weight: 600;
}

.dash-date {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.35);
}

/* Main layout */
.dash-layout {
  display: flex;
  min-height: calc(100vh - 56px);
}

/* Sidebar */
.dash-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--cream);
  border-right: 1px solid var(--cream-mid);
  padding: 20px 0;
}

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 0 20px;
  margin-bottom: 8px;
}

.sidebar-nav {
  list-style: none;
  margin-bottom: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-mid);
  border-radius: 0;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  background: var(--cream-mid);
  color: var(--navy);
}

.sidebar-link.active {
  background: rgba(0, 200, 150, 0.08);
  color: var(--teal-dim);
  border-left-color: var(--teal);
  font-weight: 600;
}

.sidebar-link svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-link.active svg {
  opacity: 1;
}

.sidebar-divider {
  height: 1px;
  background: var(--cream-mid);
  margin: 16px 20px;
}

/* Main content */
.dash-main {
  flex: 1;
  padding: 24px 28px;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── KPI Row ─── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.kpi-card {
  background: #fffdf9;
  border: 1px solid var(--cream-mid);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.kpi-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.kpi-value {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.8rem;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 8px;
}

.kpi-value.alert {
  color: var(--red);
}

.kpi-unit {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-left: 2px;
}

.kpi-delta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.kpi-delta.up { color: var(--teal-dim); }
.kpi-delta.warn { color: var(--alert); }

/* ─── Dashboard Grid ─── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.right-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Panel ─── */
.panel {
  background: #fffdf9;
  border: 1px solid var(--cream-mid);
  border-radius: var(--radius);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--cream-mid);
}

.panel-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--navy);
  margin-bottom: 3px;
}

.panel-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.panel-controls {
  display: flex;
  gap: 4px;
}

.ctrl-btn {
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--cream-mid);
  background: transparent;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.15s;
}

.ctrl-btn.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

/* ─── Chart ─── */
.chart-container {
  padding: 16px 20px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-mid);
}

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

.legend-dot.teal  { background: var(--teal); }
.legend-dot.amber { background: var(--alert); }
.legend-dot.red   { background: var(--red); }

.area-chart {
  height: 100px;
  position: relative;
}

/* ─── Pathogen Table ─── */
.pathogen-table {
  border-top: 1px solid var(--cream-mid);
}

.table-header,
.table-row {
  display: grid;
  grid-template-columns: 2fr 0.8fr 1.4fr 0.8fr 0.8fr;
  align-items: center;
  padding: 10px 20px;
  gap: 12px;
}

.table-header {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  border-bottom: 1px solid var(--cream-mid);
}

.table-row {
  border-bottom: 1px solid var(--cream-mid);
  font-size: 0.82rem;
  transition: background 0.15s;
}

.table-row:last-child { border-bottom: none; }
.table-row:hover { background: var(--cream-mid); }

.pathogen-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--text);
}

.pathogen-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--cream-mid);
  border: 1px solid #e2ddd5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-mid);
  flex-shrink: 0;
}

.pct-bar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
}

.pct-bar {
  flex: 1;
  height: 5px;
  background: var(--cream-mid);
  border-radius: 4px;
  overflow: hidden;
}

.pct-fill {
  height: 100%;
  border-radius: 4px;
}

.pct-high { background: var(--red); }
.pct-mid  { background: var(--alert); }
.pct-low  { background: var(--teal); }

.trend-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
}

.trend-cell.up  { color: var(--teal-dim); }
.trend-cell.down { color: var(--red); }
.trend-cell.neutral { color: var(--text-dim); }

.risk-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.risk-high    { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.2); }
.risk-medium  { background: rgba(245,158,11,0.1); color: var(--alert); border: 1px solid rgba(245,158,11,0.2); }
.risk-critical { background: #7f1d1d; color: #fff; }

/* ─── Alert List ─── */
.alert-count {
  background: var(--red);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 100px;
}

.alert-list {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-item {
  display: flex;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s;
}

.alert-item:hover { background: var(--cream-mid); }

.alert-item.critical { background: rgba(239,68,68,0.06); border-color: rgba(239,68,68,0.15); }
.alert-item.high     { background: rgba(245,158,11,0.06); border-color: rgba(245,158,11,0.15); }
.alert-item.medium   { background: var(--cream-mid); border-color: #e2ddd5; }

.alert-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alert-item.critical .alert-icon { background: rgba(239,68,68,0.15); color: var(--red); }
.alert-item.high     .alert-icon { background: rgba(245,158,11,0.15); color: var(--alert); }
.alert-item.medium   .alert-icon { background: var(--cream-mid); color: var(--text-dim); }

.alert-content { flex: 1; }

.alert-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 3px;
}

.alert-meta {
  font-size: 0.72rem;
  color: var(--text-mid);
  line-height: 1.4;
  margin-bottom: 4px;
}

.alert-time {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-weight: 500;
}

.alert-seemore {
  padding: 8px 12px;
  text-align: center;
}

.alert-seemore a {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--teal-dim);
  text-decoration: none;
}

/* ─── Antibiogram ─── */
.ab-select {
  background: var(--cream-mid);
  border: 1px solid var(--cream-mid);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-mid);
  cursor: pointer;
}

.ab-list {
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ab-row {
  display: grid;
  grid-template-columns: 1fr 2fr 40px;
  align-items: center;
  gap: 10px;
}

.ab-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}

.ab-bar-wrap { width: 100%; }

.ab-bar {
  height: 8px;
  background: var(--cream-mid);
  border-radius: 6px;
  overflow: hidden;
}

.ab-fill {
  height: 100%;
  border-radius: 6px;
}

.ab-good { background: var(--teal); }
.ab-warn { background: var(--alert); }
.ab-bad  { background: var(--red); }

.ab-pct {
  font-size: 0.75rem;
  font-weight: 700;
  text-align: right;
}

.ab-pct.good { color: var(--teal-dim); }
.ab-pct.warn { color: var(--alert); }
.ab-pct.bad  { color: var(--red); }

.ab-legend {
  display: flex;
  gap: 16px;
  padding: 8px 20px 14px;
  border-top: 1px solid var(--cream-mid);
}

.ab-legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  color: var(--text-dim);
}

.ab-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.ab-legend-dot.good { background: var(--teal); }
.ab-legend-dot.warn { background: var(--alert); }
.ab-legend-dot.bad  { background: var(--red); }

/* ─── Facility panel ─── */
.facility-panel {}

.facility-bars {
  padding: 12px 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.facility-row {
  display: grid;
  grid-template-columns: 80px 1fr 44px 60px;
  align-items: center;
  gap: 12px;
}

.facility-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}

.facility-bar-wrap { width: 100%; }

.facility-bar {
  height: 10px;
  background: var(--cream-mid);
  border-radius: 6px;
  overflow: relative;
  position: relative;
}

.facility-fill {
  height: 100%;
  border-radius: 6px;
}

.facility-high { background: var(--red); }
.facility-mid  { background: var(--alert); }
.facility-low  { background: var(--teal); }

.facility-avg-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--navy);
  border-radius: 2px;
}

.facility-val {
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
}

.facility-val.high { color: var(--red); }
.facility-val.mid  { color: var(--alert); }
.facility-val.low  { color: var(--teal-dim); }

.facility-avg-label {
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* ─── Responsive ─── */
@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  .right-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 800px) {
  .dash-sidebar { display: none; }
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .right-col { grid-template-columns: 1fr; }
}

@media (max-width: 500px) {
  .kpi-row { grid-template-columns: 1fr; }
}