:root {
  --app-ink: #17202e;
  --app-muted: #637083;
  --app-border: #d9e1ec;
  --app-panel: #ffffff;
  --app-soft: #f4f7fb;
  --app-navy: #14213d;
  --app-teal: #0f766e;
  --app-gold: #c88719;
  --app-danger: #c2410c;
  --app-shadow: 0 18px 45px rgba(20, 33, 61, 0.12);
}

html {
  font-size: 14px;
  min-height: 100%;
  position: relative;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  color: var(--app-ink);
  margin-bottom: 0;
  min-height: 100vh;
}

.app-body {
  background:
    radial-gradient(circle at 12% -12%, rgba(15, 118, 110, 0.16), transparent 34rem),
    linear-gradient(180deg, #eef4f9 0%, #f8fafc 42%, #eef2f7 100%);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-navbar {
  background: linear-gradient(135deg, #10213f 0%, #15375d 52%, #0f766e 100%);
  box-shadow: 0 14px 35px rgba(20, 33, 61, 0.26);
  padding: 0.85rem 1rem;
}

.app-brand {
  align-items: center;
  color: #fff !important;
  display: inline-flex;
  gap: 0.75rem;
  min-width: 15rem;
}

.app-brand-mark {
  align-items: center;
  background: #f7f1de;
  border-radius: 0.5rem;
  color: #14213d;
  display: inline-flex;
  font-weight: 800;
  height: 2.5rem;
  justify-content: center;
  letter-spacing: 0;
  width: 2.5rem;
}

.app-brand-title,
.app-brand-subtitle,
.dropdown-item-title,
.dropdown-item-subtitle {
  display: block;
}

.app-brand-title {
  font-weight: 750;
  line-height: 1.1;
}

.app-brand-subtitle {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.78rem;
  line-height: 1.1;
}

.app-navbar .navbar-toggler {
  border-color: rgba(255, 255, 255, 0.28);
}

.app-navbar .navbar-toggler-icon {
  filter: invert(1) grayscale(1) brightness(2);
}

.app-nav-main,
.app-nav-user {
  align-items: center;
  gap: 0.25rem;
}

.app-navbar .nav-link {
  border-radius: 0.45rem;
  color: rgba(255, 255, 255, 0.84) !important;
  font-weight: 650;
  padding: 0.55rem 0.8rem;
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link:focus {
  background: rgba(255, 255, 255, 0.12);
  color: #fff !important;
}

.app-user-name {
  color: rgba(255, 255, 255, 0.72) !important;
  font-weight: 500 !important;
  max-width: 15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-nav-button {
  background: #f7f1de;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 0.45rem;
  color: #14213d !important;
  font-weight: 750;
  padding: 0.45rem 0.85rem;
}

.app-nav-button:hover,
.app-nav-button:focus {
  background: #fff;
  color: #0f172a !important;
}

.app-dropdown {
  border: 0;
  border-radius: 0.6rem;
  box-shadow: var(--app-shadow);
  min-width: 18rem;
  overflow: hidden;
  padding: 0.45rem;
}

.app-dropdown .dropdown-item {
  border-radius: 0.45rem;
  padding: 0.7rem 0.85rem;
}

.app-dropdown .dropdown-item:hover,
.app-dropdown .dropdown-item:focus {
  background: #e9f5f3;
}

.dropdown-item-title {
  color: var(--app-ink);
  font-weight: 750;
}

.dropdown-item-subtitle {
  color: var(--app-muted);
  font-size: 0.78rem;
  margin-top: 0.1rem;
}

.app-container {
  max-width: 1900px;
  padding: 1.35rem;
}

.app-main {
  min-height: calc(100vh - 9rem);
}

.app-footer {
  color: var(--app-muted);
  font-size: 0.9rem;
  padding: 0 1.35rem 1.25rem;
}

.app-footer .container-fluid {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  max-width: 1900px;
}

.app-footer a {
  color: var(--app-teal);
  font-weight: 650;
  text-decoration: none;
}

.page-heading {
  align-items: flex-end;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.page-heading h1 {
  font-size: clamp(1.45rem, 2.2vw, 2.2rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.15;
  margin: 0;
}

.page-heading p {
  color: var(--app-muted);
  margin: 0.35rem 0 0;
  max-width: 52rem;
}

.page-eyebrow {
  color: var(--app-teal);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

.page-panel {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 0.65rem;
  box-shadow: var(--app-shadow);
  padding: 1.2rem;
}

.dashboard-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.module-card {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 0.65rem;
  box-shadow: var(--app-shadow);
  color: var(--app-ink);
  display: block;
  min-height: 12rem;
  padding: 1.2rem;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.module-card:hover,
.module-card:focus {
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 24px 55px rgba(20, 33, 61, 0.17);
  color: var(--app-ink);
  transform: translateY(-2px);
}

.module-kicker {
  color: var(--app-gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.module-part-number {
  font-size: 1rem;
  font-weight: 900;
}

.module-card h2 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0.8rem 0 0.45rem;
}

.module-card p {
  color: var(--app-muted);
  margin: 0;
}

.auth-shell {
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 0.9fr) minmax(20rem, 0.55fr);
}

.auth-aside {
  background: linear-gradient(135deg, #14213d, #0f766e);
  border-radius: 0.65rem;
  box-shadow: var(--app-shadow);
  color: #fff;
  min-height: 28rem;
  padding: 2rem;
}

.auth-aside h1 {
  font-size: clamp(1.7rem, 3vw, 3rem);
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.05;
  margin: 0 0 1rem;
  max-width: 42rem;
}

.auth-aside p {
  color: rgba(255, 255, 255, 0.76);
  max-width: 40rem;
}

.auth-card {
  align-self: start;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 0.65rem;
  box-shadow: var(--app-shadow);
  padding: 1.4rem;
}

.form-control,
.form-select {
  border-color: #cbd5e1;
  border-radius: 0.45rem;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus {
  border-color: var(--app-teal);
  box-shadow: 0 0 0 0.2rem rgba(15, 118, 110, 0.18);
}

.btn {
  border-radius: 0.45rem;
  font-weight: 700;
}

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

.btn-primary:hover,
.btn-primary:focus {
  background: #0f766e;
  border-color: #0f766e;
}

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

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

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

.table {
  color: var(--app-ink);
}

.table thead th {
  font-size: 0.8rem;
  font-weight: 800;
}

.table-responsive,
.register-grid-scroll,
.inspection-grid-scroll {
  background: #fff;
  border-radius: 0.65rem;
  box-shadow: var(--app-shadow);
}

.register-grid-scroll,
.inspection-grid-scroll {
  border-color: var(--app-border) !important;
}

.register-sheet {
  box-shadow: none;
}

.register-sheet thead th.register-datetime-column,
.register-sheet tbody td.register-datetime-column {
  max-width: calc(30mm + 10px);
  min-width: calc(30mm + 10px);
  width: calc(30mm + 10px);
}

.register-sheet thead th.register-filter-header {
  padding: 0.2rem;
}

.register-filter-title {
  display: block;
  font-weight: 800;
  margin-bottom: 0.18rem;
}

.register-result-filter,
.register-casting-filter,
.register-date-filter {
  font-size: 0.72rem;
  font-weight: 650;
  min-height: 1.7rem;
}

.register-result-filter {
  padding: 0.12rem 1.45rem 0.12rem 0.25rem;
}

.register-casting-filter,
.register-date-filter {
  padding: 0.12rem 0.25rem;
}

.register-result-count {
  background: #fff;
  border: 1px solid var(--app-border);
  border-bottom: 0;
  color: #334155;
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
}

.register-sheet tbody tr[data-virtual-row="true"] {
  height: 34px;
}

.register-sheet .virtual-spacer-cell {
  border: 0;
  height: 0;
  padding: 0;
}

.po-number-field {
  position: relative;
}

.po-number-help {
  left: calc(var(--bs-gutter-x) * 0.5);
  margin-top: 0.25rem;
  position: absolute;
  right: calc(var(--bs-gutter-x) * 0.5);
  top: 100%;
}

.register-sheet thead tr:first-child th:first-child {
  box-shadow: 0.45rem 0 0.55rem -0.45rem rgba(20, 33, 61, 0.35);
  left: 0;
  z-index: 8;
}

.register-sheet thead tr:last-child th:nth-child(-n + 5),
.register-sheet tbody td:nth-child(-n + 5) {
  background-color: #fff;
  background-clip: padding-box;
  box-shadow: inset -1px 0 0 #7f8fa6;
  position: sticky;
}

.register-sheet thead tr:last-child th:nth-child(-n + 5) {
  background-color: #d9eaf7;
  z-index: 7;
}

.register-sheet tbody td:nth-child(-n + 5) {
  z-index: 2;
}

.register-sheet thead tr:last-child th:nth-child(1),
.register-sheet tbody td:nth-child(1) {
  left: 0;
}

.register-sheet thead tr:last-child th:nth-child(2),
.register-sheet tbody td:nth-child(2) {
  left: 16mm;
}

.register-sheet thead tr:last-child th:nth-child(3),
.register-sheet tbody td:nth-child(3) {
  left: 61mm;
}

.register-sheet thead tr:last-child th:nth-child(4),
.register-sheet tbody td:nth-child(4) {
  left: 91mm;
}

.register-sheet thead tr:last-child th:nth-child(5),
.register-sheet tbody td:nth-child(5) {
  left: 121mm;
}

.register-sheet thead tr:last-child th:nth-child(5),
.register-sheet tbody td:nth-child(5) {
  box-shadow:
    inset -1px 0 0 #7f8fa6,
    0.45rem 0 0.55rem -0.45rem rgba(20, 33, 61, 0.35);
}

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

.role-group {
  border: 1px solid var(--app-border);
  border-radius: 0.55rem;
  padding: 0.85rem;
}

.role-group-title {
  color: var(--app-navy);
  font-size: 0.82rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
}

.role-group .form-check {
  margin-bottom: 0.45rem;
}

.role-label {
  color: var(--app-muted);
  font-size: 0.86rem;
}

.alert {
  border: 0;
  border-radius: 0.55rem;
  box-shadow: 0 12px 28px rgba(20, 33, 61, 0.08);
}

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

@media (max-width: 991.98px) {
  .app-navbar {
    padding: 0.75rem;
  }

  .app-nav-main,
  .app-nav-user {
    align-items: stretch;
    padding-top: 0.75rem;
  }

  .app-user-name {
    max-width: none;
  }

  .dashboard-grid,
  .auth-shell,
  .role-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 575.98px) {
  .app-container {
    padding: 1rem 0.75rem;
  }

  .app-footer {
    padding-inline: 0.75rem;
  }

  .app-footer .container-fluid {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .page-panel,
  .module-card,
  .auth-card,
  .auth-aside {
    padding: 1rem;
  }
}
