:root {
  --ink: #17202a;
  --muted: #64707d;
  --line: #d9e1ea;
  --surface: #ffffff;
  --field: #f7f9fb;
  --brand: #2f4f6f;
  --brand-dark: #1c2938;
  --accent: #bd6f24;
  --success: #1f7a4f;
  --danger: #a33b3b;
  --shadow: 0 12px 30px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background: #eef1f4;
  font-family: Aptos, "Segoe UI", Arial, sans-serif;
}

.guest-shell {
  background: #e7ebef;
}

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

.authenticated-shell .app-main {
  flex: 1;
}

a {
  color: var(--brand);
}

.app-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
}

.app-header {
  background: var(--brand-dark);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 10px 28px rgba(28, 41, 56, 0.18);
}

.app-header .navbar {
  padding: 8px 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}

.brand-mark:hover,
.brand-mark:focus {
  color: #fff;
}

.brand-mark small {
  display: block;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.74rem;
}

.brand-symbol {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

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

.navbar-toggler-icon {
  filter: invert(1);
}

.nav-link,
.nav-link:hover,
.nav-link:focus {
  color: #fff;
}

.app-header .nav-link {
  position: relative;
  margin: 0 2px;
  padding-right: 12px;
  padding-left: 12px;
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.92rem;
  font-weight: 650;
}

.app-header .nav-link:hover,
.app-header .nav-link:focus,
.app-header .nav-link.active {
  color: #fff;
}

.app-header .nav-link.active::after {
  position: absolute;
  right: 12px;
  bottom: 2px;
  left: 12px;
  height: 2px;
  content: "";
  background: var(--accent);
}

.nav-meta,
.nav-user {
  display: inline-block;
  padding: 8px 10px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.86rem;
}

.app-main {
  padding: 28px 0 48px;
}

.guest-shell .app-main {
  min-height: 100vh;
  padding: 0;
}

.guest-shell .app-main > .app-shell {
  width: 100%;
  max-width: none;
}

.app-footer {
  padding: 18px 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: #f7f9fb;
}

.login-surface {
  display: flex;
  min-height: 100vh;
  padding: 32px;
  align-items: center;
  justify-content: center;
}

.login-stage {
  display: grid;
  width: min(1160px, 100%);
  min-height: 610px;
  grid-template-columns: minmax(0, 1.3fr) minmax(380px, 450px);
  gap: 0;
  align-items: stretch;
  overflow: hidden;
  border: 1px solid rgba(28, 41, 56, 0.2);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 64px rgba(28, 41, 56, 0.18);
}

.workband,
.agreement-page {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  display: flex;
  min-height: 610px;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 50px;
  flex-direction: column;
  justify-content: center;
}

.login-visual {
  position: relative;
  min-height: 610px;
  overflow: hidden;
  border-right: 1px solid rgba(28, 41, 56, 0.2);
  background: var(--brand-dark);
}

.login-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-panel-header {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  color: var(--brand-dark);
  font-weight: 800;
}

.login-form {
  margin-top: 24px;
}

.login-form .command-button {
  min-height: 46px;
}

.workband,
.agreement-page {
  padding: 24px;
}

.workband,
.agreement-page {
  outline: 1px solid rgba(255, 255, 255, 0.7);
  outline-offset: -2px;
}

.workband.narrow {
  width: min(760px, 100%);
  margin: 0 auto;
}

.section-heading {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 22px;
}

.section-heading h1,
.login-panel h1 {
  margin: 0;
  font-size: 1.72rem;
  line-height: 1.18;
}

.section-eyebrow {
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted-copy,
.table-subtext {
  color: var(--muted);
}

.muted-copy {
  margin: 6px 0 0;
}

.stack-form {
  display: grid;
  gap: 16px;
  min-width: 0;
}

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

.grid-form.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid-form label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.form-control {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  color: var(--ink);
  background-color: var(--field);
  border-color: #c9d4df;
  border-radius: 6px;
}

.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.18rem rgba(47, 79, 111, 0.18);
}

.command-button,
.btn {
  border-radius: 6px;
  font-weight: 650;
}

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

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

.button-row,
.form-actions,
.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legacy-upgrade-panel {
  flex: 1 1 100%;
  min-width: 250px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
}

.legacy-upgrade-panel summary {
  cursor: pointer;
  color: var(--brand-dark);
  font-size: 0.84rem;
  font-weight: 750;
}

.legacy-upgrade-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.legacy-upgrade-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.role-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 6px 10px;
  min-width: 280px;
}

.role-grid label {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin: 0;
  font-size: 0.86rem;
}

.search-row {
  margin-bottom: 18px;
}

.search-row .form-control {
  flex: 1 1 320px;
  width: auto;
}

.search-row.live-search-enabled [data-live-search-submit] {
  display: none;
}

[data-customer-results] {
  transition: opacity 120ms ease;
}

[data-customer-results][aria-busy="true"] {
  opacity: 0.62;
}

.metric-pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #eef3f7;
  color: var(--brand-dark);
  font-size: 0.84rem;
  font-weight: 700;
}

.mono-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 8px;
  border: 1px solid #d4e1e8;
  border-radius: 6px;
  background: #f7f9fb;
  color: var(--brand-dark);
  font-family: Consolas, "Segoe UI Mono", monospace;
  font-size: 0.86rem;
  font-weight: 700;
}

.data-frame {
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.data-frame .table {
  margin-bottom: 0;
}

.agreement-table {
  margin-bottom: 20px;
}

.agreement-table .table {
  min-width: 620px;
}

.data-frame thead th {
  color: #41505b;
  background: #f3f7f9;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.data-frame tbody tr {
  transition: background-color 120ms ease, box-shadow 120ms ease;
}

.data-frame tbody tr:hover {
  background: #f8fbfc;
}

.table > :not(caption) > * > * {
  padding: 0.72rem 0.85rem;
}

.edit-section {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.edit-section.first {
  border-top: 0;
  padding-top: 0;
}

.edit-section h2,
.agreement-page h2 {
  margin: 0 0 14px;
  font-size: 1.12rem;
}

.section-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-row h2 {
  margin-bottom: 0;
}

.inline-check {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: .92rem;
  margin: 0;
}

.edit-table {
  min-width: 980px;
}

.wide-table .edit-table {
  min-width: 1320px;
}

.edit-table .form-control {
  min-width: 110px;
  min-height: 34px;
}

.row-command-cell {
  width: 1%;
  white-space: nowrap;
}

.row-marked-delete {
  opacity: 0.54;
}

.row-marked-delete td {
  background: #fbf1f1;
}

.archive-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #e1c7c7;
  border-radius: 8px;
  background: #fff7f5;
  color: #6f3e35;
}

.pricing-save-panel {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.pricing-form > .pricing-save-panel,
.sticky-actions {
  position: sticky;
  bottom: 12px;
  z-index: 20;
  box-shadow: 0 12px 28px rgba(28, 41, 56, 0.14);
}

.sticky-actions {
  display: flex;
  justify-content: flex-end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.pricing-save-panel div {
  display: grid;
  gap: 2px;
  margin-right: auto;
  color: var(--brand-dark);
}

.pricing-save-panel span {
  color: var(--muted);
  font-size: 0.88rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 10px 18px;
}

.detail-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.detail-grid.dense {
  grid-template-columns: 140px minmax(0, 1fr) 140px minmax(0, 1fr);
}

.detail-grid dt {
  color: var(--muted);
  font-weight: 700;
}

.detail-grid dd {
  margin: 0;
}

.copy-block {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
}

.empty-state {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 650;
  text-align: center;
}

.copy-block code {
  overflow-wrap: anywhere;
  color: var(--brand-dark);
}

.mfa-setup-grid {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin: 20px 0;
}

.mfa-qr-frame {
  display: grid;
  width: 190px;
  aspect-ratio: 1;
  padding: 12px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.mfa-qr-frame img {
  width: 100%;
  height: 100%;
}

.recovery-code-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 20px 0;
}

.recovery-code-grid code {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--brand-dark);
  text-align: center;
}

.admin-invite-panel {
  margin-bottom: 18px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.admin-invite-panel summary {
  cursor: pointer;
  color: var(--brand-dark);
  font-weight: 700;
}

.admin-invite-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(220px, 1fr);
  gap: 14px;
  align-items: end;
  margin-top: 16px;
}

.admin-invite-form fieldset {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
}

.admin-invite-form legend {
  float: none;
}

.choice-row {
  display: flex;
  gap: 7px;
  align-items: center;
}

.status-badge.status-active {
  background: #e4f3ea;
  color: #17613f;
}

.status-badge.status-locked {
  background: #f8e8e8;
  color: #8b2f2f;
}

.status-badge.status-archived {
  background: #e4e8ec;
  color: #4f5963;
}

.role-guide {
  margin: 1rem 0 1.15rem;
  padding: 1rem 0;
  border-top: 1px solid #d8e0e8;
  border-bottom: 1px solid #d8e0e8;
}

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

.role-guide-heading h2 {
  margin: 0.1rem 0 0;
  font-size: 1.15rem;
}

.role-guide-heading p {
  margin: 0;
  color: #5f6f7f;
  font-size: 0.9rem;
}

.role-guide-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 0;
}

.role-guide-grid > div {
  min-width: 0;
  padding: 0 0.9rem;
  border-left: 1px solid #e1e7ed;
}

.role-guide-grid > div:first-child {
  padding-left: 0;
  border-left: 0;
}

.role-guide-grid > div:last-child {
  padding-right: 0;
}

.role-guide-grid dt {
  margin-bottom: 0.3rem;
  color: #1d3448;
  font-size: 0.88rem;
  font-weight: 750;
}

.role-guide-grid dd {
  margin: 0;
  color: #5f6f7f;
  font-size: 0.82rem;
  line-height: 1.45;
}

@media (max-width: 1050px) {
  .role-guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem 0;
  }

  .role-guide-grid > div,
  .role-guide-grid > div:first-child {
    padding: 0 0.9rem;
    border-left: 1px solid #e1e7ed;
  }

  .role-guide-grid > div:nth-child(odd) {
    padding-left: 0;
    border-left: 0;
  }
}

@media (max-width: 620px) {
  .role-guide-heading {
    display: block;
  }

  .role-guide-heading p {
    margin-top: 0.45rem;
  }

  .role-guide-grid {
    grid-template-columns: 1fr;
  }

  .role-guide-grid > div,
  .role-guide-grid > div:first-child,
  .role-guide-grid > div:nth-child(odd) {
    padding: 0.7rem 0 0;
    border-top: 1px solid #e1e7ed;
    border-left: 0;
  }

  .role-guide-grid > div:first-child {
    padding-top: 0;
    border-top: 0;
  }
}

.trusted-device-option {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: #34495e;
    font-size: 0.94rem;
}

.trusted-device-option input {
    width: 1rem;
    height: 1rem;
    margin: 0;
}

.mfa-option-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1rem 0;
    color: #718096;
    font-size: 0.82rem;
    text-transform: uppercase;
}

.mfa-option-divider::before,
.mfa-option-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #d8e0e8;
}

.login-back-link {
    display: inline-block;
    margin-top: 1rem;
    color: #355a7d;
    font-weight: 600;
}

.status-badge.status-pending {
  background: #f5eddc;
  color: #735017;
}

.report-summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.report-field-groups {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.report-field-group {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.report-field-group legend {
  float: none;
  width: auto;
  margin-bottom: 10px;
  color: var(--brand-dark);
  font-size: 0.9rem;
  font-weight: 800;
}

.report-checkbox-grid {
  display: grid;
  gap: 8px;
}

.report-checkbox-grid .form-check,
.report-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.report-delete-form {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

.pagination-row {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.error-state {
  display: grid;
  gap: 14px;
  align-content: center;
  min-height: 320px;
}

.error-state h1,
.error-state p {
  margin: 0;
}

.request-reference {
  color: var(--muted);
  font-size: 0.82rem;
}

.alert {
  border-radius: 6px;
}

@media (max-width: 860px) {
  .login-stage {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .login-visual {
    min-height: 240px;
    border-right: 0;
    border-bottom: 1px solid rgba(28, 41, 56, 0.2);
  }

  .login-panel {
    min-height: auto;
    padding: 34px;
  }

  .section-heading,
  .button-row,
  .search-row,
  .pricing-save-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .search-row .form-control {
    flex: 0 0 auto;
    width: 100%;
  }

  .pricing-save-panel div {
    margin-right: 0;
  }

  .pricing-form > .pricing-save-panel,
  .sticky-actions {
    position: static;
    box-shadow: none;
  }

  .grid-form,
  .grid-form.compact,
  .report-field-groups,
  .detail-grid,
  .detail-grid.dense,
  .mfa-setup-grid {
    grid-template-columns: 1fr;
  }

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

  .workband,
  .agreement-page {
    padding: 18px;
  }

  .data-frame.stack-table {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .stack-table .table,
  .stack-table .table tbody {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .stack-table .table thead {
    display: none;
  }

  .stack-table .table tbody tr {
    display: block;
    overflow: hidden;
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
  }

  .stack-table .table tbody tr:last-child {
    margin-bottom: 0;
  }

  .stack-table .table tbody td {
    display: grid;
    grid-template-columns: minmax(88px, 0.36fr) minmax(0, 0.64fr);
    gap: 12px;
    align-items: start;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
    text-align: left !important;
    white-space: normal;
  }

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

  .stack-table .table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
  }

  .stack-table .table tbody td[data-label=""] {
    display: block;
  }

  .stack-table .table tbody td[data-label=""]::before {
    display: none;
  }

  .stack-table .table-actions,
  .stack-table .role-grid {
    justify-content: flex-start;
  }

  .stack-table .role-grid {
    grid-template-columns: 1fr;
    min-width: 0;
    width: 100%;
  }

  .stack-table .role-grid .btn {
    width: 100%;
  }

  .stack-table .table-actions .btn,
  .stack-table td[data-label=""] > .btn {
    width: 100%;
  }

  .pagination-row {
    justify-content: space-between;
  }
}

@media (max-width: 540px) {
  .app-main {
    padding-top: 16px;
  }

  .guest-shell .app-main {
    padding-top: 0;
  }

  .login-surface {
    min-height: 100vh;
    padding: 12px;
  }

  .login-stage {
    gap: 0;
  }

  .login-visual {
    min-height: 180px;
  }

  .login-panel {
    padding: 26px 22px;
  }

  .login-panel h1 {
    font-size: 1.58rem;
  }

  .recovery-code-grid {
    grid-template-columns: 1fr;
  }
}

@media print {
  .app-header,
  .app-footer,
  .no-print {
    display: none !important;
  }

  .app-main {
    padding: 0;
  }

  .agreement-page {
    border: 0;
    box-shadow: none;
  }
}
