/* ESPR campaign dashboard — palette and type from the ESPR Discovery page. */
:root {
  --navy: #1C3E7A;
  --navy-deep: #0E2841;
  --navy-ink: #16325C;
  --navy-mid: #1F4D78;
  --navy-soft: #2E74B5;
  --blue-light: #A6CAEC;
  --red: #CE1126;
  --cobalt: #2B5FCB;
  --cobalt-deep: #1E47A0;
  --tint-blue: #EAF1F8;
  --paper: #F5F7FA;
  --surface: #FFFFFF;
  --field: #F2F6FB;
  --field-border: #C9D6E6;
  --border: #D8DEE7;
  --border-soft: #E5E9F0;
  --ink: #0F1B2D;
  --ink-soft: #2A3548;
  --muted: #5A6677;
  --muted-soft: #8A95A5;
  --heading: var(--navy);
  --link: var(--cobalt-deep);
  --bar: #2B5FCB;
  --grid: #E5E9F0;
  --good: #1F7A4D;
  --good-tint: #EEF7F2;
  --warn: #9A6200;
  --warn-tint: #FFF6E5;
  --critical: #B3141F;
  --critical-tint: #FDF1F2;
  --topbar: #0E2841;
  --shadow-sm: 0 1px 3px rgba(14, 40, 65, 0.06);
  --shadow-md: 0 8px 24px rgba(14, 40, 65, 0.08);
  --shadow-lg: 0 30px 80px rgba(14, 40, 65, 0.18);
  --radius: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0B1626;
    --surface: #13233A;
    --field: #0F1D31;
    --field-border: #2C4060;
    --border: #2A3D5A;
    --border-soft: #22344F;
    --ink: #E8EEF6;
    --ink-soft: #C9D4E3;
    --muted: #9AA8BC;
    --muted-soft: #7A889C;
    --heading: #DCE7F7;
    --link: #8DB2F5;
    --tint-blue: #1A2E4B;
    --bar: #5C8DE8;
    --grid: #22344F;
    --good: #5CC08C;
    --good-tint: #12301F;
    --warn: #E5B04C;
    --warn-tint: #33270D;
    --critical: #F2727B;
    --critical-tint: #3A1519;
    --topbar: #07111F;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 30px 80px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

.analytics-embed { min-width: 0; }
.analytics-embed .section-head { flex-wrap: wrap; gap: 12px; }
.analytics-empty { padding: 24px; }
.analytics-empty h3 { margin: 0 0 8px; }
.analytics-empty p { color: var(--muted); margin: 0 0 16px; }
.analytics-setup summary { cursor: pointer; color: var(--link); font-weight: 600; }
.analytics-setup li { margin: 8px 0; }
.analytics-report { overflow: hidden; }
.analytics-report-frame { display: block; width: 100%; height: 760px; border: 0; background: #fff; color-scheme: light; }
.analytics-report-note { padding: 14px 20px; margin: 0; color: var(--muted); font-size: 13px; }
@media (max-width: 600px) {
  .analytics-report-frame { height: 600px; }
  .analytics-empty { padding: 18px; }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 14.5px/1.5 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue-light); outline-offset: 2px; }
.serif { font-family: 'Source Serif 4', Georgia, serif; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.boot { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---------- Sign-in ---------- */
.signin {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  padding: 40px 16px; background: linear-gradient(160deg, var(--navy-deep), var(--navy) 70%, var(--navy-mid));
}
.signin-card {
  width: 100%; max-width: 400px; padding: 36px 32px 28px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.signin-logo {
  position: relative; width: 48px; height: 48px; margin: 0 auto 18px; display: grid; place-items: center; overflow: hidden;
  border-radius: 12px; background: linear-gradient(160deg, var(--navy-deep), var(--navy)); color: #fff;
  font-family: 'Source Serif 4', Georgia, serif; font-weight: 700; font-size: 19px; box-shadow: 0 8px 20px rgba(14, 40, 65, 0.3);
}
.signin-logo .red-rule { position: absolute; left: 12px; right: 12px; bottom: 8px; height: 3px; background: var(--red); border-radius: 2px; }
.signin-card h1 { font-family: 'Source Serif 4', Georgia, serif; font-size: 28px; font-weight: 700; line-height: 1.15; color: var(--heading); margin: 8px 0 10px; letter-spacing: -0.01em; }
.signin-sub { color: var(--muted); font-size: 14px; margin: 0 0 24px; }
.signin-note { color: var(--ink-soft); font-size: 14px; margin: 0 0 18px; overflow-wrap: anywhere; }
.signin-hint { color: var(--muted); font-size: 12.5px; margin: 10px 0 0; }
.signin-card .field { margin-bottom: 12px; }
.signin-card .error-text { text-align: left; }
.signin-card .error-text:empty { display: none; }
.signin-card .dev-note { text-align: left; }
.signin-foot { font-family: 'Source Serif 4', Georgia, serif; font-style: italic; font-size: 13px; color: rgba(255, 255, 255, 0.6); margin: 0; }
.link-btn {
  display: inline-block; margin-top: 18px; padding: 2px 4px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px;
}
.link-btn:hover { color: var(--ink); }
.dev-note { padding: 10px 12px; border-radius: 8px; background: var(--warn-tint); color: var(--ink); font-size: 13px; margin-bottom: 18px; }

.eyebrow { font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase; font-weight: 600; color: var(--cobalt); }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--field-border); border-radius: 8px;
  background: var(--field); color: var(--ink);
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--cobalt); outline: none; box-shadow: 0 0 0 3px rgba(43, 95, 203, 0.18); }
.input[aria-invalid="true"] { border-color: var(--critical); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px;
  border-radius: 8px; border: 1px solid transparent; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--navy); color: #fff; white-space: nowrap;
}
.btn:hover { background: var(--navy-ink); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-google { background: var(--surface); color: var(--ink); border-color: var(--field-border); padding: 12px 16px; }
.btn-google:hover { background: var(--tint-blue); }
.btn-google.disabled { opacity: 0.55; pointer-events: none; }
.g-mark { flex: none; }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--border); }
.btn-ghost:hover { background: var(--tint-blue); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.error-text { color: var(--critical); font-size: 13.5px; margin: 8px 0 0; }

/* ---------- Shell ---------- */
.topbar { background: var(--topbar); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; }
.brand { display: flex; align-items: baseline; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.brand b { font-family: 'Source Serif 4', Georgia, serif; font-weight: 700; font-size: 18px; letter-spacing: -0.01em; white-space: nowrap; }
.brand span { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--blue-light); white-space: nowrap; }
.brand .red-rule { width: 3px; height: 18px; background: var(--red); align-self: center; border-radius: 2px; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: rgba(255, 255, 255, 0.82); min-width: 0; }
.who .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role { padding: 2px 8px; border-radius: 999px; background: rgba(166, 202, 236, 0.18); color: var(--blue-light); font-size: 11.5px; font-weight: 600; text-transform: capitalize; }
.who .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.who .btn-ghost:hover { background: rgba(255, 255, 255, 0.08); }

.layout { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar { border-right: 1px solid var(--border); background: var(--surface); padding: 20px 12px; }
.nav-label { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted-soft); font-weight: 600; padding: 16px 12px 8px; }
.nav a {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 6px;
  padding: 9px 12px; border-radius: 8px; color: var(--ink-soft); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--tint-blue); }
.nav a[aria-current="page"] { background: var(--tint-blue); color: var(--heading); font-weight: 600; box-shadow: inset 3px 0 0 var(--cobalt); }
.nav .num { font-family: 'Source Serif 4', Georgia, serif; font-size: 12px; letter-spacing: 0.1em; color: var(--muted-soft); }
.nav .label { line-height: 1.3; }
.badge { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 11.5px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
/* The Admin heading doubles as the dropdown toggle. */
.nav-toggle {
  display: flex; align-items: center; gap: 8px; width: 100%; border: 0; border-radius: 8px;
  background: none; cursor: pointer; text-align: left; font-family: inherit;
}
.nav-toggle:hover { color: var(--ink-soft); background: var(--tint-blue); }
.nav-toggle .chevron { margin-left: auto; font-size: 12px; letter-spacing: 0; transition: transform 0.15s; transform: rotate(-90deg); }
.nav-toggle[aria-expanded="true"] .chevron { transform: none; }
.nav-aerospace { margin-top: 12px; }
.nav-aerospace-toggle { color: var(--heading); font-size: 13px; letter-spacing: 0; text-transform: none; padding: 12px; line-height: 1.4; }
.nav-aerospace .nav-sub a { grid-template-columns: 14px minmax(0, 1fr) auto; font-size: 13px; }
.aerospace-types { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.aerospace-type { display: block; padding: 20px; color: var(--ink); text-decoration: none; }
.aerospace-type:hover { border-color: var(--cobalt); background: var(--tint-blue); }
.aerospace-type h3 { margin: 0; color: var(--heading); }
.aerospace-type p { margin: 8px 0 16px; color: var(--muted); }
/* Archive: its own link below Admin, with a folder icon in the number column. */
.nav-archive { margin-top: 12px; }
.nav .icon { display: inline-flex; align-items: center; color: var(--muted-soft); }
.nav .icon svg { display: block; flex-shrink: 0; }
.nav .admin-icon { color: var(--ink-soft); }
.nav .admin-person { color: var(--link); }
.nav .nav-dot { font-family: inherit; font-size: 16px; line-height: 1; letter-spacing: 0; text-align: center; }
.nav a[aria-current="page"] .nav-dot { color: var(--cobalt); }
.nav a[aria-current="page"] .icon { color: var(--cobalt); }
.nav .count { min-width: 22px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 11.5px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.tag { padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 600; }

main { padding: 28px 32px 64px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-family: 'Source Serif 4', Georgia, serif; font-weight: 600; color: var(--heading); font-size: clamp(26px, 3vw, 32px); line-height: 1.15; margin: 6px 0 4px; letter-spacing: -0.01em; }
.page-head p { margin: 0; color: var(--muted); }
.head-actions { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.section { margin-top: 28px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { font-family: 'Source Serif 4', Georgia, serif; color: var(--heading); font-size: 21px; font-weight: 600; margin: 0; }
.section-head p { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---------- Filters ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.filters .input { padding: 7px 10px; min-width: 140px; }
.filters .grow { flex: 1 1 220px; }
/* Date-range controls nest their own .filters row; drop its margin so neighbors share one bottom line. */
.filters .filters { margin-bottom: 0; }
.filters .error-text:empty { display: none; }
.segmented { display: inline-flex; border: 1px solid var(--field-border); border-radius: 8px; overflow: hidden; background: var(--field); }
.segmented button { padding: 7px 12px; border: 0; background: transparent; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.segmented button + button { border-left: 1px solid var(--field-border); }
.segmented button[aria-pressed="true"] { background: var(--navy); color: #fff; }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.tile { padding: 16px 18px; }
.tile .label { font-size: 13px; color: var(--muted); }
.tile .value { font-size: 30px; font-weight: 600; color: var(--ink); line-height: 1.2; margin-top: 4px; }
.tile .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Campaign cards ---------- */
.campaign-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.campaign-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; text-decoration: none; color: inherit; transition: box-shadow 0.15s, transform 0.15s; }
a.campaign-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.campaign-card .cc-top { display: flex; justify-content: space-between; align-items: center; }
.campaign-card .cc-num { font-family: 'Source Serif 4', Georgia, serif; font-size: 12px; letter-spacing: 0.14em; color: var(--muted); }
.campaign-card h3 { font-family: 'Source Serif 4', Georgia, serif; font-size: 19px; color: var(--heading); margin: 0; font-weight: 600; }
.campaign-card .desc { color: var(--muted); font-size: 13px; margin: 0; }
.cc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding-top: 10px; border-top: 1px solid var(--border-soft); }
.cc-stats div { display: flex; flex-direction: column; }
.cc-stats b { font-size: 18px; font-weight: 600; }
.cc-stats span { font-size: 11.5px; color: var(--muted); }
.cc-foot { font-size: 12.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.campaign-card.pending { border-style: dashed; background: transparent; box-shadow: none; }

/* ---------- Status chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid var(--border); color: var(--ink-soft); background: var(--surface); }
.chip .icon { font-size: 11px; line-height: 1; }
.chip.good { color: var(--good); background: var(--good-tint); border-color: transparent; }
.chip.warn { color: var(--warn); background: var(--warn-tint); border-color: transparent; }
.chip.critical { color: var(--critical); background: var(--critical-tint); border-color: transparent; }
.chip.review { background: var(--tint-blue); border-color: transparent; color: var(--heading); }
.chip.test { border-style: dashed; }
.chip.archived { color: var(--warn); background: var(--warn-tint); border-color: transparent; }
.delivery-status > button { cursor: pointer; }
.delivery-popover {
  position: fixed; inset: auto; margin: 0; z-index: 100;
  width: min(360px, calc(100vw - 32px)); max-height: calc(100vh - 16px); overflow: auto;
  padding: 16px; border: 1px solid var(--critical); border-radius: 10px;
  background: var(--surface); color: var(--ink); box-shadow: 0 8px 32px #0005;
  white-space: normal; overflow-wrap: anywhere; font-size: 13px; font-weight: 400; text-align: left;
}
.delivery-popover[hidden] { display: none; }
.delivery-popover p { margin: 10px 0; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
/* A table at the top or bottom of a card is clipped to the card's rounded corners (radius
   minus its 1px border), and a table ending the card drops the divider the card's own border
   already draws. Covers tables placed directly in a card and the leads list's holder. */
.card > .table-wrap:first-child, .card > :first-child > .table-wrap:first-child {
  border-top-left-radius: calc(var(--radius) - 1px); border-top-right-radius: calc(var(--radius) - 1px);
}
.card > .table-wrap:last-child, .card > :last-child > .table-wrap:last-child {
  border-bottom-left-radius: calc(var(--radius) - 1px); border-bottom-right-radius: calc(var(--radius) - 1px);
}
.card > .table-wrap:last-child > table > :last-child > tr:last-child > *,
.card > :last-child > .table-wrap:last-child > table > :last-child > tr:last-child > * { border-bottom: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
th { font-size: 11.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--surface); position: sticky; top: 0; }
.leads th, .leads td { padding: 9px 10px; font-size: 13.5px; }
.leads th { font-size: 11px; }
.nowrap { white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--tint-blue); }
.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 12.5px; color: var(--muted); }
.cell-link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--ink); font-weight: 600; text-align: left; }
.cell-link:hover { color: var(--link); text-decoration: underline; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px; color: var(--muted); font-size: 13px; gap: 10px; flex-wrap: wrap; }

/* ---------- States ---------- */
.state { padding: 36px 24px; text-align: center; color: var(--muted); }
.state h3 { font-family: 'Source Serif 4', Georgia, serif; color: var(--heading); margin: 0 0 6px; font-size: 19px; }
.state p { margin: 0 auto; max-width: 520px; }
.state.error h3 { color: var(--critical); }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--tint-blue); color: var(--ink-soft); font-size: 13.5px; margin-bottom: 14px; border-left: 4px solid var(--cobalt); }
.notice.warn { background: var(--warn-tint); border-left-color: var(--warn); }
.notice.critical { background: var(--critical-tint); border-left-color: var(--critical); }

/* ---------- Traffic chart ---------- */
.traffic { padding: 20px; }
.traffic-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.top-source { font-size: 14px; color: var(--ink-soft); }
.top-source b { color: var(--ink); }
.chart { position: relative; margin: 8px 0 4px; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .bar { fill: var(--bar); }
.chart .bar-hit { fill: transparent; cursor: default; }
.chart .bar-row:hover .bar, .chart .bar-row:focus .bar { fill: var(--cobalt-deep); }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .cat-text { fill: var(--ink-soft); font-size: 12.5px; }
.chart .val-text { fill: var(--ink-soft); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.chart .bar-row:focus { outline: none; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 5; background: var(--navy-deep); color: #fff;
  padding: 8px 10px; border-radius: 8px; font-size: 12.5px; box-shadow: var(--shadow-md); white-space: nowrap;
}
.tooltip b { display: block; margin-bottom: 2px; }
.chart-foot { font-size: 12px; color: var(--muted); margin-top: 12px; }
@media (prefers-color-scheme: dark) { .chart .bar-row:hover .bar, .chart .bar-row:focus .bar { fill: #7EA6F2; } }
.tooltip-sub { display: block; margin-top: 4px; color: var(--blue-light); font-size: 11.5px; white-space: normal; max-width: 240px; }

/* ---------- Traffic overview ---------- */
.headline { position: relative; display: flex; align-items: flex-start; gap: 14px; padding: 16px 20px; margin-bottom: 14px; }
.headline p { margin: 0; font-size: 16px; line-height: 1.55; color: var(--ink-soft); text-wrap: pretty; }
.headline b { color: var(--heading); font-weight: 600; }
.headline-mark { flex: none; width: 4px; align-self: stretch; border-radius: 2px; background: var(--red); }
.tile.pending { border-style: dashed; background: transparent; box-shadow: none; }
.tile.pending .value { color: var(--muted-soft); }
.tiles.two { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 14px; }
.split { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 0 20px; align-items: start; }

.bar-table-card { padding: 4px 4px 8px; }
.bar-table td, .bar-table th, .heat td, .heat th { padding: 10px 12px; vertical-align: middle; }
.bar-table th.bar-col { width: 42%; }
.bar-table .cell-link { display: inline-flex; gap: 6px; align-items: baseline; text-align: left; }
.bar-table .cc-num, .heat .cc-num { font-family: 'Source Serif 4', Georgia, serif; font-size: 12px; letter-spacing: 0.1em; color: var(--muted-soft); font-weight: 500; }
.bar-table tbody tr.selected { background: var(--tint-blue); box-shadow: inset 3px 0 0 var(--cobalt); }
.bar-table tbody tr.muted-row td { color: var(--muted); }
.inline-bar { display: flex; align-items: center; gap: 8px; }
.inline-bar .fill { height: 14px; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--bar); }
.inline-bar b { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 13.5px; }

.heat th[scope="row"] { font-size: 14px; letter-spacing: 0; text-transform: none; color: var(--ink); font-weight: 600; position: static; white-space: nowrap; }
.heat thead th { white-space: nowrap; }
.heat-cell { background: color-mix(in oklab, var(--bar) var(--heat, 0%), var(--surface)); border-left: 2px solid var(--surface); font-size: 13.5px; }
.heat-cell.strong { font-weight: 600; color: var(--heading); }
.heat-cell .zero, .heat-cell.empty { color: var(--muted-soft); }

.placeholder { display: flex; align-items: center; gap: 18px; padding: 8px 4px; color: var(--muted); }
.placeholder p { margin: 0; font-size: 13.5px; max-width: 420px; }
.placeholder-line { flex: none; width: 180px; height: 48px; }
.placeholder-line path { fill: none; stroke: var(--muted-soft); stroke-width: 2; stroke-dasharray: 4 5; stroke-linecap: round; }

.line-chart .line { fill: none; stroke: var(--bar); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-chart .area { fill: var(--bar); opacity: 0.12; }
.line-chart .baseline { stroke: var(--field-border); stroke-width: 1; }
.line-chart .crosshair { stroke: var(--muted-soft); stroke-width: 1; stroke-dasharray: 3 3; }
.line-chart .dot { fill: var(--bar); stroke: var(--surface); stroke-width: 2; }
.line-chart .bar-hit:focus { outline: none; }
/* ---------- Team & permissions ---------- */
.team-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.team-bar p { margin: 0; color: var(--muted); font-size: 13.5px; }
.chip.role-admin { background: var(--navy); color: #fff; border-color: transparent; }
.chip.role-editor { background: var(--tint-blue); color: var(--heading); border-color: transparent; }
.chip.role-viewer { color: var(--ink-soft); }
.role-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.role-card { padding: 14px 16px; }
.role-card p { margin: 8px 0 0; color: var(--ink-soft); font-size: 13.5px; }
.member-search { align-items: flex-end; }
.member-search .grow { flex: 1 1 320px; max-width: 520px; }
.member-search > .cell-sub { padding-bottom: 8px; }
.permissions td { vertical-align: middle; }
.add-member-card { padding: 16px 18px; margin-bottom: 20px; }
.add-member { margin-bottom: 0; }
.add-member .grow { flex: 1 1 280px; max-width: 460px; }
.add-member-card > [role="status"] { margin: 10px 0 0; }
.invites { margin-top: 0; margin-bottom: 24px; }
.permissions select.input { min-width: 140px; }
.permissions .check { margin: 0; }
.lead-section { margin-top: 40px; padding-top: 24px; border-top: 1px solid var(--border); }

/* ---------- Detail drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(14, 40, 65, 0.42); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); background: var(--paper);
  z-index: 41; overflow-y: auto; box-shadow: var(--shadow-lg); border-left: 1px solid var(--border);
}
.drawer-head { position: sticky; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); padding: 18px 22px; display: flex; justify-content: space-between; gap: 12px; z-index: 2; }
.drawer-head h2 { font-family: 'Source Serif 4', Georgia, serif; color: var(--heading); margin: 4px 0 2px; font-size: 24px; }
.drawer-head > .btn { align-self: flex-start; }
.drawer-actions { display: flex; gap: 8px; align-self: flex-start; flex-shrink: 0; }
.btn-icon { display: inline-flex; vertical-align: -2px; margin-right: 6px; }
.archived-panel { border-left: 4px solid var(--muted-soft); }
.archived-panel p { margin: 0 0 10px; }
.archived-panel p:last-child { margin-bottom: 0; }
.drawer-head .meta { color: var(--muted); font-size: 13px; }
.drawer-body { padding: 18px 22px 40px; display: grid; gap: 14px; }
.panel { padding: 16px 18px; }
.panel h3 { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.panel .hint { font-size: 12.5px; color: var(--muted); margin: -6px 0 12px; }
dl.kv { display: grid; grid-template-columns: minmax(120px, 36%) minmax(0, 1fr); gap: 8px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 13px; }
dl.kv dd { margin: 0; word-break: break-word; }
dl.kv dd.missing { color: var(--muted-soft); font-style: italic; }
.review-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.review-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { padding-left: 14px; border-left: 2px solid var(--border); }
.timeline .when { font-size: 12px; color: var(--muted); }
.timeline .what { white-space: pre-wrap; word-break: break-word; }
details summary { cursor: pointer; color: var(--link); font-weight: 600; font-size: 13px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin: 10px 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .campaign-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: 8px 16px; overflow-x: auto; }
  .nav { display: flex; gap: 4px; }
  .nav-label { display: none; }
  .nav a { grid-template-columns: auto auto auto; white-space: nowrap; }
  .nav .label { white-space: nowrap; }
  /* The horizontal mobile nav shows Team and Permissions as plain links. */
  .nav-group, .nav-sub, .nav-sub[hidden] { display: contents; }
  .nav-toggle { display: none; }
  /* Keep the Aerospace menu expandable in the horizontal mobile navigation. */
  .nav-aerospace { display: flex; margin-top: 0; align-items: flex-start; }
  .nav-aerospace .nav-toggle { display: flex; width: auto; white-space: nowrap; }
  .nav-aerospace .nav-sub { display: flex; }
  .nav-aerospace .nav-sub[hidden] { display: none; }
  .nav-aerospace .nav-sub a { grid-template-columns: auto auto auto; }
  .nav-archive { margin-top: 0; }
  .role-cards { grid-template-columns: 1fr; }
  main { padding: 20px 16px 48px; }
  .topbar-inner { padding: 10px 16px; }
  .brand span, .brand .red-rule, .who .email { display: none; }
  .review-form { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .tiles, .tiles.two, .campaign-grid, .aerospace-types { grid-template-columns: 1fr; }
  .placeholder { flex-direction: column; align-items: flex-start; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
/* Form details use the campaign drawer styling with native modal focus handling. */
.form-drawer { margin: 0 0 0 auto; padding: 0; height: 100%; max-height: 100%; max-width: 100vw; color: var(--ink); border: 0; border-left: 1px solid var(--border); }
.form-drawer::backdrop { background: rgba(14, 40, 65, 0.42); }
.form-drawer dl.kv dd { white-space: pre-wrap; }

/* ---------- Live now (GA4 realtime, dashboard/ga-realtime.js) ---------- */
.live-table + * { margin-top: 0; }
.tiles + .card { margin-top: 14px; }
.live-spark { display: block; }
.live-spark rect.on { fill: var(--navy-soft); }
.live-spark rect.off { fill: var(--border); }
.live-empty { padding: 16px 18px; }
.live-empty p { margin: 0; }
.live-empty p + p { margin-top: 4px; }

/* ---------- ESPR AI: Client Knowledge Core side panel (dashboard/assistant.js) ---------- */
:root { --jv-width: 420px; --jv-top: 57px; --jv-cyan: #5fd4ff; }
.jv-orb { display: block; overflow: visible; }
.jv-orb .ring { fill: none; stroke: var(--jv-cyan); }
.jv-orb .faint { stroke-opacity: 0.25; stroke-width: 2; }
.jv-orb .dashed { stroke-opacity: 0.6; stroke-width: 3; stroke-dasharray: 4 10; }
.jv-orb .segments { stroke-opacity: 0.8; stroke-width: 6; stroke-dasharray: 46 12 8 12; }
.jv-orb .solid { stroke-opacity: 0.6; stroke-width: 3; }
.jv-orb .tick { stroke: var(--jv-cyan); stroke-opacity: 0.5; stroke-width: 3; }
.jv-orb .tick.long { stroke-opacity: 0.95; stroke-width: 4; }
.jv-orb .core { animation: jv-breathe 3.2s ease-in-out infinite; transform-origin: 100px 100px; }
.jv-orb .core-hot { fill: #f2fdff; }
.jv-orb .spin { transform-origin: 100px 100px; animation: jv-spin 40s linear infinite; }
.jv-orb .spin.slow { animation-duration: 60s; }
.jv-orb .spin.reverse { animation-duration: 28s; animation-direction: reverse; }
.jv-orb .spin.mid { animation-duration: 90s; }
@keyframes jv-spin { to { transform: rotate(360deg); } }
@keyframes jv-breathe { 0%, 100% { transform: scale(0.94); opacity: 0.85; } 50% { transform: scale(1.04); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .jv-orb .spin, .jv-orb .core { animation: none; } }

.jv-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1px solid rgba(95, 212, 255, 0.28); border-radius: 50%; background: rgba(95, 212, 255, 0.06); cursor: pointer; flex-shrink: 0; transition: box-shadow 0.2s, border-color 0.2s; }
.jv-toggle:hover { border-color: rgba(95, 212, 255, 0.6); box-shadow: 0 0 14px rgba(95, 212, 255, 0.35); }
.jv-toggle:focus-visible { outline: 2px solid var(--jv-cyan); outline-offset: 2px; }
.jv-toggle[aria-expanded="true"] { border-color: var(--jv-cyan); box-shadow: 0 0 18px rgba(95, 212, 255, 0.5); }
.jv-toggle[aria-expanded="true"] .spin.slow { animation-duration: 14s; }
.jv-toggle[aria-expanded="true"] .spin.reverse { animation-duration: 7s; }

body.jv-open .layout { margin-right: var(--jv-width); }
.jv-panel { position: fixed; top: var(--jv-top); right: 0; bottom: 0; width: var(--jv-width); z-index: 30; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-md); }
.jv-panel[hidden] { display: none; }
.jv-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 14px; background: var(--navy-deep); color: #fff; }
.jv-head-orb { display: inline-flex; filter: drop-shadow(0 0 8px rgba(95, 212, 255, 0.45)); }
.jv-panel.busy .jv-head-orb .spin.slow { animation-duration: 10s; }
.jv-panel.busy .jv-head-orb .spin.reverse { animation-duration: 5s; }
.jv-title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.jv-title b { font-size: 14px; letter-spacing: 0.04em; }
.jv-title span { font-size: 12px; color: var(--blue-light); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jv-actions { display: flex; gap: 4px; }
.jv-icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: rgba(255, 255, 255, 0.85); cursor: pointer; }
.jv-icon-btn:hover, .jv-icon-btn.active { background: rgba(255, 255, 255, 0.12); color: #fff; }
.jv-icon-btn:focus-visible { outline: 2px solid var(--jv-cyan); }

.jv-body { flex: 1; overflow-y: auto; padding: 16px 16px 8px; font-size: 14px; color: var(--ink); }
.jv-muted { color: var(--muted); font-size: 13px; margin: 0; }
.jv-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 32px 8px; }
.jv-empty-orb { filter: drop-shadow(0 0 18px rgba(95, 212, 255, 0.35)); margin-bottom: 8px; }
.jv-empty p { margin: 0; }
.jv-hello { font-family: 'Source Serif 4', Georgia, serif; font-size: 22px; color: var(--heading); }
.jv-suggestions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; width: 100%; }
.jv-chip { text-align: left; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--field); color: var(--ink-soft); font: inherit; font-size: 13px; cursor: pointer; }
.jv-chip:hover { border-color: var(--navy-soft); }

.jv-thread { display: flex; flex-direction: column; gap: 16px; }
.jv-turn.user { display: flex; justify-content: flex-end; }
.jv-bubble { margin: 0; max-width: 85%; padding: 9px 12px; border-radius: 14px 14px 4px 14px; background: var(--navy); color: #fff; white-space: pre-wrap; overflow-wrap: anywhere; }
.jv-turn.assistant { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 10px; }
.jv-avatar { padding-top: 2px; }
.jv-turn.failed .jv-answer { color: var(--critical); }
.jv-answer { line-height: 1.55; overflow-wrap: anywhere; }
.jv-answer > :first-child { margin-top: 0; }
.jv-answer > :last-child { margin-bottom: 0; }
.jv-answer p, .jv-answer ul, .jv-answer ol, .jv-answer blockquote, .jv-answer pre { margin: 0 0 10px; }
.jv-answer ul, .jv-answer ol { padding-left: 20px; }
.jv-answer h3, .jv-answer h4, .jv-answer h5, .jv-answer h6 { margin: 14px 0 6px; font-size: 14.5px; color: var(--heading); }
.jv-answer a { color: var(--link); }
.jv-answer code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--field); border-radius: 4px; padding: 1px 4px; }
.jv-answer pre { background: var(--field); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; }
.jv-answer pre code { background: none; padding: 0; }
.jv-answer blockquote { border-left: 3px solid var(--border); padding-left: 10px; color: var(--ink-soft); }
.jv-answer hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.jv-table { overflow-x: auto; margin: 0 0 10px; border: 1px solid var(--border); border-radius: 8px; }
.jv-table table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.jv-table th, .jv-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-soft); text-align: left; vertical-align: top; }
.jv-table th { background: var(--field); color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
.jv-table tr:last-child td { border-bottom: 0; }
.jv-answer.streaming > :last-child::after { content: '▍'; color: var(--navy-soft); animation: jv-blink 1s steps(2) infinite; }
@keyframes jv-blink { 50% { opacity: 0; } }
.jv-tools { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.jv-tools li { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--field); font-size: 11.5px; color: var(--ink-soft); }
.jv-tools em { font-style: normal; color: var(--muted); }
.jv-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.jv-tools .running .jv-dot { background: var(--jv-cyan); animation: jv-blink 0.9s infinite; }
.jv-tools .failed .jv-dot { background: var(--critical); }
.jv-thinking { display: inline-flex; gap: 4px; padding: 6px 0; }
.jv-thinking span { width: 6px; height: 6px; border-radius: 50%; background: var(--navy-soft); animation: jv-blink 1.2s infinite; }
.jv-thinking span:nth-child(2) { animation-delay: 0.2s; }
.jv-thinking span:nth-child(3) { animation-delay: 0.4s; }

.jv-composer { display: flex; align-items: flex-end; gap: 8px; margin: 8px 12px 12px; padding: 8px 8px 8px 12px; border: 1px solid var(--field-border); border-radius: 14px; background: var(--field); }
.jv-composer[hidden] { display: none; }
.jv-composer:focus-within { border-color: var(--navy-soft); box-shadow: 0 0 0 3px rgba(46, 116, 181, 0.15); }
.jv-input { flex: 1; resize: none; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: 14px; line-height: 1.45; max-height: 160px; outline: none; padding: 4px 0; }
.jv-send { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--navy); color: #fff; cursor: pointer; flex-shrink: 0; }
.jv-send:disabled { opacity: 0.45; cursor: progress; }

.jv-history-wrap { display: flex; flex-direction: column; gap: 10px; }
.jv-search { width: 100%; padding: 8px 10px; border: 1px solid var(--field-border); border-radius: 8px; background: var(--field); color: var(--ink); font: inherit; font-size: 13px; }
.jv-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.jv-history li { border-radius: 8px; }
.jv-history li.current, .jv-history li:hover { background: var(--field); }
.jv-history-open { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px 2px; border: 0; background: none; color: var(--ink); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.jv-history-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jv-history-age { color: var(--muted-soft); font-size: 12px; flex-shrink: 0; }
.jv-pin { color: var(--warn); }
.jv-history-tools { display: flex; gap: 2px; padding: 0 6px 6px; opacity: 0; }
.jv-history li:hover .jv-history-tools, .jv-history li:focus-within .jv-history-tools, .jv-history li.current .jv-history-tools { opacity: 1; }
.jv-mini { border: 0; background: none; color: var(--link); font: inherit; font-size: 12px; padding: 2px 6px; border-radius: 6px; cursor: pointer; }
.jv-mini:hover { background: var(--surface); }
.jv-mini.danger { color: var(--critical); }
.jv-note { margin-top: 8px; font-size: 12px; }

@media (max-width: 1100px) {
  body.jv-open .layout { margin-right: 0; }
  .jv-panel { width: min(var(--jv-width), 100vw); box-shadow: var(--shadow-lg); }
}
@media (max-width: 640px) {
  .jv-panel { width: 100vw; top: 0; z-index: 45; }
}

/* ESPR AI panel: drag the left edge to resize (dashboard/assistant.js). */
.jv-grip { position: absolute; top: 0; bottom: 0; left: -4px; width: 8px; cursor: col-resize; z-index: 3; touch-action: none; }
.jv-grip::after { content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background 0.15s; }
.jv-grip:hover::after, .jv-grip:focus-visible::after, body.jv-resizing .jv-grip::after { background: var(--jv-cyan); }
.jv-grip:focus-visible { outline: none; }
body.jv-resizing { cursor: col-resize; user-select: none; }
body.jv-resizing .jv-panel, body.jv-resizing .layout { transition: none; }
a.jv-icon-btn[hidden] { display: none; }
@media (max-width: 640px) { .jv-grip { display: none; } }
