.dashboard {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

.dashboard-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background-color: var(--c-popup-bg);
  border-bottom: 1px solid var(--c-border);
}

.dashboard-header__right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dashboard-search-toggle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-base-subtitle-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dashboard-search-toggle svg {
  width: 1rem;
  height: 1rem;
}

.dashboard-search-toggle:hover {
  border-color: var(--c-brand);
  color: var(--c-brand);
}

.dashboard-search-toggle--active {
  border-color: var(--c-brand);
  color: var(--c-brand);
}

.dashboard-add-patient-toggle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-base-subtitle-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 1.25rem;
  line-height: 1;
}

.dashboard-add-patient-toggle:hover {
  border-color: var(--c-brand);
  color: var(--c-brand);
}

/* Toolbar */

.dashboard-toolbar {
  display: grid;
  grid-template-rows: 0fr;
  background-color: var(--c-popup-bg);
  transition: grid-template-rows 0.3s ease, opacity 0.2s ease;
  opacity: 0;
  position: relative;
  z-index: 5;
}

.dashboard-toolbar--open {
  grid-template-rows: 1fr;
  opacity: 1;
}

.dashboard-toolbar__content {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0 2rem;
  min-height: 0;
  overflow: hidden;
  border-bottom: 1px solid transparent;
}

.dashboard-toolbar--open .dashboard-toolbar__content {
  overflow: visible;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom-color: var(--c-border);
}

.dashboard-toolbar__left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 2rem;
  flex: 1;
  min-width: 0;
}

.dashboard-toolbar__filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  flex-shrink: 1;
  min-width: 0;
}

.dashboard-toolbar__filters .form-group {
  margin-bottom: 0;
}

.dashboard-toolbar__select {
  min-width: 10rem;
}

.dashboard-toolbar__search {
  flex: 1 1 240px;
  display: flex;
  align-items: center;
  min-width: 0;
  max-width: 500px;
}

.dashboard-toolbar__search .base-searchbar-underline {
  width: 100%;
}

.dashboard-toolbar__search .base-searchbar-underline__input {
  font-size: clamp(1.25rem, 3vw, 2.5rem);
  padding: 0 0.5rem 0 2.75rem;
  line-height: 1;
}

.dashboard-toolbar__search .base-searchbar-underline__icon {
  width: clamp(1.25rem, 2.2vw, 2rem);
  height: clamp(1.25rem, 2.2vw, 2rem);
}

.dashboard-toolbar__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}

@media (max-width: 720px) {
  .dashboard-toolbar__content {
    padding: 0 1rem;
  }

  .dashboard-toolbar--open .dashboard-toolbar__content {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }

  .dashboard-toolbar__left {
    width: 100%;
    flex: 1 1 100%;
  }

  .dashboard-toolbar__select,
  .dashboard-toolbar__filters {
    width: 100%;
    min-width: 0;
  }

  .dashboard-toolbar__select {
    min-width: 0;
  }

  .dashboard-toolbar__search {
    flex: 1 1 100%;
    max-width: none;
  }

  .dashboard-toolbar__actions {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
  }

  .dashboard-header {
    padding: 0.75rem 1rem;
  }

  .dashboard-content {
    padding: 1.25rem 1rem 1.5rem;
  }
}

.dashboard-toolbar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.25rem;
  border-radius: 0.5rem;
  border: none;
  background-color: var(--c-brand);
  color: var(--c-brand-text);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s ease;
}

.dashboard-toolbar__btn:hover {
  opacity: 0.85;
}

.dashboard-toolbar__btn--secondary {
  background-color: transparent;
  color: var(--c-brand);
  border: 1px solid var(--c-brand);
}

.dashboard-toolbar__btn--secondary:hover {
  background-color: var(--c-brand-highlight);
  opacity: 1;
}

.dashboard-content {
  flex: 1;
  padding: 40px 2rem 2rem;
}

.dashboard-content__top-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1.5rem;
}

/* Quick Menu */

.dashboard-quick-menu {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.dashboard-quick-menu__bar {
  display: flex;
  align-items: center;
  background-color: rgba(59, 130, 246, 0.8);
  border-radius: 0.625rem;
  padding: 0;
  cursor: pointer;
}

.dashboard-quick-menu__trigger {
  width: 3rem;
  height: 3rem;
  border-radius: 0.625rem;
  border: none;
  background-color: var(--c-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-brand-text);
  flex-shrink: 0;
  cursor: pointer;
}

.dashboard-quick-menu__icon {
  width: 1.125rem;
  height: 1.125rem;
}

.dashboard-quick-menu__items {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  transition: max-width 0.33s ease-in-out, opacity 0.33s ease-in-out, margin 0.33s ease-in-out;
}

.dashboard-quick-menu__bar:hover .dashboard-quick-menu__items {
  max-width: 30rem;
  opacity: 1;
  margin-left: 0.5rem;
  margin-right: 0.5rem;
}

.dashboard-quick-menu__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.5rem;
  border-radius: 0.4375rem;
  border: none;
  background-color: rgba(255, 255, 255, 0.15);
  color: var(--c-brand-text);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.dashboard-quick-menu__item:hover {
  background-color: rgba(255, 255, 255, 0.3);
  color: var(--c-brand-text);
}

/* Toggle button with icon */

.dashboard-quick-menu__item--toggle {
  gap: 0.375rem;
}

.dashboard-quick-menu__item-icon {
  width: 0.875rem;
  height: 0.875rem;
  stroke: var(--c-error);
  transition: stroke 0.33s ease-in-out;
}

.dashboard--clean .dashboard-quick-menu__item-icon {
  stroke: var(--c-success);
}

.dashboard-quick-menu__item--active {
  background-color: rgba(255, 255, 255, 0.35);
}

/* Force close menu after toggle click */

.dashboard-quick-menu--closing .dashboard-quick-menu__items {
  max-width: 0 !important;
  opacity: 0 !important;
  margin: 0 !important;
}

/* Clean view: collapse header */

.dashboard-header {
  max-height: 5rem;
  transition: max-height 0.33s ease-in-out, padding 0.33s ease-in-out,
              border-color 0.33s ease-in-out, opacity 0.33s ease-in-out;
}

.dashboard--clean .dashboard-header {
  overflow: hidden;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-color: transparent;
  opacity: 0;
}

/* Patients Grid */

.dashboard-patients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

.dashboard-patient-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.625rem;
  border: 1px solid var(--c-border);
  background-color: var(--c-popup-bg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
  min-width: 0;
}

.dashboard-patient-card__top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dashboard-patient-card:hover {
  border-color: var(--c-brand);
  background-color: var(--c-brand-highlight);
}

.dashboard-patient-card__avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background-color: var(--c-brand);
  color: var(--c-brand-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: 600;
  flex-shrink: 0;
}

.dashboard-patient-card__info {
  flex: 1;
  min-width: 0;
}

.dashboard-patient-card__name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--c-base-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-patient-card__plan-name {
  font-size: 0.75rem;
  color: var(--c-base-subtitle-text);
  margin-top: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-patient-card__actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-left: auto;
  flex-shrink: 0;
}

.dashboard-patient-card__icon-btn {
  position: relative;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.375rem;
  border: 1px solid var(--c-border);
  background-color: transparent;
  color: var(--c-base-subtitle-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}

.dashboard-patient-card__status-dot {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  border: 1.5px solid var(--c-popup-bg, white);
  pointer-events: none;
}

.dashboard-patient-card__status-dot--red   { background-color: #dc2626; }
.dashboard-patient-card__status-dot--green { background-color: #16a34a; }

.dashboard-patient-card__icon-btn svg {
  width: 0.875rem;
  height: 0.875rem;
}

.dashboard-patient-card__icon-btn:hover {
  border-color: var(--c-brand);
  color: var(--c-brand);
}

.dashboard-patient-card__icon-btn--generated {
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background-color: var(--c-brand-highlight);
  border-color: var(--c-brand);
  color: var(--c-brand);
  width: auto;
  padding: 0 0.375rem;
}

.dashboard-patient-card__bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.dashboard-patient-card__meta {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  flex: 1;
}

.dashboard-patient-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.5rem;
  border-radius: 1rem;
  background-color: var(--c-border);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--c-base-subtitle-text);
  white-space: nowrap;
}

.dashboard-patient-card__badge svg {
  width: 0.75rem;
  height: 0.75rem;
  flex-shrink: 0;
}

.dashboard-patient-card__badge--reason {
  min-width: 0;
}

.dashboard-patient-card__badge--reason .dashboard-patient-card__badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Card uses overflow:hidden, so flip tooltips upward to avoid clipping. */
.dashboard-patient-card .patient-shelf__tooltip-host[data-tooltip]:hover::after,
.dashboard-patient-card .patient-shelf__tooltip-host[data-tooltip]:focus-visible::after {
  top: auto;
  bottom: calc(100% + 0.5rem);
}

.dashboard-patient-card .patient-shelf__tooltip-host[data-tooltip]:hover::before,
.dashboard-patient-card .patient-shelf__tooltip-host[data-tooltip]:focus-visible::before {
  top: auto;
  bottom: calc(100% + 0.15rem);
  border-top: 0;
  border-left: 0;
  border-bottom: 1px solid var(--c-border);
  border-right: 1px solid var(--c-border);
}

.dashboard-patient-card__physician-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background-color: var(--c-border);
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--c-base-subtitle-text);
  flex-shrink: 0;
}

/* Patient status variants */
.dashboard-patient-card--good {
  background-color: var(--c-severity-good-highlight);
  border-color: var(--c-severity-good);
}
.dashboard-patient-card--good:hover {
  border-color: var(--c-severity-good);
}
.dashboard-patient-card--good .dashboard-patient-card__avatar {
  background-color: var(--c-severity-good);
}

.dashboard-patient-card--bad {
  background-color: var(--c-severity-bad-highlight);
  border-color: var(--c-severity-bad);
}
.dashboard-patient-card--bad:hover {
  border-color: var(--c-severity-bad);
}
.dashboard-patient-card--bad .dashboard-patient-card__avatar {
  background-color: var(--c-severity-bad);
}

.dashboard-patient-card--severe {
  background-color: var(--c-severity-severe-highlight);
  border-color: var(--c-severity-severe);
}
.dashboard-patient-card--severe:hover {
  border-color: var(--c-severity-severe);
}
.dashboard-patient-card--severe .dashboard-patient-card__avatar {
  background-color: var(--c-severity-severe);
}

.dashboard-patient-card--critical {
  background-color: var(--c-severity-critical-highlight);
  border-color: var(--c-severity-critical);
}
.dashboard-patient-card--critical:hover {
  border-color: var(--c-severity-critical);
}
.dashboard-patient-card--critical .dashboard-patient-card__avatar {
  background-color: var(--c-severity-critical);
}

