/* The client portal's own layout, on hub.css's tokens only, so the agency's palette, colours and fonts carry it. Phone
   first: one column, the pages in a bar along the bottom; from 760px a top bar and wider cards. */

body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font-body); }

.portal-skip { position: absolute; left: var(--space-4); top: -60px; z-index: 50; padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); background: var(--surface); color: var(--heading); box-shadow: var(--shadow-md); }
.portal-skip:focus { top: var(--space-3); }

/* The top bar: the agency's brand on its night ground. */
.portal-top { position: sticky; top: 0; z-index: 20; background: var(--night); color: var(--on-night); border-bottom: 2px solid var(--accent); }
.portal-top :focus-visible { outline-color: var(--focus-on-night); }
.portal-top-inner { display: flex; align-items: center; gap: var(--space-5); max-width: 1120px; margin: 0 auto; padding: 0 var(--space-4); min-height: 60px; }
.portal-brand { display: flex; align-items: baseline; gap: var(--space-3); min-width: 0; color: var(--on-night-strong); text-decoration: none; }
.portal-brand:hover { color: var(--on-night-strong); }
.portal-logo { display: block; max-height: 32px; max-width: 160px; align-self: center; }
.portal-brand-name { font-family: var(--font-heading); font-size: 19px; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-brand-tag { font-size: 10.5px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--on-night-tint); white-space: nowrap; }

.portal-nav { display: flex; gap: var(--space-1); margin-left: auto; }
.portal-nav a { position: relative; display: inline-flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-sm); color: var(--on-night-soft); font-size: 14px; font-weight: 600; text-decoration: none; }
.portal-nav a:hover { color: var(--on-night-strong); background: var(--night-raised); }
.portal-nav a.is-on { color: var(--on-night-strong); background: var(--night-active); }
.portal-nav-icon { display: none; }
.portal-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--accent-soft); color: var(--accent-strong); font-size: 12px; font-weight: 700; line-height: 1; }
.portal-count.is-big { min-width: 28px; height: 28px; font-size: 14px; }

.portal-signout button { min-height: 36px; padding: 0 var(--space-3); border: 1px solid var(--night-active); border-radius: var(--radius-sm); background: transparent; color: var(--on-night-soft); font: inherit; font-size: 13px; cursor: pointer; }
.portal-signout button:hover { color: var(--on-night-strong); border-color: var(--on-night-muted); }

.portal-main { max-width: 1120px; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-7); outline: none; }
.portal-main > .hub-h1 { margin-bottom: var(--space-2); }
.portal-foot { max-width: 1120px; margin: 0 auto; padding: 0 var(--space-4) var(--space-6); color: var(--text-muted); font-size: 13px; }

/* Cards */
.portal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: var(--space-5); }
.portal-card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.portal-card-title { margin: 0; font-family: var(--font-heading); font-size: 16px; font-weight: 700; color: var(--heading); }
.portal-label { margin: 0 0 var(--space-2); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.portal-eyebrow { margin: 0 0 var(--space-1); font-size: 12px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-strong); }
.portal-message { margin: 0 0 var(--space-4); }
.portal-empty { text-align: center; padding: var(--space-7) var(--space-5); }
.portal-empty-mark { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin: 0 auto var(--space-3); border-radius: 50%; background: var(--success-bg); color: var(--success); font-size: 26px; }

/* Home */
.portal-hello { margin-bottom: var(--space-5); }
.portal-hello .hub-h1 { font-size: clamp(26px, 5vw, 34px); }
.portal-client { margin-bottom: var(--space-6); }
.portal-client-name { margin: 0 0 var(--space-3); font-family: var(--font-heading); font-size: 20px; color: var(--heading); }
.portal-home-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); align-items: start; }
.portal-home-waiting { border-top: 3px solid var(--accent); }
.portal-list { list-style: none; margin: 0 0 var(--space-4); padding: 0; display: grid; gap: var(--space-3); }
.portal-list li { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-1) var(--space-2); }
.portal-list li a { font-weight: 600; }
.portal-decision { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 24px; height: 24px; border-radius: 50%; font-size: 13px; font-weight: 700; }
.portal-decision.is-ok { background: var(--success-bg); color: var(--success); }
.portal-decision.is-back { background: var(--accent-soft); color: var(--accent-strong); }

/* Approvals */
.portal-posts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-5); }
.portal-post-card { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-5); padding: var(--space-4); scroll-margin-top: 80px; }
.portal-post-media { min-width: 0; }
.portal-post-title { margin: 0 0 var(--space-3); font-family: var(--font-heading); font-size: 22px; line-height: 1.25; color: var(--heading); }
.portal-post-facts { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-5); margin: 0 0 var(--space-4); }
.portal-post-facts dt { font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-muted); }
.portal-post-facts dd { margin: 2px 0 0; color: var(--heading); font-weight: 600; }
.portal-caption { margin-bottom: var(--space-5); padding: var(--space-4); border-radius: var(--radius); background: var(--surface-alt); }
.portal-caption-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.portal-decide { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.portal-decide .hub-btn, .portal-decide .hub-btn-secondary { min-height: 48px; padding: 0 var(--space-5); font-size: 15px; }
.portal-decide > * { flex: 1 1 160px; }
/* A post decided on this visit: what was done, where its buttons were, so nothing moves under the thumb. */
.portal-post-card.is-decided .portal-post-media { opacity: 0.6; }
.portal-receipt { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: var(--space-3); align-items: start; min-height: 48px; padding: var(--space-3) var(--space-4); border-left: 3px solid var(--success); border-radius: var(--radius-sm); background: var(--surface-alt); }
.portal-receipt.is-changessent { border-left-color: var(--accent); }
.portal-receipt.is-gone { border-left-color: var(--border-mid); }
.portal-receipt-title { margin: 0; font-family: var(--font-heading); font-size: 16px; line-height: 1.3; color: var(--heading); }
.portal-receipt-text { margin: 2px 0 0; font-size: 14px; color: var(--text); }
.portal-decision.is-gone { background: var(--fill); color: var(--text-muted); }

/* The post viewer (Design's portal.post) */
.portal-media { margin: 0; }
.portal-media-loading, .portal-media-empty { display: flex; align-items: center; justify-content: center; min-height: 260px; padding: var(--space-5); border-radius: var(--radius); background: var(--surface-alt); text-align: center; }
.portal-slide { position: relative; overflow: hidden; border-radius: var(--radius); background: var(--fill); max-height: 78vh; margin: 0 auto; }
.portal-slide img { display: block; width: 100%; height: 100%; object-fit: contain; }
.portal-post.is-story .portal-slide { max-width: 360px; }
.portal-slide-nav { position: absolute; top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--surface); color: var(--heading); box-shadow: var(--shadow-md); font-size: 26px; line-height: 1; cursor: pointer; }
.portal-slide-nav:disabled { opacity: 0.35; cursor: default; }
.portal-slide-nav.is-prev { left: var(--space-3); }
.portal-slide-nav.is-next { right: var(--space-3); }
.portal-slide-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); margin-top: var(--space-3); }
.portal-slide-count { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.portal-dots { display: flex; flex-wrap: wrap; gap: 6px; }
.portal-dot { width: 24px; height: 24px; padding: 0; border: 0; background: transparent; cursor: pointer; position: relative; }
.portal-dot::after { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--fill-strong); }
.portal-dot.is-on::after { background: var(--brand); inset: 6px; }
.portal-video video { display: block; width: 100%; height: auto; max-height: 78vh; border-radius: var(--radius); background: var(--night); }
.portal-video.is-portrait video { max-width: 420px; margin: 0 auto; }
.portal-video figcaption { margin-top: var(--space-2); text-align: center; }

/* History */
.portal-history { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-3); }
.portal-history-item { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-4); }
.portal-history-body { min-width: 0; }
.portal-history-title { margin: 0 0 var(--space-1); color: var(--heading); }
.portal-history-body .hub-hint { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0; }
.portal-history-body .hub-quote { margin-top: var(--space-2); }

/* The brief's client switch */
.portal-switch { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.portal-switch a { padding: var(--space-2) var(--space-4); border: 1px solid var(--border-mid); border-radius: var(--radius-pill); color: var(--heading); text-decoration: none; font-weight: 600; font-size: 14px; }
.portal-switch a.is-on { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* Account */
.portal-account-panel { display: grid; gap: var(--space-4); max-width: 720px; }
.portal-account-panel .hub-section { margin: 0; }
.hub-narrow { max-width: 420px; }
.portal-account-brand span { margin-top: 6px; }

/* Two-step setup (Access's page): two ways to add the account. A computer scans the QR code first; a phone or tablet can't
   scan its own screen, so there the button and the key come first. */
.twostep-ways { display: flex; flex-direction: column; gap: var(--space-4); margin-bottom: var(--space-4); }
.twostep-ways p { margin: 0 0 var(--space-2); }
.twostep-ways .hub-note { margin: var(--space-3) 0 var(--space-1); }
.twostep-phone, .twostep-scan { padding-top: var(--space-4); border-top: 1px solid var(--border-soft); }
.twostep-ways > :first-child { padding-top: 0; border-top: 0; }
.twostep-ways .hub-hint:empty { display: none; }
.twostep-save { margin-bottom: var(--space-4); }
@media (max-width: 759px), (hover: none) and (pointer: coarse) {
    .twostep-phone { order: -1; padding-top: 0; border-top: 0; }
    .twostep-ways > .twostep-scan:first-child { padding-top: var(--space-4); border-top: 1px solid var(--border-soft); }
}

@media (min-width: 900px) {
    .portal-post-card { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); padding: var(--space-5); align-items: start; }
    .portal-post-body { position: sticky; top: 84px; }
}

/* Phone: the pages move to a bar along the bottom, in reach of a thumb. */
@media (max-width: 759px) {
    /* The bottom bar's height over the safe area: its 1px top border, 4px padding, a 52px link and 4px padding. */
    :root { --portal-nav-h: 61px; --portal-nav-clear: calc(var(--portal-nav-h) + env(safe-area-inset-bottom)); }
    .portal-top-inner { min-height: 54px; gap: var(--space-3); }
    .portal-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; gap: 0; margin: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: var(--night); border-top: 1px solid var(--night-active); }
    .portal-nav a { flex: 1 1 0; flex-direction: column; gap: 2px; min-height: 52px; padding: 4px 2px; justify-content: center; font-size: 11px; text-align: center; }
    .portal-nav-icon { display: block; font-size: 18px; line-height: 1; }
    .portal-nav .portal-count { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; font-size: 11px; }
    .portal-signout { margin-left: auto; }
    .portal-main { padding: var(--space-5) var(--space-4) calc(var(--space-7) + var(--portal-nav-clear)); }
    .portal-foot { padding-bottom: calc(var(--space-5) + var(--portal-nav-clear)); }
    /* The monthly brief's actions (hub.css, sticky at the foot of the screen) sit on the bar, not under it, and a field
       scrolled to, or focused, stops clear of both: 128px is the actions' bar with its buttons wrapped onto two rows. */
    .portal-main .hub-brief-bar { bottom: var(--portal-nav-clear); }
    html:has(.hub-brief-bar) { scroll-padding-bottom: calc(var(--portal-nav-clear) + 128px); }
    .portal-card { padding: var(--space-4); }
    .portal-post-card { padding: var(--space-3); gap: var(--space-4); }
    .portal-post-title { font-size: 20px; }
    .portal-brand-tag { display: none; }
}

@media (max-width: 400px) {
    .portal-decide > * { flex-basis: 100%; }
}

/* Blazor's "something went wrong" bar: hidden until the session fails. */
#blazor-error-ui { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000; box-sizing: border-box; padding: var(--space-3) var(--space-6) var(--space-3) var(--space-4); background: var(--danger-bg); color: var(--on-danger-bg); box-shadow: var(--shadow-md); }
#blazor-error-ui .dismiss { position: absolute; right: var(--space-4); top: var(--space-3); cursor: pointer; }

/* A list row with a mark: the mark, then its words. */
.portal-list li.has-mark { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: start; gap: var(--space-2) var(--space-3); }
.portal-list-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; color: var(--heading); }
.portal-nav-short { display: none; }
@media (max-width: 759px) {
    .portal-nav-long { display: none; }
    .portal-nav-short { display: inline; }
}
.portal-brief-note { margin: 0 0 var(--space-4); }
.portal-history-body .hub-quote { margin-bottom: 0; }
