:root {
  --bg: #12151d; --panel: #1b1f2a; --panel-2: #222735; --line: #2b3040; --text: #f3f4f6; --muted: #8b93a7;
  --amber: #e9b173; --blue: #3b82f6; --green: #22c55e; --purple: #a855f7; --red: #ef4444;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif; }
.hidden { display: none !important; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
button, select, input { font: inherit; color: inherit; }
.muted { color: var(--muted); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: grid; gap: 12px; text-align: center; }
.login-logo { width: 44px; margin: 0 auto; }
.login h1 { font-size: 20px; margin: 4px 0 8px; }
.login input { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; }
.login button { background: var(--amber); color: #1a1206; border: 0; border-radius: 8px; padding: 11px; font-weight: 600; cursor: pointer; }
.err { color: var(--red); min-height: 1em; margin: 0; font-size: 13px; }

/* cabecera */
.top { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 20px; }
.brand img { width: 30px; height: 30px; }
.tabs { display: flex; gap: 28px; }
.tabs a { display: flex; align-items: center; gap: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.tabs a.on { color: var(--amber); }
.right { display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.country { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; cursor: pointer; }
.avatar { width: 36px; height: 36px; border-radius: 50%; border: 0; background: #374151; font-weight: 600; font-size: 13px; cursor: pointer; }

/* páginas */
.page { max-width: 1520px; margin: 0 auto; padding: 28px 24px 48px; }
.page h1 { font-size: 30px; margin: 4px 0 22px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.card-h { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
.card-b { padding: 22px 16px 18px; display: grid; gap: 4px; }
.card-b b { font-size: 34px; font-weight: 700; letter-spacing: -.5px; }
.card-b small { color: var(--muted); font-size: 13px; }
.card[data-open] { cursor: pointer; transition: border-color .15s; }
.card[data-open]:hover { border-color: #3a4154; }
.go { margin-left: auto; color: var(--muted); font-weight: 400; }
.ic { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-style: normal; font-size: 13px; font-weight: 700; flex: none; }
.ic.blue { background: rgba(59,130,246,.16); color: var(--blue); }
.ic.amber { background: rgba(233,177,115,.16); color: var(--amber); }
.ic.green { background: rgba(34,197,94,.14); color: var(--green); }
.ic.purple { background: rgba(168,85,247,.16); color: var(--purple); }
.goal { margin-bottom: 24px; }
.goal-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.goal-row small { display: block; color: var(--muted); font-size: 13px; }
.goal-row b { font-size: 28px; }
.bar { height: 14px; background: #2c3242; border-radius: 99px; overflow: hidden; margin-bottom: 10px; }
.bar div { height: 100%; width: 0; background: var(--blue); border-radius: 99px; transition: width .6s; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; margin-bottom: 24px; }

/* gráficos */
.charts { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 24px; align-items: start; }
.viewer, .card { min-width: 0; }
.list { padding: 0 0 8px; position: sticky; top: 76px; }
.list-h { padding: 16px 20px; font-weight: 700; font-size: 17px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.grp { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 20px; background: none; border: 0; cursor: pointer; color: #e5e7eb; font-weight: 600; font-size: 14.5px; text-align: left; }
.grp:hover { background: var(--panel-2); }
.grp em { margin-left: auto; color: var(--muted); font-style: normal; font-weight: 400; font-size: 12px; }
.grp .chev { color: var(--muted); transition: transform .15s; font-weight: 400; }
.sec.open .grp .chev { transform: rotate(90deg); }
.items { display: none; padding: 2px 0 6px; }
.sec.open .items { display: block; }
.item { padding: 6px 20px 6px 60px; cursor: pointer; color: #c9cdd6; font-size: 14px; border-radius: 0; }
.item:hover { background: var(--panel-2); }
.item.on { background: #2b3141; color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.viewer-h { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.vt { font-size: 18px; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.info { color: var(--muted); font-size: 15px; font-weight: 400; cursor: help; }
.controls { display: flex; gap: 10px; flex-wrap: wrap; }
.viewer-b { padding: 22px; }
.chartbox { position: relative; height: 430px; border: 1px solid var(--line); border-radius: 6px; padding: 14px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 13px; color: #cfd3dc; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend em { color: var(--muted); font-style: normal; }
.note { font-size: 13px; margin: 12px 0 0; }
.empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 14px; pointer-events: none; text-align: center; padding: 20px; }

/* tablas */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-weight: 500; cursor: pointer; user-select: none; position: sticky; top: 0; background: var(--panel); }
tr:hover td { background: var(--panel-2); }
td.neg { color: var(--red); } td.pos { color: var(--green); }

@media (max-width: 1000px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .charts { grid-template-columns: minmax(0, 1fr); }
  .list { position: static; }
}
@media (max-width: 640px) {
  .top { grid-template-columns: 1fr auto; padding: 10px 16px; }
  .tabs { grid-column: 1 / -1; grid-row: 2; justify-content: center; }
  .brand span { display: none; }
  .page { padding: 20px 16px 40px; }
  .grid3 { grid-template-columns: 1fr; gap: 16px; }
  .goal-row b { font-size: 22px; }
  .chartbox { height: 320px; }
}
