.entity-page {
  color: var(--text-primary);
}

.entity-page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.entity-title-group {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
}

.entity-title-icon {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  margin-top: 0.05rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  color: var(--home-primary-dark);
  background: #ecfdf5;
  box-shadow: var(--shadow-sm);
}

.entity-title-icon img {
  width: 25px;
  height: 25px;
  display: block;
  opacity: 0.88;
}

.entity-kicker {
  color: var(--primary-color);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.entity-subtitle {
  color: var(--text-secondary);
  font-size: 0.98rem;
  max-width: 720px;
}

.entity-primary-action,
.entity-secondary-action,
.entity-icon-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.entity-primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--primary-color);
  color: white;
  min-height: 42px;
  padding: 0.7rem 1rem;
  white-space: nowrap;
}

.entity-primary-action:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.entity-primary-action:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

.entity-secondary-action {
  background: white;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  min-height: 42px;
  padding: 0.7rem 1rem;
}

.entity-secondary-action:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

.entity-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-size: 1rem;
  line-height: 1;
}

.entity-action-icon img {
  width: 14px;
  height: 14px;
  display: block;
  filter: brightness(0) invert(1);
}

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

.entity-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #f8fafc;
}

.entity-toolbar input {
  flex: 1;
  min-width: 180px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font: inherit;
  padding: 0.72rem 0.8rem;
  outline: none;
  background: white;
}

.entity-toolbar input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.entity-toolbar-actions {
  display: flex;
  gap: 0.55rem;
}

.entity-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.1rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.entity-numbered-card {
  position: relative;
  padding-top: 3.55rem;
}

.entity-number-label {
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.45rem 0.9rem;
  border-radius: 7px 0 10px 0;
  background: hsl(var(--entity-number-hue) 85% 92%);
  color: hsl(var(--entity-number-hue) 70% 28%);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.entity-card:hover {
  border-color: #bfdbfe;
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.entity-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: -0.2rem 0 1rem 50px;
}

.entity-card-action,
.entity-danger-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 800;
  padding: 0.52rem 0.75rem;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.entity-card-action {
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-secondary);
}

.entity-card-action:not(:disabled):hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  transform: translateY(-1px);
}

.entity-card-action.danger,
.entity-danger-action {
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #be123c;
}

.entity-card-action.danger:not(:disabled):hover,
.entity-danger-action:not(:disabled):hover {
  border-color: #fb7185;
  background: #ffe4e6;
  color: #9f1239;
  transform: translateY(-1px);
}

.entity-card-action:disabled,
.entity-danger-action:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.entity-disabled-tooltip {
  position: relative;
  display: inline-flex;
  width: fit-content;
}

.entity-disabled-tooltip::before,
.entity-disabled-tooltip::after {
  position: absolute;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.16s ease, transform 0.16s ease;
  z-index: 30;
}

.entity-disabled-tooltip::before {
  content: "";
  bottom: calc(100% + 2px);
  border: 6px solid transparent;
  border-top-color: #0f172a;
}

.entity-disabled-tooltip::after {
  content: attr(data-tooltip);
  bottom: calc(100% + 14px);
  max-width: min(240px, 80vw);
  width: max-content;
  border-radius: 8px;
  background: #0f172a;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.25;
  padding: 0.48rem 0.62rem;
  text-align: center;
  white-space: normal;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
}

.entity-disabled-tooltip.tooltip-below::before,
.entity-disabled-tooltip.tooltip-below::after {
  bottom: auto;
  transform: translate(-50%, -4px);
}

.entity-disabled-tooltip.tooltip-below::before {
  top: calc(100% + 2px);
  border-top-color: transparent;
  border-bottom-color: #0f172a;
}

.entity-disabled-tooltip.tooltip-below::after {
  top: calc(100% + 14px);
}

.entity-disabled-tooltip.tooltip-align-end::after {
  right: 0;
  left: auto;
  transform: translate(0, -4px);
}

.entity-disabled-tooltip:hover::before,
.entity-disabled-tooltip:hover::after,
.entity-disabled-tooltip:focus-visible::before,
.entity-disabled-tooltip:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.entity-disabled-tooltip.tooltip-align-end:hover::after,
.entity-disabled-tooltip.tooltip-align-end:focus-visible::after {
  transform: translate(0, 0);
}

.entity-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.entity-avatar {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #dbeafe;
  color: var(--primary-dark);
  font-weight: 800;
}

.entity-card-title {
  min-width: 0;
  flex: 1;
}

.entity-card-title h2 {
  color: var(--text-primary);
  font-size: 1.02rem;
  line-height: 1.3;
  margin: 0 0 0.2rem;
  overflow-wrap: anywhere;
}

.entity-card-title p {
  color: var(--text-muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.status-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.28rem 0.55rem;
}

.status-active {
  background: #dcfce7;
  color: #166534;
}

.status-inactive {
  background: #f1f5f9;
  color: #475569;
}

.entity-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.entity-summary-item {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem;
  background: #f8fafc;
  border: 1px solid #eef2f7;
  border-radius: 8px;
}

.entity-summary-item span,
.entity-detail-grid span,
.entity-field span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.entity-summary-item strong {
  color: var(--text-primary);
  font-size: 0.86rem;
  text-align: right;
  overflow-wrap: anywhere;
}

.entity-details {
  border-top: 1px solid var(--border-color);
  padding-top: 0.85rem;
}

.entity-details summary {
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 800;
}

.entity-details[open] summary {
  margin-bottom: 0.85rem;
}

.entity-detail-grid {
  display: grid;
  gap: 0.8rem;
}

.entity-detail-grid p {
  color: var(--text-primary);
  font-size: 0.9rem;
  margin-top: 0.15rem;
  overflow-wrap: anywhere;
}

.entity-empty-state,
.entity-warning {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #f8fafc;
  padding: 1.5rem;
}

.entity-empty-state {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.7rem;
}

.entity-empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ecfdf5;
  color: #047857;
  font-weight: 900;
}

.entity-empty-state h2 {
  font-size: 1.2rem;
  margin: 0;
}

.entity-empty-state p,
.entity-warning p {
  color: var(--text-secondary);
  max-width: 680px;
}

.entity-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(15, 23, 42, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.entity-modal-overlay.stacked {
  z-index: 140;
}

.entity-modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: white;
  border-radius: 8px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  padding: 1.25rem;
}

.entity-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.entity-modal-header h2 {
  font-size: 1.25rem;
  margin: 0;
}

.entity-icon-button {
  width: 36px;
  height: 36px;
  background: #f1f5f9;
  color: var(--text-secondary);
}

.entity-icon-button:hover {
  background: #e2e8f0;
  color: var(--text-primary);
}

.entity-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.entity-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.entity-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.entity-field input,
.entity-field select,
.entity-field textarea {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font: inherit;
  padding: 0.75rem 0.8rem;
  outline: none;
  background: white;
}

.entity-field textarea {
  resize: vertical;
}

.entity-field input:focus,
.entity-field select:focus,
.entity-field textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.entity-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-secondary);
  font-weight: 700;
}

.entity-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
}

.entity-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
}

.entity-confirm-modal {
  width: min(480px, 100%);
}

.entity-confirm-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
}

.entity-confirm-body p {
  color: var(--text-secondary);
  margin: 0;
}

.entity-confirm-body strong {
  color: #9f1239;
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.entity-impact-body {
  animation: entityImpactPulse 0.85s steps(2, start) infinite;
}

.entity-confirm-body .entity-impact-target {
  color: var(--text-primary);
  font-weight: 700;
}

.entity-confirm-body .entity-impact-warning,
.entity-impact-body .entity-impact-count,
.entity-impact-body .entity-impact-count strong,
.entity-impact-body .entity-impact-danger {
  color: var(--home-danger, #dc2626);
  font-weight: 800;
}

.entity-confirm-body .entity-impact-section-title {
  color: var(--text-primary);
  font-weight: 700;
}

.entity-impact-body ul {
  color: var(--text-secondary);
  margin: 0;
  padding-left: 1.1rem;
}

.entity-impact-body li {
  margin: 0.35rem 0;
}

@keyframes entityImpactPulse {
  0%,
  100% {
    border-color: #fecaca;
    background: #fff1f2;
    box-shadow: 0 0 0 rgba(220, 38, 38, 0);
  }

  50% {
    border-color: #ef4444;
    background: #ffe4e6;
    box-shadow: 0 0 18px rgba(220, 38, 38, 0.45);
  }
}

@media (prefers-reduced-motion: reduce) {
  .entity-impact-body {
    animation: none;
  }
}

.entity-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #f8fafc;
}

.entity-pagination p,
.entity-pagination span {
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 700;
}

.entity-pagination-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.entity-secondary-action:disabled {
  color: var(--text-muted);
  background: #f1f5f9;
  border-color: var(--border-color);
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .entity-page-header,
  .entity-form-actions,
  .entity-toolbar,
  .entity-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .entity-primary-action,
  .entity-secondary-action {
    width: 100%;
  }

  .entity-title-group {
    gap: 0.7rem;
  }

  .entity-title-icon {
    width: 42px;
    height: 42px;
  }

  .entity-title-icon img {
    width: 22px;
    height: 22px;
  }

  .entity-form-grid {
    grid-template-columns: 1fr;
  }

  .entity-toolbar-actions,
  .entity-pagination-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .entity-card-header {
    flex-wrap: wrap;
  }

  .entity-card-actions {
    display: grid;
    grid-template-columns: 1fr;
    margin-left: 0;
  }

  .status-badge {
    margin-left: 50px;
  }
}
