/* ==========================================================================
   Tennessee Community Impact Dashboard · The Jason Foundation theme.
   Colors come from the JFI logo: sky blue "j", black wordmark, white field.
   >>> TO RECOLOR: change the --jfi-* values below. <<<
   ========================================================================== */
:root {
  --jfi-blue:      #459bd8;   /* logo "j": accents, chart fills, focus rings */
  --jfi-blue-ink:  #1b6ea8;   /* blue used as TEXT on light (meets contrast) */
  --jfi-black:     #111111;   /* wordmark: primary buttons, headings */
  --jfi-white:     #ffffff;

  --blue-soft: rgba(59,154,217,0.12);
  --blue-line: rgba(59,154,217,0.40);

  --bg:       #f5f6f7;
  --panel:    #ffffff;
  --panel-2:  #f9fafb;
  --panel-3:  #eef0f2;
  --ink:      #111111;
  --muted:    #5d6470;
  --muted-2:  #8d939d;
  --line:     rgba(17,17,17,0.11);
  --line-2:   rgba(17,17,17,0.06);
  --btn-bg:   var(--jfi-black);
  --btn-ink:  #ffffff;

  --green: #1d7f52;  --green-soft: rgba(29,127,82,0.12);
  --amber: #8a5a00;  --amber-soft: rgba(230,160,20,0.18);
  --red:   #c62a3c;  --red-soft:   rgba(198,42,60,0.10);
  --slate: #4b5563;  --slate-soft: rgba(75,85,99,0.11);

  --radius: 12px; --radius-sm: 8px;
  --shadow: 0 16px 40px rgba(17,17,17,0.14);
  --shadow-sm: 0 2px 8px rgba(17,17,17,0.06);
  --font: 'Inter', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

:root[data-theme="dark"] {
  --jfi-blue-ink: #7cc0ef;
  --blue-soft: rgba(59,154,217,0.18);
  --blue-line: rgba(59,154,217,0.50);
  --bg:      #0e1013;
  --panel:   #171a1f;
  --panel-2: #1c2026;
  --panel-3: #252a31;
  --ink:     #eceef1;
  --muted:   #a0a7b2;
  --muted-2: #6f7682;
  --line:    rgba(255,255,255,0.11);
  --line-2:  rgba(255,255,255,0.06);
  --btn-bg:  #f2f3f5;
  --btn-ink: #111111;
  --green: #4ade80;  --green-soft: rgba(74,222,128,0.14);
  --amber: #fbbf24;  --amber-soft: rgba(251,191,36,0.16);
  --red:   #f87171;  --red-soft:   rgba(248,113,113,0.15);
  --slate: #a5b0bf;  --slate-soft: rgba(165,176,191,0.14);
  --shadow: 0 16px 40px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.45;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
/* Role switch: body.is-viewer hides admin controls (the server enforces it too). */
.is-viewer .admin-only, body:not(.is-viewer) .viewer-only { display: none !important; }
/* County project switch (Settings): body.county-off hides its nav, picker and links. */
.county-off .county-only { display: none !important; }
.campaigns-off .campaign-only { display: none !important; }
a { color: var(--jfi-blue-ink); }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--jfi-blue); outline-offset: 2px; }

/* ---------- logo / wordmark ---------- */
.logo-slot { display: inline-flex; align-items: center; }
.logo-slot img { height: 42px; width: auto; display: block; }
.logo-lg img { height: 60px; }
.wordmark { display: inline-flex; align-items: flex-end; gap: 2px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.wordmark .jf { font-family: Georgia, 'Times New Roman', serif; font-style: italic; font-size: 30px; line-height: 0.9; letter-spacing: -0.08em; margin-right: 4px; }
.wordmark .jf .j { color: var(--jfi-blue); }
.wordmark .the { font-weight: 300; font-size: 18px; }
.wordmark .name { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.logo-lg .wordmark .jf { font-size: 46px; }
.logo-lg .wordmark .the, .logo-lg .wordmark .name { font-size: 26px; }
:root[data-theme="dark"] .logo-slot img { background: #fff; border-radius: 6px; padding: 4px 8px; }

/* ---------- login ---------- */
.login-scrim { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card {
  width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line);
  border-top: 4px solid var(--jfi-blue); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.login-title { font-size: 20px; font-weight: 800; margin-top: 18px; }
.login-card .sub { color: var(--muted); margin: 4px 0 18px; font-size: 14px; }
.login-err { color: var(--red); min-height: 20px; margin-top: 10px; font-size: 14px; }

/* ---------- shell ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 10px 20px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: inline-flex; text-decoration: none; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px;
  padding: 8px 12px; border-radius: 999px; white-space: nowrap;
}
.nav a:hover { color: var(--ink); background: var(--panel-3); }
.nav a.active { color: var(--ink); background: var(--blue-soft); box-shadow: inset 0 0 0 1px var(--blue-line); }
.nav-badge { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--red); color: #fff; font-size: 12px; text-align: center; }
.topright { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--panel-3); }

.subheader { background: var(--panel); border-bottom: 1px solid var(--line); box-shadow: inset 0 3px 0 var(--jfi-blue); }
.subheader-inner { max-width: 1280px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.program-name { font-weight: 800; font-size: 17px; }
.program-sub { color: var(--muted); font-size: 13px; }
.county-pick { display: flex; align-items: center; gap: 10px; }
.county-pick select { min-width: 220px; }
.county-pick .seg.pick-mode { margin: 0; flex-wrap: nowrap; flex-shrink: 0; gap: 4px; }
.pick-mode button { min-height: 32px; padding: 4px 12px; }
.period { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.period .seg { margin: 0; }
.period-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.period-bar .field { margin: 0; }
.period-bar input { width: auto; }
details.more > summary { cursor: pointer; font-weight: 600; margin: 4px 0 12px; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---------- typography + layout ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 26px; font-weight: 800; }
.page-head .meta { color: var(--muted); font-size: 14px; margin-top: 4px; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumb a { color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions select { width: auto; }
.section { margin-top: 28px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 18px; font-weight: 800; }
.hint { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm); }
.panel h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px; font-weight: 700; }
.empty { padding: 28px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); background: var(--panel); }

/* ---------- buttons + inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--panel);
  padding: 9px 16px; font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; color: var(--ink);
  min-height: 40px;
}
.btn:hover { background: var(--panel-3); }
.btn-primary { background: var(--btn-bg); color: var(--btn-ink); border-color: var(--btn-bg); }
.btn-primary:hover { background: var(--btn-bg); opacity: 0.88; }
.btn-blue { background: var(--jfi-blue); color: #0b2233; border-color: var(--jfi-blue); }
.btn-blue:hover { background: var(--jfi-blue); opacity: 0.9; }
.btn-danger { color: var(--red); border-color: var(--red-soft); }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 12px; font-size: 13px; min-height: 32px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=date], input[type=datetime-local], input[type=month], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--panel-2); min-height: 40px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-line); border-color: var(--jfi-blue); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel-2); font-size: 14px; cursor: pointer; }
.check input { margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 6px; margin: 0 0 16px; }
legend { font-weight: 800; padding: 0 6px; }

/* ---------- chips ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--slate-soft); color: var(--slate); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.blue { background: var(--blue-soft); color: var(--jfi-blue-ink); }
.chip.sample { background: repeating-linear-gradient(135deg, var(--amber-soft), var(--amber-soft) 6px, transparent 6px, transparent 12px); color: var(--amber); border: 1px dashed var(--amber); }
.banner { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px dashed var(--amber); background: var(--amber-soft); color: var(--ink); font-size: 14px; margin-bottom: 16px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; }
.kpi .eye { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; border: 0; border-radius: 999px; background: transparent; color: var(--muted-2); cursor: pointer; display: grid; place-items: center; }
.kpi .eye:hover, .kpi .eye:focus-visible { background: var(--panel-3); color: var(--ink); }
.kpi .k-label { padding-right: 24px; }
.hidden-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.hidden-bar .chip { border: 0; cursor: pointer; }
.print-only { display: none; }
.kpi .k-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi .k-val { font-size: 24px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--muted-2); }

/* ---------- ad cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.card.is-sample { border-style: dashed; border-color: var(--amber); }
.card-thumb { aspect-ratio: 1 / 1; background: var(--panel-3); display: block; overflow: hidden; position: relative; border-bottom: 1px solid var(--line-2); }
/* contain, not cover: the whole graphic always shows, never cropped */
.card-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
.card-thumb .noimg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted-2); font-size: 13px; }
.card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.card-body { padding: 14px 14px 10px; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.card-title { font-weight: 800; font-size: 16px; line-height: 1.25; text-decoration: none; color: var(--ink); }
.card-title:hover { text-decoration: underline; }
.card-meta { font-size: 13px; color: var(--muted); }
.card-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; border-top: 1px solid var(--line-2); padding-top: 8px; margin-top: auto; }
.card-stats div { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.card-stats b { display: block; font-size: 15px; color: var(--ink); letter-spacing: 0; font-variant-numeric: tabular-nums; }
.card-foot { display: flex; gap: 8px; padding: 10px 14px 14px; }
.card-foot .btn { flex: 1; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 700; background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover td { background: var(--panel-2); }
tr.clickable { cursor: pointer; }
tfoot td { font-weight: 800; background: var(--panel-2); border-top: 1px solid var(--line); }
td.wrap-cell { white-space: normal; min-width: 220px; max-width: 360px; }
th.rec-col { text-align: right; }
th .sub { display: block; text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--muted-2); }
.cell-empty { color: var(--muted-2); }
.share { color: var(--muted-2); font-size: 12px; margin-left: 4px; }
.bar { display: inline-block; height: 6px; background: var(--jfi-blue); border-radius: 3px; vertical-align: middle; margin-left: 6px; opacity: 0.85; }

/* ---------- ad detail ---------- */
.fb-preview { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; max-width: 480px; }
.fb-head { display: flex; gap: 10px; align-items: center; padding: 12px; }
.fb-avatar { width: 38px; height: 38px; flex: 0 0 38px; border-radius: 999px; background: var(--panel-3); display: flex; align-items: center; justify-content: center; font-family: Georgia, serif; font-style: italic; font-size: 18px; white-space: nowrap; letter-spacing: -0.08em; }
.fb-avatar .j { color: var(--jfi-blue); }
.fb-avatar img { width: 30px; height: 30px; display: block; }
:root[data-theme="dark"] .fb-avatar { background: #fff; }
.fb-name { font-weight: 700; font-size: 14px; }
.fb-spons { font-size: 12px; color: var(--muted); }
.fb-text { padding: 0 12px 10px; white-space: pre-wrap; font-size: 14px; }
.fb-media img { width: 100%; display: block; }
.fb-media-strip { display: flex; gap: 6px; padding: 8px 12px; overflow-x: auto; }
.fb-media-strip a { flex: 0 0 auto; font-size: 12px; }
.fb-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--panel-2); border-top: 1px solid var(--line-2); }
.fb-foot .h { font-weight: 700; font-size: 14px; }
.fb-foot .d { font-size: 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.timeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.step { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--panel); display: flex; flex-direction: column; gap: 6px; border-top-width: 4px; }
.step.recorded { border-top-color: var(--green); }
.step.due { border-top-color: var(--jfi-blue); background: var(--blue-soft); }
.step.overdue { border-top-color: var(--red); }
.step.upcoming { border-top-color: var(--line); }
.step.none { border-top-color: var(--line); opacity: 0.7; }
.step .s-label { font-weight: 800; }
.step .s-when { font-size: 13px; color: var(--muted); }

.checkin-list { display: flex; flex-direction: column; gap: 8px; }
.checkin { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); text-decoration: none; color: var(--ink); flex-wrap: wrap; }
.checkin:hover { background: var(--panel-2); }
.checkin .c-main { flex: 1; min-width: 200px; }
.checkin .c-title { font-weight: 700; }
.checkin .c-sub { font-size: 13px; color: var(--muted); }

/* ---------- modal ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(10,12,15,0.55); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 32px 16px; overflow-y: auto; }
.modal { width: 100%; max-width: 760px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); border-top: 4px solid var(--jfi-blue); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 18px; font-weight: 800; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
.bd-table input { min-height: 34px; padding: 5px 8px; }
.bd-table td { padding: 4px 6px; }
.bd-table td:first-child { min-width: 120px; }
details.bd { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; background: var(--panel-2); }
details.bd summary { cursor: pointer; padding: 10px 12px; font-weight: 700; }
details.bd .bd-inner { padding: 0 12px 12px; overflow-x: auto; }
.county-list { max-height: 340px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; }
.county-list label { display: flex; gap: 6px; align-items: center; padding: 4px 6px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.county-list label:hover { background: var(--panel-3); }
.media-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.media-item { width: 120px; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--panel-2); font-size: 12px; }
.media-item img { width: 100%; height: 80px; object-fit: cover; display: block; }
.media-item .mi-foot { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px; gap: 4px; }

/* ---------- help "?" + guide ---------- */
.help { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 999px; font-size: 11px; font-weight: 800; text-decoration: none; vertical-align: middle; background: var(--blue-soft); color: var(--jfi-blue-ink); border: 1px solid var(--blue-line); letter-spacing: 0; text-transform: none; }
a.help:hover { background: var(--jfi-blue); color: #fff; }
.guide-toc { display: flex; gap: 8px; flex-wrap: wrap; }
.guide-toc a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); text-decoration: none; color: var(--ink); font-weight: 600; font-size: 14px; }
.terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.term { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; scroll-margin-top: 90px; }
.term h3 { font-size: 17px; font-weight: 800; }
.term .aka { font-size: 13px; color: var(--muted); margin-top: 2px; }
.term p { margin: 8px 0 0; }
.term .ex { color: var(--ink); background: var(--panel-2); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 14px; }
.term .better { font-size: 14px; }
.term .tip { font-size: 14px; color: var(--muted); }
.term.focus { border-color: var(--jfi-blue); box-shadow: 0 0 0 3px var(--blue-soft); }

/* ---------- metric switch + chart ---------- */
.seg { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.seg button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; cursor: pointer; min-height: 34px; color: var(--muted); }
.seg button:hover { color: var(--ink); background: var(--panel-3); }
.seg button[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-ink); border-color: var(--btn-bg); }
.chart-panel { padding: 12px 12px 8px; }
.chart { width: 100%; min-height: 120px; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg .grid { stroke: var(--line-2); stroke-width: 1; }
.chart-svg .tick { fill: var(--muted); font-size: 12px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-svg .end-label { fill: var(--ink); font-size: 13px; font-weight: 700; font-family: var(--font); }
.chart-svg .dot { stroke: var(--panel); stroke-width: 2; }
.chart-svg .crosshair { stroke: var(--muted-2); stroke-width: 1; }
.chart-svg .hit { cursor: crosshair; outline: none; }
.chart-svg .hit:focus-visible { stroke: var(--jfi-blue); stroke-width: 2; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 2px 4px 8px; font-size: 13px; color: var(--muted); }
.lg-item { display: inline-flex; align-items: center; gap: 6px; max-width: 280px; }
.lg-key { width: 14px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.lg-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-tip { position: fixed; z-index: 70; pointer-events: none; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 8px 10px; font-size: 13px; max-width: 320px; }
.chart-tip .tt-head { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.chart-tip .tt-row { display: flex; align-items: center; gap: 8px; }
.chart-tip .tt-key { width: 12px; height: 3px; border-radius: 2px; flex: 0 0 auto; }
.chart-tip strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.chart-tip .tt-name { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--jfi-black); color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 60; font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--red); }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  .grid-2 { grid-template-columns: 1fr; }
  .timeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; padding: 8px 16px; gap: 8px; }
  .nav { order: 3; flex: 1 1 100%; flex-wrap: wrap; }
  .topright { margin-left: auto; }
  .subheader-inner, .wrap { padding-left: 16px; padding-right: 16px; }
  .county-pick { width: 100%; }
  .county-pick select { min-width: 0; flex: 1; }
  .page-head h1 { font-size: 22px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .modal-scrim { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .wordmark .the, .wordmark .name { font-size: 15px; }
  .logo-slot img { height: 36px; }
}

/* ---------- print ---------- */
@media print {
  .topbar, .subheader, .actions, .card-foot, .btn, .no-print, .help, .banner .admin-only, .page-head, .toast, .chart-tip, .filters a, .section-head .hint { display: none !important; }
  .print-only { display: block !important; }
  .print-head { margin-bottom: 18px; padding-bottom: 12px; border-bottom: 3px solid var(--jfi-blue); }
  .print-head h1 { font-size: 22px; margin: 10px 0 4px; }
  .print-head .logo-slot img { height: 40px; }
  .kpi, .card, tr, .chart-panel { break-inside: avoid; }
  .filters { border: 0; padding: 0; }
  .table-wrap { overflow: visible !important; border: 0; }
  table { font-size: 10px; width: 100%; }
  th, td { padding: 4px 6px !important; }
  tfoot { display: table-row-group; }
  .section-head, h2 { break-after: avoid; }
  .cards { grid-template-columns: repeat(3, 1fr) !important; gap: 10px; }
  .card-thumb { aspect-ratio: auto !important; height: 130px; }
  .card-thumb img { object-fit: cover; height: 100%; }
  details.more:not([open]) { display: none; }
  body { background: #fff; }
}

/* ---------- dashboards ---------- */
.filters { display: grid; gap: 10px; margin-bottom: 14px; }
.filters .f-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.filters .f-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); min-width: 64px; }
.filters .seg { margin: 0; }
.filters select { width: auto; min-width: 150px; }
.seg .sec-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 2px; }
tr.subtotal td { font-weight: 700; background: var(--panel-2); }
tr.is-off td { color: var(--muted-2); }
.target { white-space: nowrap; }
.target.met { color: var(--green); font-weight: 700; }
.target.short { color: var(--amber); font-weight: 700; }
.group-desc { color: var(--muted); font-size: 13px; margin-top: 4px; }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.groups-admin input, .groups-admin select { min-height: 32px; padding: 4px 8px; }
.groups-admin td { vertical-align: middle; }
.groups-admin .num input { width: 70px; text-align: right; }
@media (max-width: 720px) {
  .filters .f-label { min-width: 0; width: 100%; }
  .filters select { width: 100%; }
}

/* ---------- security panels ---------- */
.qr { display: block; margin: 10px 0; border-radius: 8px; background: #fff; padding: 6px; }
code.key, pre.codes { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
code.key { background: var(--panel-3); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
pre.codes { background: var(--panel-3); padding: 12px 14px; border-radius: 8px; font-size: 15px; line-height: 1.7; columns: 2; margin: 10px 0; }
ol.steps { padding-left: 20px; margin: 0 0 6px; }
ul.checklist { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
tr.risky td { background: var(--amber-soft); }
.nav-badge.blue { background: var(--jfi-blue); }
.seg a.segbtn { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 6px 12px; font-weight: 600; font-size: 13px; color: var(--muted); text-decoration: none; min-height: 34px; display: inline-flex; align-items: center; }
.seg a.segbtn[aria-pressed="true"] { background: var(--btn-bg); color: var(--btn-ink); border-color: var(--btn-bg); }
/* Long post text in tables: wrap, show 3 lines, "Show more" for the rest. */
td.post-cell { white-space: normal; min-width: 260px; max-width: 560px; line-height: 1.45; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; white-space: pre-line; }
.clamp.open { display: block; -webkit-line-clamp: unset; line-clamp: unset; }
.link-btn { border: 0; background: none; padding: 2px 0; color: var(--jfi-blue-ink); font-weight: 600; font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
/* Results table on a post/ad page: hug the numbers instead of spreading across the page. */
.table-wrap table.compact { width: auto; min-width: min(100%, 420px); }
table.compact td:first-child, table.compact th:first-child { padding-right: 48px; }
table.compact th.rec-col, table.compact td.num { min-width: 110px; }
/* Paid ads | Organic posts switch on dashboards */
.kind-switch { margin: 4px 0 10px; }
.kind-switch button { font-size: 14px; padding: 8px 16px; }
.timeline.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 720px) { .timeline.three { grid-template-columns: 1fr; } }
.table-wrap:has(> table.compact) { display: inline-block; max-width: 100%; }
