body.portal-body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 74% -12%, rgba(22,135,255,.14), transparent 36%),
    linear-gradient(180deg,#07121f 0%,#02070d 100%);
  color: #f5f8fc;
  font-family: Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}

.portal-shell {
  width: min(1120px,calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 52px;
}

.portal-brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.portal-security-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #9eb3ca;
  border: 1px solid rgba(158,179,202,.24);
  background: rgba(8,24,39,.62);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: .78rem;
  font-weight: 700;
}

.portal-security-label span { color: #32d296; font-size: .65rem; }

.portal-card {
  background: linear-gradient(180deg,rgba(11,27,44,.97),rgba(5,17,29,.99));
  border: 1px solid rgba(79,132,181,.22);
  border-radius: 22px;
  padding: clamp(28px,5vw,50px);
  box-shadow: 0 28px 90px rgba(0,0,0,.32);
}

.portal-state-panel { max-width: 780px; }
.portal-kicker,.portal-section-eyebrow,.portal-dashboard-kicker {
  margin: 0 0 9px;
  color: #63a9ff;
  font-size: .73rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.portal-card h1 { margin: 0; font-size: clamp(2rem,5vw,3.2rem); line-height: 1.05; letter-spacing: -.035em; }
.portal-copy { color: #afc0d4; max-width: 64ch; line-height: 1.65; }
.portal-loader { width: 34px; height: 34px; margin-top: 24px; border: 3px solid rgba(255,255,255,.12); border-top-color: #63a9ff; border-radius: 50%; animation: portal-spin .9s linear infinite; }

.portal-safe-note {
  margin-top: 24px;
  padding: 14px 16px;
  border-radius: 11px;
  background: rgba(99,169,255,.065);
  border: 1px solid rgba(99,169,255,.16);
  color: #aebed1;
  line-height: 1.55;
  font-size: .82rem;
}

.portal-button,.portal-secondary-link {
  appearance: none;
  border-radius: 9px;
  padding: 11px 15px;
  font: inherit;
  font-size: .84rem;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.portal-button { border: 1px solid #1687ff; background: #147de6; color: #fff; }
.portal-button:hover { background: #1687ff; }
.portal-button:disabled { opacity: .55; cursor: not-allowed; }
.portal-secondary-link { display: inline-flex; margin-top: 14px; color: #c8d6e7; border: 1px solid rgba(255,255,255,.12); }

/* Signed-out customer entry */
.portal-signed-out { max-width: none; }
.portal-auth-layout {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(390px,470px);
  gap: clamp(38px,6vw,76px);
  align-items: center;
  min-height: 520px;
}

.portal-auth-intro { min-width: 0; }
.portal-auth-intro h1 { max-width: 10ch; font-size: clamp(2.8rem,5.4vw,4.5rem); }
.portal-auth-lead { max-width: 52ch; font-size: 1.02rem; margin-top: 18px; }
.portal-auth-benefits { display: grid; gap: 12px; margin-top: 30px; max-width: 620px; }
.portal-auth-benefits > div {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: start;
  padding: 12px 0;
  border-top: 1px solid rgba(255,255,255,.07);
}
.portal-auth-benefits > div:first-child { border-top: 0; }
.portal-auth-benefit-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(73,162,255,.22);
  border-radius: 9px;
  background: rgba(22,135,255,.08);
  color: #82bdff;
  font-weight: 850;
}
.portal-auth-benefits strong,.portal-auth-benefits small { display: block; }
.portal-auth-benefits strong { color: #eaf3fc; font-size: .91rem; }
.portal-auth-benefits small { margin-top: 3px; color: #859bb1; font-size: .78rem; line-height: 1.45; }

.portal-auth-panel { min-width: 0; }
.portal-auth-panel-card {
  width: 100%;
  padding: 18px;
  border: 1px solid #1b3a55;
  border-radius: 17px;
  background: linear-gradient(160deg,#091927,#06131f);
  box-shadow: 0 24px 55px rgba(0,0,0,.25);
}
.portal-auth-panel-head {
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 4px 4px 15px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.portal-auth-panel-head strong,.portal-auth-panel-head small { display:block; }
.portal-auth-panel-head strong { font-size: .9rem; }
.portal-auth-panel-head small { margin-top: 2px; color: #8097ad; font-size: .72rem; }
.portal-auth-lock {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: #8ce4c1;
  background: rgba(50,210,150,.09);
  border: 1px solid rgba(50,210,150,.2);
  font-weight: 900;
}
.portal-sign-in { width:100%; min-height: 390px; padding-top: 22px; }
.portal-sign-in > div { width:100%; }

/* Authenticated product shell */
body[data-portal-view="authenticated"] { background: #050d17; }
body[data-portal-view="authenticated"] .portal-shell {
  width: min(1480px,calc(100% - 28px));
  padding: 14px 0 30px;
}
body[data-portal-view="authenticated"] .portal-brand-row,
body[data-portal-view="authenticated"] .portal-footnote { display:none; }
body[data-portal-view="authenticated"] .portal-card {
  padding: 0;
  overflow: hidden;
  border-radius: 18px;
  border-color: #17314a;
  background: #06111c;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}

.portal-dashboard-shell {
  min-height: calc(100vh - 44px);
  display: grid;
  grid-template-columns: 232px minmax(0,1fr);
}

.portal-dashboard-sidebar {
  padding: 23px 17px;
  background: linear-gradient(180deg,#071421,#04101b);
  border-right: 1px solid #17314a;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.portal-dashboard-brand { padding: 3px 7px 26px; }
.portal-dashboard-nav { display:grid; gap:7px; }
.portal-dashboard-nav-item {
  min-height: 44px;
  display:flex;
  align-items:center;
  gap:11px;
  padding:0 12px;
  border:1px solid transparent;
  border-radius:9px;
  color:#aebfd0;
  font-size:.82rem;
  font-weight:750;
  text-decoration:none;
}
.portal-dashboard-nav-item:hover,.portal-dashboard-nav-item.active {
  background:#0e2236;
  border-color:#1d456a;
  color:#fff;
}
.portal-dashboard-nav-item.active { box-shadow: inset 3px 0 0 #1687ff; }
.portal-dashboard-sidebar-foot { margin-top:auto; display:grid; gap:13px; }
.portal-dashboard-business-chip {
  display:grid;
  grid-template-columns:auto 1fr;
  gap:10px;
  align-items:center;
  padding:10px;
  border:1px solid #1c354c;
  background:#091827;
  border-radius:11px;
  min-width:0;
}
.portal-dashboard-business-avatar {
  display:grid;
  place-items:center;
  width:34px;
  height:34px;
  border-radius:50%;
  background:#14385a;
  color:#9ed0ff;
  font-size:.68rem;
  font-weight:850;
}
.portal-dashboard-business-chip strong,.portal-dashboard-business-chip small { display:block; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.portal-dashboard-business-chip strong { font-size:.75rem; }
.portal-dashboard-business-chip small { margin-top:2px; color:#7f95aa; font-size:.65rem; }
.portal-back-link { padding: 0 7px; color:#8298ae; text-decoration:none; font-size:.72rem; }

.portal-dashboard-main { min-width:0; }
.portal-dashboard-topbar {
  min-height:80px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:18px;
  padding:14px 28px;
  border-bottom:1px solid rgba(255,255,255,.07);
  background:rgba(5,13,23,.91);
  backdrop-filter:blur(18px);
  position:sticky;
  top:0;
  z-index:10;
}
.portal-dashboard-topbar h1 { font-size:1.18rem; letter-spacing:-.02em; }
.portal-dashboard-kicker { color:#7690aa; font-size:.59rem; margin-bottom:2px; }
.portal-dashboard-top-actions { display:flex; align-items:center; gap:10px; }
.portal-live-pill {
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:8px 11px;
  border:1px solid rgba(50,210,150,.22);
  background:rgba(50,210,150,.07);
  color:#83e6bf;
  border-radius:999px;
  font-size:.7rem;
  font-weight:750;
}
.portal-live-pill i { width:7px; height:7px; border-radius:50%; background:#32d296; box-shadow:0 0 10px rgba(50,210,150,.55); }

.portal-dashboard-content {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 30px 44px;
}
.portal-overview { margin-bottom: 20px; }
.portal-overview h2 { margin: 3px 0 5px; font-size: clamp(1.7rem,3vw,2.35rem); letter-spacing:-.035em; }
.portal-overview > p:last-child { margin:0; color:#93a7ba; font-size:.88rem; max-width:68ch; }

.portal-summary-grid {
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:13px;
  margin-bottom:18px;
}
.portal-summary-card {
  min-height:125px;
  padding:17px;
  border:1px solid #1a344d;
  border-radius:13px;
  background:linear-gradient(145deg,#0a1928,#07131f);
}
.portal-summary-card-priority {
  border-color:#835f25;
  background:linear-gradient(145deg,rgba(71,44,9,.34),#081522);
}
.portal-summary-card span,.portal-summary-card small { display:block; }
.portal-summary-card span { color:#a8b9ca; font-size:.75rem; font-weight:700; }
.portal-summary-card strong { display:block; margin:13px 0 6px; font-size:2.25rem; line-height:1; letter-spacing:-.04em; }
.portal-summary-card small { color:#748ba1; font-size:.66rem; }
.portal-summary-card .portal-summary-word { font-size:1.4rem; margin-top:20px; }

.portal-workspace-section { display:grid; gap:16px; }
.portal-dashboard-panel {
  border:1px solid #1a344d;
  border-radius:13px;
  overflow:hidden;
  background:linear-gradient(150deg,#091827,#07131f);
  box-shadow:0 14px 36px rgba(0,0,0,.14);
}
.portal-dashboard-panel-priority { border-color:rgba(240,180,77,.23); }
.portal-panel-head {
  min-height:62px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:18px;
  padding:10px 17px;
  border-bottom:1px solid #162d43;
}
.portal-panel-head > div:first-child { display:flex; align-items:center; gap:10px; }
.portal-panel-head h2 { margin:1px 0 0; font-size:.95rem; letter-spacing:-.01em; }
.portal-panel-head .portal-section-eyebrow { margin:0; color:#7896b6; font-size:.59rem; }
.portal-alert-dot { width:8px; height:8px; flex:0 0 auto; border-radius:50%; background:#f0b44d; box-shadow:0 0 12px rgba(240,180,77,.38); }
.portal-panel-note { color:#71889e; font-size:.65rem; white-space:nowrap; }

.portal-enquiry-list { display:grid; gap:0; padding:7px; }
.portal-enquiry-card {
  padding:14px 15px;
  border:1px solid transparent;
  border-radius:10px;
  background:transparent;
}
.portal-enquiry-card + .portal-enquiry-card { border-top-color:rgba(255,255,255,.04); }
.portal-enquiry-card:hover { background:#0d2032; border-color:#193e5f; }
.portal-enquiry-card-decision { background:linear-gradient(90deg,rgba(240,180,77,.055),transparent 58%); }
.portal-enquiry-top { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.portal-enquiry-reference { color:#7695b3; font-size:.62rem; letter-spacing:.08em; font-weight:800; }
.portal-enquiry-card h3 { margin:4px 0 1px; font-size:.9rem; }
.portal-enquiry-subtitle { margin:0; color:#8499ae; font-size:.75rem; }
.portal-status {
  flex:0 0 auto;
  display:inline-flex;
  padding:5px 8px;
  border-radius:6px;
  font-size:.59rem;
  font-weight:850;
  text-transform:uppercase;
  border:1px solid rgba(255,255,255,.12);
  color:#cdd8e5;
  background:rgba(255,255,255,.05);
}
.portal-status-needs-attention { color:#ffd791; background:rgba(240,180,77,.11); border-color:rgba(240,180,77,.28); }
.portal-status-waiting-for-customer { color:#7fe6bf; background:rgba(50,210,150,.09); border-color:rgba(50,210,150,.2); }
.portal-status-complete { color:#a5b4c4; background:#111f2c; border-color:#263a4d; }

.portal-enquiry-details {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:8px;
  margin-top:12px;
}
.portal-enquiry-detail { padding:9px 10px; border-radius:8px; border:1px solid #18334b; background:#0a1826; }
.portal-enquiry-detail-label { display:block; color:#748da5; font-size:.57rem; text-transform:uppercase; letter-spacing:.07em; margin-bottom:3px; font-weight:750; }
.portal-enquiry-detail strong { font-size:.72rem; color:#dce6ef; }
.portal-enquiry-message {
  margin:12px 0 0;
  padding:10px 12px;
  color:#aebdca;
  line-height:1.5;
  font-size:.74rem;
  border-left:2px solid rgba(99,169,255,.34);
  background:rgba(7,18,30,.42);
}
.portal-decision-box {
  margin-top:12px;
  padding:11px 12px;
  border-radius:9px;
  background:rgba(240,180,77,.06);
  border:1px solid rgba(240,180,77,.18);
}
.portal-decision-box > strong { color:#f1c979; font-size:.72rem; }
.portal-decision-box p { margin:3px 0 9px; color:#b8ae98; line-height:1.5; font-size:.7rem; }
.portal-required-action { display:grid; gap:2px; padding-top:9px; border-top:1px solid rgba(255,255,255,.07); }
.portal-required-action span { color:#899db0; font-size:.57rem; text-transform:uppercase; letter-spacing:.08em; }
.portal-required-action strong { font-size:.72rem; }
.portal-empty { margin:0; padding:16px; color:#8197ab; font-size:.75rem; }
.portal-dashboard-note { margin:17px 0 0; }
.portal-footnote { text-align:center; color:#6f879f; font-size:.75rem; line-height:1.5; margin:20px auto 0; max-width:62ch; }

@keyframes portal-spin { to { transform:rotate(360deg); } }

@media (max-width: 1180px) {
  .portal-summary-grid { grid-template-columns:repeat(2,minmax(0,1fr)); }
}

@media (max-width: 900px) {
  .portal-auth-layout { grid-template-columns:1fr; gap:28px; min-height:0; }
  .portal-auth-intro h1 { max-width:15ch; }
  .portal-auth-panel-card { max-width:560px; }
  .portal-dashboard-shell { grid-template-columns:1fr; }
  .portal-dashboard-sidebar {
    display:grid;
    grid-template-columns:auto 1fr auto;
    align-items:center;
    gap:16px;
    padding:12px 15px;
    border-right:0;
    border-bottom:1px solid #17314a;
  }
  .portal-dashboard-brand { padding:0; }
  .portal-dashboard-nav { display:flex; justify-content:center; }
  .portal-dashboard-sidebar-foot { margin:0; display:flex; align-items:center; }
  .portal-dashboard-business-chip { display:none; }
  .portal-back-link { white-space:nowrap; }
  .portal-dashboard-topbar { position:static; }
}

@media (max-width: 680px) {
  .portal-shell { width:min(100% - 18px,1120px); padding-top:16px; }
  .portal-brand-row { align-items:flex-start; flex-direction:column; margin-bottom:18px; }
  .portal-card { border-radius:16px; padding:22px 18px; }
  .portal-auth-intro h1 { font-size:2.65rem; }
  .portal-auth-benefits { margin-top:22px; }
  .portal-auth-panel-card { padding:12px; }
  body[data-portal-view="authenticated"] .portal-shell { width:100%; padding:0; }
  body[data-portal-view="authenticated"] .portal-card { border:0; border-radius:0; min-height:100vh; }
  .portal-dashboard-shell { min-height:100vh; }
  .portal-dashboard-sidebar {
    grid-template-columns:1fr auto;
    gap:10px;
    position:sticky;
    top:0;
    z-index:20;
  }
  .portal-dashboard-nav { justify-content:flex-end; }
  .portal-dashboard-nav-item { min-height:38px; padding:0 10px; font-size:.72rem; }
  .portal-dashboard-nav-item:first-child { display:none; }
  .portal-dashboard-sidebar-foot { display:none; }
  .portal-dashboard-topbar { padding:13px 14px; min-height:70px; }
  .portal-dashboard-topbar h1 { font-size:.95rem; }
  .portal-dashboard-top-actions { gap:7px; }
  .portal-live-pill { display:none; }
  .portal-signout-button { padding:9px 11px; font-size:.72rem; }
  .portal-dashboard-content { padding:21px 13px 34px; }
  .portal-overview h2 { font-size:1.65rem; }
  .portal-summary-grid { grid-template-columns:1fr 1fr; gap:9px; }
  .portal-summary-card { min-height:105px; padding:13px; }
  .portal-summary-card:last-child { grid-column:1/-1; min-height:auto; }
  .portal-summary-card strong { font-size:1.9rem; }
  .portal-summary-card .portal-summary-word { margin-top:12px; font-size:1.15rem; }
  .portal-panel-head { align-items:flex-start; padding:12px; }
  .portal-panel-note { display:none; }
  .portal-enquiry-top { flex-direction:column; gap:8px; }
  .portal-enquiry-details { grid-template-columns:1fr; }
  .portal-status { align-self:flex-start; }
}

@media (max-width: 430px) {
  .portal-summary-grid { grid-template-columns:1fr; }
  .portal-summary-card:last-child { grid-column:auto; }
  .portal-dashboard-brand .brand-copy { display:none; }
}

@media (prefers-reduced-motion: reduce) {
  .portal-loader { animation:none; }
}

.portal-business-section{margin-top:18px;border:1px solid #1a344d;background:linear-gradient(150deg,#091827,#07131f);border-radius:14px;overflow:hidden}
.portal-business-heading{border-bottom:1px solid #162d43}
.portal-business-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;padding:14px}
.portal-business-card{min-height:86px;padding:13px;border:1px solid #18334b;background:#0a1826;border-radius:9px}
.portal-business-card span{display:block;color:#748da5;font-size:.58rem;text-transform:uppercase;letter-spacing:.07em;font-weight:750}
.portal-business-card strong{display:block;margin-top:5px;color:#dce6ef;font-size:.75rem;line-height:1.5;white-space:pre-wrap}
.portal-business-guardrails{margin:0 14px 14px;padding:14px;border:1px solid rgba(50,210,150,.16);background:rgba(50,210,150,.045);border-radius:10px}
.portal-business-guardrails h3{margin:4px 0 10px;font-size:.88rem}
.portal-business-guardrails ul{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px 24px;margin:0;padding-left:18px;color:#9cafbf;font-size:.7rem;line-height:1.5}
@media(max-width:680px){.portal-business-grid,.portal-business-guardrails ul{grid-template-columns:1fr}}

.portal-settings-section{margin-top:18px;border:1px solid #1a344d;background:linear-gradient(150deg,#091827,#07131f);border-radius:14px;overflow:hidden}
.portal-settings-heading{border-bottom:1px solid #162d43}
.portal-connections-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;padding:14px}
.portal-connection-card{min-height:120px;padding:13px;border:1px solid #18334b;background:#0a1826;border-radius:9px}
.portal-connection-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.portal-connection-card-head strong{font-size:.78rem}
.portal-connection-card p{margin:10px 0 0;color:#8297aa;font-size:.68rem;line-height:1.5}
.portal-connection-status{display:inline-flex;padding:4px 7px;border-radius:999px;font-size:.55rem;font-weight:850;white-space:nowrap;border:1px solid #2a4257;color:#9eb0c1;background:#111f2d}
.portal-connection-status-connected{color:#82e0b9;background:rgba(50,210,150,.09);border-color:rgba(50,210,150,.2)}
.portal-connection-status-authorised{color:#f2cb83;background:rgba(240,180,77,.09);border-color:rgba(240,180,77,.2)}
.portal-connection-status-action-required,.portal-connection-status-connection-issue{color:#ffd791;background:rgba(240,180,77,.11);border-color:rgba(240,180,77,.28)}
@media(max-width:900px){.portal-connections-grid{grid-template-columns:1fr 1fr}}
@media(max-width:680px){.portal-connections-grid{grid-template-columns:1fr}}

/* Public portal return navigation; authenticated header stays hidden by the
   existing data-portal-view rule. No provider or session behavior changes. */
.portal-brand-row {
 display:grid;
 grid-template-columns:1fr auto auto;
}
.portal-return-link {
 display:inline-flex;
 align-items:center;
 justify-content:center;
 min-height:44px;
 padding:0 8px;
 color:#b5d7f5;
 font-size:.8rem;
 font-weight:600;
 text-decoration:none;
 white-space:nowrap;
 border-radius:6px;
}
.portal-return-link:hover { color:#fff; text-decoration:underline; text-underline-offset:4px; }
.portal-return-link:focus-visible { outline:2px solid #83c4ff; outline-offset:3px; }
@media (max-width:680px) {
 .portal-brand-row { grid-template-columns:minmax(0,1fr) auto; gap:10px 4px; align-items:center; }
 .portal-brand-row > .brand { grid-column:1; grid-row:1; }
 .portal-return-link { grid-column:2; grid-row:1; padding-inline:4px; font-size:.75rem; }
 .portal-security-label { grid-column:1 / -1; grid-row:2; justify-self:start; }
}

/* B01: constrain the Clerk root by its stable portal mount ID. */
@media (max-width: 680px) {
  #portal-sign-in,
  #portal-sign-in .cl-rootBox,
  #portal-sign-in .cl-cardBox,
  #portal-sign-in .cl-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }
}
