/* Impact Media client portal: one stylesheet for portal, admin, studio, reports and PDF.
   Theme colors come from CSS variables set per client (--brand, --accent...) in the page head. */

:root {
  --brand: #0f172a;
  --brand-ink: #ffffff;
  --brand-soft: #f1f5f9;
  --accent: #4f46e5;
  --accent-ink: #4338ca;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #4b5563;
  --text-3: #6b7280;

  --good: #047857;
  --good-bg: #ecfdf5;
  --bad: #b91c1c;
  --bad-bg: #fef2f2;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --info: #1d4ed8;
  --info-bg: #eff6ff;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-heading: var(--font);
  --btn-bg: var(--accent-ink);
  --btn-ink: #ffffff;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); font-feature-settings: "tnum" 1, "cv11" 1; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -0.01em; font-family: var(--font-heading); }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 0.75em; }
img { max-width: 100%; }
code, pre { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* "Skip to content": off screen until it gets keyboard focus. main has tabindex="-1" so focus can land on it. */
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow-lg); text-decoration: none !important; }
.skip-link:focus { top: 8px; }
main:focus { outline: none; }

/* Sideways scrollers (tab bars, the period picker): no scrollbar; an edge fades while there's more to
   scroll to (the classes are set by the small script in layout.tsx, which also brings the active item into view). */
.scroller { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.scroller::-webkit-scrollbar { display: none; }
.scroller.has-more-end { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 40px), transparent); }
.scroller.has-more-start { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 40px), transparent); }
.scroller.has-more-start.has-more-end { -webkit-mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to right, transparent, #000 40px, #000 calc(100% - 40px), transparent); }

/* ── Buttons, badges, status, flash ─────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 500; cursor: pointer; text-decoration: none !important; white-space: nowrap; transition: background 0.12s, border-color 0.12s; }
.btn--sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn--primary { background: var(--btn-bg); color: var(--btn-ink); }
.btn--primary:hover { filter: brightness(0.95); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover { background: var(--surface-2); }
.btn--ghost { background: transparent; color: inherit; border-color: transparent; }
.btn--ghost:hover { background: rgba(0, 0, 0, 0.05); }
.btn--danger { background: var(--surface); color: var(--bad); border-color: #fecaca; }
.btn--danger:hover { background: var(--bad-bg); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge--good { background: var(--good-bg); color: var(--good); }
.badge--bad { background: var(--bad-bg); color: var(--bad); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--info { background: var(--info-bg); color: var(--info); }
.badge--muted { background: #f3f4f6; color: var(--text-2); }
.badge--brand { background: var(--brand-soft); color: var(--brand); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); text-transform: capitalize; }
.status__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.status--good .status__dot { background: #10b981; }
.status--bad .status__dot { background: #ef4444; }
.status--warn .status__dot { background: #f59e0b; }

.flash { padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 16px; border: 1px solid; }
.flash--ok { background: var(--good-bg); border-color: #a7f3d0; color: #065f46; }
.flash--error { background: var(--bad-bg); border-color: #fecaca; color: #991b1b; }
.flash--info { background: var(--info-bg); border-color: #bfdbfe; color: #1e40af; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 0; }
.card__title { font-size: 14px; font-weight: 600; }
.card__subtitle { margin: 2px 0 0; font-size: 12px; color: var(--text-3); }
.card__body { padding: 14px 16px 16px; }
.card__actions { display: flex; gap: 6px; }

.empty { text-align: center; padding: 28px 16px; color: var(--text-3); }
.empty__title { color: var(--text-2); font-weight: 500; margin-bottom: 4px; }
.empty__action { margin-top: 12px; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field__label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field__hint { font-size: 12px; color: var(--text-3); }
input[type="text"], input[type="email"], input[type="url"], input[type="number"], input[type="date"], input[type="month"], input[type="time"], input[type="search"], input[type="password"], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font: inherit; color: var(--text); background: var(--surface);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input[type="color"] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0 16px; }
.check { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.check--block { align-items: flex-start; }
.check--block input { margin-top: 3px; }
.copy-field { width: 100%; font-size: 13px; resize: vertical; }
.form-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
/* position: relative keeps .sr-only text (absolutely positioned) inside the scrolling area on phones. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; position: relative; }
/* A table wider than its card shows a soft shadow on the side(s) with more to scroll to: the white covers
   scroll with the table (local) and hide the shadows (scroll) once an end is reached. */
.card .table-wrap {
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 40px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 40px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(16, 24, 40, 0.18), transparent) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(16, 24, 40, 0.18), transparent) right center / 14px 100% no-repeat scroll;
}
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; color: var(--text-3); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid #f1f2f4; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
/* Row headers (th scope="row") rule like the cells next to them, not like the column headers. */
.table tbody th { border-bottom-color: #f1f2f4; }
.table tbody tr:last-child th { border-bottom: 0; }
.table tfoot th { border-top: 1px solid var(--border); border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:hover { background: #fafbfc; }
.table .entity { max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Narrow screens: a table--stack shows each row as a small card (cells labeled with data-label), so row actions stay in view. */
@media (max-width: 640px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
  .table--stack tr:last-child { border-bottom: 0; }
  .table--stack td { padding: 2px 0; border-bottom: 0; }
  .table--stack td:first-child { font-weight: 600; }
  .table--stack td[data-label]::before { content: attr(data-label) ": "; color: var(--text-3); }
  .table--stack td.right { text-align: left; padding-top: 6px; }
}
.table tfoot td { font-weight: 600; border-top: 1px solid var(--border); }
.delta { font-size: 11px; margin-left: 4px; }
.delta--good { color: var(--good); }
.delta--bad { color: var(--bad); }
.delta--neutral { color: var(--text-3); }
.share-bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--accent); opacity: 0.6; vertical-align: middle; margin-right: 6px; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs__item { padding: 10px 12px; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; text-decoration: none !important; }
.tabs__item:hover { color: var(--text); }
.tabs__item.is-active { color: var(--text); border-bottom-color: var(--accent-ink); }

/* ── Client portal ─────────────────────────────────────────────────────── */
.preview-banner { background: #111827; color: #e5e7eb; font-size: 12px; text-align: center; padding: 6px 16px; }
.preview-banner a { color: #fff; text-decoration: underline; }
.portal-header { background: var(--brand); color: var(--brand-ink); position: sticky; top: 0; z-index: 20; }
.portal-header__inner { max-width: 1360px; margin: 0 auto; display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 60px; }
.portal-brand { display: flex; align-items: center; color: inherit; text-decoration: none !important; flex-shrink: 0; }
.client-logo { display: block; object-fit: contain; }
.client-logo--sm { height: 24px; max-width: 120px; }
.client-logo--md { height: 32px; max-width: 160px; }
.client-logo--lg { height: 48px; max-width: 220px; }
.client-wordmark { font-weight: 700; letter-spacing: -0.02em; }
.client-wordmark--sm { font-size: 15px; }
.client-wordmark--md { font-size: 18px; }
.client-wordmark--lg { font-size: 26px; }
.portal-nav { display: flex; gap: 2px; flex: 1; min-width: 0; }
.portal-nav__item { color: inherit; opacity: 0.78; padding: 8px 12px; border-radius: var(--radius-sm); white-space: nowrap; font-weight: 500; text-decoration: none !important; }
.portal-nav__item:hover { opacity: 1; background: color-mix(in srgb, var(--brand-ink) 10%, transparent); }
.portal-nav__item.is-active { opacity: 1; background: color-mix(in srgb, var(--brand-ink) 16%, transparent); }
.portal-user { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.portal-user .btn--ghost { color: inherit; border-color: color-mix(in srgb, var(--brand-ink) 35%, transparent); }
.portal-subnav { background: var(--surface); border-bottom: 1px solid var(--border); color: var(--text); }
.portal-subnav__inner { max-width: 1360px; margin: 0 auto; padding: 0 24px; display: flex; gap: 4px; }
.portal-subnav__item { padding: 10px 12px; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; text-decoration: none !important; }
.portal-subnav__item.is-active { color: var(--text); border-bottom-color: var(--brand); }
/* The page is a column: main grows so the footer sits at the bottom of short pages, whatever the header's height. */
body.portal:not(.preview-page) { display: flex; flex-direction: column; min-height: 100vh; }
.portal-main { width: 100%; max-width: 1360px; margin: 0 auto; padding: 24px; flex: 1 0 auto; }
.portal-footer { display: flex; justify-content: center; align-items: center; gap: 8px; color: var(--text-3); font-size: 12px; padding: 24px; }
.portal-footer__logo { height: 20px; width: auto; opacity: 0.85; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: color-mix(in srgb, var(--brand-ink) 18%, transparent); color: inherit; display: grid; place-items: center; font-weight: 600; cursor: pointer; list-style: none; }
.avatar::-webkit-details-marker { display: none; }
.menu { position: relative; }
.menu__panel { position: absolute; right: 0; top: 40px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; z-index: 30; }
.menu__meta { padding: 8px 10px; font-size: 12px; color: var(--text-3); border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu__item { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; font: inherit; border-radius: var(--radius-sm); cursor: pointer; color: var(--text); }
.menu__item:hover { background: var(--surface-2); }

.page-title { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-title h1 { font-size: 24px; }
.page-title__meta { color: var(--text-3); font-size: 13px; margin-top: 4px; }

/* Period picker */
.period-picker { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.segmented { display: inline-flex; background: #eef0f3; border-radius: 8px; padding: 3px; gap: 2px; overflow-x: auto; max-width: 100%; }
.segmented a, .segmented button { padding: 5px 10px; border-radius: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap; border: 0; background: none; cursor: pointer; text-decoration: none !important; }
.segmented .is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ── Dashboard grid and widgets ─────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.w-quarter { grid-column: span 3; }
.w-third { grid-column: span 4; }
.w-half { grid-column: span 6; }
.w-two_thirds { grid-column: span 8; }
.w-full { grid-column: span 12; }
@media (max-width: 1100px) { .w-quarter { grid-column: span 6; } .w-third { grid-column: span 6; } .w-two_thirds { grid-column: span 12; } }
@media (max-width: 760px) { .dash-grid > * { grid-column: span 12; } }
.widget { display: flex; flex-direction: column; }
.widget .card__body { flex: 1; }
.widget__foot { padding: 0 16px 12px; font-size: 11px; color: var(--text-3); }
.widget--error .card__body { color: var(--bad); font-size: 13px; }
.chart-box { position: relative; height: 240px; }
.chart-box--sm { height: 160px; }
.chart-box--lg { height: 320px; }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); position: relative; min-width: 0; }
.kpi--primary { border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); background: color-mix(in srgb, var(--brand-soft) 60%, #fff); }
.kpi__label { font-size: 12px; color: var(--text-3); font-weight: 500; display: flex; gap: 6px; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin-top: 2px; white-space: nowrap; }
.kpi__meta { font-size: 12px; color: var(--text-3); margin-top: 2px; display: flex; gap: 6px; flex-wrap: wrap; }
.kpi__spark { height: 28px; margin-top: 6px; }
.kpi--big .kpi__value { font-size: 34px; }
.pill-delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; padding: 0 6px; border-radius: 999px; }
.pill-delta--good { background: var(--good-bg); color: var(--good); }
.pill-delta--bad { background: var(--bad-bg); color: var(--bad); }
.pill-delta--neutral { background: #f3f4f6; color: var(--text-2); }

.pacing { display: flex; flex-direction: column; gap: 14px; }
.pacing__row { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: center; }
.pacing__bar { position: relative; height: 10px; background: #eef0f3; border-radius: 5px; overflow: visible; }
.pacing__fill { position: absolute; inset: 0 auto 0 0; background: var(--brand); border-radius: 5px; max-width: 100%; }
.pacing__expected { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); opacity: 0.55; }
.pacing__meta { font-size: 12px; color: var(--text-2); white-space: nowrap; }

.alert-list, .insight-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.alert__icon { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; background: var(--text-3); }
.alert--critical .alert__icon { background: #ef4444; }
.alert--warning .alert__icon { background: #f59e0b; }
.alert--info .alert__icon { background: #3b82f6; }
.alert__text { font-size: 13px; }
.alert__meta { font-size: 11px; color: var(--text-3); }
.all-clear { display: flex; gap: 8px; align-items: center; color: var(--good); font-weight: 500; font-size: 13px; }
.insight { padding: 10px 12px; border-left: 3px solid var(--border-strong); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.insight--positive { border-left-color: #10b981; }
.insight--warning { border-left-color: #f59e0b; }
.insight--critical { border-left-color: #ef4444; }
.insight__title { font-weight: 600; font-size: 13px; }
.insight__body { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.insight__body p:last-child { margin-bottom: 0; }

.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel__step { display: grid; grid-template-columns: 130px 1fr 90px; gap: 10px; align-items: center; font-size: 13px; }
.funnel__bar { height: 22px; border-radius: 4px; background: color-mix(in srgb, var(--brand) 75%, #fff); min-width: 2px; }
.funnel__rate { font-size: 11px; color: var(--text-3); padding-left: 140px; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery__item { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.gallery__img { aspect-ratio: 1; background: #f3f4f6 center/cover no-repeat; display: grid; place-items: center; color: var(--text-3); font-size: 11px; }
.gallery__body { padding: 8px 10px; font-size: 12px; }
.gallery__name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gallery__stats { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px; color: var(--text-2); margin-top: 4px; }

.score-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.score { text-align: center; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.score__ring { width: 76px; height: 76px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--score-color, var(--brand)) calc(var(--score, 0) * 1%), #eef0f3 0); }
.score__ring span { width: 60px; height: 60px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 18px; font-weight: 700; }
.score__label { font-weight: 600; font-size: 13px; }
.score__meta { font-size: 11px; color: var(--text-3); }
.note-widget { font-size: 14px; color: var(--text-2); }

/* ── Client overview ────────────────────────────────────────────────────── */
.overview-hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; box-shadow: var(--shadow); }
.link-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.link-card { display: flex; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); box-shadow: var(--shadow); text-decoration: none !important; transition: border-color 0.12s, transform 0.12s; }
a.link-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.link-card__icon { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex-shrink: 0; font-size: 18px; }
.link-card__title { font-weight: 600; }
.link-card__desc { font-size: 13px; color: var(--text-3); }
.team-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.team-member { display: flex; gap: 10px; align-items: center; }
.team-member__avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; overflow: hidden; }
.service-chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Reports ────────────────────────────────────────────────────────────── */
.report-list { display: grid; gap: 12px; }
.report-doc { max-width: 920px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 40px 48px; }
.report-cover { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; border-bottom: 3px solid var(--brand); padding-bottom: 20px; margin-bottom: 28px; }
.report-cover h1 { font-size: 28px; }
.report-section { margin-bottom: 36px; break-inside: avoid-page; }
.report-section > h2 { font-size: 19px; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.report-narrative { font-size: 15px; line-height: 1.65; color: #1f2937; }
.report-narrative h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3); margin: 16px 0 6px; }
.report-note { background: var(--brand-soft); border-left: 3px solid var(--brand); padding: 10px 14px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 12px 0; font-size: 14px; }
.report-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin: 12px 0 16px; }
.report-figures__title { caption-side: top; text-align: left; font-weight: 600; font-size: 13px; padding: 0 10px 6px; color: var(--text-2, inherit); }
.report-figures .table th[scope="row"] { font-weight: 400; color: inherit; font-size: 13px; white-space: normal; }
.report-widgets { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; margin: 16px 0; }
.report-widgets .card { box-shadow: none; }
.report-footer { color: var(--text-3); font-size: 11px; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 24px; }
.num-warning { background: #fef3c7; border-bottom: 2px solid #f59e0b; }

/* ── Admin ──────────────────────────────────────────────────────────────── */
.admin-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.admin-sidebar { background: var(--brand); color: var(--brand-ink); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.admin-brand { color: inherit; font-weight: 700; font-size: 16px; padding: 4px 10px; text-decoration: none !important; display: block; }
.admin-brand__logo { display: block; height: 22px; width: auto; max-width: 210px; object-fit: contain; object-position: left center; margin-bottom: 4px; }
.admin-brand__sub { display: block; font-weight: 400; font-size: 12px; opacity: 0.65; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.admin-nav__item { color: inherit; opacity: 0.75; padding: 8px 10px; border-radius: var(--radius-sm); font-weight: 500; text-decoration: none !important; display: flex; align-items: center; gap: 8px; }
.admin-nav__badge { margin-left: auto; }
.admin-nav__item:hover { opacity: 1; background: color-mix(in srgb, var(--brand-ink) 8%, transparent); }
.admin-nav__item.is-active { opacity: 1; background: color-mix(in srgb, var(--brand-ink) 14%, transparent); }
.admin-nav__sep { height: 1px; background: color-mix(in srgb, var(--brand-ink) 15%, transparent); margin: 8px 4px; }
.admin-sidebar__user { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px; border-top: 1px solid color-mix(in srgb, var(--brand-ink) 15%, transparent); }
.admin-sidebar__user .muted { color: inherit; opacity: 0.6; }
.admin-sidebar .btn--ghost { color: inherit; }
.admin-main { min-width: 0; }
.admin-client-bar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 12px 28px 0; }
.admin-client-bar__title { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }
.admin-client-bar__title a:not(.btn) { color: var(--text); }
.swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid rgba(0, 0, 0, 0.1); flex-shrink: 0; }
/* A client's color swatch and name on one line (the name may wrap, the swatch stays beside it). */
.client-name { display: inline-flex; align-items: center; gap: 8px; }
.admin-content { padding: 24px 28px 48px; max-width: 1200px; }
/* Row actions in admin tables wrap onto a second line instead of widening the table past its card. */
.admin .table td.right.nowrap { white-space: normal; }
.admin .table td.right > form { display: inline-block !important; margin: 2px 0; }
/* Data sources: the row's actions as a tidy two-row grid (Edit, Test, Sync now / Backfill, Disable, Delete). */
.conn-actions { display: grid; grid-template-columns: repeat(3, max-content); gap: 4px; justify-content: end; }
.conn-actions > form, .conn-actions > details { display: block !important; }
.conn-actions .btn { width: 100%; justify-content: center; }
.conn-id { overflow-wrap: anywhere; }
.conn-sync { min-width: 140px; }
.admin-content--wide { max-width: none; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 1000px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.diff-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.diff-list li { padding: 6px 10px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; border-left: 3px solid var(--accent); }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; }
pre.json { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: var(--radius-sm); overflow: auto; max-height: 420px; }

@media (max-width: 860px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; }
  .admin-content { padding: 16px; }
  .admin-client-bar { padding: 12px 16px 0; }
  .portal-header__inner { padding: 0 16px; gap: 12px; }
  .portal-main { padding: 16px; }
  .portal-user .btn { display: none; }
  .report-doc { padding: 24px 16px; }
  /* The floating "Ask about your numbers" button (ask.js) sits 16px from the bottom: keep the footer and the
     end of the page clear of it. */
  body.portal--ask .portal-footer { padding-bottom: 88px; }
}
/* Phones: brand and user menu on the first row, the main tabs on a full-width row of their own (scrolled so
   the active tab shows, an edge fading while there's more). The header scrolls away instead of taking a
   third of the screen. */
@media (max-width: 760px) {
  .portal-header { position: static; }
  .portal-header__inner { flex-wrap: wrap; height: auto; padding: 6px 16px 0; gap: 0 12px; }
  .portal-brand { flex: 1 1 auto; min-width: 0; height: 44px; }
  .portal-brand .client-logo--md { max-width: 60vw; }
  .portal-brand .client-wordmark { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .portal-nav { order: 3; flex: 1 0 100%; margin: 0 -16px; padding: 2px 12px 8px; }
  .portal-nav__item { padding: 8px 10px; }
  .portal-subnav__inner { padding: 0 8px; }
  .portal-subnav__item { padding: 10px 8px; }
}

/* ── AI studio (staff) ──────────────────────────────────────────────────── */
.studio { display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); gap: 0; height: calc(100vh - 110px); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.studio__chat { display: flex; flex-direction: column; border-right: 1px solid var(--border); min-height: 0; }
.studio__preview { display: flex; flex-direction: column; min-height: 0; background: var(--bg); }
.studio__preview-bar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.studio__frame { flex: 1; border: 0; width: 100%; background: var(--bg); }
@media (max-width: 1000px) { .studio { grid-template-columns: 1fr; height: auto; } .studio__chat { height: 70vh; } .studio__frame { height: 70vh; } }

.chat { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat__log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat__msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.55; }
.chat__msg p:last-child { margin-bottom: 0; }
.chat__msg ul, .chat__msg ol { margin: 4px 0 8px; padding-left: 18px; }
.chat__msg--user { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.chat__msg--user a { color: #fff; }
.chat__msg--assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat__status { align-self: flex-start; font-size: 12px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.chat__status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
.chat__form { border-top: 1px solid var(--border); padding: 10px; display: flex; gap: 8px; align-items: flex-end; }
.chat__form textarea { min-height: 44px; max-height: 180px; }
.chat__suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 8px; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer; color: var(--text-2); font: inherit; font-size: 12px; }
.chip:hover { border-color: var(--accent); color: var(--accent-ink); }
.proposal { border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border)); border-radius: var(--radius); background: var(--surface); padding: 12px; align-self: stretch; }
.proposal__title { font-weight: 600; font-size: 13px; margin-bottom: 8px; display: flex; justify-content: space-between; gap: 8px; }
.proposal__warnings { font-size: 12px; color: var(--warn); margin: 8px 0 0; padding-left: 16px; }
.proposal__actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.proposal--applied { border-color: #a7f3d0; background: var(--good-bg); }
.proposal--discarded { opacity: 0.6; }

/* ── Ask drawer (client) ────────────────────────────────────────────────── */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: var(--surface); box-shadow: var(--shadow-lg); z-index: 50; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 0.2s ease; }
.drawer.is-open { transform: none; }
.drawer__head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.drawer__backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.3); z-index: 40; display: none; }
.drawer__backdrop.is-open { display: block; }

/* ── Auth ───────────────────────────────────────────────────────────────── */
body.auth { background: var(--brand-soft); }
.auth-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 32px; border-top: 4px solid var(--brand); }
.auth-brand { margin-bottom: 20px; color: var(--brand); }
.auth-logo { display: block; height: 40px; width: auto; max-width: 260px; }
.auth-logo-band { display: inline-flex; padding: 10px 14px; border-radius: 8px; background: var(--brand); }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-card .btn { width: 100%; justify-content: center; height: 40px; }
.auth-footer { margin-top: 18px; font-size: 12px; color: var(--text-3); }

/* ── Print / PDF ────────────────────────────────────────────────────────── */
@page { size: A4; margin: 14mm 12mm; }
@media print {
  body { background: #fff; font-size: 12px; }
  body.portal:not(.preview-page) { display: block; min-height: 0; }
  .portal-header, .portal-footer, .preview-banner, .no-print, .drawer, .drawer__backdrop, #ask-root, .skip-link { display: none !important; }
  .portal-main { padding: 0; max-width: none; }
  .report-doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .chart-box { height: 200px; }
  a { color: inherit; }
}
body.print-mode { background: #fff; }
body.print-mode .report-doc { border: 0; box-shadow: none; padding: 0; max-width: none; }

/* Client meetings (admin) */
.meeting__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.meeting__title { font-size: 18px; margin: 0 0 2px; }
.meeting__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.meeting__label { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); margin: 0 0 4px; }
.meeting__list { margin: 0; padding-left: 18px; }
.meeting__list li { margin-bottom: 4px; }
.meeting-notes { margin: 0; padding-left: 18px; }

/* Onboarding steps (src/views/admin/onboarding.tsx) */
.setup-step { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.setup-step--done, .setup-step--skipped { border-left-color: #16a34a; }
.setup-step--waiting { border-left-color: #d97706; }
.setup-step--blocked { border-left-color: #dc2626; }
.setup-step p { margin: 6px 0; }
