/* ============================================================
   ESG MONITOR — heritage redesign
   Paleta: marfil / azul tinta / carmesi / oro viejo
   ============================================================ */

:root {
  --paper: #F6F2EA;
  --card: #FFFFFF;
  --ink: #0B2239;
  --ink-soft: #3C4A5A;
  --muted: #8A8273;
  --line: #E4DCCB;
  --line-soft: #EFE9DC;
  --accent: #B5121B;
  --gold: #B08D2B;
  --navy: #01233D;
  --green: #1F7A3D;
  --green-bg: #E8F3EB;
  --amber: #A8741A;
  --amber-bg: #F7EFDE;
  --red: #B43326;
  --red-bg: #F9E9E6;
  --shadow: 0 1px 2px rgba(11,34,57,.05), 0 8px 24px -16px rgba(11,34,57,.25);
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Inter", -apple-system, "Segoe UI", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- layout ---------- */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--navy);
  color: #D9D2C2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 26px 22px 22px;
  border-bottom: 1px solid rgba(217,210,194,.14);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 38px; height: 38px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  color: var(--gold);
  font-size: 15px;
  letter-spacing: .5px;
}

.brand-name {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  color: #F4EFE3;
  letter-spacing: .8px;
}
.brand-name small {
  display: block;
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 2.6px;
  color: var(--gold);
  margin-top: 2px;
}

.nav { padding: 18px 12px; flex: 1; }

.nav-label {
  font-size: 10px;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: rgba(217,210,194,.45);
  padding: 8px 12px 6px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin: 2px 0;
  border-radius: 8px;
  color: #C9C2B2;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 2px solid transparent;
  transition: background .15s, color .15s;
}
.nav a svg { width: 17px; height: 17px; opacity: .75; }
.nav a:hover { background: rgba(244,239,227,.07); color: #F4EFE3; }
.nav a.active {
  background: rgba(181,18,27,.16);
  border-left: 2px solid var(--accent);
  color: #FFFFFF;
}
.nav a.active svg { opacity: 1; }

.side-foot {
  padding: 16px 22px 20px;
  border-top: 1px solid rgba(217,210,194,.14);
  font-size: 11px;
  color: rgba(217,210,194,.5);
}
.side-foot b { color: var(--gold); font-weight: 600; }

/* ---------- main ---------- */

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  background: rgba(246,242,234,.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 40;
}

.search {
  flex: 1;
  max-width: 440px;
  position: relative;
}
.search input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font: inherit;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,141,43,.14); }
.search svg {
  position: absolute; left: 13px; top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--muted);
}
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: none;
  z-index: 60;
}
.search-results.open { display: block; }
.search-results button {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 14px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}
.search-results button:hover { background: var(--paper); }
.search-results small { color: var(--muted); }

.top-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }

.bell {
  position: relative;
  background: none; border: 1px solid var(--line);
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  cursor: pointer;
  color: var(--ink-soft);
  background: var(--card);
}
.bell:hover { border-color: var(--gold); }
.bell svg { width: 17px; height: 17px; }
.bell .dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  border: 1.5px solid var(--card);
}

.user { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), #2E4A66);
  color: var(--gold);
  display: grid; place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 14px;
}
.user-meta { line-height: 1.25; }
.user-meta b { font-size: 13px; font-weight: 600; display: block; }
.user-meta span { font-size: 11px; color: var(--muted); }

.logout {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.logout:hover { border-color: var(--accent); color: var(--accent); }

.content { padding: 28px; max-width: 1340px; width: 100%; margin: 0 auto; }

/* ---------- page heading ---------- */

.page-head { margin-bottom: 22px; }
.eyebrow {
  font-size: 10.5px;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 6px;
}
.page-head h1 {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: .2px;
}
.page-head p.sub { color: var(--muted); margin-top: 4px; max-width: 640px; }

.rule {
  height: 1px;
  background: linear-gradient(90deg, var(--gold), transparent 60%);
  margin: 14px 0 0;
  border: 0;
}

/* ---------- cards / grid ---------- */

.grid { display: grid; gap: 18px; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px){ .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; } }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
}

.card h3 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 4px;
}
.card .hint { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

.kpi .kpi-label {
  font-size: 10.5px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
.kpi .kpi-value {
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  margin: 6px 0 2px;
  font-variant-numeric: lining-nums;
}
.kpi .kpi-foot { font-size: 12px; color: var(--ink-soft); }
.kpi .kpi-foot .up { color: var(--green); font-weight: 600; }
.kpi .kpi-foot .down { color: var(--red); font-weight: 600; }

/* ---------- tabs ---------- */

.tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .15s;
}
.tab:hover { border-color: var(--gold); }
.tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #F4EFE3;
}
.tab.active .count { color: var(--gold); }
.tab .count { color: var(--muted); font-size: 11px; margin-left: 6px; }

/* ---------- table ---------- */

.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow); }

table.esg { width: 100%; border-collapse: collapse; min-width: 920px; }

table.esg thead th {
  position: sticky; top: 0;
  background: #FBF9F4;
  font-size: 10.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
table.esg thead th.center { text-align: center; }
table.esg thead th .arr { color: var(--gold); margin-left: 4px; font-size: 10px; }

table.esg tbody td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  white-space: nowrap;
}
table.esg tbody tr { cursor: pointer; transition: background .12s; }
table.esg tbody tr:hover { background: #FBF8F1; }
table.esg tbody tr:last-child td { border-bottom: 0; }

.co-name {
  font-weight: 600;
  font-size: 13.5px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.co-isin { font-size: 11px; color: var(--muted); letter-spacing: .4px; }
.cell-dim {
  color: var(--ink-soft);
  font-size: 13px;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flag {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  color: var(--navy);
  background: var(--amber-bg);
  border: 1px solid #EADFC2;
  padding: 2px 9px;
  border-radius: 999px;
  max-width: 148px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.flag.none { background: none; border: 0; color: var(--line); }

.score {
  display: inline-grid;
  place-items: center;
  min-width: 42px;
  padding: 4px 7px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  position: relative;
}
.score.g { background: var(--green-bg); color: var(--green); }
.score.y { background: var(--amber-bg); color: var(--amber); }
.score.r { background: var(--red-bg); color: var(--red); }

/* tooltip */
.tip { position: relative; }
.tip .tip-box {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--navy);
  color: #EDE7D8;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: 0 10px 30px -10px rgba(1,35,61,.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, transform .15s;
  z-index: 50;
}
.tip .tip-box::after {
  content: "";
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--navy);
}
.tip:hover .tip-box { opacity: 1; transform: translateX(-50%) translateY(0); }
.tip-box table { border-collapse: collapse; }
.tip-box th {
  font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--gold); font-weight: 600; padding: 0 12px 4px 0; text-align: left;
}
.tip-box td { padding: 0 12px 0 0; font-weight: 600; }

.table-tools { display: flex; align-items: center; gap: 14px; margin: 18px 0 14px; flex-wrap: wrap; }
.table-tools .spacer { flex: 1; }
.mini-search { position: relative; }
.mini-search input {
  padding: 8px 12px 8px 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font: inherit; font-size: 13px;
  outline: none;
  width: 240px;
}
.mini-search input:focus { border-color: var(--gold); }
.mini-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--muted); }
.result-count { font-size: 12px; color: var(--muted); }

/* ---------- legend ---------- */
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--ink-soft); align-items: center; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; vertical-align: -1px; }
.legend .lg i { background: var(--green); }
.legend .ly i { background: var(--amber); }
.legend .lr i { background: var(--red); }

/* ---------- ficha ---------- */

.ficha-head {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  flex-wrap: wrap;
}
.ficha-id { flex: 1; min-width: 260px; }
.ficha-id h1 { font-family: var(--serif); font-size: 28px; font-weight: 700; }
.ficha-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.chipline {
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 999px;
  padding: 4px 12px;
  color: var(--ink-soft);
}
.chipline b { color: var(--ink); font-weight: 600; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); text-decoration: none;
  font-size: 13px; font-weight: 500; margin-bottom: 14px;
  background: none; border: 0; cursor: pointer; font-family: inherit;
}
.back-link:hover { text-decoration: underline; }

.dials { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 18px; }
.dial-card { text-align: center; }
.dial-card .dial-label {
  font-size: 10.5px; letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-top: 8px;
}
.dial-value {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 26px;
}
.dial-value.g { color: var(--green); }
.dial-value.y { color: var(--amber); }
.dial-value.r { color: var(--red); }

.metric-row {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.metric-row:last-child { border-bottom: 0; }
.metric-name { flex: 1; font-size: 13px; color: var(--ink-soft); }
.bar { flex: 2; height: 6px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; transition: width .6s cubic-bezier(.2,.7,.3,1); }
.bar i.g { background: var(--green); }
.bar i.y { background: var(--amber); }
.bar i.r { background: var(--red); }
.metric-val { width: 40px; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.toggle-more {
  background: none; border: 0;
  color: var(--accent);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  padding: 6px 0;
}
.toggle-more:hover { text-decoration: underline; }

/* ---------- alerts ---------- */

.alert-item {
  display: flex; gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line-soft);
}
.alert-item:last-child { border-bottom: 0; }
.alert-ico {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 50%;
  display: grid; place-items: center;
}
.alert-ico.pos { background: var(--green-bg); color: var(--green); }
.alert-ico.neg { background: var(--red-bg); color: var(--red); }
.alert-ico.info { background: var(--amber-bg); color: var(--gold); }
.alert-ico svg { width: 17px; height: 17px; }
.alert-body b { font-size: 13.5px; }
.alert-body p { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.alert-body .when { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ---------- exclusion ---------- */

.excl-item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line-soft);
}
.excl-item:last-child { border-bottom: 0; }
.excl-item .desc { flex: 1; }
.excl-item .desc b { font-size: 13.5px; display: block; }
.excl-item .desc span { font-size: 12px; color: var(--muted); }

.switch {
  width: 40px; height: 22px;
  border-radius: 999px;
  background: var(--line);
  border: 0;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex: 0 0 40px;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch.on { background: var(--green); }
.switch.on::after { left: 21px; }

/* ---------- charts ---------- */

.chart-flex { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; }
.donut-legend { flex: 1; min-width: 180px; }
.donut-legend .metric-row { padding: 7px 0; }
.dl-swatch { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 11px; }

.spark-axis { font-size: 10px; fill: var(--muted); font-family: var(--sans); }

/* ---------- ranking list ---------- */

.rank-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
}
.rank-row:hover .rank-name { color: var(--accent); }
.rank-row:last-child { border-bottom: 0; }
.rank-pos {
  font-family: var(--serif);
  font-weight: 700;
  color: var(--gold);
  width: 22px;
  font-size: 15px;
}
.rank-name { flex: 1; font-weight: 500; font-size: 13px; transition: color .12s; }
.rank-idx { font-size: 11px; color: var(--muted); }

/* ---------- footer ---------- */

.foot {
  margin-top: 34px;
  padding: 18px 0 8px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
}
.foot b { font-family: var(--serif); color: var(--ink-soft); }

/* ---------- view transitions ---------- */

.view { display: none; animation: fadeUp .28s ease both; }
.view.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- responsive ---------- */

@media (max-width: 880px) {
  .sidebar { display: none; }
  .content { padding: 18px; }
}
