

#dashboard-host { display: contents; }

#dashboard.home-dashboard-active-fallback,
#home-dashboard-unavailable.home-dashboard-active-fallback {
  display: block;
}

#dashboard .dash-topbar .small-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 58px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.2;
}

#dashboard .dash-topbar .small-button.is-loading {
  min-width: 96px;
  cursor: wait;
  opacity: 0.78;
}

#dashboard .dash-topbar .small-button.is-loading::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 2px solid rgba(16, 63, 82, 0.28);
  border-top-color: #103f52;
  border-radius: 50%;
  animation: dashboard-refresh-spin 0.7s linear infinite;
}

@keyframes dashboard-refresh-spin {
  to { transform: rotate(360deg); }
}

#dashboard .dash-topbar .utility-actions {
  gap: 10px;
  margin-right: 10px;
}

.dash-card-trend { grid-column: span 2; }

.dash-donut-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.dash-donut {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dash-donut-hole {
  position: absolute;
  inset: 16px;
  background: #fff;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.dash-donut-big { font-size: 15px; font-weight: 700; color: var(--text); }
.dash-donut-sub { font-size: 10px; color: var(--muted); }
.dash-legend { flex: 1 1 150px; }
.dash-legend-value { font-size: 11px; }

.dash-bar-row { padding: 3px 0; }
.dash-bar-head { display: flex; justify-content: space-between; font-size: 12.5px; }
.dash-bar-track {
  height: 8px;
  background: #e9eef5;
  border-radius: 5px;
  margin-top: 4px;
  overflow: hidden;
}
.dash-bar-fill { height: 100%; border-radius: 5px; }

.dash-trend-svg { width: 100%; height: auto; }
.dash-trend-month { font-size: 9px; fill: var(--muted); }
.dash-trend-legend { display: flex; gap: 16px; margin-top: 6px; flex-wrap: wrap; }

@media (max-width: 1100px) {
  .dash-card-trend { grid-column: 1 / -1; }
}

.dash-alert {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  padding: 3px 0;
}

.dash-alert-mark {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  font-weight: 700;
}

.dash-alert-ok .dash-alert-mark { background: #27ae60; }
.dash-alert-warn .dash-alert-mark { background: #f2994a; }
.dash-alert-info .dash-alert-mark { background: #2f80ed; }

/*
 * The fallback selectors below carry a zero-specificity :where() gate so a
 * stale Home fallback (kept until the hashchange listener runs) cannot apply
 * the Home grid/sidebar layout under the next route's :target for one frame.
 */
body:has(#dashboard:target) main,
body:has(#dashboard.home-dashboard-active-fallback):where(:not(:has(:target:not(#dashboard)))) main,
body:has(#home-dashboard-unavailable.home-dashboard-active-fallback):where(:not(:has(:target))) main {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: start;
  justify-content: stretch;
  gap: 16px;
}

body:has(#dashboard:target) .dashboard,
body:has(#dashboard.home-dashboard-active-fallback):where(:not(:has(:target:not(#dashboard)))) .dashboard,
body:has(#home-dashboard-unavailable.home-dashboard-active-fallback):where(:not(:has(:target))) .dashboard {
  width: 100%;
  display: grid;
  position: sticky;
  top: 46px;
  max-height: calc(100vh - 64px);
  overflow: auto;
  padding: 14px;
  gap: 12px;
  grid-template-columns: 1fr;
  align-content: start;
}

body:has(#dashboard:target) .dashboard-menu-header,
body:has(#dashboard.home-dashboard-active-fallback):where(:not(:has(:target:not(#dashboard)))) .dashboard-menu-header,
body:has(#home-dashboard-unavailable.home-dashboard-active-fallback):where(:not(:has(:target))) .dashboard-menu-header { display: block; }

body:has(#dashboard:target) .dashboard .section-title,
body:has(#dashboard.home-dashboard-active-fallback):where(:not(:has(:target:not(#dashboard)))) .dashboard .section-title,
body:has(#home-dashboard-unavailable.home-dashboard-active-fallback):where(:not(:has(:target))) .dashboard .section-title {
  font-size: 11px;
  margin: 2px 0 8px;
  color: #64748b;
  font-weight: 800;
  text-transform: uppercase;
}

body:has(#dashboard:target) .dashboard .action-button,
body:has(#dashboard.home-dashboard-active-fallback):where(:not(:has(:target:not(#dashboard)))) .dashboard .action-button,
body:has(#home-dashboard-unavailable.home-dashboard-active-fallback):where(:not(:has(:target))) .dashboard .action-button {
  min-height: 38px;
  padding: 8px 12px;
  box-shadow: 0 4px 12px rgba(22, 34, 42, 0.05);
  font-size: 12px;
  line-height: 1.2;
}

body:has(#dashboard:target) #dashboard.screen,
body:has(#dashboard.home-dashboard-active-fallback):where(:not(:has(:target:not(#dashboard)))) #dashboard.screen,
body:has(#home-dashboard-unavailable.home-dashboard-active-fallback):where(:not(:has(:target))) #home-dashboard-unavailable.screen {
  width: 100%;
  min-width: 0;
  padding: 18px 18px 20px;
}

@media (max-width: 900px) {
  body:has(#dashboard:target) main,
  body:has(#dashboard.home-dashboard-active-fallback):where(:not(:has(:target:not(#dashboard)))) main,
  body:has(#home-dashboard-unavailable.home-dashboard-active-fallback):where(:not(:has(:target))) main { grid-template-columns: 1fr; }

  body:has(#dashboard:target) .dashboard,
  body:has(#dashboard.home-dashboard-active-fallback):where(:not(:has(:target:not(#dashboard)))) .dashboard,
  body:has(#home-dashboard-unavailable.home-dashboard-active-fallback):where(:not(:has(:target))) .dashboard {
    position: static;
    max-height: none;
  }
}
