.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.5rem 4vw;
  max-width: 1080px;
  width: 100%;
  margin: 0 auto;
}

.app-logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-strong);
}

.app-header__actions {
  display: flex;
  gap: 0.75rem;
}

.lock-button {
  border: none;
  border-radius: 999px;
  padding: 0.55rem 1.2rem;
  background: rgba(15, 23, 42, 0.1);
  color: var(--text-strong);
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.lock-button:hover {
  transform: translateY(-1px);
  background: rgba(15, 23, 42, 0.18);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.app-main {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 3rem 1.5rem 4rem;
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.login-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 1.2rem;
  padding: 2.75rem 2.5rem;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.login-card__title {
  margin: 0;
  font-size: 1.75rem;
  color: var(--text-strong);
  text-align: center;
}

.login-card__subtitle {
  margin: -0.75rem 0 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
}

.login-card__label {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.login-card__input {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 0.85rem;
  padding: 0.75rem 0.85rem;
  font-size: 1rem;
  color: var(--text-strong);
  background: #f8fafc;
  transition: border 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.login-card__input:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(56, 105, 255, 0.15);
}

.login-card__button {
  border: none;
  border-radius: 0.9rem;
  padding: 0.8rem;
  font-weight: 600;
  font-size: 1rem;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.login-card__button:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(56, 105, 255, 0.25);
}

.login-card__error {
  margin: -0.25rem 0 0;
  color: #dc2626;
  font-size: 0.9rem;
  text-align: center;
}

@media (max-width: 640px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .app-main {
    padding-top: 2rem;
  }

  .login-card {
    padding: 2.25rem 1.75rem;
  }
}

.dashboard {
  width: min(1600px, 100vw);
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.health-bar {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.health-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: 0.9rem;
  background: #fff;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
  align-items: center;
}

.health-card--disabled {
  opacity: 0.6;
}

.health-card--loading {
  border: 1px solid rgba(250, 204, 21, 0.25);
}

.health-card--healthy {
  border: 1px solid rgba(22, 163, 74, 0.25);
}

.health-card--unhealthy {
  border: 1px solid rgba(220, 38, 38, 0.25);
}

.health-indicator {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 999px;
  flex-shrink: 0;
  background: rgba(148, 163, 184, 0.5);
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.15);
}

.health-indicator--loading {
  background: #facc15;
  box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.2);
}

.health-indicator--healthy {
  background: #16a34a;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.2);
}

.health-indicator--unhealthy {
  background: #dc2626;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2);
}

.health-card__content {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.health-card__label {
  font-weight: 600;
  color: var(--text-strong);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.health-card__label[aria-disabled="true"] {
  pointer-events: none;
  color: var(--text-muted);
  text-decoration: none;
  cursor: default;
}

.health-card__status {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.health-card__hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.dashboard__header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dashboard__header h1 {
  margin: 0;
  font-size: 2rem;
  color: var(--text-strong);
}

.dashboard__header p {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.dashboard__timestamp {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.refresh-button {
  border: none;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  padding: 0.65rem 1.2rem;
  border-radius: 0.8rem;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.refresh-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0.4rem 1.2rem rgba(56, 128, 255, 0.25);
}

.refresh-button:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.metrics {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric-card {
  background: #fff;
  border-radius: 1rem;
  padding: 1.2rem 1.4rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.metric-card__label {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.metric-card__value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text-strong);
}

.metric-card__change {
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.metric-card__change--positive {
  color: #0a8d48;
}

.metric-card__change--negative {
  color: #c93845;
}

.content-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 880px) {
  .content-grid {
    grid-template-columns: 2fr 1fr;
  }

  .content-grid > .panel:last-child {
    grid-column: span 2;
  }
}

.panel {
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
  padding: 1.5rem;
  overflow: hidden;
}

.panel--error {
  background: rgba(220, 38, 38, 0.12);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: #991b1b;
}

.panel--error p {
  margin: 0.5rem 0 0;
  color: inherit;
}

.panel__error-list {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  color: inherit;
}

.panel__error-list li + li {
  margin-top: 0.25rem;
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.panel__header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--text-strong);
}

.panel__badge {
  background: rgba(56, 128, 255, 0.12);
  color: var(--brand);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.panel__badge--alert {
  background: rgba(255, 100, 126, 0.15);
  color: #d63b57;
}

.panel__placeholder {
  margin: 0;
  padding: 0.5rem 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.panel__placeholder--error {
  color: #b91c1c;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.table th {
  text-align: left;
  padding: 0.75rem 0.5rem;
  color: var(--text-muted);
  font-weight: 600;
}

.table td {
  padding: 0.75rem 0.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  color: var(--text-strong);
}

.table__placeholder {
  text-align: center;
  padding: 1.5rem 0.5rem;
  color: var(--text-muted);
}

.table__placeholder--error {
  color: #b91c1c;
}

.table tbody tr:hover {
  background: rgba(56, 128, 255, 0.08);
}

.wellness-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.wellness-list__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-strong);
  font-weight: 600;
}

.wellness-list__name {
  font-weight: 600;
}

.wellness-list__score {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.progress {
  width: 100%;
  height: 0.6rem;
  background: rgba(148, 163, 184, 0.25);
  border-radius: 999px;
  margin-top: 0.4rem;
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), #7b5cff);
}

.alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.alert {
  background: rgba(56, 128, 255, 0.1);
  border-radius: 0.9rem;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.alert--critical {
  background: rgba(214, 59, 87, 0.15);
}

.alert--warning {
  background: rgba(255, 175, 64, 0.18);
}

.alert--info {
  background: rgba(56, 128, 255, 0.1);
}

.alert__resident {
  font-weight: 600;
  color: var(--text-strong);
}

.alert__message {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.alert__meta {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.alert__button {
  border: none;
  background: #fff;
  color: var(--brand);
  font-weight: 600;
  border-radius: 999px;
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: background 160ms ease;
}

.alert__button:hover {
  background: rgba(56, 128, 255, 0.12);
}

.admin-tools {
  display: grid;
  gap: 1.5rem;
}

.admin-tools--single {
  display: block;
}

.admin-tools--single > .panel {
  width: 100%;
}

@media (min-width: 880px) {
  .admin-tools {
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  }

  .admin-tools--single {
    display: block;
  }
}

.form-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.form-field span {
  font-weight: 600;
  color: var(--text-strong);
}

.form-field small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.form-control {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 0.75rem;
  padding: 0.65rem 0.75rem;
  font-size: 0.95rem;
  color: var(--text-strong);
  background: #f8fafc;
  transition: border 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(56, 105, 255, 0.14);
}

.form-actions {
  margin-top: 0.25rem;
  display: flex;
  justify-content: flex-end;
}

.form-submit {
  border: none;
  border-radius: 0.75rem;
  padding: 0.65rem 1.2rem;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.form-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 0.4rem 1.2rem rgba(56, 128, 255, 0.25);
}

.form-submit:disabled {
  opacity: 0.65;
  cursor: wait;
  transform: none;
  box-shadow: none;
}

.form-placeholder {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.form-message {
  margin: 0;
  font-size: 0.9rem;
}

.form-message--error {
  color: #dc2626;
}

.form-message--success {
  color: #047857;
}

.form-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.form-inline .form-control {
  flex: 1;
}

.form-secondary-button {
  border: none;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-strong);
  font-weight: 600;
  border-radius: 0.65rem;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  transition: background 160ms ease;
}

.form-secondary-button:hover {
  background: rgba(15, 23, 42, 0.14);
}

.table__row--clickable {
  cursor: pointer;
}

.table__row--clickable:hover {
  background: rgba(56, 128, 255, 0.12);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
}

.modal {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.modal__header h2 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--text-strong);
}

.modal__close {
  border: none;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-strong);
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.modal__close:hover {
  background: rgba(15, 23, 42, 0.12);
}

.modal__body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem 1.5rem;
}

.modal__secondary {
  border: none;
  border-radius: 0.65rem;
  padding: 0.55rem 1rem;
  background: rgba(15, 23, 42, 0.08);
  color: var(--text-strong);
  font-weight: 600;
  cursor: pointer;
  transition: background 160ms ease;
}

.modal__secondary:hover {
  background: rgba(15, 23, 42, 0.14);
}

.icon-button {
  border: none;
  background: rgba(56, 128, 255, 0.12);
  color: var(--brand);
  border-radius: 0.65rem;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 160ms ease;
}

.table-actions {
  display: flex;
  gap: 0.5rem;
}

.form-secondary-button--danger {
  background: rgba(220, 38, 38, 0.15);
  color: #b91c1c;
}

.form-secondary-button--danger:hover {
  background: rgba(220, 38, 38, 0.25);
}

.icon-button:hover {
  background: rgba(56, 128, 255, 0.18);
}

.modal-details {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.modal-details dt {
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.35rem;
}

.modal-details dd {
  margin: 0;
  color: var(--text-strong);
}

.modal-details ul {
  margin: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* User Type Card Styles */
.user-type-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.user-type-card {
  display: flex;
  align-items: center;
  padding: 1rem;
  border-radius: 0.85rem;
  border: 2px solid rgba(148, 163, 184, 0.3);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
  background: #f8fafc;
}

.user-type-card:hover {
  border-color: rgba(148, 163, 184, 0.5);
  background: #fff;
}

.user-type-card--selected {
  border-color: var(--brand);
  background: rgba(56, 128, 255, 0.05);
  box-shadow: 0 0 0 3px rgba(56, 128, 255, 0.12);
}

.user-type-card input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

.user-type-card__content {
  margin-left: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.user-type-card__title {
  font-weight: 600;
  color: var(--text-strong);
}

.user-type-card__desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Delete Preview Styles */
.delete-preview {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.delete-preview__warning {
  color: #dc2626;
  font-weight: 600;
  margin: 0;
}

.delete-preview__stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  background: #f8fafc;
  padding: 1.25rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.delete-preview__stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
}

.delete-preview__stat span {
  color: var(--text-muted);
}

.delete-preview__stat strong {
  color: #dc2626;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1rem;
}

.form-submit--danger {
  background: #dc2626;
}

.form-submit--danger:hover {
  background: #b91c1c;
  box-shadow: 0 0.4rem 1.2rem rgba(220, 38, 38, 0.25);
}
