/* Review Insights - static dashboard styles.
 *
 * Mesura brand shell for the per-run dashboards served on reports.mesura.consulting.
 * The goal is visual continuity with mesura.consulting/herramientas: a visitor who
 * clicks a case should not feel they left the site. Tokens are copied verbatim from
 * mesura-website/src/app/tokens.css (the live values), and the chrome + primitives
 * mirror the herramientas components (Container, Card, Button, the chrome header/footer,
 * the case-study Beat). No dark mode: the brand is always warm/light, accent terracotta.
 *
 * Fonts: Google Fonts CDN import (Fraunces + Inter), matching tokens.css. The branding
 * repo has no self-hosted fonts/ folder in this checkout, so the CDN import is the source.
 */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;1,9..144,400;1,9..144,600&family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  /* Primitives: warm paper (trust base) */
  --paper-50: hsl(60 17% 98%);
  --paper-100: hsl(45 30% 96%);
  --paper-200: hsl(35 32% 93%);
  --paper-300: hsl(35 26% 87%);

  /* Primitives: warm ink (text) */
  --ink-900: hsl(20 23% 8%);
  --ink-700: hsl(22 14% 27%);
  --ink-500: hsl(24 9% 42%);

  /* Primitives: terracotta / arcilla (brand accent). Two-ended scale: the light end
     (100/400) is the visible brand colour; the dark end (500/600/700) carries WCAG AA
     as fill behind near-white text (500) and as text on light (700). */
  --bronze-100: hsl(19 55% 92%);
  --bronze-400: hsl(15 63% 60%); /* = #D97757, the board terracotta */
  --bronze-500: hsl(15 58% 45%);
  --bronze-600: hsl(14 58% 40%);
  --bronze-700: hsl(13 55% 35%);

  /* Primitives: graphite (cool structural neutral) */
  --graphite-300: hsl(220 14% 82%);
  --graphite-500: hsl(220 7% 48%);
  --graphite-700: hsl(220 9% 30%);
  --graphite-900: hsl(220 12% 16%);

  /* Primitives: functional accents (NOT brand) - used for chart sentiment/urgency only */
  --green-100: hsl(150 42% 91%);
  --green-500: hsl(152 47% 40%);
  --blue-100: hsl(208 70% 93%);
  --blue-500: hsl(212 68% 49%);

  /* Semantic: surfaces & text */
  --bg: var(--paper-50);
  --surface: var(--paper-100);
  --surface-2: var(--paper-200);
  --border: var(--paper-300);
  --ink: var(--ink-900);
  --ink-soft: var(--ink-700);
  --ink-muted: var(--ink-500);
  --ink-tech: var(--graphite-900);

  /* Semantic: brand accents */
  --primary: var(--bronze-500);
  --primary-hover: var(--bronze-600);
  --primary-tint: var(--bronze-100);
  --primary-text: var(--bronze-700); /* bronze TEXT on light (AA-safe) */
  --on-primary: var(--paper-50);
  --accent-graphite: var(--graphite-700);

  /* Typography: Fraunces (display, italic keyword = the signature) + Inter (body) */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;

  /* Radii */
  --r-sm: 0.375rem;
  --r-md: 0.625rem;
  --r-lg: 1rem;
  --r-xl: 1.5rem;
}

/* ================================================================
   Base
   ================================================================ */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--primary); color: var(--on-primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
img, svg { max-width: 100%; }

/* ================================================================
   Layout primitives (mirror components/ui/container.tsx)
   ================================================================ */
.container {
  margin-inline: auto;
  width: 100%;
  max-width: 72rem; /* max-w-6xl */
  padding-inline: 1.5rem; /* px-6 */
}
@media (min-width: 768px) {
  .container { padding-inline: 2rem; } /* md:px-8 */
}
main { flex: 1 1 auto; }

/* ================================================================
   Chrome: header + footer (mirror herramientas-chrome.tsx)
   ================================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
}
@media (prefers-reduced-transparency: reduce) {
  .site-header { background: color-mix(in srgb, var(--bg) 95%, transparent); backdrop-filter: none; }
}
.site-header > .container {
  display: flex;
  height: 4rem; /* h-16 */
  align-items: center;
  justify-content: space-between;
}
/* Brand lockup: mirrors mesura-website BrandWordmark (isotipo + MESURA + Consulting tail).
   One font-size scales the whole mark; every part is em-relative to it, same proportions as
   the site (lettermark 0.64em, tail 0.538em/0.18em tracking, isotipo spans the two-line stack). */
.brand-lockup {
  display: inline-flex;
  align-items: center;
  gap: 0.65em;
  font-size: 1.35rem;
  line-height: 1;
  text-decoration: none;
}
.brand-isotipo {
  height: calc(0.64em + 0.15em + 0.538em);
  width: auto;
  flex-shrink: 0;
  display: block;
}
.brand-words {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15em;
}
.brand-lettermark {
  height: 0.64em;
  width: auto;
  display: block;
  color: var(--ink);
}
.brand-tail {
  font-family: var(--font-display);
  font-size: 0.538em;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--primary-text);
}
/* Hidden below sm, mirroring the site's `hidden sm:inline-flex`. Scoped under
   .site-header so it outranks the single-class `.btn { display: inline-flex }`
   defined later in the file (equal specificity would let .btn win the cascade). */
.site-header .header-cta { display: none; }
@media (min-width: 640px) { .site-header .header-cta { display: inline-flex; } }

.site-footer {
  margin-top: auto;
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  padding-block: 2.5rem; /* py-10 */
}
.site-footer > .container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5rem;
}
@media (min-width: 640px) {
  .site-footer > .container { flex-direction: row; align-items: center; justify-content: space-between; }
}
.footer-link { font-size: 0.875rem; color: var(--ink-soft); transition: color 0.15s ease; }
.footer-link:hover { color: var(--ink); }
.footer-brand { font-size: 0.75rem; color: var(--ink-soft); }

/* ================================================================
   Button (mirror components/ui/button.tsx, flat treatment)
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border: 1px solid transparent;
  border-radius: var(--r-lg);
  padding: 0.625rem 1.25rem; /* py-2.5 px-5 */
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border-color: var(--border); background: var(--surface); color: var(--ink); }
.btn-outline:hover { background: var(--surface-2); }

/* ================================================================
   Card (mirror components/ui/card.tsx)
   ================================================================ */
.card {
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--surface);
  padding: 1.5rem;
}
.card-interactive { transition: background-color 0.15s ease; }
.card-interactive:hover { background: var(--surface-2); }

/* ================================================================
   Typography primitives
   ================================================================ */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; color: var(--ink); letter-spacing: -0.01em; line-height: 1.15; }

.eyebrow {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-muted);
}
.section-eyebrow {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--primary-text);
  margin-bottom: 0.45rem;
}
.section-title {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.section-subtitle {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-style: italic;
  font-weight: 400;
  color: var(--ink-muted);
  margin-top: 0.3rem;
}

/* Metric: typographic stack (Fraunces value + uppercase label) */
.metric { padding: 0.2rem 0 1.1rem; border-bottom: 1px solid var(--border); }
.metric-value {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1;
  letter-spacing: -0.03em;
  font-feature-settings: "tnum" 1, "lnum" 1;
}
.metric-unit { font-size: 1.3rem; font-weight: 400; color: var(--ink-muted); margin-left: 0.15rem; letter-spacing: 0; }
.metric-label {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-muted);
  margin-top: 0.8rem;
}

/* Beat: labelled prose block (mirror case-study.tsx Beat) */
.beat {
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  padding-block: 2.5rem;
}
.beat:first-child { border-top: 0; }
@media (min-width: 768px) {
  .beat { display: grid; grid-template-columns: 12rem 1fr; gap: 2.5rem; }
}
.beat-label {
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--primary-text);
}
.beat-body { margin-top: 0.75rem; font-size: 1.05rem; line-height: 1.7; color: var(--ink-muted); }
@media (min-width: 768px) { .beat-body { margin-top: 0; } }

/* ================================================================
   Utilities
   ================================================================ */
.divider { border: 0; border-top: 1px solid var(--border); margin-block: 2rem; }
.grid-4 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
@media (min-width: 768px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media (min-width: 768px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }

/* ================================================================
   Dashboard: controls, tabs, panels
   ================================================================ */
.dash { padding-block: 3rem 5rem; }
.dash-head { display: flex; flex-direction: column; gap: 1.25rem; }
@media (min-width: 768px) { .dash-head { flex-direction: row; align-items: flex-end; justify-content: space-between; } }
.dash-controls { display: flex; flex-direction: column; gap: 0.4rem; }
.ctrl-label { font-size: 0.65rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.18em; color: var(--ink-muted); }
select#biz-select {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  min-width: 15rem;
}
.dash-meta { font-size: 0.8rem; color: var(--ink-muted); margin-top: 0.3rem; }
.dash-meta strong { color: var(--ink-soft); font-weight: 600; }

.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin: 2rem 0 1.5rem; }
.tab {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-muted);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 0.85rem 1.2rem;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.panel[hidden] { display: none; }
/* Full-width stacked charts (issues + benchmark panels). */
.chart-stack > * + * { margin-top: 1.5rem; }

/* Chart frame: static hairline card. Charts are not clickable; data reads through
   the Plotly hover tooltip. */
.chart-frame {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 1rem 1rem 0.5rem;
}
.chart-title { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.18em; color: var(--ink-muted); padding-bottom: 0.5rem; }
.chart { width: 100%; min-height: 260px; }

/* Action plan cards */
.action-card { border-top: 1px solid var(--border); padding: 1.6rem 0 1.4rem; }
.action-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.action-topic { font-size: 0.66rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.18em; color: var(--primary-text); margin-bottom: 0.4rem; }
.action-title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 500; color: var(--ink); line-height: 1.2; }
.action-rank { font-family: var(--font-display); font-style: italic; color: var(--ink-muted); margin-right: 0.45rem; }
.action-priority { text-align: right; flex-shrink: 0; }
.action-priority-value { font-family: var(--font-display); font-size: 2.2rem; font-weight: 400; color: var(--primary-text); line-height: 1; }
.action-priority-label { font-size: 0.58rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.2em; color: var(--ink-muted); margin-top: 0.4rem; }
.action-desc { margin-top: 0.8rem; color: var(--ink-soft); line-height: 1.6; }
.action-rec { border-left: 2px solid var(--primary); padding-left: 0.9rem; margin-top: 0.8rem; color: var(--ink); line-height: 1.55; }

/* Tables (negative quotes + data explorer) */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); }
/* Data explorer: cap height and scroll INSIDE the box (the sticky header stays put)
   so the page itself does not grow with hundreds of rows. */
.data-scroll { max-height: 60vh; overflow-y: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
table.data thead th {
  background: var(--surface-2);
  color: var(--ink-soft);
  text-align: left;
  font-weight: 600;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0.7rem 0.8rem;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
table.data tbody td { padding: 0.6rem 0.8rem; border-top: 1px solid var(--border); vertical-align: top; color: var(--ink-soft); }
table.data tbody tr:hover { background: var(--surface); }
/* Sortable headers (data explorer only). */
.panel[data-panel="data"] table.data thead th { cursor: pointer; user-select: none; }
table.data thead th[data-sort="asc"]::after { content: " \25B2"; font-size: 0.7em; }
table.data thead th[data-sort="desc"]::after { content: " \25BC"; font-size: 0.7em; }

/* Data tab header: eyebrow left, download button top-right. */
.data-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }

/* Filters: groups side by side, each group's options stacked one per line. */
.filters { display: flex; flex-wrap: wrap; gap: 1.5rem 3rem; margin-bottom: 1.25rem; }
.filter-group { display: flex; flex-direction: column; gap: 0.5rem; }
.filter-group > div { display: flex; flex-direction: column; gap: 0.4rem; }
.chk { display: flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--ink-soft); cursor: pointer; }
.chk input { accent-color: var(--primary); }
.caption { font-size: 0.78rem; color: var(--ink-muted); margin-top: 0.8rem; }
