:root {
  color-scheme: light;
  --bg: #f3f5f1;
  --panel: #ffffff;
  --line: #dce4df;
  --line-soft: #c8d4ce;
  --text: #17383a;
  --muted: #647574;
  --accent: #e97859;
  --accent-soft: #eaf2ed;
  --q1: #eaf2ed;
  --q2: #dcebe2;
  --q3: #f5e9c9;
  --q4: #f4ddd6;
  --pos: #087a55;
  --neg: #ad4d37;
  --radius-lg: 5px;
  --radius-md: 5px;
  --shadow: 0 1px 2px rgba(23, 56, 58, 0.07), 0 6px 16px rgba(23, 56, 58, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image: linear-gradient(rgba(23, 56, 58, .025) 1px, transparent 1px), linear-gradient(90deg, rgba(23, 56, 58, .025) 1px, transparent 1px);
  background-size: 26px 26px;
  color: var(--text);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
  padding-top: var(--topbar-height);
}

h1, h2, h3 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: 0; }

.topbar {
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 6px rgba(23, 56, 58, 0.08);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
}

h1 {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
  min-width: 0;
}

.inline-check {
  flex-direction: row !important;
  align-items: center;
  gap: 6px !important;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 8px 10px;
  font-size: 12px;
}

select,
input,
button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text);
  max-width: 100%;
}

select {
  text-overflow: ellipsis;
}

select:focus,
input:focus,
button:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

button {
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.status {
  margin: 12px 16px;
  color: var(--muted);
  font-size: 12px;
}

.insights {
  margin: 12px 16px;
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(0, 2fr);
  gap: 10px;
}

.insight-card,
.chart-panel {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.insight-card {
  padding: 10px 12px;
}

.insight-card h3 {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
}

.insight-card ol {
  margin: 0;
  padding-left: 18px;
  font-size: 11px;
}

.notes-section {
  margin-top: 8px;
}

.notes-section:first-of-type {
  margin-top: 0;
}

.notes-section h4 {
  margin: 0 0 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

.notes-section ul {
  margin: 0;
  padding-left: 16px;
  font-size: 11px;
  line-height: 1.4;
}

.notes-section ul:empty {
  display: none;
}

.chart-panel {
  margin: 12px 16px;
  padding: 12px;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.chart-head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

#eloChart {
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #fbfcfe;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 6px 2px 0;
  color: var(--muted);
  font-size: 11px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chart-legend-swatch {
  display: inline-block;
  width: 18px;
  height: 3px;
  border-radius: 2px;
}

.chart-legend-swatch.primary { background: #1c5051; }
.chart-legend-swatch.comparison { background: #e97859; }

.hidden { display: none; }

.compare-box {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.compare-box label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.compare-box select {
  width: 100%;
  max-width: 360px;
}

.compare-result {
  margin-top: 12px;
}

.compare-prob {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.compare-name {
  flex: 0 0 auto;
  font-weight: 600;
  white-space: nowrap;
}

.compare-bar {
  flex: 1;
  height: 8px;
  border-radius: 6px;
  background: #e7e9ee;
  overflow: hidden;
}

.compare-bar-fill {
  display: block;
  height: 100%;
  background: var(--accent);
}

.compare-prob-numbers {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  margin-top: 4px;
}

.compare-outcomes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.compare-outcome {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--radius-md);
  font-size: 12px;
}

.table-wrap {
  margin: 12px 16px 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

.table-wrap > table > thead {
  display: table-header-group;
  background: var(--panel);
}
.table-wrap > table > tbody { display: table-row-group; }
.table-wrap > table > thead > tr,
.table-wrap > table > tbody > tr { display: table-row; }

th, td {
  border: 1px solid var(--line);
  padding: 2px 3px;
  font-size: 10px;
  text-align: center;
  white-space: nowrap;
  width: 42px;
  min-width: 42px;
  max-width: 42px;
}

th { font-weight: 700; }

thead th {
  position: static !important;
  top: auto !important;
  z-index: auto;
  background: var(--panel);
}

.table-sticky-head {
  display: block;
  position: fixed;
  z-index: 19;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.12);
  pointer-events: none;
  visibility: hidden;
  contain: layout paint;
}

.table-sticky-head.is-visible { visibility: visible; }
.table-sticky-head table { margin: 0; }

thead tr:nth-child(1) th:not(.name-col):not(.final-col) { height: var(--thead-row1-h); }

th.name-col,
td.name-col {
  background: #eaf2ed;
  text-align: left;
  width: 200px;
  min-width: 200px;
  max-width: 200px;
}

th.final-col,
td.final-col {
  background: #f3f5f1;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
}

th.two-lines {
  width: 78px;
  min-width: 78px;
  max-width: 78px;
  white-space: normal;
  line-height: 1.05;
}

th.name-end-col,
td.name-end-col {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
  text-align: left;
  background: #eaf2ed;
}

td.grupo-B {
    background-color: #c7ded7;
}

td.grupo-A {
    background-color: #f5e9c9;
}

td.grupo-A-B,
td.grupo-B-A {
  background-color: #f4ddd6;
  font-weight: 600;
}

tbody tr { cursor: pointer; }

tbody tr:hover td {
  background: var(--accent-soft);
}

tbody tr:hover td.name-col {
  background: #dcebe2;
}

tbody tr.row-selected td {
  background: #eaf2ed;
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

tbody tr.row-selected td.name-col {
  background: #c8dacf;
}

.quarter-1 { background: var(--q1); }
.quarter-2 { background: var(--q2); }
.quarter-3 { background: var(--q3); }
.quarter-4 { background: var(--q4); }

.event-head { height: 22px; padding: 0 2px; }

.event-ellipsis {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
  font-size: 9px;
  line-height: 1.1;
}

.delta-pos { color: var(--pos); font-weight: 700; }
.delta-neg { color: var(--neg); font-weight: 700; }

.cell-empty {
  background: #fafafa;
  color: #b0b6c0;
}

.two-lines {
  line-height: 1.05;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.chart-toggle {
  margin-left: auto;
  margin-right: 8px;
}

@media (max-width: 640px) {
  .topbar { padding: 10px 12px; }
  h1 { font-size: 15px; }

  .controls label,
  .controls .inline-check {
    flex: 1 1 100%;
  }

  select, input, button {
    padding: 9px 10px;
    font-size: 13px;
  }

  .insights, .chart-panel, .table-wrap {
    margin-left: 10px;
    margin-right: 10px;
  }

  .insights {
    grid-template-columns: 1fr;
  }

  .compare-box select {
    max-width: none;
  }

  .compare-outcomes {
    gap: 6px;
  }
}

.detail-panel { margin: 12px 16px; padding: 12px; border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.detail-panel h2 { margin: 0 0 10px; font-size: 13px; }
.detail-controls { display: flex; flex-wrap: wrap; gap: 10px; }
.detail-controls label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 11px; }
.detail-controls select { min-width: 260px; }
.detail-summary { margin: 10px 0; font-size: 12px; color: var(--muted); }
.detail-table-wrap { overflow-x: auto; }
.detail-table-wrap table { width: 100%; border-collapse: collapse; font-size: 12px; }
.detail-table-wrap th, .detail-table-wrap td { padding: 7px 8px; text-align: left; border-top: 1px solid var(--line); }
.positive { color: var(--pos); font-weight: 600; }.negative { color: var(--neg); font-weight: 600; }

/* A tabela de auditoria não usa o cabeçalho fixo da tabela principal. */
.detail-table-wrap thead th { position: static; top: auto; z-index: auto; background: #eaf2ed; }
.detail-table-wrap table { min-width: 680px; width: 100%; }
.detail-table-wrap th, .detail-table-wrap td { width: auto; min-width: 0; max-width: none; font-size: 13px; }
.detail-table-wrap th { color: #17383a; }
.detail-own-row td { background: #dcebe2; color: #12383c; font-weight: 600; }
.detail-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 12px; border: 1px solid #dce4df; border-radius: 5px; background: #eaf2ed; color: #536b66; font-size: 13px; line-height: 1.4; }
.detail-summary strong { color: var(--text); }
.detail-summary span + span { border-left: 1px solid #dce4df; padding-left: 16px; }

/* Organização do painel: visão geral, confrontos e tabela completa. */
.brand-row { display:flex; align-items:center; justify-content:space-between; gap:16px; }
.brand-identity { display:flex; align-items:center; gap:12px; min-width:0; text-decoration:none; }
.brand-logo { display:block; width:40px; height:44px; object-fit:contain; flex:0 0 auto; }
.brand-copy { min-width:0; }
.eyebrow { display:block; margin-bottom:2px; color:rgb(192, 213, 203); font-family:"Trebuchet MS", "Gill Sans", sans-serif; font-size:10px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; cursor:pointer; }
.brand-row h1 { margin:0; }
.brand-copy h1 { color:rgb(246, 247, 241); font-family:Georgia, "Times New Roman", serif; font-size:20px; line-height:1.1; font-weight:400; -webkit-font-smoothing:antialiased; cursor:pointer; }
.view-nav { display:flex; gap:4px; padding:4px; background:var(--bg); border-radius:var(--radius-md); }
.view-nav-btn { border:0; background:transparent; padding:7px 10px; color:var(--muted); }
.view-nav-btn.is-active { background:var(--panel); color:var(--text); box-shadow:0 1px 3px rgba(15,23,42,.12); }
.app-view.hidden { display:none; }
.section-head, .table-section-head { margin:12px 16px 10px; display:flex; justify-content:space-between; align-items:end; gap:12px; }
.section-head h2, .table-section-head h2 { margin:0; font-size:16px; }
.section-head p, .table-section-head p { margin:3px 0 0; font-size:12px; color:var(--muted); }
.link-button { color:var(--accent); white-space:nowrap; }
.ranking-panel { margin:12px 16px; }
.ranking-list { display:grid; grid-template-columns:repeat(auto-fit,minmax(240px,1fr)); gap:8px; }
.ranking-card { width:100%; display:grid; grid-template-columns:30px 1fr auto; gap:9px; align-items:center; text-align:left; padding:12px; border:1px solid var(--line); background:var(--panel); border-radius:var(--radius-md); box-shadow:var(--shadow); }
.ranking-card.is-selected { border-color:var(--accent); background:var(--accent-soft); }
.ranking-place { color:var(--muted); font-weight:700; }
.ranking-name { font-weight:700; }
.ranking-meta { display:block; margin-top:2px; font-size:11px; color:var(--muted); }
.ranking-score { text-align:right; font-weight:700; font-variant-numeric:tabular-nums; }
.ranking-delta { display:block; margin-top:2px; text-align:right; font-size:11px; }
.table-section-head { align-items:center; }
.table-hint { color:var(--muted); font-size:12px; white-space:nowrap; }
@media (max-width:640px) { .brand-row { align-items:flex-start; flex-direction:column; gap:9px; } .brand-identity { width:100%; } .brand-logo { width:36px; height:40px; } .view-nav { width:100%; } .view-nav-btn { flex:1; font-size:11px; padding:8px 4px; } .section-head, .table-section-head { margin-left:10px; margin-right:10px; align-items:flex-start; flex-direction:column; } .ranking-panel { margin-left:10px; margin-right:10px; } .ranking-list { grid-template-columns:1fr; } .link-button { width:100%; } .detail-controls select { min-width:0; width:100%; } .detail-controls label { width:100%; } }

.filter-toggle { display:none; }
.topbar.confrontos-active .controls, .topbar.confrontos-active .filter-toggle { display:none !important; }
@media (max-width:640px) {
  .filter-toggle { display:block; width:100%; padding:9px 10px; color:var(--accent); background:var(--accent-soft); border-color:var(--line-soft); }
  .topbar .controls { display:none; margin-top:10px; }
  .topbar.filters-open .controls { display:flex; }
}

.topbar { background-color:#12383c; background-image:repeating-linear-gradient(155deg,transparent 0 31px,rgba(255,255,255,.035) 32px,transparent 33px 64px),linear-gradient(110deg,#12383c 0%,#17464a 65%,#245a59 100%); border-bottom-color:#17464a; }
.topbar::after { position:absolute; right:0; bottom:0; left:0; height:3px; background:linear-gradient(90deg,#e97859 0 24%,#e3bd61 24% 36%,transparent 36%); content:""; pointer-events:none; }
.topbar h1, .topbar .eyebrow { color:#fff; }
.topbar .brand-copy .eyebrow { color:rgb(192, 213, 203); }
.topbar .brand-copy h1 { color:rgb(246, 247, 241); font-weight:400; }
.controls label { color:#d7edf1; }
.controls select, .controls input, .controls button { border-color:#a9c4b8; }
.view-nav { background:rgba(255,255,255,.16); }
.view-nav-btn { color:#e2f4f5; }
.view-nav-btn.is-active { color:#12383c; background:#fff; }
.ranking-list { grid-template-columns:1fr; }
.ranking-card { grid-template-columns:34px 1fr auto; border-left:5px solid #1c5051; }
.ranking-card.is-selected { border-color:#e3bd61; background:#fff9ea; }
.ranking-side { display:flex; flex-direction:column; align-items:end; gap:3px; }
.ranking-group { display:inline-block; padding:3px 8px; border-radius:999px; font-size:11px; font-weight:800; }
.ranking-group.group-A { background:#f1cf78; color:#493400; }
.ranking-group.group-B { background:#1c5051; color:#fff; }
.ranking-group.group-A-to-B { background:#f4ddd6; color:#ad4d37; }
.ranking-group.group-B-to-A { background:#eaf2ed; color:#1c5051; }
.ranking-group.group-none { background:#e5ebe7; color:#526c65; }
.ranking-list > .chart-panel { grid-column:1 / -1; margin:0; border-left:5px solid #e3bd61; }
.detail-panel, .insight-card, .chart-panel, .table-wrap { border-color:#c8d4ce; }
@media (max-width:640px) { .ranking-card { padding:11px 10px; } .ranking-group { font-size:10px; } }


.status:empty { display:none; }
.ranking-panel, .ranking-list { max-width:820px; }
.ranking-panel { margin-left:auto; margin-right:auto; }
.inline-check { color:#132b3b !important; }
.inline-check input { accent-color:var(--accent); }
.group-note { list-style:none; display:flex; align-items:flex-start; gap:7px; padding:7px 8px; margin:4px 0; border-radius:5px; background:#eaf2ed; }
.notes-section ul { padding-left:0; }
.group-note-marker { display:grid; place-items:center; flex:0 0 24px; width:24px; height:24px; border-radius:50%; color:#fff; font-weight:800; background:#1c5051; }
.group-note.up .group-note-marker { background:#087a55; }.group-note.down .group-note-marker { background:#ad4d37; }.group-note-content { min-width:0; color:var(--muted); line-height:1.45; }.group-note strong { color:#12383c; }
.ranking-group.group-A-to-B { background:#f4ddd6; color:#ad4d37; }
.ranking-group.group-B-to-A { background:#eaf2ed; color:#1c5051; }
.chart-year-label { display:flex; align-items:center; gap:5px; color:var(--muted); font-size:11px; }
.chart-year-label select { padding:6px 8px; }
.ranking-group[class*="group-A-"]:not(.group-A-to-B) { background:#f4ddd6; color:#ad4d37; }
.ranking-group[class*="group-B-"]:not(.group-B-to-A) { background:#eaf2ed; color:#1c5051; }
