/* Pet Intelligence v2 — CIS-branded dashboard styles.
   Navy #303841 · Orange #FF5722 · Cream #FAF7F2 · Instrument Serif + Manrope */

:root {
  --navy: #303841;
  --navy-soft: #4a5461;
  --orange: #FF5722;
  --orange-soft: #FF7A4F;
  --cream: #FAF7F2;
  --card: #ffffff;
  --ink: #303841;
  --muted: #6b7480;
  --line: #e8e2d8;
  --ok: #5E7A4A;
  --warn: #C89B3C;
  --bad: #B3402A;
  --teal: #2C7B7D;
  --shadow: 0 1px 3px rgba(48, 56, 65, 0.08), 0 1px 2px rgba(48, 56, 65, 0.05);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--cream);
  color: var(--ink);
  font-family: "Manrope", -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--navy); text-decoration: none; border-bottom: 1px solid rgba(48,56,65,.25); }
a:hover { color: var(--orange); border-bottom-color: var(--orange); }

.boot {
  padding: 80px 40px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

/* ── sidebar ─────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 26px 0 18px;
  z-index: 10;
}
.logo { padding: 0 22px 22px; border-bottom: 1px solid rgba(255,255,255,.12); }
.logo-name {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 25px;
  letter-spacing: .2px;
}
.logo-sub {
  margin-top: 3px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--orange-soft);
  font-weight: 600;
}
.sidebar nav { flex: 1; padding: 14px 0; overflow-y: auto; }
.nav-link {
  display: block;
  padding: 9px 22px;
  color: rgba(255,255,255,.72);
  font-weight: 600;
  font-size: 13.5px;
  border-bottom: none;
  border-left: 3px solid transparent;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,.05); border-bottom: none; }
.nav-link.active {
  color: #fff;
  border-left-color: var(--orange);
  background: rgba(255, 87, 34, .12);
}
.side-foot { padding: 14px 22px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 12px; }
.side-foot .dl {
  display: inline-block;
  color: #fff;
  background: var(--orange);
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 12.5px;
}
.side-foot .dl:hover { background: var(--orange-soft); color: #fff; }
.side-foot .gen { margin-top: 10px; color: rgba(255,255,255,.5); }

/* ── main ─────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  padding: 30px 36px 60px;
  max-width: 1460px;
}
.page-title {
  font-family: "Instrument Serif", Georgia, serif;
  font-weight: 400;
  font-size: 34px;
  margin: 0 0 20px;
  color: var(--navy);
}
h2 {
  font-family: "Manrope", sans-serif;
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 12px;
  color: var(--navy);
}
.h-sub { font-weight: 500; font-size: 12px; color: var(--muted); margin-left: 8px; }

.card {
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 20px;
}

/* ── KPI cards ─────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi { padding: 16px 18px 14px; margin-bottom: 0; }
.kpi-value {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 34px;
  line-height: 1.1;
  color: var(--navy);
}
.kpi-label {
  margin-top: 4px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.kpi-sub { margin-top: 2px; font-size: 11px; color: var(--muted); }

/* ── tables ─────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
.tbl-wrap.tall { max-height: 560px; overflow-y: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  position: sticky;
  top: 0;
  background: var(--card);
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  font-weight: 700;
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  white-space: nowrap;
  z-index: 1;
}
.tbl td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  white-space: nowrap;
}
.tbl td.wrap { white-space: normal; min-width: 220px; }
.tbl tbody tr:hover td { background: rgba(255, 87, 34, .04); }
.tbl .num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--orange); }
.arrow { color: var(--orange); margin-left: 3px; font-size: 9px; }
.brand-cell { font-weight: 700; color: var(--navy); }
.strong { font-weight: 800; }
.dim { color: #b3aca0; }
.err { white-space: normal; max-width: 340px; color: var(--bad); }
.mono { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.matrix td, .matrix th { padding: 6px 8px; }
.promo-text { color: var(--orange); font-weight: 600; }

.empty {
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}
.footnote { font-size: 12px; color: var(--muted); margin: 12px 2px 0; }
.formula { line-height: 1.7; }
.formula em { color: var(--navy); font-style: normal; font-weight: 700; }

/* ── badges / chips / tones ─────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
.tone-ok     { background: rgba(94,122,74,.14);  color: var(--ok); }
.tone-warn   { background: rgba(200,155,60,.16); color: #8a6a20; }
.tone-bad    { background: rgba(179,64,42,.13);  color: var(--bad); }
.tone-accent { background: rgba(255,87,34,.13);  color: var(--orange); }
.tone-teal   { background: rgba(44,123,125,.14); color: var(--teal); }
.tone-muted  { background: rgba(74,84,97,.12);   color: var(--muted); }
.tone-fuzzy  { background: var(--warn); color: #fff; }
.tone-bg-ok   { background: var(--ok); }
.tone-bg-warn { background: var(--warn); }
.tone-bg-bad  { background: var(--bad); }
.tone-bg-muted{ background: var(--muted); }

.chip-static {
  display: inline-block;
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11.5px;
  margin: 1px 4px 1px 0;
  color: var(--navy-soft);
  white-space: nowrap;
}

/* interactive filter chips */
.filter-row { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.chip {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 10px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy-soft);
  cursor: pointer;
}
.chip:hover { border-color: var(--orange); color: var(--orange); }
.chip.on { background: var(--orange); border-color: var(--orange); color: #fff; }
.chip.zero:not(.on) { opacity: .45; }
.chip-n { margin-left: 5px; font-weight: 500; opacity: .75; font-size: 11px; }

.select, .search {
  font: inherit;
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card);
  color: var(--ink);
}
.search { width: 260px; max-width: 100%; margin-bottom: 12px; }
.search:focus, .select:focus { outline: 2px solid rgba(255,87,34,.35); border-color: var(--orange); }

.index-pill {
  display: inline-block;
  min-width: 38px;
  text-align: center;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--cream);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.index-pill.hot { background: var(--orange); color: #fff; }

.move { font-weight: 800; margin-left: 6px; }
.move.up { color: var(--bad); }
.move.down { color: var(--ok); }

/* ── overview run strip ─────────────────── */
.run-strip { display: flex; flex-wrap: wrap; gap: 6px; }
.run-box {
  width: 44px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: default;
}
.run-id { font-size: 11px; font-weight: 800; }
.legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ── changes feed ───────────────────────── */
.run-group { margin-top: 16px; }
.run-head {
  font-weight: 800;
  color: var(--navy);
  padding: 6px 2px;
  border-bottom: 2px solid var(--navy);
  margin-bottom: 2px;
  font-size: 13.5px;
}
.type-cell { width: 120px; }
.ret-cell { width: 130px; color: var(--navy-soft); }
.detail-cell { font-variant-numeric: tabular-nums; }

/* ── sparkline ──────────────────────────── */
.spark { display: block; }

/* ── scorecard ──────────────────────────── */
.score-toolbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 10px; align-items: flex-start; }
.brand-picker { position: relative; }
.brand-picker .search { margin-bottom: 0; width: 280px; }
.picker-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(48,56,65,.16);
  z-index: 30;
  max-height: 380px;
  overflow-y: auto;
}
.picker-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--ink);
}
.picker-item:hover { background: rgba(255,87,34,.08); }
.picker-item.current { color: var(--orange); }
.btn {
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 7px;
  border: none;
  background: var(--orange);
  color: #fff;
  cursor: pointer;
}
.btn:hover { background: var(--orange-soft); }

.score-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.score-brand {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 30px;
  color: var(--navy);
}
.score-ring {
  min-width: 108px;
  text-align: center;
  background: var(--navy);
  color: #fff;
  border-radius: 12px;
  padding: 12px 18px;
}
.score-num {
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 40px;
  line-height: 1;
  color: var(--orange-soft);
}
.score-cap { font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px; margin-top: 4px; color: rgba(255,255,255,.7); }

.score-comps { display: flex; flex-wrap: wrap; gap: 8px 40px; }
.comp { display: flex; gap: 10px; align-items: baseline; }
.comp-label { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; color: var(--navy-soft); }
.comp-val { font-weight: 700; font-variant-numeric: tabular-nums; }

.ret-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.ret-card { margin-bottom: 0; padding: 14px 16px; }
.ret-name {
  font-weight: 800;
  color: var(--navy);
  border-bottom: 2px solid var(--orange);
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.ret-stats div { display: flex; justify-content: space-between; padding: 3px 0; font-size: 12.5px; }
.rs-label { color: var(--muted); }
.rs-val { font-weight: 700; font-variant-numeric: tabular-nums; }

.fuzzy-block { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.fuzzy-row {
  border: 1px dashed var(--warn);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(200,155,60,.05);
}
.fuzzy-row .mono { margin-left: 8px; }
.fuzzy-members { margin-top: 6px; display: flex; flex-direction: column; gap: 3px; }
.fuzzy-member { font-size: 12.5px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

/* ── topbar: channel toggle + own-label (§11.B) ── */
.topbar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.seg-label {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.seg button {
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 14px;
  border: none;
  background: none;
  color: var(--navy-soft);
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: none; }
.seg button:hover { color: var(--orange); }
.seg button.on { background: var(--navy); color: #fff; }
.ck {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--navy-soft);
  cursor: pointer;
  user-select: none;
}
.ck input { accent-color: var(--orange); }

/* own-label badge (§11.B) */
.badge.own { background: var(--navy); color: #fff; margin-left: 6px; vertical-align: 1px; }

/* brand links (drill into scorecard) */
.brand-link { font-weight: 700; color: var(--navy); border-bottom: 1px dashed rgba(48,56,65,.35); }
.brand-link:hover { color: var(--orange); border-bottom-color: var(--orange); }

/* display pagination */
.pager { display: flex; align-items: center; gap: 12px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.btn-sm {
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--navy-soft);
  cursor: pointer;
}
.btn-sm:hover:not(:disabled) { border-color: var(--orange); color: var(--orange); }
.btn-sm:disabled { opacity: .4; cursor: default; }

/* overview weekly changes strip */
.week-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 2px;
  border-bottom: 1px solid var(--line);
}
.week-row:last-child { border-bottom: none; }
.week-tag {
  font-weight: 800;
  font-size: 12px;
  color: var(--navy);
  min-width: 76px;
  font-variant-numeric: tabular-nums;
}

/* ── responsive ─────────────────────────── */
@media (max-width: 940px) {
  .sidebar { position: static; width: auto; padding: 16px 0 0; }
  .sidebar nav { display: flex; flex-wrap: wrap; padding: 8px 12px; }
  .nav-link { border-left: none; border-bottom: 3px solid transparent; padding: 8px 12px; }
  .nav-link.active { border-left: none; border-bottom-color: var(--orange); }
  .side-foot { padding-bottom: 14px; }
  .main { margin-left: 0; padding: 20px 16px 50px; }
}

/* ── print (scorecard PDF export) ───────── */
@media print {
  .sidebar, .no-print { display: none !important; }
  body { background: #fff; }
  .main { margin-left: 0; padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .tbl-wrap.tall { max-height: none; overflow: visible; }
  .scorecard-view::before {
    content: "Brand Consistency Scorecard — Commercial Impact Solutions";
    display: block;
    font-family: "Instrument Serif", Georgia, serif;
    font-size: 22px;
    margin-bottom: 14px;
    color: #303841;
  }
  a { border-bottom: none; color: inherit; }
}
