/* =========================================================================
   Scorecard tab (assets/js/view-insights.js) and CV mode Territory tab (assets/js/territory.js)
   Uses the reference-board palette from vivid.css and the soft card style from soft.css.
   ========================================================================= */
.tab[data-view="scorecard"] { --lq: var(--v-peri); }
/* narrow screens: only the selected tab keeps its label (the rest show an icon + hover title) */
@media (max-width: 1360px) { .tabs .tab:not([aria-selected="true"]) > span { display: none; } .tabs .tab { padding: 0 11px; } }

.view-insight { max-width: none; padding: 10px clamp(12px, 1.1vw, 24px) 20px; }
.view-insight h2 { font-size: 15px; margin: 0; }

/* status colours shared by the scorecard */
.st-ok { --st: var(--v-blue); --st-ink: #fff; }
.st-off { --st: var(--v-sun); --st-ink: #3d2b00; }
.st-short { --st: var(--v-orange); --st-ink: #fff; }
.st-low { --st: var(--mv-low); --st-ink: #fff; }
.st-crit { --st: var(--mv-crit); --st-ink: #fff; }
.st-none { --st: var(--s-card-2); --st-ink: var(--muted); }

/* ---------------------------------------------------------------- Scorecard */
.sc-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; }
.sc-key { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px 0 8px; border-radius: 999px; background: var(--s-inner);
  font-size: 12px; color: var(--text-2); }
.sc-key i { width: 10px; height: 10px; border-radius: 3px; background: var(--st); }
.sc-key.st-none i { box-shadow: inset 0 0 0 1px var(--s-line); }
.sc-key b { font-family: var(--mono, inherit); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }

.sc-grid { display: grid; gap: 3px; align-items: center; overflow-x: auto; padding-bottom: 4px; }
.sc-h { font-size: 11px; color: var(--muted); text-align: center; padding-bottom: 2px; }
.sc-h:first-child { text-align: left; }
.sc-h.r, .sc-num { text-align: right; }
.sc-d.fri { color: var(--v-orange-ink); }
.sc-name { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; padding-right: 8px; }
.sc-name b { font-weight: 600; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-name span { font-size: 10.5px; color: var(--muted); }
.sc-cell { display: block; height: 22px; min-width: 12px; border: 0; padding: 0; border-radius: 4px; background: var(--st); cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease; }
span.sc-cell { cursor: default; }
button.sc-cell:hover { transform: scale(1.18); box-shadow: 0 0 0 2px var(--s-inner), 0 0 0 3.5px var(--st); position: relative; z-index: 1; }
.sc-num { font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.sc-pct { display: inline-block; min-width: 46px; padding: 2px 8px; border-radius: 999px; font-weight: 600; color: var(--text); font-size: 12px; text-align: center;
  background: linear-gradient(90deg, color-mix(in srgb, var(--v-blue) 22%, transparent) var(--p), var(--s-inner) var(--p)); }
.sc-score { display: flex; align-items: center; gap: 12px; margin: 0 0 10px; font-size: 12.5px; color: var(--text-2); line-height: 1.3; }
.sc-score small { color: var(--muted); }
.sc-pct.big { font-size: 20px; padding: 6px 14px; min-width: 76px; }

.sc-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; max-width: 1100px; }
.sc-cal .sc-h { text-align: left; padding-left: 4px; }
.sc-day { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; min-height: 66px; padding: 7px 9px; border: 0; border-radius: 10px;
  background: var(--st); color: var(--st-ink); text-align: left; font: inherit; cursor: pointer; transition: transform .15s ease, filter .15s ease; }
.sc-day b { font-size: 15px; font-weight: 600; line-height: 1; }
.sc-day small { font-size: 11.5px; opacity: .9; font-variant-numeric: tabular-nums; }
.sc-day i { font-style: normal; font-size: 10.5px; opacity: .85; margin-top: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
button.sc-day:hover { transform: translateY(-1px); filter: brightness(1.06) saturate(1.05); }
span.sc-day { cursor: default; background: var(--s-inner); color: var(--muted); }
.sc-day.out { background: transparent; }

/* ---------------------------------------------------------------- shared bits used by the Territory tab */
.pl-sub { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; }
.al-when { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); line-height: 1.25; }
.al-when b { font-size: 12.5px; font-weight: 600; color: var(--text); }
.al-go { font-size: 11.5px; color: var(--v-blue); opacity: 0; transition: opacity .15s ease; white-space: nowrap; }

/* =========================================================================
   CV mode: General / CV switch and the Territory tab (assets/js/territory.js)
   ========================================================================= */
.tab[data-view="territory"] { --lq: var(--v-orange); }
.tab.tab-terr[hidden] { display: none !important; }
.team-ctl { gap: 6px; }
.team-ctl #teamSeg button[data-team="cv"] { font-weight: 700; letter-spacing: .02em; }
.team-ctl .cv-mode { animation: trIn .25s ease; }
.team-ctl .cv-mode[hidden] { display: none !important; }
body.cv-on #teamSeg button[data-team="cv"][aria-pressed="true"] { background: var(--v-orange) !important; color: #fff !important; }
@keyframes trIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

.tr-layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); gap: 10px; align-items: start; }
.tr-layout > #terrBody { display: contents; }
#terrBody > .card { grid-column: 1; min-width: 0; }
#terrBody > .tr-hero, .tr-layout.solo #terrBody > .card { grid-column: 1 / -1; }
.tr-map-card { grid-column: 2; grid-row: 2 / span 2; position: sticky; top: calc(var(--topbar-h) + var(--filterbar-h, 61px) + 10px);
  height: calc(100vh - var(--topbar-h) - var(--filterbar-h, 61px) - 24px); min-height: 420px; display: flex; flex-direction: column; }
.tr-map-card[hidden] { display: none; }
.tr-map { flex: 1; min-height: 0; border-radius: 10px; overflow: hidden; }
.tr-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding-top: 8px; font-size: 11.5px; color: var(--text-2); }
.tr-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tr-legend i { width: 14px; height: 10px; border-radius: 3px; }
.tr-legend i.dash { background: transparent; border: 1.5px dashed; }
.tr-tt { font-size: 12px; }

/* hero: name, coverage ring, three facts */
.tr-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 18px; padding-top: 12px; padding-bottom: 12px; }
.tr-cap { font-size: 11.5px; color: var(--muted); }
.tr-name { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; margin: 2px 0 2px !important; font-size: 24px !important; font-weight: 600; letter-spacing: -.01em; }
.tr-group { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: color-mix(in srgb, var(--v-orange) 16%, var(--s-inner)); color: var(--v-orange-ink); }
.tr-change { display: inline-flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--text-2); }
.tr-pick { height: 28px; padding: 0 28px 0 12px; border: 1px solid var(--s-line); background-color: var(--s-inner); color: var(--text); font: inherit; font-size: 12px; max-width: 260px; }
.tr-ring-wrap { position: relative; display: flex; align-items: center; gap: 10px; }
.tr-ring { width: 76px; height: 76px; transform: rotate(-90deg); }
.tr-ring circle { fill: none; stroke-width: 8; }
.tr-ring .bg { stroke: var(--s-inner); }
.tr-ring .fg { stroke: var(--v-blue); stroke-linecap: round; animation: trRing 1s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes trRing { from { stroke-dasharray: 0 var(--c); } }
.tr-ring-num { position: absolute; left: 0; top: 0; width: 76px; height: 76px; display: flex; align-items: baseline; justify-content: center; padding-top: 25px; gap: 2px; }
.tr-ring-num b { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tr-ring-num span { font-size: 11px; color: var(--muted); }
.tr-ring-cap { font-size: 12px; color: var(--text-2); line-height: 1.25; }
.tr-facts { display: flex; gap: 8px; }
.tr-fact { display: flex; flex-direction: column; min-width: 112px; padding: 9px 13px; border-radius: 10px; background: var(--s-inner); line-height: 1.2; }
.tr-fact b { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tr-fact span { font-size: 12px; color: var(--text-2); }
.tr-fact small { font-size: 11px; color: var(--muted); margin-top: 3px; }
.tr-fact.warn b { color: var(--v-orange-ink); }
.tr-fact.bad b { color: var(--mv-crit); }

/* checklist */
.tr-key { display: flex; gap: 10px; font-size: 11.5px; color: var(--text-2); flex: none; }
.tr-key span { display: inline-flex; align-items: center; gap: 5px; }
.tr-key i { width: 9px; height: 9px; border-radius: 50%; background: var(--sc); }
.st-visited { --sc: var(--v-blue); } .st-passed { --sc: var(--v-sun); } .st-none { --sc: var(--v-orange); }
.tr-rows { display: flex; flex-direction: column; gap: 4px; }
.tr-row { display: grid; grid-template-columns: 26px minmax(0, 1.25fr) minmax(70px, 1fr) 46px 92px; align-items: center; gap: 12px; padding: 7px 12px 7px 8px;
  border: 0; border-radius: 10px; background: var(--s-inner); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: background .15s ease, box-shadow .2s ease; }
.tr-row:hover { background: color-mix(in srgb, var(--sc) 7%, var(--s-inner)); }
.tr-row.flash { animation: trFlash 1.2s ease; }
@keyframes trFlash { 0%, 40% { box-shadow: 0 0 0 2px var(--sc); } 100% { box-shadow: 0 0 0 2px transparent; } }
.tr-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--sc) 14%, transparent); color: var(--sc); }
.tr-row.st-visited .tr-ico { background: var(--sc); color: #fff; }
.tr-row.st-passed .tr-ico { color: var(--v-sun-ink); }
.tr-ico svg { width: 15px; height: 15px; }
.tr-up { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.tr-up b { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-up small { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-row.st-none .tr-up b { color: var(--v-orange-ink); }
.tr-strip { display: grid; gap: 1.5px; height: 16px; }
.tr-strip i { border-radius: 2px; background: var(--s-card); }
.tr-strip i.a { background: var(--s-card-2); }
.tr-strip i.p { background: var(--v-sun); }
.tr-strip i.v { background: var(--v-blue); }
.tr-num { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.tr-num b { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tr-num small { font-size: 10.5px; color: var(--muted); }
.tr-tbar { display: block; width: 100%; height: 3px; margin-top: 4px; border-radius: 2px; background: var(--s-card); }
.tr-tbar i { display: block; height: 100%; border-radius: 2px; background: var(--v-blue); }

/* outside the territory */
.tr-out-list { display: flex; flex-direction: column; gap: 4px; }
.tr-out { --t: var(--v-red); display: grid; grid-template-columns: 76px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 8px 12px; border: 0; border-radius: 10px;
  background: var(--s-inner); color: var(--text); font: inherit; text-align: left; cursor: pointer; box-shadow: inset 3px 0 0 var(--v-red); transition: background .15s ease; }
.tr-out:hover { background: color-mix(in srgb, var(--v-red) 6%, var(--s-inner)); }
.tr-out:hover .al-go { opacity: 1; }
.tr-out-what { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.tr-tag { font-size: 11.5px; padding: 2px 9px; border-radius: 999px; background: color-mix(in srgb, var(--v-red) 9%, transparent); color: var(--text-2); }
.tr-tag b { font-weight: 600; color: var(--text); }
.tr-tag em { color: var(--muted); }
.tr-out-tot { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--mv-crit); }

/* team table */
.tr-team tbody tr { cursor: pointer; }
.tr-team tbody tr:hover td { background: color-mix(in srgb, var(--v-blue) 5%, transparent); }
.tr-cov { display: inline-block; vertical-align: middle; width: 120px; height: 6px; border-radius: 999px; background: var(--s-card); overflow: hidden; margin-right: 8px; }
.tr-cov i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--v-orange), var(--v-blue)); }
.tr-cov-n { font-size: 12px; font-variant-numeric: tabular-nums; }
.tr-team td.tr-bad { color: var(--mv-crit); font-weight: 600; }
.tr-team td.tr-warn { color: var(--v-orange-ink); font-weight: 600; }

@media (max-width: 1280px) { .tr-hero { grid-template-columns: minmax(0, 1fr) auto; } .tr-facts { grid-column: 1 / -1; } }
@media (max-width: 1100px) { .tr-layout { grid-template-columns: 1fr; } .tr-map-card { grid-column: 1; grid-row: auto; position: static; height: 420px; } }
@media (prefers-reduced-motion: reduce) { .tr-ring .fg, .team-ctl .cv-mode, .tr-row.flash { animation: none; } }

/* territory hero: written summary + upazilas by name */
.tr-brief { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 7px; padding-top: 12px; border-top: 1px solid var(--s-line); }
.tr-lead { margin: 0 0 3px; font-size: 13.5px; line-height: 1.55; color: var(--text-2); max-width: 1100px; }
.tr-lead b { color: var(--text); font-weight: 600; }
.tr-lead em { font-style: normal; font-weight: 600; padding: 0 6px; border-radius: 6px; white-space: nowrap; }
.tr-lead .c-v { color: var(--v-blue); background: color-mix(in srgb, var(--v-blue) 10%, transparent); }
.tr-lead .c-p { color: var(--v-sun-ink); background: color-mix(in srgb, var(--v-sun) 24%, transparent); }
.tr-lead .c-n { color: var(--v-orange-ink); background: color-mix(in srgb, var(--v-orange) 14%, transparent); }
.tr-lead .c-o { color: var(--mv-crit); background: color-mix(in srgb, var(--v-red) 11%, transparent); }
.tr-lane { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: start; }
.tr-lane.l-v { --lc: var(--v-blue); } .tr-lane.l-p { --lc: var(--v-sun); } .tr-lane.l-n { --lc: var(--v-orange); } .tr-lane.l-o { --lc: var(--v-red); }
.tr-lane-h { display: flex; align-items: center; gap: 7px; height: 24px; font-size: 12px; color: var(--text-2); }
.tr-lane-h i { width: 8px; height: 8px; border-radius: 50%; background: var(--lc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--lc) 18%, transparent); }
.tr-lane-h b { margin-left: auto; margin-right: 6px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.tr-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; min-width: 0; }
.tr-chip { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border: 1px solid transparent; border-radius: 999px; font: inherit; font-size: 12px;
  color: var(--text); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease; }
.tr-chip small { font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; opacity: .85; }
.tr-chip:hover { transform: translateY(-1px); box-shadow: 0 2px 8px -3px color-mix(in srgb, var(--lc) 70%, transparent); }
.tr-chip.vis { background: color-mix(in srgb, var(--v-blue) 12%, var(--s-inner)); }
.tr-chip.vis small { color: var(--v-blue); }
.tr-chip.pas { background: color-mix(in srgb, var(--v-sun) 26%, var(--s-inner)); }
.tr-chip.none { background: var(--s-inner); border: 1px dashed color-mix(in srgb, var(--v-orange) 75%, transparent); color: var(--v-orange-ink); }
.tr-chip.out { background: color-mix(in srgb, var(--v-red) 11%, var(--s-inner)); }
.tr-chip.out small { color: var(--mv-crit); }
.tr-dgrp { font-size: 10.5px; color: var(--muted); margin: 0 2px 0 6px; }
.tr-dgrp:first-child { margin-left: 0; }
.tr-none-txt { font-size: 12px; color: var(--muted); line-height: 24px; }

/* territory hero, compact: identity on the left, one scoreboard panel on the right, summary below */
.tr-hero { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 18px; padding-top: 10px !important; padding-bottom: 10px !important; }
.tr-name { font-size: 22px !important; margin: 1px 0 !important; }
.tr-change { margin-top: 5px; }
.tr-score { display: flex; align-items: stretch; background: var(--s-inner); border-radius: 12px; padding: 4px; }
.tr-seg { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 118px; padding: 6px 14px; position: relative; }
.tr-seg + .tr-seg::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 1px; background: var(--s-line); }
.tr-seg-ring { flex-direction: row; align-items: center; gap: 8px; min-width: 0; padding-left: 8px; }
.tr-seg-ring .tr-ring { width: 52px; height: 52px; }
.tr-seg-ring .tr-ring-num { left: 8px; top: 50%; width: 52px; height: auto; transform: translateY(-50%); padding: 0; align-items: baseline; }
.tr-seg-ring .tr-ring-num b { font-size: 16px; }
.tr-seg-ring .tr-ring-num span { font-size: 9.5px; }
.tr-ring .bg { stroke: var(--s-card); }
.tr-fact { background: none !important; border-radius: 0; line-height: 1.15; }
.tr-fv { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.tr-fv b { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tr-fv span { font-size: 11.5px; color: var(--text-2); }
.tr-fact small { font-size: 10.5px; color: var(--muted); margin: 0; }
.tr-meter { display: block; height: 3px; border-radius: 2px; background: var(--s-card); overflow: hidden; }
.tr-meter i { display: block; height: 100%; border-radius: 2px; background: var(--mc); transform-origin: left; animation: trMeter .9s cubic-bezier(.2, .8, .2, 1) both; }
.m-v { --mc: var(--v-blue); } .m-o { --mc: var(--v-red); } .m-n { --mc: var(--v-orange); }
@keyframes trMeter { from { transform: scaleX(0); } }
.tr-brief { padding-top: 9px; gap: 5px; }
.tr-lead { font-size: 13px; line-height: 1.5; margin-bottom: 1px; }
.tr-lane { grid-template-columns: 132px minmax(0, 1fr); gap: 8px; }
.tr-chip, .tr-lane-h { height: 22px; }
.tr-chip { padding: 0 9px; font-size: 11.5px; }
.tr-none-txt { line-height: 22px; }
@media (max-width: 1280px) { .tr-hero { grid-template-columns: 1fr; } .tr-score { justify-self: start; } }
@media (prefers-reduced-motion: reduce) { .tr-meter i { animation: none; } }
