:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1f2933;
  --muted: #6b7785;
  --line: #e1e5ea;
  --accent: #1f6f6b;
  --accent-soft: #e4f1f0;
  --warn: #8a5a00;
  --warn-soft: #fdf1d8;
  --err: #a12b2b;
  --err-soft: #fbe6e6;
  --ok: #1d6b3a;
  --ok-soft: #e3f4e8;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45; }
a { color: var(--accent); }
h2 { margin: 0; font-size: 1.3rem; }
h3 { margin: 0 0 .6rem; font-size: 1.05rem; }
h4 { margin: 1rem 0 .4rem; font-size: .95rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.na { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }


.badge-demo { background: var(--accent-soft); color: var(--accent); }
.badge-live { background: var(--warn-soft); color: var(--warn); }

.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .45rem .9rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; font-size: .92rem; cursor: pointer; text-decoration: none; }
.btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #185a57; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn-sm { padding: .25rem .6rem; font-size: .85rem; }



.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: .25rem; }
.panel-inner { margin-top: .6rem; }
.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.between { justify-content: space-between; }
.notice { padding: .55rem .8rem; border-radius: var(--radius); font-size: .92rem; margin: .5rem 0; }
.notice-info { background: var(--accent-soft); color: #14504d; }
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.notice-error { background: var(--err-soft); color: var(--err); }
.notice-inline.err { color: var(--err); }
.notice-inline.ok { color: var(--ok); }
#flash .notice { margin: 0; }


.bar { flex: 1; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); transition: width .3s; }

ul.plain { margin: .3rem 0; padding-left: 1.1rem; }
.kv { border-collapse: collapse; margin: .4rem 0; }
.kv th { text-align: left; font-weight: 500; color: var(--muted); padding: .2rem 1.2rem .2rem 0; }
.kv td { padding: .2rem 0; }
details { margin: .4rem 0; }
summary { cursor: pointer; color: var(--accent); }

.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(125px, 1fr)); gap: .4rem .5rem; }
.fgrid .ms-wrap { grid-column: span 1; }
.hint, label small, .lbl small { color: var(--muted); font-size: .74rem; font-weight: 400; display: block; line-height: 1.25; }
.hint { margin: 0; }
.lbl { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; color: var(--muted); margin-bottom: .2rem; }
.ms-wrap { display: flex; flex-direction: column; position: relative; }
.ms, .colmenu { position: relative; }
.ms summary { cursor: pointer; list-style: none; border: 1px solid var(--line); border-radius: 6px; padding: .4rem .55rem; background: #fff; font-size: .92rem; color: var(--text); }
.ms summary::after { content: " ▾"; color: var(--muted); }
.ms-list { position: absolute; z-index: 5; top: calc(100% + 2px); left: 0; min-width: 14rem; max-height: 16rem; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgba(0,0,0,.12); padding: .35rem .6rem; display: flex; flex-direction: column; }
.tchips { display: flex; flex-wrap: wrap; gap: .35rem; }
.tchip { flex-direction: row; cursor: pointer; }
.tchip input { position: absolute; opacity: 0; pointer-events: none; }
.tchip span { display: inline-block; padding: .28rem .7rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--text); font-size: .85rem; user-select: none; }
.tchip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.tchip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.unit { align-self: center; color: var(--muted); font-size: .85rem; }
.colmenu summary { list-style: none; display: inline-flex; }
.breakdown { margin: .4rem 0; }
.raise-form { margin-top: .6rem; padding-top: .6rem; border-top: 1px dashed var(--line); }
.job-meta { margin: .3rem 0 0; }
table.data th a.sort { color: inherit; text-decoration: none; white-space: nowrap; }
table.data th a.sort:hover { color: var(--accent); }
table.data th .arrow { color: var(--accent); }
table.data .c-country, table.data .c-category, table.data .c-verified, table.data .c-phone, table.data .c-erv,
table.data .c-rpw, table.data .c-last, table.data .c-paid, table.data .c-dur, table.data .c-reach,
table.data .c-lrate, table.data .c-c1k, table.data .c-comm, table.data .c-viral, table.data .c-stab,
table.data .c-top, table.data .c-growth, table.data .c-name, table.data .c-offer, table.data .c-updated,
table.data .c-status { display: none; }
body.show-country table.data .c-country, body.show-category table.data .c-category,
body.show-verified table.data .c-verified, body.show-phone table.data .c-phone,
body.show-erv table.data .c-erv, body.show-rpw table.data .c-rpw, body.show-last table.data .c-last,
body.show-paid table.data .c-paid, body.show-dur table.data .c-dur, body.show-reach table.data .c-reach,
body.show-lrate table.data .c-lrate, body.show-c1k table.data .c-c1k, body.show-comm table.data .c-comm,
body.show-viral table.data .c-viral, body.show-stab table.data .c-stab, body.show-top table.data .c-top,
body.show-growth table.data .c-growth, body.show-name table.data .c-name, body.show-offer table.data .c-offer,
body.show-updated table.data .c-updated, body.show-status table.data .c-status { display: table-cell; }
.defs-wide { grid-template-columns: 11rem 1fr; }
label { display: flex; flex-direction: column; gap: .2rem; font-size: .82rem; color: var(--muted); }
label.inline { flex-direction: row; align-items: center; gap: .4rem; color: var(--text); font-size: .92rem; margin: .25rem 0; }
input[type=text], input:not([type]), input[type=search], select { font: inherit; font-size: .92rem; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); min-width: 0; }
.f-search { flex: 1 1 260px; }
.f-search input { width: 100%; }
.range { display: flex; gap: .3rem; }
.range input { width: 100%; min-width: 0; max-width: 7rem; padding: .3rem .45rem; }

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { text-align: left; font-weight: 600; font-size: .78rem; color: var(--muted); padding: .5rem .5rem; border-bottom: 1px solid var(--line); background: #fafbfc; vertical-align: bottom; position: sticky; top: 0; }
table.data td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #f8fafb; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }
table.data .col-check { width: 2rem; text-align: center; }
table.data.compact td, table.data.compact th { padding: .35rem .6rem; }
table.narrow { width: auto; min-width: 16rem; }
.account-link { font-weight: 550; text-decoration: none; }
.account-link:hover { text-decoration: underline; }
.empty { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 2rem 1rem; text-align: center; color: var(--muted); }

.chip { display: inline-block; padding: .08rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 550; background: var(--bg); color: var(--muted); white-space: nowrap; vertical-align: middle; }
.chip-demo { background: #e8e6f5; color: #4a3f9a; }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-fin { background: var(--accent-soft); color: var(--accent); }
.st-done { background: var(--ok-soft); color: var(--ok); }
.st-partial { background: var(--warn-soft); color: var(--warn); }
.st-error { background: var(--err-soft); color: var(--err); }
.st-queued, .st-processing, .chip-run { background: var(--accent-soft); color: var(--accent); }

.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

.modal { position: fixed; inset: 0; background: rgba(20, 28, 36, .45); display: flex; justify-content: center; align-items: flex-start; padding: 2rem 1rem; overflow-y: auto; z-index: 10; }
.modal[hidden] { display: none; }
.modal-panel { background: var(--surface); border-radius: 12px; width: 100%; max-width: 1000px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.modal-card { padding: 1.25rem 1.5rem 1.5rem; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .6rem; }
.meta-line { display: flex; gap: .4rem 1rem; align-items: center; flex-wrap: wrap; }
.block { border-top: 1px solid var(--line); margin-top: 1.1rem; padding-top: 1rem; }
.defs { display: grid; grid-template-columns: 11rem 1fr; gap: .4rem 1rem; margin: .5rem 0; }
.defs dt { color: var(--muted); font-size: .88rem; }
.defs dd { margin: 0; }
table.metrics { border-collapse: collapse; width: 100%; }
table.metrics th { text-align: left; font-weight: 600; padding: .45rem .8rem .45rem 0; vertical-align: top; white-space: nowrap; width: 14rem; }
table.metrics td { padding: .45rem .8rem .45rem 0; vertical-align: top; border-bottom: 1px solid var(--line); }
table.metrics td:nth-child(2) { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; width: 7rem; text-align: right; }
table.metrics td.expl { color: var(--muted); font-size: .86rem; font-weight: 400; text-align: left; white-space: normal; width: auto; }
.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 .9rem; padding: .7rem .9rem .9rem; }
legend { padding: 0 .4rem; font-weight: 600; font-size: .9rem; }
fieldset label { margin-top: .4rem; }
fieldset input, fieldset select { width: 100%; }
fieldset label.inline input { width: auto; }
.calc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: .8rem 0 .4rem; }
.calc-cell { background: var(--bg); border-radius: var(--radius); padding: .7rem .9rem; }
.calc-title { font-weight: 600; }
.calc-cpm, .calc-label { color: var(--muted); font-size: .8rem; }
.calc-value { font-size: 1.4rem; font-weight: 650; margin-top: .2rem; }
.offer-form { margin-top: .8rem; align-items: flex-end; }
.offer-form input { width: 12rem; }

@media (max-width: 900px) {
  .grid2, .grid3, .calc-grid { grid-template-columns: 1fr; }
  .defs { grid-template-columns: 1fr; }
}

#flash:empty, #campaign-panel:empty, #import-panel:empty, #estimate-panel:empty, #job-panel:empty { display: none; }
table.data td.email { max-width: 13rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.updated { width: 5.5rem; }
table.data td.updated .time { color: var(--muted); }

.notice-warn { background: var(--warn-soft); color: var(--warn); }
.mixed { color: var(--warn); font-weight: 600; cursor: help; }
.price-range { white-space: nowrap; }
.clear-link { margin-left: .1rem; }

/* Spend page */
:root {
  --c-profile: #1f6f6b;
  --c-about: #d19a2a;
  --c-clips: #4a63b8;
  --c-other: #8a94a0;
  --chart-grid: var(--line);
  --chart-axis: var(--muted);
}
.spend-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: space-between; margin-bottom: .4rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg-item { padding: .35rem .8rem; color: var(--text); text-decoration: none; font-size: .9rem; background: var(--surface); }
.seg-item + .seg-item { border-left: 1px solid var(--line); }
.seg-item.on { background: var(--accent); color: #fff; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; font-size: .85rem; margin-bottom: .3rem; }
.legend .sw { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
svg.chart { width: 100%; height: auto; display: block; }
svg.chart .grid { stroke: var(--chart-grid); stroke-width: 1; }
svg.chart .baseline { stroke: var(--chart-axis); stroke-width: 1; }
svg.chart .axis { fill: var(--chart-axis); font-size: 11px; font-family: var(--font); }
svg.chart .hit { fill: transparent; }
svg.chart .bar-day:hover .hit { fill: var(--accent-soft); opacity: .6; }
svg.chart .line { fill: none; stroke: var(--c-clips); stroke-width: 2; stroke-linejoin: round; }
svg.chart .dot { fill: var(--c-clips); }
.seg-profile { fill: var(--c-profile); background: var(--c-profile); }
.seg-about { fill: var(--c-about); background: var(--c-about); }
.seg-clips { fill: var(--c-clips); background: var(--c-clips); }
.seg-other { fill: var(--c-other); background: var(--c-other); }
td.recon-diff.warn { color: var(--warn); font-weight: 600; }

/* ---------------------------------------------------------------------------
   Workspace layout (T4): header, summary, sphere bar, sidebar filters, table, side panel
   --------------------------------------------------------------------------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 500; white-space: nowrap; }
.counters { display: flex; gap: .75rem; flex-wrap: wrap; margin: .6rem 0; }
.counters > div { background: var(--bg); border-radius: var(--radius); padding: .5rem .9rem; min-width: 8.5rem; }
.counters b { display: block; font-size: 1.3rem; }
.counters span { color: var(--muted); font-size: .82rem; }
.progress-count { font-variant-numeric: tabular-nums; font-size: .9rem; white-space: nowrap; }
.chips { display: contents; }
label.visually-label { display: block; }

/* header */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.topbar-in { max-width: 1760px; margin: 0 auto; padding: .5rem 1.25rem; display: flex; align-items: center; gap: 1.25rem; }
.brand { font-size: 1.1rem; font-weight: 650; letter-spacing: .2px; color: var(--text); text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: .15rem; }
.nav a, .nav button { font: inherit; font-size: .92rem; color: var(--muted); background: none; border: 0; padding: .4rem .75rem; border-radius: 6px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.nav a:hover, .nav button:hover { color: var(--text); background: var(--bg); }
.nav a[aria-current=page] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .9rem; }
.balance { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.balance b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }

.page { max-width: 1760px; margin: 0 auto; padding: .8rem 1.25rem 1.25rem; display: flex; flex-direction: column; gap: .7rem; }

/* summary line */
.summarybar { display: flex; align-items: center; justify-content: space-between; gap: .6rem 1.5rem; flex-wrap: wrap; }
.summary { margin: 0; display: flex; flex-wrap: wrap; gap: .2rem 1.1rem; align-items: baseline; font-size: .95rem; color: var(--muted); }
.summary b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 650; }
.summary-spend { color: var(--muted); text-decoration: none; border-bottom: 1px dotted var(--muted); }
.summary-spend:hover { color: var(--accent); border-color: var(--accent); }
.summary-spend b { color: var(--accent); }
.selection { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

/* job line */
.jobline { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .4rem .8rem; }
.jobline-row { display: flex; align-items: center; gap: .5rem .9rem; flex-wrap: wrap; }
.jobline-title { font-weight: 600; }
.jobline .bar { flex: 1 1 8rem; min-width: 6rem; max-width: 22rem; height: 8px; }
.jobline .job-meta { color: var(--muted); }
.jobline-now { margin: .2rem 0 0; }
.jobline .notice { margin: .4rem 0 .1rem; }
.jobdone > summary { list-style: none; cursor: pointer; color: var(--text); }
.jobdone > summary::-webkit-details-marker { display: none; }
.jobline-more { color: var(--accent); }
.jobdone[open] .jobline-more { display: none; }
.jobdone-body { padding: .3rem 0 .2rem; }
.jobdone-body p { margin: .35rem 0; }
.errfold > summary { color: var(--err); }

/* sphere bar */
.spheres { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.sphere { position: relative; font: inherit; cursor: pointer; display: inline-flex; flex-direction: row; color: var(--text); font-size: .88rem; margin: 0; padding: 0; background: none; border: 0; gap: 0; }
.sphere input { position: absolute; opacity: 0; pointer-events: none; }
.sphere > span, button.sphere { display: inline-flex; align-items: baseline; gap: .3rem; padding: .26rem .65rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); user-select: none; white-space: nowrap; transition: background-color .12s, border-color .12s; }
button.sphere { color: var(--text); font-size: .88rem; }
.sphere:hover > span, button.sphere:hover { border-color: var(--accent); }
.sphere em { font-style: normal; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.sphere input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.sphere input:checked + span em { color: rgba(255,255,255,.78); }
.sphere input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
button.sphere.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.sphere-none > span { border-style: dashed; color: var(--muted); }

/* workspace: sidebar + results */
.workspace { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 1rem; align-items: start; margin-top: .7rem; }
.filters { margin: 0; }
.sidebar { position: sticky; top: 3.6rem; max-height: calc(100vh - 4.4rem); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .2rem .8rem .8rem; }
.sidebar-head { display: flex; align-items: center; gap: .5rem; padding: .55rem 0; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.sidebar-head h2 { font-size: 1rem; margin-right: auto; }
.sidebar-close, .filters-toggle, .sidebar-scrim { display: none; }
.fgroup { border-top: 1px solid var(--line); margin: 0; padding: 0; }
.fgroup > summary { list-style: none; cursor: pointer; padding: .6rem 0; color: var(--text); font-weight: 600; font-size: .92rem; display: flex; justify-content: space-between; align-items: center; }
.fgroup > summary::-webkit-details-marker { display: none; }
.fgroup > summary::after { content: "▾"; color: var(--muted); font-weight: 400; transition: transform .15s; }
.fgroup:not([open]) > summary::after { transform: rotate(-90deg); }
.fgroup[open] { padding-bottom: .7rem; }
.fgroup > .fgrid, .fgroup > .tchips, .fgroup > .hint, .fgroup > label { margin-top: .35rem; }
.fgroup > .tchips + .tchips { margin-top: .4rem; }
.fgrid { display: grid; grid-template-columns: 1fr; gap: .55rem; }
.sidebar .range input { max-width: none; }
.sidebar .ms-list { position: static; box-shadow: none; max-height: 11rem; margin-top: .25rem; min-width: 0; }
.per-page { margin-top: .6rem; border-top: 1px solid var(--line); padding-top: .7rem; }
.per-page select { width: auto; }

.results { min-width: 0; display: flex; flex-direction: column; gap: .5rem; }
.tablebar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.f-search { flex: 0 1 24rem; min-width: 12rem; }
.f-search input { width: 100%; }
.colmenu summary { list-style: none; display: inline-flex; }
.colmenu summary::-webkit-details-marker { display: none; }
.colmenu .ms-list { right: 0; left: auto; }
.colmenu:first-of-type .ms-list { left: 0; right: auto; }
.menu-list { padding: .25rem; min-width: 14rem; }
.menu-item { display: block; text-align: left; font: inherit; font-size: .9rem; color: var(--text); background: none; border: 0; padding: .45rem .6rem; border-radius: 6px; cursor: pointer; text-decoration: none; }
.menu-item:hover { background: var(--accent-soft); color: var(--accent); }
.bulkbar { display: flex; align-items: center; gap: .35rem .5rem; flex-wrap: wrap; margin: 0 0 .5rem; min-height: 1.9rem; }
.found { margin-right: .3rem; font-size: .92rem; }
.fchip { display: inline-block; padding: .12rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: .8rem; text-decoration: none; white-space: nowrap; }
.fchip:hover { background: var(--accent); color: #fff; }
.clear-link { font-size: .85rem; margin-left: .2rem; }

/* table */
.table-wrap { overflow: auto; max-height: calc(100vh - 17.5rem); min-height: 14rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overscroll-behavior: contain; }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
table.data th { text-align: left; font-weight: 600; font-size: .78rem; line-height: 1.25; color: var(--muted); padding: .45rem .5rem; border-bottom: 1px solid var(--line); background: #fafbfc; vertical-align: bottom; position: sticky; top: 0; z-index: 2; }
table.data td { padding: .36rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; background: var(--surface); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #f6f9fa; }
table.data tr.is-open td { background: var(--accent-soft); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.num { text-align: right; }
table.data.main { width: max-content; min-width: 100%; }
table.data.main th.col-check, table.data.main td.col-check { position: sticky; left: 0; z-index: 3; width: 2.4rem; min-width: 2.4rem; max-width: 2.4rem; padding-left: .4rem; padding-right: .2rem; text-align: center; }
table.data.main td.col-check { z-index: 1; }
table.data.main th.col-acc, table.data.main td.col-acc { position: sticky; left: 2.4rem; z-index: 3; box-shadow: 1px 0 0 var(--line); }
table.data.main td.col-acc { z-index: 1; max-width: 10.5rem; overflow: hidden; text-overflow: ellipsis; }
table.data td.email { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.spheres-cell { white-space: nowrap; }
table.data td.updated { width: 5.5rem; }
.stag { display: inline-block; padding: .04rem .5rem; margin-right: .2rem; border-radius: 999px; background: #edf0f3; color: #3a4654; font-size: .78rem; }
.stag-more { background: transparent; color: var(--muted); padding-left: 0; }
td.t-hi { background-image: linear-gradient(rgba(31,111,107,.11), rgba(31,111,107,.11)); color: #14504d; }
td.t-lo { color: var(--muted); }
.na { color: #9aa5b1; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-top: .5rem; flex-wrap: wrap; }
.pager-btns { display: flex; gap: .4rem; }
.empty .btn { margin-top: .4rem; }

/* side panel with the account card */
.panel-side { position: fixed; top: 0; right: 0; bottom: 0; width: min(42rem, 100vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: -14px 0 36px rgba(20, 28, 36, .16); z-index: 30; overflow-y: auto; overscroll-behavior: contain; animation: panel-in .16s ease-out; }
.panel-side[hidden] { display: none; }
@keyframes panel-in { from { transform: translateX(1.5rem); opacity: .4; } to { transform: none; opacity: 1; } }
.card-top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: .9rem 1.1rem .4rem; }
.card-head h2 { word-break: break-all; }
.card-nav { display: flex; gap: .15rem; overflow-x: auto; padding: 0 .7rem .45rem; }
.card-nav a { padding: .25rem .6rem; border-radius: 999px; font-size: .85rem; color: var(--muted); text-decoration: none; white-space: nowrap; }
.card-nav a:hover { background: var(--accent-soft); color: var(--accent); }
.card-body { padding: .6rem 1.1rem 3rem; }
.card .block { scroll-margin-top: 6.5rem; margin-top: 1.1rem; padding-top: .9rem; border-top: 1px solid var(--line); }
.card .block h3 { font-size: 1.02rem; }
.card .defs { grid-template-columns: 9.5rem 1fr; }
.card .table-wrap { max-height: none; min-height: 0; }
.card table.data { width: max-content; min-width: 100%; }
.card .grid3, .card .calc-grid { grid-template-columns: repeat(3, 1fr); }
.card .fold > summary { font-weight: 600; margin: .3rem 0; }
.card table.metrics, .card table.metrics tbody { display: block; }
.card table.metrics tr { display: grid; grid-template-columns: 1fr auto; gap: .05rem 1rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.card table.metrics th, .card table.metrics td { display: block; padding: 0; border: 0; width: auto; white-space: normal; }
.card table.metrics td:nth-child(2) { text-align: right; }
.card table.metrics td.expl { grid-column: 1 / -1; font-size: .82rem; }

@media (max-width: 1199px) {
  .workspace { display: block; }
  .filters-toggle { display: inline-flex; }
  .sidebar { position: fixed; z-index: 40; top: 0; left: 0; bottom: 0; max-height: none; width: min(21rem, 92vw); border-radius: 0; transform: translateX(-102%); transition: transform .18s ease-out; box-shadow: 14px 0 36px rgba(20, 28, 36, .18); visibility: hidden; }
  body.filters-open .sidebar { transform: none; visibility: visible; }
  body.filters-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(20, 28, 36, .4); z-index: 35; }
  .sidebar-close { display: inline-flex; }
  .table-wrap { max-height: calc(100vh - 15rem); }
}
@media (max-width: 600px) {
  .page { padding: .5rem .75rem 1rem; gap: .5rem; }
  .topbar-in { flex-wrap: wrap; gap: .1rem .8rem; padding: .4rem .75rem .2rem; }
  .brand { font-size: 1rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; margin: 0 -.4rem; }
  .nav a, .nav button { padding: .35rem .6rem; }
  .topbar-right { flex-direction: column; align-items: flex-end; gap: .1rem; }
  .topbar-right .badge { font-size: .7rem; padding: .1rem .5rem; }
  .balance { font-size: .75rem; }
  .summary { font-size: .88rem; gap: .1rem .8rem; }
  .spheres { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .35rem; scroll-snap-type: x proximity; margin: 0 -.75rem; padding-left: .75rem; padding-right: .75rem; }
  .sphere { scroll-snap-align: start; flex: none; }
  .selection:not(.has-sel) { display: none; }
  .bulkbar #select-by-filter, .bulkbar #collect-uncollected { flex: 1 1 auto; }
  .f-search { flex-basis: 100%; }
  .tablebar .spacer { display: none; }
  .card .defs, .card .grid3, .card .calc-grid { grid-template-columns: 1fr; }
  .table-wrap { max-height: calc(100vh - 11rem); }
}
@media (prefers-reduced-motion: reduce) {
  .panel-side { animation: none; }
  .sidebar { transition: none; }
}
table.data th.num a.sort { display: inline-block; max-width: 6.5rem; }
table.data th a.sort { white-space: normal; }
table.data .short { display: inline-block; max-width: 6.5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.tablebar .htmx-indicator { display: none; }
.tablebar .htmx-indicator.htmx-request { display: inline; }

/* campaigns */
.page-title { margin: 0; font-size: 1.25rem; }
.page-title .back { text-decoration: none; color: var(--muted); margin-right: .25rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: .6rem .9rem; align-items: end; }
.form-grid .wide, .form-grid .assump, .form-grid .form-actions { grid-column: 1 / -1; }
.form-actions { display: flex; align-items: center; gap: .8rem; }
.card .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
input[type=date], textarea { font: inherit; font-size: .92rem; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); min-width: 0; }
textarea { resize: vertical; }
.assump { margin: 0; }
.assump legend { font-weight: 600; font-size: .85rem; padding: 0 .4rem; color: var(--accent); }
.metrics-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr)); gap: .6rem; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .65rem .8rem; }
.metric-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.metric-value { font-size: 1.3rem; font-weight: 650; font-variant-numeric: tabular-nums; margin: .1rem 0; }
.metric-hint { font-size: .75rem; color: var(--muted); line-height: 1.3; }
.overdue { color: var(--err); font-weight: 600; font-size: .85rem; }
.status-select { padding: .2rem .4rem; font-size: .85rem; }
.cst-candidate { background: var(--bg); color: var(--muted); }
.cst-contacted, .cst-interested { background: var(--accent-soft); color: var(--accent); }
.cst-agreed, .cst-published, .cst-done { background: var(--ok-soft); color: var(--ok); }
.cst-declined { background: var(--err-soft); color: var(--err); }
.cs-active { background: var(--ok-soft); color: var(--ok); }
.contact-log { list-style: none; margin: .6rem 0 0; padding: 0; }
.contact-log li { padding: .45rem 0; border-top: 1px solid var(--line); }
.scen { width: 100%; margin-bottom: .5rem; }
.scen th[scope=row] { font-weight: 550; text-align: left; position: static; background: none; color: var(--text); font-size: .88rem; }
.frozen { margin-top: .6rem; padding: .6rem .8rem; background: var(--bg); border-radius: var(--radius); }
.frozen h4 { margin: 0 0 .2rem; }
.pick-panel .row { display: flex; align-items: end; gap: .6rem; flex-wrap: wrap; }
@media (max-width: 600px) { .card .form-grid { grid-template-columns: 1fr; } }

.logout-form { display: flex; align-items: center; gap: .3rem; margin: 0; }
.user-email { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.login-card { width: 100%; max-width: 22rem; padding: 1.5rem; }
.login-form { display: flex; flex-direction: column; gap: .8rem; margin-top: 1rem; }
.login-form label { display: flex; flex-direction: column; gap: .25rem; font-size: .9rem; }
.login-form input { font: inherit; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.login-form .notice { margin: 0; }
