body {
  min-height: 100vh;
  background-color: var(--bs-tertiary-bg);
}

.app-logo {
  max-height: 44px;
  width: auto;
  flex: 0 0 auto;
  object-fit: contain;
}

@media (max-width: 767.98px) {
  .app-logo {
    max-height: 36px;
  }
}

[data-bs-theme="light"] .btn {
  box-shadow: 0 0.08rem 0.2rem rgba(15, 23, 42, 0.1);
}

[data-bs-theme="light"] .btn-primary {
  background: #2563eb;
  border-color: #1d4ed8;
  box-shadow: 0 0.14rem 0.4rem rgba(37, 99, 235, 0.24);
}

[data-bs-theme="light"] .btn-outline-secondary {
  color: #1f2937;
  border-color: #94a3b8;
  background: #dbe4ef;
}

[data-bs-theme="light"] .btn-outline-secondary:hover,
[data-bs-theme="light"] .btn-outline-secondary:focus,
[data-bs-theme="light"] .btn-outline-secondary:active,
[data-bs-theme="light"] .btn-outline-secondary.active {
  color: #0f172a;
  border-color: #64748b;
  background: #cbd7e6;
}

[data-bs-theme="light"] .btn-outline-primary,
[data-bs-theme="light"] .btn-outline-success,
[data-bs-theme="light"] .btn-outline-warning,
[data-bs-theme="light"] .btn-outline-danger {
  background: #e8eef5;
}

[data-bs-theme="light"] .btn-outline-primary:hover,
[data-bs-theme="light"] .btn-outline-primary:focus,
[data-bs-theme="light"] .btn-outline-primary:active,
[data-bs-theme="light"] .btn-outline-primary.active {
  background: #cfe0ff;
}

[data-bs-theme="light"] .btn-outline-success:hover,
[data-bs-theme="light"] .btn-outline-success:focus,
[data-bs-theme="light"] .btn-outline-success:active,
[data-bs-theme="light"] .btn-outline-success.active {
  background: #cfeedd;
}

[data-bs-theme="light"] .btn-outline-warning:hover,
[data-bs-theme="light"] .btn-outline-warning:focus,
[data-bs-theme="light"] .btn-outline-warning:active,
[data-bs-theme="light"] .btn-outline-warning.active {
  background: #f6e3ad;
}

[data-bs-theme="light"] .btn-outline-danger:hover,
[data-bs-theme="light"] .btn-outline-danger:focus,
[data-bs-theme="light"] .btn-outline-danger:active,
[data-bs-theme="light"] .btn-outline-danger.active {
  background: #f5cfd2;
}

.portal-intro {
  border: 1px solid var(--bs-border-color);
  border-radius: 1rem;
  padding: 1rem 1.1rem;
  background:
    radial-gradient(circle at top left, rgba(13, 110, 253, 0.16), transparent 38%),
    linear-gradient(135deg, var(--bs-body-bg), var(--bs-tertiary-bg));
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.06);
}

.auth-shell {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 1.5rem;
  background:
    radial-gradient(circle at top left, rgba(13, 110, 253, 0.18), transparent 38%),
    radial-gradient(circle at bottom right, rgba(25, 135, 84, 0.16), transparent 42%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(248, 249, 250, 0.92));
  box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.12);
}

[data-bs-theme="dark"] .auth-shell {
  background:
    radial-gradient(circle at top left, rgba(13, 110, 253, 0.24), transparent 38%),
    radial-gradient(circle at bottom right, rgba(25, 135, 84, 0.18), transparent 42%),
    linear-gradient(145deg, rgba(33, 37, 41, 0.96), rgba(24, 26, 27, 0.94));
}

.auth-shell::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 12rem;
  height: 12rem;
  background: linear-gradient(135deg, rgba(13, 110, 253, 0.24), rgba(13, 110, 253, 0));
  border-radius: 50%;
  transform: translate(-30%, -35%);
  pointer-events: none;
}

.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(13, 110, 253, 0.1);
  color: var(--bs-primary-text-emphasis);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.auth-badge::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.75;
}

.auth-title {
  font-size: clamp(1.8rem, 2vw, 2.4rem);
  line-height: 1.1;
}

.portal-card {
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border-radius: 1rem;
}

.portal-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.portal-modal {
  border: 1px solid var(--bs-border-color);
  border-radius: 1.25rem;
  overflow: hidden;
  box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.14);
}

.portal-modal .modal-header {
  border-bottom-color: var(--bs-border-color);
  background:
    radial-gradient(circle at top left, rgba(13, 110, 253, 0.12), transparent 42%),
    linear-gradient(135deg, var(--bs-body-bg), var(--bs-tertiary-bg));
}

.portal-modal .modal-footer {
  border-top-color: var(--bs-border-color);
}

.portal-modal .form-control,
.portal-modal .form-select,
.portal-modal textarea {
  border-radius: 0.8rem;
}

.portal-kpi,
.admin-summary-card,
.admin-card {
  border: 1px solid var(--bs-border-color);
  border-radius: 1rem;
  padding: 1rem;
  background: var(--bs-body-bg);
  height: 100%;
  box-shadow: 0 0.35rem 0.9rem rgba(0, 0, 0, 0.05);
}

.portal-kpi-grid {
  display: grid;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
}

.portal-kpi-grid--steps {
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}

.portal-kpi-grid--summary {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
}

.portal-kpi-grid .portal-kpi {
  padding: 0.8rem 0.9rem;
  border-radius: 0.9rem;
  box-shadow: 0 0.25rem 0.7rem rgba(0, 0, 0, 0.045);
}

.portal-kpi-grid .h5 {
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.portal-kpi-grid--summary .portal-kpi {
  flex: 0 0 9rem;
  min-width: 9rem;
}

.portal-kpi-grid--summary .portal-kpi--status {
  flex-basis: 18rem;
  min-width: 18rem;
}

.portal-shell-header {
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.portal-table {
  margin-bottom: 0;
}

.portal-table th {
  white-space: nowrap;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--bs-secondary-color);
  border-bottom-width: 1px;
}

.portal-table td,
.portal-table th {
  vertical-align: middle;
}

.portal-table tbody tr:last-child td {
  border-bottom: 0;
}

.portal-ping-link {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  color: inherit;
  text-decoration: none;
}

.portal-ping-link:hover,
.portal-ping-link:focus-visible {
  color: inherit;
  text-decoration: none;
}

.portal-ping-link:focus-visible {
  outline: 2px solid rgba(13, 110, 253, 0.35);
  outline-offset: 3px;
  border-radius: 0.4rem;
}

.portal-ping-link:hover .badge,
.portal-ping-link:focus-visible .badge {
  box-shadow: 0 0 0 0.15rem rgba(13, 110, 253, 0.18);
}

.table-sortable thead th[data-sortable-column="1"],
.table-sort-linked thead th[data-sort-linked="1"] {
  cursor: pointer;
  user-select: none;
}

.table-sortable thead th[data-sortable-column="1"] {
  position: relative;
  padding-right: 1.7rem;
}

.table-sortable thead th[data-sortable-column="1"]::after {
  content: "↕";
  position: absolute;
  right: 0.55rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  opacity: 0.42;
}

.table-sortable thead th[data-sortable-column="1"][aria-sort="ascending"]::after {
  content: "↑";
  opacity: 0.9;
}

.table-sortable thead th[data-sortable-column="1"][aria-sort="descending"]::after {
  content: "↓";
  opacity: 0.9;
}

.table-sortable thead th[data-sortable-column="1"]:focus-visible,
.table-sort-linked thead th[data-sort-linked="1"]:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: -2px;
}

.table-sort-header-link {
  color: inherit;
  text-decoration: none;
}

.portal-code {
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bs-dark);
  color: #fff;
  border-radius: 0.75rem;
  padding: 1rem;
  font-size: 0.875rem;
  margin: 0;
}

.portal-log-line {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--bs-font-monospace);
  font-size: 0.875rem;
}

.portal-diff {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.portal-diff-chunk {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.85rem;
  overflow: hidden;
  background: var(--bs-body-bg);
}

.portal-diff-chunk-header {
  padding: 0.55rem 0.85rem;
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
  background: var(--bs-tertiary-bg);
  border-bottom: 1px solid var(--bs-border-color);
}

.portal-diff-code {
  background: var(--bs-dark);
  color: #fff;
  font-family: var(--bs-font-monospace);
  font-size: 0.84rem;
}

.portal-diff-line {
  display: grid;
  grid-template-columns: 3rem 3rem 1rem minmax(0, 1fr);
  gap: 0.75rem;
  padding: 0.22rem 0.85rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.portal-diff-line-context {
  color: rgba(255, 255, 255, 0.7);
}

.portal-diff-line-added {
  background: rgba(25, 135, 84, 0.2);
}

.portal-diff-line-removed {
  background: rgba(220, 53, 69, 0.22);
}

.portal-diff-line-number,
.portal-diff-line-prefix {
  color: rgba(255, 255, 255, 0.55);
  user-select: none;
}

.portal-diff-line-number {
  text-align: right;
}

.portal-diff-line-prefix {
  font-weight: 700;
}

.portal-diff-line-text {
  min-width: 0;
}

.portal-diff-full-profiles {
  border: 1px solid var(--bs-border-color);
  border-radius: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--bs-body-bg);
}

.portal-diff-full-profiles summary {
  cursor: pointer;
  font-weight: 600;
}

.portal-diff-full-profiles[open] summary {
  margin-bottom: 0.75rem;
}

.portal-muted-note {
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
}

.portal-actions-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.portal-actions-inline-compact {
  gap: 0.35rem;
}

.portal-actions-inline > form {
  margin: 0;
}

.portal-actions-cell {
  container-type: inline-size;
}

.portal-actions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  width: 100%;
}

.portal-actions-grid .btn {
  width: 100%;
  height: 100%;
  white-space: normal;
  line-height: 1.15;
  text-align: center;
}

@container (min-width: 11rem) {
  .portal-actions-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@container (min-width: 17rem) {
  .portal-actions-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.portal-table-compact td,
.portal-table-compact th {
  padding-top: 0.55rem;
  padding-bottom: 0.55rem;
}

.portal-inline-details {
  margin-top: 0.4rem;
}

.portal-inline-details summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--bs-secondary-color);
}

.portal-inline-details[open] summary {
  margin-bottom: 0.5rem;
}

.portal-form-card .form-control,
.portal-form-card .form-select,
.portal-form-card textarea {
  border-radius: 0.75rem;
}

.portal-form-card .btn,
.portal-toolbar .btn {
  border-radius: 999px;
}

.portal-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.portal-toolbar-search {
  min-width: min(100%, 22rem);
}

.portal-subtitle {
  color: var(--bs-secondary-color);
  margin-bottom: 0;
}

.portal-stat {
  font-size: 2.25rem;
  font-weight: 600;
  line-height: 1;
}

.portal-kpi-grid .portal-stat {
  font-size: clamp(1.45rem, 2vw, 1.95rem);
}

.portal-kpi-grid--summary .portal-stat {
  font-size: clamp(1.25rem, 1.6vw, 1.7rem);
}

.portal-badges {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

[data-bs-theme="dark"] .portal-intro {
  background:
    radial-gradient(circle at top left, rgba(110, 168, 254, 0.18), transparent 38%),
    linear-gradient(135deg, rgba(13, 17, 23, 0.9), rgba(33, 37, 41, 0.92));
}

[data-bs-theme="dark"] .portal-code {
  background: #0d1117;
}

[data-bs-theme="dark"] .portal-diff-code {
  background: #0d1117;
}

@media (min-width: 768px) {
  .admin-grid > [class*="col-"] {
    display: flex;
  }

  .admin-grid .card,
  .admin-grid .admin-summary-card {
    width: 100%;
  }
}

@media (max-width: 767px) {
  .portal-shell-header {
    position: static;
  }

  .portal-stat {
    font-size: 1.8rem;
  }
}
