/* ReportFalcon - brand: navy #041532, blue #2665f3, sky #309bfe, cyan #0ad3fe (change in :root).
   Agencies with their own colours override the brand variables below (see branding.css_variables). */
:root {
  --navy: #041532;
  --navy-2: #041532;
  --accent: #2665f3;
  --accent-hover: #2056cf;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --accent-ring: rgba(38, 101, 243, .25);
  --accent-glow: rgba(10, 211, 254, .35);
  --ice: #0ad3fe;
  --ice-tint: rgba(10, 211, 254, .14);
  --login-end: #1e3a8a;
  --bg: #f5f6f9;
  --surface: #ffffff;
  --border: #dfe2f0;
  --border-soft: #e9ebf5;
  --text: #1f2937;
  --text-2: #4a5072;
  --muted: #5f6582;
  --good: #15803d;
  --good-soft: #e9f6ee;
  --bad: #b91c1c;
  --bad-soft: #fdeeee;
  --warn-soft: #fff6e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(30, 41, 59, 0.06), 0 4px 16px rgba(30, 41, 59, 0.05);
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Inter', system-ui, sans-serif;

  /* source colours, shared by the page-traffic cards */
  --src-google: #2a78d6;
  --src-bing: #1baf7a;
  --src-ai: #4a3aa7;
  --src-direct: #eb6834;
  --src-other: #9aa5b4;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font: 800 28px/1.15 var(--display); letter-spacing: -0.01em; }
h2 { font: 800 20px/1.2 var(--display); }
h3 { font-size: 15px; font-weight: 600; }
h4 { font-size: 14px; font-weight: 600; }
code { background: var(--accent-soft); padding: 1px 6px; border-radius: 4px; font-size: 12.5px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.inline { display: inline; }
.error-text { color: var(--bad); }
.print-only { display: none; }

/* ---------------------------------------------------------------- layout */
.container { max-width: 1180px; margin: 0 auto; padding: 28px 16px 64px; }
.report-container { max-width: 1240px; margin: 0 auto; padding: 0 16px 64px; }

.topbar { background: var(--navy); color: #fff; }
.topbar-inner { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 600; }
.brand:hover { color: #fff; text-decoration: none; }
.brand img { height: 30px; }
.brand .brand-product { padding-left: 12px; border-left: 1px solid rgba(255,255,255,.25); font-size: 14px; letter-spacing: .02em; }
.brand .platform-logo { height: 30px; }
.brand .brand-agency { display: flex; align-items: center; padding-left: 12px; border-left: 1px solid rgba(255,255,255,.25); }
.brand .brand-agency img { height: 24px; max-width: 160px; object-fit: contain; }
.brand .brand-agency img.logo-on-dark { height: 18px; }
.brand .brand-agency .brand-text { font-size: 14px; font-weight: 600; letter-spacing: .01em; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { color: #d6dcf0; padding: 6px 12px; border-radius: 8px; font-size: 13.5px; }
.topbar nav a:hover, .topbar nav a.active { color: #fff; background: var(--ice-tint); text-decoration: none; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { margin: 4px 0 4px; }
.page-head p { margin: 0; max-width: 680px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.callout { background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: 10px; padding: 12px 16px; margin-bottom: 20px; }
.flash { border-radius: 10px; padding: 11px 16px; margin: 0 0 16px; border: 1px solid; }
.flash-success { background: var(--good-soft); border-color: #bfe3cc; color: #14532d; }
.flash-error { background: var(--bad-soft); border-color: #f3c5c5; color: #7f1d1d; }
.flash-warning { background: var(--warn-soft); border-color: #f2dda5; color: #6b4b00; }
.empty { text-align: center; padding: 64px 16px; }
.empty p { max-width: 520px; margin: 0 auto 20px; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* ---------------------------------------------------------------- buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s; }
.btn:hover { text-decoration: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: #c3c8dc; color: var(--text); background: #f9fafb; }
.btn-google { background: #fff; color: #1f1f1f; border-color: #747775; gap: 10px; font-weight: 500; }
.btn-google:hover { background: #f8faff; color: #1f1f1f; border-color: #747775; }
.or-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--muted); font-size: 12.5px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.center { text-align: center; }
.btn-danger { background: var(--surface); color: var(--bad); border-color: #f0c4c4; }
.btn-danger:hover { background: var(--bad-soft); color: var(--bad); }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; font-weight: 500; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

label { display: block; font-weight: 500; font-size: 13px; margin-bottom: 14px; color: var(--text-2); }
input, select, textarea { display: block; width: 100%; margin-top: 6px; font: 14px var(--font); color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-ring); border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }
.danger-zone { margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border); }

.mt { margin-top: 16px; }
.tag-muted { background: #f0eff7; color: var(--text-2); }
.copy-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0 4px; }
.copy-value { font-size: 15px; padding: 8px 12px; background: var(--accent-soft); border: 1px solid var(--accent-border); border-radius: 8px; }
.instructions { white-space: pre-wrap; font-size: 13px; line-height: 1.55; color: var(--text-2); background: #f9fafb; border: 1px solid var(--border-soft); border-radius: 10px; padding: 14px 16px; margin: 8px 0 10px; max-height: 320px; overflow: auto; }
.steps { padding-left: 20px; display: grid; gap: 6px; }
.sa-upload { margin-top: 12px; max-width: 520px; }
.sa-upload input[type=file] { padding: 7px; }
details summary { cursor: pointer; color: var(--accent); }
.props-status-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: -6px 0 12px; }
.props-status-row p { margin: 0; }

/* ---------------------------------------------------------------- share dialog & shared reports */
.dialog { border: 0; border-radius: 14px; padding: 24px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 24px 64px rgba(29, 38, 80, .3); color: var(--text); }
.dialog::backdrop { background: rgba(29, 38, 80, .45); }
.dialog h3 { font: 800 19px var(--display); margin-bottom: 6px; }
.dialog-close { position: absolute; right: 14px; top: 10px; }
.dialog-close button { border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
.dialog .copy-row input { flex: 1 1 220px; margin: 0; font-size: 13px; }
.share-ok { color: var(--good); font-weight: 600; margin: 4px 0 8px; }
.link-cell { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.report-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.report-list a.report-item { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
.report-list a.report-item:hover { border-color: #c3c8dc; text-decoration: none; }
.report-item strong { display: block; font-size: 15px; }
.snapshot-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 0; margin-bottom: 8px; }
.snapshot-bar .muted { font-size: 13px; }
.snapshot-bar a.muted { display: block; margin-bottom: 2px; }
.snapshot-bar strong { font-size: 16px; }

/* ---------------------------------------------------------------- login */
.login-page { background: linear-gradient(160deg, var(--navy) 0%, var(--login-end) 100%); min-height: 100vh; }
.login-page .container { padding-bottom: 12vh; }
.login-card { max-width: 380px; margin: 12vh auto 0; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-card-wide { max-width: 440px; margin-top: 8vh; }
.login-logo { height: 46px; max-width: 100%; object-fit: contain; object-position: left; margin-bottom: 20px; }
.login-card .brand-text.login-logo { display: block; height: auto; font-size: 22px; color: var(--navy); }
.auth-foot { margin: 18px 0 0; }

/* ---------------------------------------------------------------- agency logos, team, branding */
.brand-text { font: 800 18px/1.1 var(--display); letter-spacing: -0.01em; }
.logo-on-dark { background: #fff; border-radius: 8px; padding: 5px 9px; box-sizing: content-box; }
.brand img.logo-on-dark { height: 22px; }
.cover-agency img.logo-on-dark { height: 30px; }
.cover-agency .brand-text { display: inline; margin: 0; font-size: 22px; color: #fff; text-transform: none; letter-spacing: -0.01em; }
.report-footer .brand-text { font-size: 17px; color: var(--navy); }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; margin: 0; }
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.color-grid input[type=color] { height: 42px; padding: 4px; cursor: pointer; }
.logo-field + .logo-field { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-soft); }
.logo-preview { height: 72px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border); border-radius: 10px; margin-bottom: 10px; background: #fff; }
.logo-preview.on-dark { background: var(--navy); border-style: solid; }
.logo-preview img { max-height: 48px; max-width: 80%; }
.brand-preview { border: 1px solid var(--border-soft); border-radius: 12px; overflow: hidden; }
.brand-preview-cover { background: var(--navy); color: #fff; padding: 18px 18px 16px; display: grid; gap: 6px; }
.brand-preview-cover strong { font: 800 20px var(--display); }
.brand-preview-agency { display: flex; align-items: center; gap: 10px; font-size: 11px; color: #aab4d6; text-transform: uppercase; letter-spacing: .1em; margin-top: 6px; }
.brand-preview-agency img { height: 26px; }
.brand-preview-agency img.logo-on-dark { height: 20px; }
.brand-preview-agency .brand-text { font-size: 15px; color: #fff; text-transform: none; letter-spacing: 0; }
.brand-preview-body { padding: 16px 18px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand-preview-line { width: 120px; height: 32px; }
.invite-form { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(180px, 1.4fr) auto; gap: 12px; align-items: end; }
.invite-form label { margin: 0; }
.invite-form .btn { height: 41px; }
@media (max-width: 640px) { .invite-form, .color-grid { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- dashboard */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.client-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.client-card-head { display: flex; gap: 12px; align-items: center; min-width: 0; }
.client-card-head > div { min-width: 0; }
.client-card h2 { font-size: 17px; margin: 0 0 2px; }
.client-card h2 a { color: var(--text); }
.client-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 10px; border: 1px solid var(--border-soft); padding: 4px; background: #fff; }
.client-initial { width: 44px; height: 44px; border-radius: 10px; background: var(--navy); color: var(--ice); display: grid; place-items: center; font: 800 20px var(--display); flex-shrink: 0; }
.conn-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.conn-list li { display: flex; align-items: center; gap: 8px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn-list .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.conn-list .ok .dot { background: var(--good); }
.conn-list .missing .dot { background: #c3cdd9; }
.client-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.client-card-foot .card-via { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.client-card-foot .actions { flex-wrap: nowrap; margin-left: auto; }

/* ---------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfaff; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table.compact td { padding: 7px 8px; }
.table.compact th { padding: 7px 8px; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text); }
.table th[data-dir="desc"]::after { content: " ↓"; }
.table th[data-dir="asc"]::after { content: " ↑"; }
.table td.kw { font-weight: 500; max-width: 340px; }
/* max-width: 0 + width: 100% lets the URL column take the leftover space and truncate, instead of widening the table */
.table td.url { max-width: 0; width: 100%; min-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.url a { color: var(--text); }
.table-card { padding: 8px 12px; overflow-x: auto; }
.collapsible:not(.expanded) tr.extra { display: none; }
.more-btn { margin: 10px 10px 6px; font-size: 13px; }

.chg { font-variant-numeric: tabular-nums; font-size: 12.5px; font-weight: 500; }
.chg.up, .delta.up { color: var(--good); }
.chg.down, .delta.down { color: var(--bad); }
.chg.flat, .delta.flat { color: var(--muted); }
.badge-new { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; }
.delta { font-size: 12.5px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.swatch, .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: -1px; }

/* ---------------------------------------------------------------- report toolbar */
.report-toolbar { position: sticky; top: 0; z-index: 20; background: rgba(246, 245, 251, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); margin: 0 -16px 24px; padding: 12px 16px; display: flex; gap: 12px 20px; align-items: flex-end; flex-wrap: wrap; }
.toolbar-title { display: flex; flex-direction: column; min-width: 140px; }
.toolbar-title strong { font-size: 15px; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; flex: 0 1 auto; }
.controls label { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.controls input, .controls select { margin-top: 4px; height: 34px; padding: 4px 9px; font-size: 13.5px; width: auto; min-width: 0; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.share-reset { margin-top: 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.shared .report-toolbar { margin-top: 0; }

.loading { text-align: center; padding: 120px 16px; color: var(--muted); }
.spinner { width: 36px; height: 36px; margin: 0 auto 16px; border-radius: 50%; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- report: cover */
.cover { position: relative; overflow: hidden; background: var(--navy); color: #fff; border-radius: 16px; padding: 36px 36px 32px; margin-bottom: 24px; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.cover::after { content: ""; position: absolute; right: -60px; top: -60px; width: 340px; height: 340px; background: radial-gradient(circle, var(--accent-glow), transparent 65%); pointer-events: none; }
.cover > * { position: relative; z-index: 1; }
.cover h1 { color: #fff; font-size: 36px; margin: 6px 0 4px; }
.eyebrow { margin: 0; color: var(--ice); text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 600; }
.cover-site { margin: 0; color: #c3cbe6; }
.cover-client-logo { max-height: 48px; max-width: 200px; background: #fff; border-radius: 8px; padding: 6px 10px; margin-bottom: 14px; }
.cover-dates { display: flex; gap: 28px; margin-top: 24px; flex-wrap: wrap; }
.cover-dates span { display: block; color: var(--ice); font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; }
.cover-dates strong { font-size: 16px; font-weight: 600; }
.cover-agency { align-self: flex-end; text-align: right; }
.cover-agency span { display: block; color: #aab4d6; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 6px; }
.cover-agency img { height: 40px; }

/* ---------------------------------------------------------------- report: sections */
.section { margin-bottom: 36px; scroll-margin-top: 150px; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }
.section-num { font: 800 13px var(--display); color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 3px 8px; }
#report-root { counter-reset: report-section; }
.section-num::before { counter-increment: report-section; content: counter(report-section, decimal-leading-zero); }
.stars { color: #e3a008; letter-spacing: 1px; }
.review-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.review-list li { border-top: 1px solid var(--border-soft); padding-top: 10px; }
.review-list p { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.review-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 13px; }
.section-sub { color: var(--muted); font-size: 13px; }
/* Per-client on/off switch for each report section (agency view only) */
.section-switch { order: 9; margin-left: auto; align-self: center; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--accent); user-select: none; }
.section-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 34px; height: 20px; border-radius: 999px; background: #c9cbe0; transition: background .15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(29, 38, 80, .3); transition: transform .15s; }
.section-switch input:checked + .switch-track { background: var(--accent); }
.section-switch input:checked + .switch-track::after { transform: translateX(14px); }
.section-switch input:focus-visible + .switch-track { outline: 2px solid var(--accent-ring); outline-offset: 2px; }
.section.is-hidden { margin-bottom: 18px; }
.section.is-hidden > :not(.section-head) { display: none; }
.section.is-hidden .section-head { margin-bottom: 0; padding: 10px 14px; border: 1px dashed var(--border); border-radius: var(--radius); }
.section.is-hidden .section-head h2 { color: var(--muted); }
.section.is-hidden .section-switch { color: var(--muted); }
.section.is-hidden .section-num::before { counter-increment: none; content: "–"; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.two-col-wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.two-col > .card, .three-col > .card { margin-bottom: 0; }
.footnote { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.source-hint { font-size: 12.5px; color: var(--muted); margin: -8px 0 18px; }

/* summary */
.summary-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
.summary-card { margin-bottom: 0; }
.summary-headline { font: 800 19px/1.3 var(--display); margin-bottom: 12px; }
.summary-points { margin: 0; padding-left: 20px; display: grid; gap: 8px; color: var(--text-2); }
.summary-points li::marker { color: var(--accent); }
.summary-side { display: flex; flex-direction: column; gap: 16px; }
.summary-side .card { margin: 0; }
.wins, .focus { padding: 16px 18px; }
.wins { border-left: 3px solid var(--good); }
.focus { border-left: 3px solid var(--accent); }
.wins h4, .focus h4 { display: flex; align-items: center; gap: 8px; }
.wins .icon, .focus .icon { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 10px; color: #fff; }
.wins .icon { background: var(--good); }
.focus .icon { background: var(--accent); font-weight: 700; }
.wins ul, .focus ul { margin: 0; padding-left: 18px; font-size: 13px; display: grid; gap: 5px; color: var(--text-2); }
.notes-card { margin-top: 16px; }
.notes-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.notes-card textarea { margin-top: 4px; }
.notes-print { white-space: pre-wrap; color: var(--text-2); }

/* KPI tiles */
.kpi-group-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; margin: 8px 0 10px; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; margin: 4px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-foot { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; min-height: 18px; }
.kpi-prev { font-size: 12px; color: var(--muted); }

/* charts */
.chart-card { padding: 18px 20px 16px; }
.chart-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.chart-head h3 { margin-bottom: 2px; }
.chart-head p { margin: 0; }
.chart-box { position: relative; height: 320px; }
.chart-box-sm { height: 260px; }
.tabs { display: inline-flex; background: var(--bg); border: 1px solid var(--border-soft); border-radius: 9px; padding: 3px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; font: 500 12.5px var(--font); color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.tabs button:hover { color: var(--text); }
.tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(29, 38, 80, .12); }

/* top pages by traffic */
.source-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin: -4px 0 12px; }
.source-legend .sw { margin-right: 6px; }
.sw-google, .seg-google { background: var(--src-google); }
.sw-bing, .seg-bing { background: var(--src-bing); }
.sw-ai, .seg-ai { background: var(--src-ai); }
.sw-direct, .seg-direct { background: var(--src-direct); }
.sw-other, .seg-other { background: var(--src-other); }
.seg-dev1 { background: #2a78d6; }
.seg-dev2 { background: #eb6834; }
.seg-dev3 { background: #1baf7a; }
.seg-dev4 { background: #eda100; }
.seg-brand { background: var(--ice); }
.seg-nonbrand { background: var(--accent); }
.pt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.pt-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; break-inside: avoid; }
.pt-top { display: flex; gap: 12px; align-items: flex-start; }
.pt-rank { flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px; background: var(--navy); color: var(--ice); display: grid; place-items: center; font: 800 13px var(--display); }
.pt-title { min-width: 0; }
.pt-name { font-weight: 600; line-height: 1.3; }
.tag-top { background: var(--navy); color: var(--ice); margin-left: 4px; vertical-align: 1px; }
.pt-path { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-total { margin: 12px 0 8px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.pt-total strong { font-size: 24px; font-weight: 600; }
.pt-total span { color: var(--muted); font-size: 12.5px; }
.stackbar, .sharebar { display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden; background: var(--border-soft); margin-bottom: 12px; }
.stackbar .seg, .sharebar .seg { display: block; height: 100%; min-width: 2px; }
.pt-sources { display: flex; gap: 6px; margin: 0; }
.pt-sources div { flex: 1 1 0; min-width: 0; }
.pt-sources dt { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pt-sources dt .sw { width: 7px; height: 7px; margin-right: 4px; border-radius: 2px; }
.pt-sources dd { margin: 2px 0 0; font-weight: 600; font-size: 13px; font-variant-numeric: tabular-nums; }

.ai-total { margin: 8px 0 12px; display: flex; gap: 8px; align-items: baseline; }
.ai-total strong { font-size: 28px; font-weight: 600; }

.report-footer { margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; gap: 24px; align-items: flex-start; }
.report-footer p { margin: 0 0 6px; }
.footer-logo { height: 34px; }

/* ---------------------------------------------------------------- platform admin */
.topbar nav a.nav-admin { color: #fde68a; }
.admin-topbar { background: #111827; }
.admin-topbar .topbar-inner { height: auto; min-height: 60px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
.support-bar { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 8px 16px; background: #fef3c7; color: #78350f; border-bottom: 1px solid #fcd34d; font-size: 13.5px; text-align: center; }
.support-bar .support-exit { background: #78350f; color: #fff; }
.support-bar .support-exit:hover { background: #92400e; color: #fff; }
.admin-alert { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.admin-alert a { white-space: nowrap; font-weight: 600; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-grid-sm { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 4px; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; color: var(--text); }
a.stat:hover { border-color: #c3c8dc; text-decoration: none; color: var(--text); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font: 800 28px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat-value-sm { font-size: 20px; }
.stat-of { font-size: 16px; font-weight: 600; color: var(--muted); }
.stat-sub { font-size: 12.5px; color: var(--muted); }
.meter { display: block; height: 6px; border-radius: 999px; background: var(--border-soft); overflow: hidden; margin: 4px 0; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--accent); }
.admin-two { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; margin-bottom: 16px; }
.admin-two > .card { margin-bottom: 0; }
.admin-chart { position: relative; height: 220px; }
.activity-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: 13.5px; }
.activity-list li { display: grid; gap: 2px; padding-bottom: 10px; border-bottom: 1px solid var(--border-soft); }
.activity-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.activity-action { font: 600 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--text-2); }
.filter-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filter-row input, .filter-row select { width: auto; flex: 1 1 220px; max-width: 360px; margin: 0; }
.filter-row select { flex: 0 1 200px; }
.table-scroll { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: #6b4b00; }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
h1 .badge { font-size: 13px; vertical-align: middle; }
.src-tags { display: inline-flex; gap: 4px; }
.src-tag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); color: var(--muted); background: #fff; text-decoration: line-through; text-decoration-color: rgba(95, 101, 130, .5); }
.src-tag.on { border-color: transparent; background: var(--good-soft); color: var(--good); text-decoration: none; }
.row-actions { position: relative; display: inline-block; text-align: left; }
.row-actions summary { list-style: none; }
.row-actions summary::-webkit-details-marker { display: none; }
/* Opens inside the row (tables scroll sideways, which would clip a floating menu). */
.row-actions-menu { margin-top: 6px; min-width: 230px; display: grid; gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.row-actions-menu form { margin: 0; }
.link-btn.error-text { color: var(--bad); }
.row-actions-menu .link-btn { display: block; width: 100%; text-align: left; padding: 6px 8px; border-radius: 6px; font-size: 13px; }
.row-actions-menu .link-btn:hover { background: var(--accent-soft); text-decoration: none; }
.admin-brand { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-left: 6px; border: 1px solid rgba(0, 0, 0, .1); }
.danger-card { border-color: #f3c5c5; }
.danger-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--border-soft); }
.danger-row:first-of-type { border-top: 0; }
.danger-row p { margin: 0; flex: 1 1 260px; }
.danger-row .grow { flex: 1 1 320px; margin: 0; }
.btn-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.input-sm { width: 120px; margin: 0; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1000px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary-grid, .two-col, .two-col-wide-left, .three-col { grid-template-columns: minmax(0, 1fr); }
  .two-col > .card, .three-col > .card { margin-bottom: 0; }
}
@media (max-width: 640px) {
  .cover { padding: 24px 20px; }
  .cover h1 { font-size: 28px; }
  .cover-agency { text-align: left; align-self: flex-start; }
  .kpi-value { font-size: 22px; }
  .report-footer { flex-direction: column; }
  .controls label { flex: 1 1 140px; }
  .controls input, .controls select { width: 100%; }
  .chart-box { height: 260px; }
  .brand .brand-product { display: none; }
  .brand .platform-logo { height: 24px; }
  .brand .brand-agency { padding-left: 8px; }
  .brand .brand-agency .brand-text { font-size: 13px; }
  .report-toolbar { position: static; }
}

/* ---------------------------------------------------------------- PDF download (desktop layout on any device) */
body.pdf-mode .no-print, body.pdf-mode .more-btn, body.pdf-mode .tabs, body.pdf-mode .section.is-hidden { display: none !important; }
body.pdf-mode .print-only { display: block; }
body.pdf-mode .notes-card.is-empty { display: none; }
body.pdf-mode #report-root { max-width: none; background: #fff; }
body.pdf-mode .card, body.pdf-mode .kpi, body.pdf-mode .pt-card { box-shadow: none; border-color: #e4e2f0; }
body.pdf-mode .section { margin-bottom: 22px; }
body.pdf-mode .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
body.pdf-mode .summary-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
body.pdf-mode .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
body.pdf-mode .two-col-wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
body.pdf-mode .three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
body.pdf-mode .pt-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
body.pdf-mode .chart-box { height: 280px; }
body.pdf-mode .chart-box-sm { height: 230px; }
body.pdf-mode .cover { padding: 36px; }
body.pdf-mode .cover h1 { font-size: 36px; }
body.pdf-mode .table-card { overflow: visible; }
body.pdf-mode .table td.url { white-space: normal; word-break: break-all; }

/* ---------------------------------------------------------------- print / PDF */
@page { size: A4; margin: 12mm; }
@media print {
  body { background: #fff; font-size: 11.5px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .no-print, .topbar, .report-toolbar, .share-reset, .more-btn, .tabs, .section.is-hidden { display: none !important; }
  .print-only { display: block; }
  .notes-card.is-empty { display: none; }
  .report-container { max-width: none; padding: 0; }
  .card, .kpi, .pt-card { box-shadow: none; border-color: #e4e2f0; }
  .section { break-inside: auto; margin-bottom: 18px; }
  .section-head { break-after: avoid; }
  .card, .kpi, .pt-card, .chart-card, tr { break-inside: avoid; }
  #search-trends, #traffic, #top-keywords { break-before: page; }
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .summary-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
  .two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col-wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .three-col { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-box { height: 250px; }
  .chart-box-sm { height: 210px; }
  .pt-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .table-card { overflow: visible; }
  .table td.url { white-space: normal; word-break: break-all; }
  a { color: inherit; }
}
