/* ============================================================
   SEER SEO Hub — executive briefing room design system
   Fraunces (display serif) + Archivo (data grotesque)
   SEER brand palette · deep navy shell · light-blue accents
   ============================================================ */

:root {
    --paper: #F5F7F9;
    --surface: #FFFFFF;
    --ink: #062B47;
    --ink-soft: #6b7280;
    --ink-faint: #9ca3af;
    --line: #e5e7eb;
    --line-soft: #eef0f2;
    --navy: #093E66;
    --navy-deep: #062B47;
    --navy-mid: #0a4a7a;
    --navy-bright: #0e5d99;
    --accent: #0e5d99;
    --accent-soft: #bcd3e6;
    --green: #047A40;
    --green-tint: #ecfdf5;
    --red: #dc2626;
    --red-tint: #fef2f2;
    --amber: #f59e0b;
    --neutral: #9ca3af;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(6, 43, 71, .04), 0 10px 28px -16px rgba(6, 43, 71, .16);
    --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
    --font-body: 'Archivo', 'Helvetica Neue', Arial, sans-serif;
    --sidebar-w: 236px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--paper);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-soft); color: var(--navy-deep); }

/* ---------- App shell ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background:
        radial-gradient(120% 60% at 0% 0%, rgba(188, 211, 230, .08) 0%, transparent 55%),
        linear-gradient(168deg, var(--navy) 0%, var(--navy-deep) 78%);
    color: #bcd3e6;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
}

/* White-on-transparent logo, straight on the navy sidebar */
.wordmark {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 20px 20px 16px;
    text-decoration: none;
    border-bottom: 1px solid rgba(188, 211, 230, .16);
}
.wordmark img {
    width: 124px;
    max-width: 100%;
    height: auto;
    display: block;
}
.wordmark .product-label {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .3em;
    text-transform: uppercase;
    color: var(--accent-soft);
    padding: 2px 10px;
    border: 1px solid rgba(188, 211, 230, .35);
    border-radius: 999px;
}

.sidebar nav { padding: 18px 12px; flex: 1; overflow-y: auto; }

.nav-label {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .24em;
    text-transform: uppercase;
    color: rgba(188, 211, 230, .5);
    padding: 16px 10px 7px;
}
.nav-label:first-child { padding-top: 2px; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: #bcd3e6;
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: background .15s, color .15s;
    position: relative;
}
.sidebar nav a svg { width: 17px; height: 17px; opacity: .75; flex-shrink: 0; }
.sidebar nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar nav a.active {
    background: var(--navy-mid);
    color: #fff;
}
.sidebar nav a.active::before {
    content: '';
    position: absolute;
    left: -12px; top: 7px; bottom: 7px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-soft);
}
.sidebar nav a.active svg { opacity: 1; color: var(--accent-soft); }

.sidebar-foot {
    padding: 16px 20px;
    border-top: 1px solid rgba(188, 211, 230, .16);
    font-size: 11px;
    color: rgba(188, 211, 230, .6);
    line-height: 1.6;
}
.sidebar-foot strong { color: rgba(255, 255, 255, .8); font-weight: 600; }

/* ---------- Content column ---------- */

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 32px;
    background: rgba(245, 247, 249, .88);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}

.menu-btn {
    display: none;
    background: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 9px;
    cursor: pointer;
    color: var(--ink);
}
.menu-btn svg { width: 18px; height: 18px; display: block; }

.search { position: relative; width: 280px; }
.search svg {
    position: absolute; left: 11px; top: 50%;
    transform: translateY(-50%);
    width: 14px; height: 14px;
    color: var(--ink-faint);
    pointer-events: none;
}
.search input {
    width: 100%;
    padding: 8px 12px 8px 33px;
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--ink-faint); }
.search input:focus { border-color: var(--navy-bright); box-shadow: 0 0 0 3px rgba(14, 93, 153, .14); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.signin-link {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--navy);
    text-decoration: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 14px;
    background: var(--surface);
}
.signin-link:hover { border-color: var(--navy-bright); }

.month-form { display: flex; align-items: center; gap: 8px; }
.month-form label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.month-form select {
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    padding: 7px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    outline: none;
}
.month-form select:focus { border-color: var(--navy-bright); }

main { padding: 30px 32px 12px; flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; }

/* Staggered page-load rise */
@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
main > * { animation: rise .45s cubic-bezier(.2, .7, .3, 1) both; }
main > *:nth-child(2) { animation-delay: .05s; }
main > *:nth-child(3) { animation-delay: .10s; }
main > *:nth-child(4) { animation-delay: .15s; }
main > *:nth-child(5) { animation-delay: .20s; }
main > *:nth-child(6) { animation-delay: .25s; }
main > *:nth-child(n+7) { animation-delay: .30s; }

@media (prefers-reduced-motion: reduce) {
    main > * { animation: none; }
}

.foot {
    padding: 18px 32px 26px;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    font-size: 11px;
    color: var(--ink-faint);
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---------- Page header ---------- */

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.eyebrow {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .24em;
    text-transform: uppercase;
    color: var(--navy-bright);
    margin-bottom: 6px;
}

h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 30px;
    line-height: 1.1;
    color: var(--navy-deep);
    letter-spacing: -.01em;
}

.page-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 7px; }
.page-meta a { color: var(--navy); }
.etl-stamp { font-size: 11px; color: var(--ink-soft); background: rgba(14,93,153,.08); padding: 3px 10px; border-radius: 4px; display: inline-block; margin-top: 4px; }

h2 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 18px;
    color: var(--navy-deep);
}

.crumbs { font-size: 12px; color: var(--ink-faint); margin-bottom: 10px; }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--navy); }
.crumbs span::before { content: '/'; margin: 0 7px; color: var(--line); }

/* ---------- KPI cards ---------- */

.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px 14px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.kpi::before {
    content: '';
    position: absolute;
    top: 0; left: 18px; right: 18px;
    height: 2px;
    border-radius: 0 0 2px 2px;
    background: linear-gradient(90deg, var(--navy-bright), transparent);
}
.kpi .label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.kpi .value {
    font-family: var(--font-display);
    font-size: 27px;
    font-weight: 600;
    color: var(--navy-deep);
    padding-top: 5px;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.kpi .sub { font-size: 11.5px; color: var(--ink-soft); padding-top: 3px; }

/* ---------- Panels ---------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 26px;
    overflow: hidden;
}
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 15px 20px;
    border-bottom: 1px solid var(--line-soft);
}
.panel-head .hint { font-size: 11.5px; color: var(--ink-faint); }
.panel-body { padding: 20px; }

.tables-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: 20px;
    align-items: start;
    margin-bottom: 26px;
}

/* ---------- Tables ---------- */

.table-scroll { overflow-x: auto; }

table.report {
    border-collapse: collapse;
    width: 100%;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
table.report th {
    padding: 11px 14px;
    text-align: right;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    border-bottom: 2px solid var(--ink);
    white-space: nowrap;
    background: var(--surface);
}
table.report.sortable th { cursor: pointer; user-select: none; }
table.report.sortable th:hover { color: var(--navy); }
table.report th[data-asc]::after { content: ' ▴'; color: var(--navy-bright); }
table.report th[data-asc="false"]::after { content: ' ▾'; }
table.report th:first-child { text-align: left; }
table.report td {
    padding: 9px 14px;
    text-align: right;
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
}
table.report td:first-child { text-align: left; font-weight: 500; }
table.report tbody tr { transition: background .12s; }
table.report tbody tr:hover { background: #FBFAF6; }
table.report tbody tr:last-child td { border-bottom: none; }
table.report td a { color: var(--navy); text-decoration: none; font-weight: 600; }
table.report td a:hover { color: var(--navy-bright); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- ETL Pipeline log ---------- */
#etlTable { border-collapse: separate !important; border-spacing: 16px 0 !important; margin: 0 -16px; }
#etlTable th,
#etlTable td { padding: 10px 0 !important; text-align: left !important; white-space: nowrap; }
#etlTable th { border-bottom: 2px solid var(--ink); }
#etlTable td { border-bottom: 1px solid var(--line-soft); }
#etlTable th.r,
#etlTable td.r { text-align: right !important; }
#etlTable .etl-err { max-width: 320px; overflow: hidden; text-overflow: ellipsis; color: var(--red); font-size: 12px; }

/* ---------- Delta chips & badges ---------- */

.cell {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 11.5px;
    min-width: 52px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.positive { background: var(--green); color: #fff; }
.neutral  { background: var(--neutral); color: #fff; }
.negative { background: var(--red); color: #fff; }
.outlier  { background: var(--amber); color: #fff; }
.na { color: var(--ink-faint); font-size: 12px; }

.badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 3px 9px;
    border-radius: 999px;
    border: 1px solid var(--line);
    color: var(--ink-soft);
    background: var(--surface);
}
.badge.accent { border-color: rgba(14, 93, 153, .35); color: var(--navy-bright); background: #eef5fb; }

.legend { display: flex; gap: 18px; margin: 14px 2px 26px; font-size: 11px; color: var(--ink-soft); flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-box { width: 11px; height: 11px; border-radius: 3px; }
.legend-box.positive { background: var(--green); }
.legend-box.neutral  { background: var(--ink-faint); }
.legend-box.negative { background: var(--red); }
.legend-box.outlier  { background: var(--amber); }
.legend-box.high   { background: var(--green); }
.legend-box.medium { background: #0891b2; }
.legend-box.low    { background: var(--amber); }
.legend-box.none   { background: var(--red); }

.sov-high   { background: var(--green); color: #fff; }
.sov-medium { background: #0891b2; color: #fff; }
.sov-low    { background: var(--amber); color: #fff; }
.sov-none   { background: var(--red); color: #fff; }

.rank { font-family: var(--font-display); font-weight: 600; color: var(--ink-faint); }
tr:first-child .rank { color: var(--amber); }

/* ---------- Funnel ---------- */

.funnel-grid {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 20px;
    align-items: start;
    margin-bottom: 26px;
}

.funnel { padding: 22px 26px 18px; }
.funnel-tier {
    border-radius: 9px;
    color: #fff;
    text-align: center;
    padding: 13px 14px 11px;
    margin: 0 auto 7px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12);
}
.funnel-tier .tier-label {
    font-size: 9.5px;
    text-transform: uppercase;
    letter-spacing: .18em;
    font-weight: 700;
    opacity: .72;
}
.funnel-tier .tier-value {
    font-family: var(--font-display);
    font-size: 23px;
    font-weight: 600;
    padding: 3px 0 2px;
    font-variant-numeric: tabular-nums;
}
.funnel-tier .tier-deltas { font-size: 11px; opacity: .95; display: flex; justify-content: center; gap: 14px; }
.funnel-tier .tier-deltas .cell { background: rgba(255, 255, 255, .16); color: #fff; min-width: 0; padding: 1px 8px; }
.funnel-split { display: flex; gap: 7px; width: 88%; margin: 0 auto 7px; }
.funnel-split .funnel-tier { flex: 1; margin: 0; }
.tier-1 { background: #093E66; width: 100%; }
.tier-2 { background: #0a4a7a; }
.tier-3 { background: #0e5d99; width: 64%; }
.tier-4 { background: #047A40; width: 46%; }
.tier-5 { background: var(--navy-deep); width: 34%; }

/* ---------- Chart tabs ---------- */

.chart-tabs { display: flex; gap: 4px; }
.chart-tab { background: transparent; border: 1px solid var(--line); color: var(--ink-faint); font-size: 12px; font-weight: 600; padding: 5px 14px; border-radius: 999px; cursor: pointer; transition: all .15s ease; font-family: var(--font-body); }
.chart-tab:hover { border-color: var(--navy-bright); color: var(--navy-bright); }
.chart-tab.active { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- Sparkline ---------- */

.spark { width: 100%; height: auto; display: block; }
.spark polyline { stroke: var(--navy); }
.spark circle { fill: var(--navy-bright); cursor: pointer; }
.spark circle:hover { fill: var(--amber); r: 5; }
.spark .grid { stroke: var(--line-soft); stroke-width: 1; }
.spark .tick { fill: var(--ink-faint); font-size: 10.5px; font-family: var(--font-body); }
.spark .area { fill: rgba(9, 62, 102, .07); stroke: none; }
.spark .area-total { fill: rgba(14, 93, 153, .05); }
.spark .line-total { stroke: var(--navy-bright); stroke-dasharray: 4 3; }
.spark .dot-total { fill: var(--navy-bright); opacity: .6; }
.spark .dot-total:hover { fill: var(--amber); opacity: 1; r: 4; }
.spark .latest { fill: var(--navy-deep); font-size: 12px; font-weight: 700; font-family: var(--font-body); }
.spark .latest-total { fill: var(--navy-bright); font-size: 11px; font-weight: 600; }

/* ---------- Empty states ---------- */

.empty {
    text-align: center;
    padding: 54px 24px;
    color: var(--ink-soft);
}
.empty svg { width: 38px; height: 38px; color: var(--accent-soft); margin-bottom: 12px; }
.empty h3 { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--navy-deep); margin-bottom: 6px; }
.empty p { font-size: 13px; max-width: 420px; margin: 0 auto; }
.empty code { background: var(--paper); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; font-size: 12px; }

/* ---------- Forms & buttons ---------- */

button, input[type=submit] {
    font-family: var(--font-body);
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
button:hover { background: var(--navy-bright); }
button:active { transform: translateY(1px); }
button.danger { background: transparent; color: var(--red); border: 1px solid rgba(220, 38, 38, .35); padding: 5px 11px; font-size: 11.5px; }
button.danger:hover { background: var(--red-tint); }
button.ghost { background: transparent; color: var(--navy); border: 1px solid var(--line); }
button.ghost:hover { background: var(--paper); }

input[type=text], input[type=email], select {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--ink);
    padding: 8px 11px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
}
input:focus, select:focus { border-color: var(--navy-bright); }

/* Executive summary */
.exec-health-row {
    display: flex; gap: 14px; margin-bottom: 26px; flex-wrap: wrap;
}
.exec-health-card {
    display: flex; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 14px 20px;
    box-shadow: var(--shadow); flex: 1; min-width: 140px;
}
.exec-health-icon {
    font-size: 18px; width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
}
.exec-health-icon.health-up { background: #ecfdf5; color: #047A40; }
.exec-health-icon.health-down { background: #fef2f2; color: #dc2626; }
.exec-health-num {
    font-family: var(--font-display); font-size: 22px; font-weight: 700;
    color: var(--navy-deep); line-height: 1.1;
}
.exec-health-label { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .1em; }

.exec-grid-3 {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px; margin-bottom: 26px;
}
.exec-grid-3 .panel { margin-bottom: 0; }

.exec-list { padding: 0 16px 16px; }
.exec-list-header {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .12em; color: var(--ink-faint);
    padding: 8px 0 6px 10px; margin-bottom: 4px;
}
.exec-list-header.positive-border { border-left: 3px solid #047A40; }
.exec-list-header.negative-border { border-left: 3px solid #dc2626; }

.exec-row {
    display: flex !important; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: 5px;
    text-decoration: none !important; color: inherit;
    transition: background .15s;
    width: 100%;
}
.exec-row:hover { background: #f3f4f6; }
.exec-row-rank {
    font-family: var(--font-display); font-weight: 700;
    font-size: 13px; color: var(--navy-bright); min-width: 22px;
}
.exec-row-name {
    flex: 1; font-size: 13px; font-weight: 500; color: var(--navy-deep);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.exec-row-sessions { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }

/* Brand page two-column layout */
.brand-two-col { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.brand-two-col .panel { margin-bottom: 0; }
@media (max-width: 800px) { .brand-two-col { grid-template-columns: 1fr; } }

/* Universal Keywords grid */
.uk-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.uk-trade-label {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .12em; color: var(--ink-faint); margin-bottom: 8px;
    padding-bottom: 6px; border-bottom: 2px solid var(--line);
}
.uk-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 5px 0; border-bottom: 1px solid var(--line-soft);
    font-size: 12.5px;
}
.uk-kw { color: var(--ink); flex: 1; }
@media (max-width: 900px) { .uk-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .uk-grid { grid-template-columns: 1fr; } }

/* Heatmap */
.heatmap-form { margin-bottom: 24px; }
.heatmap-form-row {
    display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap;
}
.heatmap-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.heatmap-form label .label { font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: 1px; }
.heatmap-form select, .heatmap-form input[type=text], .heatmap-form input[type=number] {
    padding: 6px 10px; border: 1px solid #e5e7eb; border-radius: 4px; font-size: 13px; min-width: 180px;
}
.heatmap-result { width: 100%; }
.heatmap-result h2 { font-family: 'Montserrat', sans-serif; font-size: 16px; color: #093E66; margin-bottom: 4px; }
.heatmap-grid {
    display: grid; gap: 4px; margin: 16px 0;
}
.heatmap-cell {
    aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
    border-radius: 4px; font-family: 'Montserrat', sans-serif; font-weight: 700;
    font-size: 14px; color: #fff; cursor: default;
}
.heatmap-center { outline: 3px solid #062B47; outline-offset: -1px; }
.rank-top { background: #047A40; }
.rank-mid { background: #0e5d99; }
.rank-low { background: #f59e0b; }
.rank-bottom { background: #dc2626; }
.rank-none { background: #374151; }
.heatmap-legend { display: flex; gap: 16px; font-size: 10px; color: #6b7280; margin-top: 4px; }

form.inline { display: inline; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Ops scorecard: divided stat grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: var(--line-soft);
}
.stat { background: var(--surface); padding: 15px 18px 13px; }
.stat-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.stat-value {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 600;
    color: var(--navy-deep);
    padding: 4px 0 3px;
    font-variant-numeric: tabular-nums;
}
.stat-sub { font-size: 11.5px; color: var(--ink-soft); }

.panel.note-callout { border-left: 4px solid var(--navy-bright); }
.panel.note-callout .panel-head { background: #f0f6fb; }

.note-body { font-size: 13.5px; line-height: 1.65; white-space: pre-line; }
.note-print { display: none; font-size: 13px; line-height: 1.6; white-space: pre-line; }
.vendor-line { margin-top: 2px; }
.vendor-contact { color: var(--navy-bright); }

.glossary-list { display: grid; gap: 14px; }
.glossary-item dt { font-weight: 600; font-size: 13.5px; color: var(--navy-deep); margin-bottom: 2px; }
.glossary-item dd { font-size: 13px; color: var(--ink-soft); line-height: 1.55; }
details.defs > summary { list-style: none; cursor: pointer; }
details.defs > summary::-webkit-details-marker { display: none; }
details.defs > summary .hint::after { content: ' ▸'; }
details.defs[open] > summary .hint::after { content: ' ▾'; }
details.defs > summary a { color: var(--navy); }

.note-form textarea {
    width: 100%;
    font-family: var(--font-body);
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--ink);
    padding: 12px 14px;
    background: #FBFCFD;
    border: 1px solid var(--line);
    border-radius: 8px;
    outline: none;
    resize: vertical;
    margin-bottom: 10px;
}
.note-form textarea:focus { border-color: var(--navy-bright); background: #fff; }

.flash {
    background: var(--green-tint);
    border: 1px solid rgba(4, 122, 64, .35);
    color: var(--green);
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 13px;
    font-weight: 500;
}

.error-banner {
    background: #fef2f2;
    border: 1px solid rgba(220, 38, 38, .35);
    color: #991b1b;
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
}
.error-banner .error-code {
    font-weight: 700;
    color: #dc2626;
}
.error-banner .error-contact {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-actions button, .btn-ghost { display: inline-flex; align-items: center; gap: 6px; }
.page-actions button svg, .btn-ghost svg { width: 14px; height: 14px; }
.btn-ghost {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--navy);
    text-decoration: none;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 8px 16px;
}
.btn-ghost:hover { background: var(--paper); }

/* ---------- Executive Dashboard ---------- */

.kpis-exec { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.kpi .sub .delta-row { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 3px; }

.cell-sm {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 10px;
    font-variant-numeric: tabular-nums;
}

/* Filter bar */
.filter-panel { margin-bottom: 18px; }
.filter-bar {
    display: flex;
    gap: 14px;
    padding: 12px 20px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.filter-bar label { display: flex; flex-direction: column; gap: 3px; }
.filter-label {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.filter-bar select { min-width: 140px; }

/* Movers grid */
.movers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1px;
    background: var(--line-soft);
}
.mover-col { background: var(--surface); padding: 16px 18px; }
.mover-heading {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-left: 10px;
    border-left: 3px solid var(--ink-faint);
}
.mover-heading.gaining { border-color: var(--green); color: var(--green); }
.mover-heading.declining { border-color: var(--red); color: var(--red); }
.mover-heading.traffic { border-color: var(--navy-bright); color: var(--navy-bright); }
.mover-heading.impressions { border-color: var(--amber); color: var(--amber); }

.exec-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line-soft);
}
.exec-card:last-child { border-bottom: none; }
.exec-rank {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--paper);
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-soft);
}
.exec-info {
    flex: 1;
    min-width: 0;
}
.exec-info a {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--navy);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.exec-info a:hover { color: var(--navy-bright); text-decoration: underline; text-underline-offset: 3px; }
.exec-info .sub {
    font-size: 11px;
    color: var(--ink-faint);
}

/* Segment tabs */
.segment-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.seg-tab {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-soft);
    text-decoration: none;
    padding: 5px 12px;
    border-radius: 999px;
    border: 1px solid var(--line);
    transition: background .15s, color .15s;
}
.seg-tab:hover { background: var(--paper); color: var(--navy); }
.seg-tab.active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

/* Rollup cards */
.rollup-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1px;
    background: var(--line-soft);
}
.rollup-card {
    background: var(--surface);
    padding: 18px 20px 14px;
}
.rollup-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--navy-deep);
    margin-bottom: 8px;
}
.rollup-stat { margin-bottom: 4px; }
.rollup-number {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 600;
    color: var(--navy-deep);
    font-variant-numeric: tabular-nums;
}
.rollup-unit {
    font-size: 11px;
    color: var(--ink-soft);
    margin-left: 4px;
}
.rollup-deltas { margin-top: 6px; }

/* Trend arrows */
.trend-arrow {
    font-size: 12px;
    display: inline-block;
    width: 22px;
    text-align: center;
}
.trend-arrow.up { color: var(--green); }
.trend-arrow.down { color: var(--red); }
.trend-arrow.flat { color: var(--ink-faint); font-size: 9px; }

/* Status badge */
.status-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 999px;
}
.status-badge.up { background: var(--green-tint); color: var(--green); }
.status-badge.down { background: var(--red-tint); color: var(--red); }
.status-badge.flat { background: var(--paper); color: var(--ink-faint); }

/* ---------- Print (Download PDF) ---------- */

@media print {
    .sidebar, .topbar, .overlay, .foot, .page-actions, .note-form, .legend, .signin-link { display: none !important; }
    .note-body { display: none; }
    .note-print { display: block; }
    body { background: #fff; }
    .shell { display: block; }
    main { max-width: 100%; padding: 0; }
    main > * { animation: none; }
    .panel, .kpi { box-shadow: none; border: 1px solid #d6d9dd; break-inside: avoid; }
    .funnel-grid { grid-template-columns: 1fr; }
    .funnel-tier, .cell, .tier-1, .tier-2, .tier-3, .tier-4, .tier-5 {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ---------- Mobile ---------- */

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5, 34, 58, .45);
    z-index: 35;
}

@media (max-width: 960px) {
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        height: 100%;
        transform: translateX(-100%);
        transition: transform .25s cubic-bezier(.2, .7, .3, 1);
        box-shadow: 12px 0 40px rgba(5, 34, 58, .3);
    }
    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .overlay { display: block; }
    body.nav-open { overflow: hidden; }

    .menu-btn { display: block; }
    .topbar { padding: 10px 16px; gap: 10px; }
    .search { flex: 1; width: auto; min-width: 0; }
    main { padding: 22px 16px 8px; }
    .foot { padding: 14px 16px 22px; }
    h1 { font-size: 24px; }
    .funnel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 960px) and (min-width: 641px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .month-form label { display: none; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 20px; }
    .kpi .value { font-size: 22px; }
    .page-head { margin-bottom: 18px; }
    .panel-body, .funnel { padding: 14px; }
    .funnel-split { width: 94%; }
    .tier-3 { width: 76%; }
    .tier-4 { width: 60%; }
    .tier-5 { width: 48%; }
}

/* Featured reviews */
.reviews-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 16px; }
.review-card { background: var(--bg-page); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.review-stars { color: #f5a623; font-size: 16px; margin-bottom: 8px; }
.review-text { font-size: 13px; line-height: 1.5; color: var(--text-mid); margin: 0 0 10px; }
.review-author { font-size: 12px; font-weight: 600; color: var(--ink); }
@media (max-width: 768px) { .reviews-grid { grid-template-columns: 1fr; } }

/* Universal keyword heatmap table */
.uk-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.uk-table th, .uk-table td { padding: 4px 3px; text-align: center; border-bottom: 1px solid var(--border); }
.uk-kw-col { text-align: left !important; white-space: nowrap; position: sticky; left: 0; background: var(--bg-card); z-index: 1; min-width: 140px; font-weight: 500; }
.uk-brand-col { font-size: 10px; font-weight: 600; color: var(--text-mid); white-space: nowrap; min-width: 50px; max-width: 70px; overflow: hidden; text-overflow: ellipsis; }
.uk-pos { color: var(--ink-faint); font-size: 11px; }
.uk-pos.uk-top3 { background: var(--green); color: #fff; font-weight: 700; }
.uk-pos.uk-top10 { background: #2e7d32; color: #fff; font-weight: 600; }
.uk-pos.uk-top20 { background: var(--amber); color: #fff; font-weight: 600; }
.uk-pos.uk-low { background: var(--red); color: #fff; font-weight: 600; }

/* Branded search terms */
.hidden { display: none !important; }
.branded-row { cursor: pointer; }
.branded-terms-row td { background: var(--bg-card); padding: 8px 12px !important; }
.branded-terms-list { display: flex; flex-wrap: wrap; gap: 6px; }
.branded-term {
    display: inline-block;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 10px;
    font-size: 0.82rem;
    color: var(--text-mid);
}
