:root {
  --bg: #E6E4E7;
  --card: #FFFFFF;
  --ink: #111111;
  --muted: #5B5F66;
  --line: #E4E6EB;
  --yellow: #FFC900;
  --olive: #5E5214;
  --green: #12B76A;
  --grey: #5B5F66;
  --pos-bg: #E3F6EC; --pos: #10804A;
  --neg-bg: #FDE7E7; --neg: #C62828;
  --neu-bg: #EEF0F3; --neu: #5B5F66;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 2px 8px rgba(16,24,40,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: Inter, system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.topbar { background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 14px clamp(16px, 3vw, 56px); }
.client { display: flex; align-items: center; gap: 14px; }
.client-logo { height: 52px; display: flex; align-items: center; }
.client-logo img { height: 100%; max-width: 200px; object-fit: contain; object-position: left center; display: block; }
.client-initial { width: 52px; height: 52px; border-radius: 50%; background: #EEF0F3; color: #B5B9C0; display: grid; place-items: center; font-weight: 800; font-size: 26px; }
.client-logo.has-img + .client-name { padding-left: 16px; border-left: 1px solid var(--line); }
.client-name { font-size: 22px; font-weight: 700; }
.agency-logo { height: 52px; }

.wrap { padding: 24px clamp(16px, 3vw, 56px) 32px; max-width: 1600px; margin: 0 auto; }

.filters { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.filters-right { display: flex; gap: 12px; flex-wrap: wrap; }
.select { position: relative; display: inline-flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #D5D8DE; border-radius: 10px; height: 50px; padding: 0 16px; font: inherit; font-size: 17px; color: var(--ink); cursor: pointer; }
.select select { appearance: none; border: 0; background: transparent; font: inherit; color: inherit; padding-right: 28px; cursor: pointer; outline: none; min-width: 200px; max-width: 320px; }
.select .chev { position: absolute; right: 14px; pointer-events: none; }
.date-btn .chev { position: static; }
.ico, .chev { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.date-picker { position: relative; }
.date-panel[hidden] { display: none; }
.date-panel { position: absolute; z-index: 20; top: 58px; left: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(16,24,40,.14); display: flex; width: min(560px, calc(100vw - 32px)); }
.presets { display: flex; flex-direction: column; padding: 8px; border-right: 1px solid var(--line); min-width: 180px; }
.presets button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
.presets button:hover { background: #F4F5F8; }
.presets button.active { background: #FFF6CC; font-weight: 600; }
.custom { padding: 16px; display: flex; flex-direction: column; gap: 12px; flex: 1; font-size: 13px; color: var(--muted); }
.custom label { display: flex; flex-direction: column; gap: 4px; }
.custom input, .custom select { font: inherit; font-size: 14px; color: var(--ink); border: 1px solid #D5D8DE; border-radius: 8px; padding: 8px 10px; }
.panel-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; }
.btn, .btn-ghost { font: inherit; font-size: 14px; font-weight: 600; border-radius: 8px; padding: 9px 16px; cursor: pointer; border: 1px solid transparent; }
.btn { background: var(--ink); color: #fff; }
.btn-ghost { background: #fff; border-color: #D5D8DE; color: var(--ink); }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 22px; margin-bottom: 22px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px clamp(18px, 1.6vw, 26px); }
.kpi { display: flex; gap: 14px; align-items: center; min-height: 128px; }
.kpi-ico { width: clamp(48px, 3.6vw, 64px); height: clamp(48px, 3.6vw, 64px); border-radius: 12px; background: #F1F2F5; display: grid; place-items: center; flex: none; }
.kpi-ico svg { width: 36px; height: 36px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.kpi-body { flex: 1; min-width: 0; }
.kpi-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kpi-label { font-size: clamp(14px, 1.05vw, 17px); line-height: 1.25; color: #222; }
.kpi-value { font-size: clamp(30px, 2.6vw, 44px); font-weight: 800; letter-spacing: -.5px; margin-top: 4px; white-space: nowrap; }
.kpi-prev { font-size: 13px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.delta { font-size: 14px; font-weight: 500; padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.delta.pos { background: var(--pos-bg); color: var(--pos); }
.delta.neg { background: var(--neg-bg); color: var(--neg); }
.delta.neu { background: var(--neu-bg); color: var(--neu); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin-bottom: 22px; }
.card h2 { font-size: 24px; font-weight: 700; margin: 0 0 18px; letter-spacing: -.3px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.legend { display: flex; gap: 18px; font-size: 16px; align-items: center; padding-top: 4px; }
.legend span { display: inline-flex; align-items: center; gap: 8px; }
.sq { width: 18px; height: 18px; border-radius: 4px; display: inline-block; }
.sq.dark { background: var(--ink); }
.ln { width: 22px; height: 4px; border-radius: 2px; display: inline-block; }
.ln.yellow { background: var(--yellow); }

.funnel { display: flex; align-items: center; height: 220px; }
.f-seg { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: #fff; margin-left: -18px; padding: 0 30px; }
.f-seg:first-child { margin-left: 0; }
.f-seg .f-label { font-size: clamp(14px, 1.3vw, 22px); font-weight: 500; }
.f-seg .f-value { font-size: clamp(28px, 3vw, 50px); font-weight: 800; letter-spacing: -.5px; }
.f-seg.s0 { background: var(--ink); height: 100%; clip-path: polygon(0 0, calc(100% - 36px) 4%, 100% 50%, calc(100% - 36px) 96%, 0 100%); }
.f-seg.s1 { background: var(--olive); height: 86%; clip-path: polygon(0 0, calc(100% - 36px) 4%, 100% 50%, calc(100% - 36px) 96%, 0 100%, 36px 50%); }
.f-seg.s2 { background: var(--yellow); color: var(--ink); height: 74%; clip-path: polygon(0 0, calc(100% - 36px) 4%, 100% 50%, calc(100% - 36px) 96%, 0 100%, 36px 50%); }
.f-seg.s3 { background: #FFE57A; color: var(--ink); height: 62%; clip-path: polygon(0 0, calc(100% - 36px) 4%, 100% 50%, calc(100% - 36px) 96%, 0 100%, 36px 50%); }
.funnel-rates { display: flex; margin-top: 12px; }
.f-rate { flex: 1; text-align: center; font-size: 13px; color: var(--muted); line-height: 1.3; padding: 0 6px; }
.f-rate b { display: block; color: var(--ink); font-size: 18px; font-weight: 700; }
.funnel-note { margin: 10px 0 0; font-size: 12px; color: var(--muted); text-align: center; font-style: italic; }

.chart-box { position: relative; height: 240px; }

.donut-wrap { display: flex; align-items: center; justify-content: space-around; gap: 24px; flex-wrap: wrap; }
.donut-box { position: relative; width: 240px; height: 240px; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; font-size: 18px; }
.donut-legend li { display: flex; align-items: center; gap: 12px; }
.donut-legend i { width: 20px; height: 20px; border-radius: 4px; flex: none; }
.donut-legend small { color: var(--muted); font-size: 14px; margin-left: 4px; }

.campaigns { list-style: none; margin: 0; padding: 0; counter-reset: c; display: flex; flex-direction: column; gap: 22px; }
.campaigns li { counter-increment: c; }
.c-row { display: flex; justify-content: space-between; gap: 12px; font-size: 18px; margin-bottom: 10px; }
.c-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-name::before { content: counter(c) ".  "; }
.c-stats { white-space: nowrap; }
.c-meta { margin: -4px 0 8px 26px; font-size: 13px; color: var(--muted); }
.seg-toggle { display: inline-flex; background: #F1F2F5; border-radius: 8px; padding: 3px; }
.seg-toggle button { border: 0; background: none; font: inherit; font-size: 13px; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.seg-toggle button.active { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16,24,40,.08); }
.c-bar { height: 12px; background: #E4E6EB; border-radius: 6px; overflow: hidden; margin-left: 26px; }
.c-bar span { display: block; height: 100%; background: var(--yellow); border-radius: 6px; }
.empty { color: var(--muted); font-size: 15px; padding: 24px 0; text-align: center; }

.sync { color: var(--muted); font-size: 13px; }
.notice { background: var(--yellow); color: var(--ink); font-size: 14px; font-weight: 600; text-align: center; padding: 8px 16px; }

/* ── Pie de página comercial (estilo indexcol.com) ── */
.site-foot { position: relative; overflow: hidden; background: var(--bg); padding: 8px clamp(16px, 3vw, 56px) 40px; font-family: Barlow, "Helvetica Neue", Arial, sans-serif; color: #333; }
.foot-inner { position: relative; z-index: 1; max-width: 1600px; margin: 0 auto; padding: 28px 0 0 clamp(0px, 22vw, 380px); border-top: 1px solid #A9A6AB; }
.foot-title { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; font-size: 14px; margin: 0 0 14px; color: #111; }
.socials { display: flex; gap: 10px; flex-wrap: wrap; }
.socials a { width: 44px; height: 44px; border: 2px solid #111; border-radius: 50%; display: grid; place-items: center; color: #111; transition: background .15s, color .15s, border-color .15s; }
.socials a:hover { background: var(--yellow); border-color: var(--yellow); }
.socials svg { width: 22px; height: 22px; fill: currentColor; }
.socials svg.stroke { fill: none; stroke: currentColor; stroke-width: 2; }
.copy { margin: 26px 0 0; font-size: 14px; color: #555; }
.copy a { color: #111; text-decoration: none; border-bottom: 2px solid var(--yellow); padding-bottom: 1px; }
.copy a:hover { color: #C99F00; }
.foot-dots { position: absolute; left: 0; bottom: 0; width: min(380px, 40vw); height: 100%; min-height: 220px;
  background-image: radial-gradient(#8E8B91 1.3px, transparent 1.7px); background-size: 12px 12px;
  -webkit-mask-image: radial-gradient(circle at 0% 100%, #000 15%, transparent 72%); mask-image: radial-gradient(circle at 0% 100%, #000 15%, transparent 72%); }
.foot-dots img { position: absolute; left: 20px; bottom: 18px; }
.foot-tag { position: absolute; right: clamp(16px, 3vw, 56px); bottom: 18px; }

.loading .card, .loading .kpis .card { opacity: .55; transition: opacity .2s; }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: 1fr; }
  .topbar { padding: 10px 16px; }
  .agency-logo { height: 34px; }
  .client-name { font-size: 17px; }
  .select { width: 100%; }
  .select select { min-width: 0; max-width: none; width: 100%; }
  .filters-right, .date-picker { width: 100%; }
  .date-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .date-panel { flex-direction: column; }
  .presets { border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; }
  .funnel { height: 170px; }
  .f-seg { padding: 0 20px; margin-left: -12px; }
  .c-row { font-size: 15px; flex-direction: column; gap: 2px; }
  .c-meta { margin-left: 0; }
  .c-bar { margin-left: 0; }
  .foot-inner { padding-left: 0; padding-bottom: 40px; }
  .foot-tag { display: none; }
  .client-logo { height: 38px; }
  .client-logo img { max-width: 120px; }
  .client-logo.has-img + .client-name { display: none; }
  .card { padding: 18px; }
  .card h2 { font-size: 20px; }
}
