:root {
  --portal-primary: #1d4ed8;
  --portal-primary-dark: #1e40af;
  --portal-ink: #172033;
  --portal-muted: #657087;
  --portal-line: #e3e8f0;
  --portal-soft: #f5f7fb;
  --portal-success: #16794b;
  --portal-danger: #b42318;
}

html { scroll-behavior: smooth; }
body {
  background: var(--portal-soft);
  color: var(--portal-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh;
}

a { color: var(--portal-primary); }
.py-lg-6 { padding-top: 6rem !important; padding-bottom: 6rem !important; }
.navbar-brand { color: var(--portal-ink); letter-spacing: -.02em; }
.company-brand { align-items: center; display: flex; gap: .75rem; min-width: 0; text-decoration: none; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { color: var(--portal-ink); font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-caption { color: var(--portal-muted); font-size: .65rem; font-weight: 750; letter-spacing: .07em; margin-bottom: .16rem; text-transform: uppercase; }
.btn { border-radius: .65rem; font-weight: 600; min-height: 2.6rem; }
.btn-sm { min-height: 2rem; }
.btn-primary { background: var(--portal-primary); border-color: var(--portal-primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--portal-primary-dark); border-color: var(--portal-primary-dark); }
.form-control, .form-select, .input-group-text {
  border-color: #cfd7e5;
  border-radius: .65rem;
  min-height: 2.8rem;
}
.form-control:focus, .form-select:focus {
  border-color: #7da4f4;
  box-shadow: 0 0 0 .22rem rgba(29, 78, 216, .12);
}
.form-label { color: #344054; font-size: .9rem; font-weight: 650; }
.required::after { color: var(--portal-danger); content: " *"; }
.optional { color: var(--portal-muted); font-size: .76rem; font-weight: 500; margin-left: .25rem; }
.invalid-feedback, .field-error { color: var(--portal-danger); font-size: .86rem; }

.surface-card, .form-section, .detail-card {
  background: #fff;
  border: 1px solid var(--portal-line);
  border-radius: 1rem;
  box-shadow: 0 8px 30px rgba(28, 39, 60, .045);
}
.narrow-container { max-width: 660px; }
.auth-container { max-width: 520px; }
.auth-page, .public-page { background: radial-gradient(circle at 50% 0, #edf3ff, var(--portal-soft) 42%); }
.brand-mark {
  align-items: center;
  background: var(--portal-primary);
  border-radius: .8rem;
  color: #fff;
  display: flex;
  font-size: 1.25rem;
  font-weight: 800;
  height: 3rem;
  justify-content: center;
  width: 3rem;
}
.brand-mark-sm { border-radius: .65rem; flex: 0 0 auto; height: 2.5rem; width: 2.5rem; }
.brand-mark-nav { border-radius: .65rem; flex: 0 0 auto; font-size: .85rem; height: 2.35rem; width: 2.35rem; }
.eyebrow { color: var(--portal-primary); font-size: .76rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }

.metric-card {
  background: #fff;
  border: 1px solid var(--portal-line);
  border-radius: .9rem;
  display: flex;
  flex-direction: column;
  min-height: 112px;
  padding: 1.2rem;
}
.metric-card span { color: var(--portal-muted); font-size: .86rem; }
.metric-card strong { font-size: 2rem; letter-spacing: -.04em; margin-top: auto; }
.admin-table th { color: #667085; font-size: .75rem; font-weight: 750; letter-spacing: .035em; padding-bottom: .8rem; text-transform: uppercase; }
.admin-table td { border-color: #edf0f5; padding-bottom: .9rem; padding-top: .9rem; }
.admin-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.admin-side-card { top: 6.5rem !important; }
.empty-state { border: 1px dashed #cfd7e5; border-radius: .75rem; }
.status-badge { border-radius: 999px; display: inline-block; font-size: .76rem; font-weight: 750; padding: .38rem .68rem; white-space: nowrap; }
.status-pending { background: #fff6d8; color: #7a4d00; }
.status-used { background: #dcf8e9; color: #09603a; }
.status-expired { background: #eef1f5; color: #596274; }
.status-revoked { background: #fee7e7; color: #9f2420; }
.invitation-created { background: #edf9f3; border: 1px solid #b8e3cc; border-radius: 1rem; }
.back-link { color: #566074; font-size: .9rem; font-weight: 600; text-decoration: none; }

.detail-card { margin-bottom: 1.5rem; padding: 1.35rem; }
.detail-card h2 { font-size: 1rem; margin-bottom: 1rem; }
.detail-card dl { display: grid; gap: .8rem 1.2rem; grid-template-columns: minmax(110px, 38%) 1fr; margin: 0; }
.detail-card dt { color: var(--portal-muted); font-size: .85rem; font-weight: 600; }
.detail-card dd { margin: 0; overflow-wrap: anywhere; }
.detail-card address { font-style: normal; line-height: 1.7; }
.clean-list { margin-bottom: 0; padding-left: 1.1rem; }
.clean-list li + li { margin-top: .5rem; }
.sensitive-value { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.vendor-page { background: #f7f8fb; }
.vendor-header { background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--portal-line); box-shadow: 0 6px 24px rgba(28, 39, 60, .035); }
.vendor-container { max-width: 920px; }
.vendor-brand { max-width: min(100%, 620px); }
.vendor-company-name { font-size: 1.05rem; }
.security-note { border-left: 3px solid #a9bce6; color: #5c667b; padding-left: .75rem; }
.form-section { margin-bottom: 1.5rem; padding: 1.4rem; }
.section-heading { align-items: flex-start; display: flex; gap: .9rem; margin-bottom: 1.4rem; }
.section-heading > span {
  align-items: center;
  background: #eaf0ff;
  border-radius: 50%;
  color: var(--portal-primary);
  display: flex;
  flex: 0 0 auto;
  font-size: .78rem;
  font-weight: 800;
  height: 2rem;
  justify-content: center;
  width: 2rem;
}
.section-heading h2 { font-size: 1.15rem; margin: .25rem 0 .2rem; }
.section-heading p { color: var(--portal-muted); font-size: .9rem; margin: 0; }
.repeat-card { background: #f8faff; border: 1px solid #dbe3f2; border-radius: .8rem; margin-bottom: 1rem; padding: 1rem; }
.repeat-card.compact { background: #fff; }
.conditional-group { border-bottom: 1px solid #edf0f5; margin-bottom: 1.4rem; padding-bottom: 1.4rem; }
.conditional-group legend { font-size: .95rem; font-weight: 650; }
.choice-row { display: flex; gap: .75rem; }
.choice-row label {
  align-items: center;
  border: 1px solid #d5dce8;
  border-radius: .65rem;
  cursor: pointer;
  display: flex;
  gap: .5rem;
  min-width: 92px;
  padding: .65rem .8rem;
}
.choice-row input, .choice-cards input, .declaration-box input { accent-color: var(--portal-primary); height: 1.05rem; width: 1.05rem; }
.choice-cards { display: grid; gap: .75rem; grid-template-columns: repeat(3, 1fr); }
.choice-cards label { cursor: pointer; }
.choice-cards input { opacity: 0; position: absolute; }
.choice-cards span { border: 1px solid #d5dce8; border-radius: .75rem; display: block; font-weight: 650; padding: 1rem; text-align: center; }
.choice-cards input:checked + span { background: #eef3ff; border-color: var(--portal-primary); color: var(--portal-primary-dark); box-shadow: inset 0 0 0 1px var(--portal-primary); }
.choice-cards input:focus-visible + span { outline: 3px solid rgba(29, 78, 216, .2); }
.privacy-callout { background: #f0f6ff; border-radius: .65rem; color: #405477; font-size: .86rem; padding: .75rem 1rem; }
.document-list { border: 1px solid var(--portal-line); border-radius: .8rem; overflow: hidden; }
.document-row { padding: 1rem; }
.document-row + .document-row { border-top: 1px solid var(--portal-line); }
.document-row > div:first-child { align-items: center; display: flex; justify-content: space-between; }
.requirement { border-radius: 999px; font-size: .68rem; font-weight: 800; letter-spacing: .04em; padding: .25rem .5rem; text-transform: uppercase; }
.requirement-required { background: #fee7e7; color: #9f2420; }
.requirement-optional { background: #eef1f5; color: #596274; }
.requirement-conditional { background: #fff6d8; color: #7a4d00; }
.declaration-box { align-items: flex-start; background: #f8faff; border: 1px solid #d5dce8; border-radius: .8rem; cursor: pointer; display: flex; gap: .8rem; line-height: 1.55; padding: 1rem; }
.declaration-box input { flex: 0 0 auto; margin-top: .2rem; }
.declaration-invalid { border-color: var(--portal-danger); }
.submit-panel { padding: 1.5rem 1rem 4rem; }

.message-icon { align-items: center; border-radius: 50%; display: flex; font-size: 1.6rem; font-weight: 800; height: 4rem; justify-content: center; width: 4rem; }
.message-icon-success { background: #dcf8e9; color: var(--portal-success); }
.message-icon-warning { background: #fff1d6; color: #99600b; }
.reference-box { background: #f4f7fc; border-radius: .8rem; display: inline-flex; flex-direction: column; gap: .25rem; min-width: 280px; padding: 1rem 1.5rem; }
.reference-box span { color: var(--portal-muted); font-size: .78rem; text-transform: uppercase; }
.reference-box strong { font-size: 1.25rem; letter-spacing: .03em; }

.company-setup-container { max-width: 1120px; }
.setup-page { background: radial-gradient(circle at 15% 0, #edf3ff, var(--portal-soft) 38%); }
.company-setup-card { overflow: hidden; position: relative; }
.setup-badge { background: #eaf0ff; border-radius: 999px; color: var(--portal-primary); display: inline-flex; font-size: .72rem; font-weight: 800; letter-spacing: .07em; padding: .45rem .7rem; text-transform: uppercase; }
.setup-progress { align-items: center; display: flex; max-width: 480px; }
.setup-step { align-items: center; color: var(--portal-muted); display: flex; font-size: .78rem; font-weight: 750; gap: .45rem; white-space: nowrap; }
.setup-step strong { align-items: center; background: #e9edf4; border-radius: 50%; color: #687386; display: inline-flex; height: 1.7rem; justify-content: center; width: 1.7rem; }
.setup-step.is-active { color: var(--portal-primary-dark); }
.setup-step.is-active strong { background: var(--portal-primary); color: #fff; box-shadow: 0 0 0 4px rgba(29, 78, 216, .1); }
.setup-step.is-complete { color: var(--portal-success); }
.setup-step.is-complete strong { background: #dcf8e9; color: var(--portal-success); }
.setup-progress-line { background: #dce2ec; flex: 1 1 auto; height: 2px; margin: 0 .75rem; min-width: 24px; }
.setup-progress-line.is-complete { background: #8bd3ad; }
.setup-security-note { align-items: flex-start; background: #f0f6ff; border: 1px solid #d7e5ff; border-radius: .8rem; color: #405477; display: flex; flex-direction: column; font-size: .88rem; gap: .2rem; padding: .9rem 1rem; }
.setup-identity-card { align-items: center; background: #fff; border-radius: .9rem; box-shadow: 0 18px 45px rgba(11, 25, 66, .24); color: var(--portal-ink); display: flex; gap: 1rem; margin: .75rem 0 1.25rem; padding: 1.25rem; position: relative; }
.setup-identity-card .brand-mark { flex: 0 0 auto; }
.setup-identity-name { font-size: 1.05rem; overflow-wrap: anywhere; }
.setup-check-list { display: flex; flex-direction: column; gap: .75rem; margin-bottom: 1.5rem; position: relative; }
.setup-check-list span { align-items: center; display: flex; font-size: .9rem; gap: .65rem; }
.setup-check-list strong { align-items: center; background: rgba(255, 255, 255, .15); border-radius: 50%; display: inline-flex; flex: 0 0 auto; height: 1.6rem; justify-content: center; width: 1.6rem; }
.company-preview { background: linear-gradient(145deg, #153aa3 0%, #1d4ed8 56%, #3b73ed 100%); border-radius: 1.1rem; box-shadow: 0 22px 55px rgba(29, 78, 216, .24); color: #fff; display: flex; flex-direction: column; justify-content: center; overflow: hidden; padding: 1.5rem; position: relative; }
.company-preview::before { background: rgba(255, 255, 255, .09); border-radius: 50%; content: ""; height: 250px; position: absolute; right: -100px; top: -110px; width: 250px; }
.company-preview-label { font-size: .72rem; font-weight: 800; letter-spacing: .08em; position: relative; text-transform: uppercase; }
.company-preview-window { background: #f7f8fb; border: 1px solid rgba(255, 255, 255, .45); border-radius: .9rem; box-shadow: 0 18px 45px rgba(11, 25, 66, .25); color: var(--portal-ink); margin: .75rem 0 1.2rem; overflow: hidden; position: relative; }
.company-preview-header { align-items: center; background: #fff; border-bottom: 1px solid var(--portal-line); display: flex; gap: .8rem; padding: 1rem; }
.company-preview-header .brand-mark { flex: 0 0 auto; font-size: .95rem; height: 2.65rem; width: 2.65rem; }
.company-preview-body { display: flex; flex-direction: column; gap: .65rem; padding: 1.2rem; }
.preview-line { background: #dfe5ef; border-radius: 999px; display: block; height: .55rem; width: 100%; }
.preview-line-short { background: #b8c9ef; width: 38%; }
.preview-line-medium { width: 72%; }
.preview-button { align-self: flex-start; background: var(--portal-primary); border-radius: .45rem; display: block; height: 1.75rem; margin-top: .25rem; width: 42%; }

[hidden] { display: none !important; }

@media (max-width: 767.98px) {
  .form-section { border-left: 0; border-right: 0; border-radius: .75rem; padding: 1.15rem; }
  .choice-cards { grid-template-columns: 1fr; }
  .detail-card dl { grid-template-columns: 1fr; gap: .25rem; }
  .detail-card dd { margin-bottom: .65rem; }
  .document-row > div:first-child { align-items: flex-start; gap: .5rem; }
  .display-6 { font-size: 2rem; }
  .admin-table { min-width: 740px; }
  .company-preview { min-height: 430px; }
}

@media (max-width: 575.98px) {
  .navbar-brand.company-brand { max-width: calc(100vw - 92px); }
  .vendor-company-name { max-width: calc(100vw - 105px); }
  .setup-step { font-size: .7rem; }
  .setup-progress-line { margin: 0 .45rem; }
}

@media (max-width: 575.98px) {
  .table-responsive { overflow: visible; }
  .admin-table { display: block; min-width: 0; }
  .admin-table thead {
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    height: 1px;
    overflow: hidden;
    position: absolute;
    white-space: nowrap;
    width: 1px;
  }
  .admin-table tbody { display: grid; gap: .85rem; }
  .admin-table tr {
    border: 1px solid var(--portal-line);
    border-radius: .75rem;
    display: block;
    padding: .55rem .75rem;
  }
  .admin-table td {
    align-items: start;
    border: 0;
    display: grid;
    gap: .75rem;
    grid-template-columns: minmax(90px, 34%) minmax(0, 1fr);
    overflow-wrap: anywhere;
    padding: .45rem 0;
    text-align: left !important;
    white-space: normal !important;
  }
  .admin-table td::before {
    color: var(--portal-muted);
    content: attr(data-label);
    font-size: .72rem;
    font-weight: 750;
    letter-spacing: .035em;
    text-transform: uppercase;
  }
  .admin-table td[data-label="Actions"] { align-items: center; }
  .admin-table td[data-label="Actions"] .admin-actions { grid-column: 2; }
}
