:root {
  --app-primary: #1957a6;
  --app-primary-dark: #12447f;
  --app-bg: #f4f7fb;
  --app-surface: #ffffff;
  --app-text: #172033;
  --app-muted: #5f6b7c;
  --app-border: #dce3ec;
  --app-focus: rgba(25, 87, 166, 0.28);
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  background: var(--app-bg);
  color: var(--app-text);
  font-size: 1rem;
  line-height: 1.55;
}

.app-container {
  max-width: 1240px;
}

.navbar-brand {
  color: var(--app-primary);
}

.navbar .nav-link {
  border-radius: 0.5rem;
  color: #42506a;
  margin-inline: 0.125rem;
  padding-inline: 0.75rem;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus-visible {
  background: #edf3fb;
  color: var(--app-primary-dark);
}

.navbar .nav-link.active {
  background: #e6effb;
  color: var(--app-primary-dark);
  font-weight: 600;
}

.skip-link {
  background: var(--app-text);
  color: #fff;
  left: 1rem;
  padding: 0.75rem 1rem;
  position: fixed;
  top: -5rem;
  z-index: 2000;
}

.skip-link:focus {
  top: 1rem;
}

.auth-shell {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.auth-card {
  max-width: 480px;
  width: 100%;
}

.content-narrow {
  margin-inline: auto;
  max-width: 760px;
}

.card {
  border-radius: 1rem;
}

.card-header {
  border-radius: 1rem 1rem 0 0 !important;
}

.eyebrow {
  color: var(--app-primary);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.text-secondary {
  color: var(--app-muted) !important;
}

.btn {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 44px;
}

.btn-sm {
  min-height: 36px;
}

.btn-primary {
  background: var(--app-primary);
  border-color: var(--app-primary);
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: var(--app-primary-dark);
  border-color: var(--app-primary-dark);
}

.form-control,
.form-select,
.input-group .btn {
  min-height: 44px;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus-visible,
.page-link:focus-visible,
.nav-link:focus-visible {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.25rem var(--app-focus);
  outline: 0;
}

.form-label {
  font-weight: 600;
}

.table > :not(caption) > * > * {
  border-color: var(--app-border);
  padding: 1rem;
}

.table thead th {
  background: #f8fafc;
  color: #536077;
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.error-detail {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-actions {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.mobile-record-list {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.mobile-record {
  border: 1px solid var(--app-border);
  border-radius: 0.875rem;
  min-width: 0;
  padding: 1rem;
}

.mobile-record-header {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
}

.mobile-record-title {
  font-size: 1.125rem;
  font-weight: 700;
  line-height: 1.35;
}

.mobile-record-details {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 1rem 0 0;
}

.mobile-record-details > div {
  min-width: 0;
}

.mobile-record-details dt {
  color: var(--app-muted);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.125rem;
}

.mobile-record-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.mobile-record-error {
  background: #fff2f3;
  border-radius: 0.625rem;
  color: #b4232f;
  font-size: 0.875rem;
  margin-top: 1rem;
  overflow-wrap: anywhere;
  padding: 0.75rem;
}

.mobile-record-actions {
  border-top: 1px solid var(--app-border);
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
  padding-top: 1rem;
}

.mobile-record-actions > *,
.mobile-record-actions .btn {
  min-width: 0;
  width: 100%;
}

.mobile-record-primary-action {
  grid-column: 1 / -1;
}

.empty-state {
  padding: 4rem 1.5rem;
  text-align: center;
}

.back-link {
  color: var(--app-primary);
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.page-link {
  color: var(--app-primary);
  min-height: 42px;
  min-width: 42px;
  text-align: center;
}

.page-item.active .page-link {
  background: var(--app-primary);
  border-color: var(--app-primary);
}

.list-pagination-wrap {
  border-top: 1px solid var(--app-border);
  padding-top: 1rem !important;
}

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

.list-pagination-controls,
.pagination-size-control {
  align-items: center;
  display: flex;
  gap: 0.75rem;
}

.pagination-size-control .form-select {
  min-width: 92px;
  width: auto;
}

.pagination {
  flex-wrap: nowrap;
}

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

@media (max-width: 991.98px) {
  .navbar-collapse {
    padding-block: 1rem;
  }

  .navbar-nav {
    gap: 0.25rem;
  }

  .navbar-collapse form .btn {
    width: 100%;
  }

  .responsive-list-card .card-header {
    padding: 1.25rem 1rem 0.75rem !important;
  }
}

@media (max-width: 575.98px) {
  .navbar-brand {
    font-size: 1.125rem;
  }

  .navbar-toggler {
    min-height: 44px;
    min-width: 44px;
    padding: 0.375rem 0.625rem;
  }

  main.app-container {
    padding-bottom: 2rem !important;
    padding-top: 1.5rem !important;
  }

  .auth-shell {
    align-items: flex-start;
    padding: 1rem;
  }

  .auth-card {
    margin-top: 8vh;
  }

  .card-body {
    padding-inline: 1rem;
  }

  .content-narrow .card-body {
    padding: 1.25rem !important;
  }

  .mobile-full-width {
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  .list-pagination {
    align-items: stretch;
    flex-direction: column;
  }

  .list-pagination-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-size-control {
    justify-content: space-between;
  }

  .pagination {
    justify-content: center;
    width: 100%;
  }

  .pagination-page-number:not(.active) {
    display: none;
  }

  .page-link {
    align-items: center;
    display: flex;
    justify-content: center;
    min-height: 44px;
  }

  .mobile-record-details {
    gap: 0.875rem 1rem;
  }

  .empty-state {
    padding: 3rem 1rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
