/* Portal de clientes · Koa Studio. Mismo lenguaje que koastudio.site: oscuro, serif editorial, bordes finos. */
:root {
  color-scheme: dark;
  --bg: #0A0A0A; --surface: #101010; --surface-2: #161616;
  --line: rgba(255,255,255,.09); --line-2: rgba(255,255,255,.16);
  --ink: #F5F3EF; --ink-2: #A3A09B; --ink-3: #6A6864;
  --ember: #E8442A;
  --good: #6FCF97; --warn: #E6B450; --bad: #F0605D;
  --serif: 'Newsreader', Georgia, 'Times New Roman', serif;
  --sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --gutter: 20px; --maxw: 1120px; --r: 14px;
}
@media (min-width: 760px) { :root { --gutter: 40px; } }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased;
  background: var(--bg) radial-gradient(900px 420px at 50% -180px, rgba(232,68,42,.07), transparent 70%) no-repeat;
  min-height: 100vh;
}
a { color: var(--ink); text-underline-offset: 3px; text-decoration-color: var(--line-2); }
a:hover { text-decoration-color: var(--ember); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -.01em; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(34px, 5.5vw, 52px); line-height: 1.08; }
h2 { font-size: clamp(24px, 3.2vw, 30px); line-height: 1.2; }
h3 { font-size: 20px; line-height: 1.3; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.eyebrow { display: inline-flex; align-items: center; gap: 12px; font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-2); }
.eyebrow::before { content: ''; width: 24px; height: 1px; background: var(--ink-3); }
.lead { color: var(--ink-2); font-size: 18px; max-width: 60ch; }
:focus-visible { outline: 2px solid var(--ember); outline-offset: 3px; border-radius: 4px; }

.demo-banner { background: #1d1608; color: #e9cf9a; border-bottom: 1px solid #3a2c10; padding: 8px var(--gutter); font-size: 13px; text-align: center; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ---------- barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: rgba(10,10,10,.82); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-weight: 600; font-size: 15px; letter-spacing: -.005em; }
.brand img { width: 30px; height: 30px; border-radius: 8px; display: block; }
.who { display: flex; align-items: center; gap: 12px; color: var(--ink-2); font-size: 14px; }
.who-name { max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .who-name { display: none; } }

/* ---------- encabezado de página ---------- */
.page-head { padding: 56px 0 8px; }
.page-head h1 { margin: 18px 0 10px; }
@media (max-width: 560px) { .page-head { padding-top: 36px; } }

/* ---------- pestañas ---------- */
.tabs { display: flex; gap: 28px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 28px 0 36px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: 0; color: var(--ink-2); font: inherit; font-size: 15px; padding: 14px 0; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; min-height: 48px; transition: color .15s; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.badge-count { background: var(--ember); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 600; padding: 2px 8px; margin-left: 8px; vertical-align: 1px; }

/* ---------- botones ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--ink); color: #0A0A0A; border: 1px solid var(--ink); border-radius: 8px; padding: 11px 20px; min-height: 44px; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, opacity .15s; }
.btn:hover { background: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; border-color: var(--line-2); color: var(--ink); font-weight: 500; }
.btn.ghost:hover { border-color: var(--ink-2); background: rgba(255,255,255,.03); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 14px; }
.btn.block { width: 100%; }

/* ---------- tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 28px; margin-bottom: 20px; }
.card h3 { margin-bottom: .35em; }
@media (max-width: 560px) { .card { padding: 20px; } }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 44px 0 18px; }
.section-title h2 { margin: 0; }
.grid { display: grid; gap: 16px; }

/* ---------- cifra principal ---------- */
.hero { display: grid; grid-template-columns: 1.35fr 1fr; gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 20px; }
.hero-main { padding: 32px; border-right: 1px solid var(--line); }
.hero-side { display: grid; grid-template-rows: repeat(3, 1fr); }
.hero-side .stat { border-bottom: 1px solid var(--line); background: transparent; padding: 18px 28px; }
.hero-side .stat:last-child { border-bottom: 0; }
.big { font-family: var(--serif); font-size: clamp(52px, 8vw, 76px); line-height: 1; letter-spacing: -.02em; margin: 14px 0 12px; }
.hero-note { color: var(--ink-2); font-size: 15px; margin: 0; max-width: 46ch; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } .hero-main { border-right: 0; border-bottom: 1px solid var(--line); padding: 24px; } .hero-side { grid-template-rows: none; grid-template-columns: repeat(3, 1fr); } .hero-side .stat { border-bottom: 0; border-right: 1px solid var(--line); padding: 16px; } .hero-side .stat:last-child { border-right: 0; } }
@media (max-width: 520px) { .hero-side { grid-template-columns: 1fr; } .hero-side .stat { border-right: 0; border-bottom: 1px solid var(--line); } }

/* ---------- cifras ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stat { background: var(--surface); padding: 22px 24px; }
.stat .label { font-size: 13px; color: var(--ink-2); }
.stat .value { font-family: var(--serif); font-size: 30px; line-height: 1.15; margin: 4px 0 2px; letter-spacing: -.01em; }
.stat .hint { font-size: 12.5px; color: var(--ink-2); }
.stat { min-width: 0; }
.stat .value { overflow-wrap: anywhere; }
@media (max-width: 860px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stat { padding: 16px; } .stat .value { font-size: 23px; } .hero-main { padding: 22px 20px; } }
.delta { display: block; font-size: 12.5px; margin-top: 2px; }
.delta.up { color: var(--good); } .delta.down { color: var(--bad); } .delta.flat { color: var(--ink-2); }

/* ---------- estados ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 3px 12px; font-size: 12.5px; font-weight: 500; border: 1px solid var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.good { color: var(--good); border-color: rgba(111,207,151,.45); background: rgba(111,207,151,.07); }
.pill.warn { color: var(--warn); border-color: rgba(230,180,80,.45); background: rgba(230,180,80,.07); }
.pill.bad { color: var(--bad); border-color: rgba(240,96,93,.45); background: rgba(240,96,93,.07); }
.pill.accent { color: var(--ember); border-color: rgba(232,68,42,.5); background: rgba(232,68,42,.08); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- escala del CPA ---------- */
.gauge { margin-top: 26px; }
.gauge-track { position: relative; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: visible; }
.gauge-track .z { position: absolute; top: 0; bottom: 0; }
.gauge-track .z.good { background: rgba(111,207,151,.55); border-radius: 999px 0 0 999px; }
.gauge-track .z.warn { background: rgba(230,180,80,.5); }
.gauge-track .z.bad { background: rgba(240,96,93,.5); border-radius: 0 999px 999px 0; }
.gauge-track .mark { position: absolute; top: -6px; width: 4px; height: 20px; border-radius: 2px; background: var(--ink); transform: translateX(-50%); box-shadow: 0 0 0 3px var(--surface); }
.gauge-ticks { position: relative; height: 44px; margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.gauge-ticks span { position: absolute; top: 0; white-space: nowrap; }
.gauge-ticks .t-good { transform: none; }
.gauge-ticks .t-bad { transform: translateX(-100%); text-align: right; }
.gauge-ticks b { display: block; color: var(--ink); font-weight: 500; font-size: 13px; }
@media (max-width: 560px) { .gauge-ticks { height: 84px; } .gauge-ticks .t-bad { top: 42px; } }

/* ---------- gráfico ---------- */
.chart-wrap { overflow-x: auto; }
.chart { width: 100%; min-width: 560px; height: auto; }
.chart .base { stroke: var(--line-2); }
.chart .bar { fill: var(--ink-3); }
.chart .bar.good { fill: rgba(111,207,151,.8); } .chart .bar.warn { fill: rgba(230,180,80,.8); } .chart .bar.bad { fill: rgba(240,96,93,.8); }
.chart .axis { fill: var(--ink-2); font-size: 11px; font-family: var(--sans); }
.chart .val { fill: var(--ink); font-size: 12px; paint-order: stroke; stroke: var(--surface); stroke-width: 5px; stroke-linejoin: round; }
.chart .ref { stroke-dasharray: 4 5; stroke-width: 1.25; }
.chart .ref.good { stroke: var(--good); } .chart .ref.warn { stroke: var(--warn); }
.chart .axis.good { fill: var(--good); } .chart .axis.warn { fill: var(--warn); }

/* ---------- listas y acciones ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 16px 0; border-top: 1px solid var(--line); display: flex; gap: 14px; align-items: flex-start; }
.list li:first-child { border-top: 0; padding-top: 4px; }
.todo { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: 1px solid var(--line); }
.todo:first-child { border-top: 0; padding-top: 2px; }
.todo-n { flex: none; width: 28px; height: 28px; border-radius: 50%; background: rgba(232,68,42,.12); color: var(--ember); display: grid; place-items: center; font-size: 13px; font-weight: 600; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.prose p { margin: 0; color: #D6D3CD; }
.prose-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, 1fr); }
.prose-grid .card { margin: 0; }
.prose-grid .card .eyebrow { margin-bottom: 14px; }
@media (max-width: 760px) { .prose-grid { grid-template-columns: 1fr; } }
.quote { font-family: var(--serif); font-size: clamp(21px, 2.6vw, 26px); line-height: 1.4; color: var(--ink); max-width: 52ch; margin: 0 0 28px; }

/* ---------- selector de períodos ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.chip { background: transparent; border: 1px solid var(--line-2); color: var(--ink-2); border-radius: 999px; padding: 8px 16px; font: inherit; font-size: 14px; cursor: pointer; min-height: 40px; transition: all .15s; }
.chip:hover { color: var(--ink); border-color: var(--ink-2); }
.chip[aria-pressed="true"] { background: var(--ink); color: #0A0A0A; border-color: var(--ink); font-weight: 600; }

/* ---------- creativos ---------- */
.creative-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.creative { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; display: flex; flex-direction: column; }
.frame { position: relative; aspect-ratio: 9 / 11; background: radial-gradient(120% 80% at 50% 0, #1b1b1b, #0d0d0d); display: grid; place-items: center; text-decoration: none; border-bottom: 1px solid var(--line); }
.frame .play { width: 58px; height: 58px; border-radius: 50%; border: 1px solid var(--line-2); display: grid; place-items: center; background: rgba(255,255,255,.04); transition: transform .15s, background .15s; }
.frame:hover .play { transform: scale(1.06); background: rgba(255,255,255,.09); }
.frame .play svg { width: 20px; height: 20px; fill: var(--ink); margin-left: 3px; }
.frame .chip-st { position: absolute; top: 14px; left: 14px; }
.frame .vlabel { position: absolute; bottom: 14px; left: 0; right: 0; text-align: center; font-size: 12px; color: var(--ink-2); letter-spacing: .06em; }
.video { width: 100%; height: 100%; object-fit: cover; background: #000; }
.creative-body { padding: 18px 20px 20px; display: grid; gap: 10px; flex: 1; align-content: start; }
.creative-body strong { font-size: 15px; font-weight: 600; word-break: break-word; }
.creative-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.changes label { margin-top: 4px; }

/* ---------- checklist ---------- */
.ring { --p: 0; width: 92px; height: 92px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 6; }
.ring .bg { stroke: var(--surface-2); }
.ring .fg { stroke: var(--ink); stroke-linecap: round; transition: stroke-dashoffset .5s ease; }
.ring .num { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--serif); font-size: 21px; letter-spacing: -.02em; }
.progress-card { display: flex; align-items: center; gap: 24px; }
.cat-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.cat-head .count { font-size: 13px; color: var(--ink-2); }
.check { display: flex; gap: 14px; align-items: flex-start; cursor: pointer; width: 100%; }
.check input { appearance: none; -webkit-appearance: none; flex: none; width: 22px; height: 22px; margin: 2px 0 0; border: 1.5px solid var(--line-2); border-radius: 6px; background: transparent; cursor: pointer; display: grid; place-items: center; transition: all .15s; }
.check input:hover { border-color: var(--ink-2); }
.check input:checked { background: var(--ink); border-color: var(--ink); }
.check input:checked::after { content: ''; width: 6px; height: 11px; border: solid #0A0A0A; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.check.done .t { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--ink-3); }
.lock { flex: none; width: 22px; height: 22px; margin-top: 2px; display: grid; place-items: center; color: var(--ink-2); }
.lock svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ---------- formularios ---------- */
label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=datetime-local], input[type=url], select, textarea {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; color: var(--ink); font: inherit; font-size: 15px; padding: 11px 14px; min-height: 46px; transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover, textarea:hover { border-color: var(--line-2); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 3px rgba(232,68,42,.22); }
textarea { min-height: 96px; resize: vertical; }
.fields { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.field.full { grid-column: 1 / -1; }

/* ---------- panel de Koa ---------- */
.layout { display: grid; gap: 32px; grid-template-columns: 290px 1fr; align-items: start; }
.sidebar { position: sticky; top: 88px; }
.sidebar .client-btn { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); padding: 14px 16px; margin-bottom: 10px; cursor: pointer; font: inherit; min-height: 48px; transition: border-color .15s, background .15s; }
.sidebar .client-btn:hover { border-color: var(--line-2); }
.sidebar .client-btn[aria-current="true"] { border-color: var(--ink); background: var(--surface-2); }
.sidebar .client-btn strong { font-weight: 600; font-size: 15px; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } .sidebar { position: static; } }
.table-wrap { overflow-x: auto; padding: 8px 12px; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 14px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-2); font-weight: 500; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255,255,255,.015); }

/* ---------- avisos ---------- */
#toasts { position: fixed; bottom: 20px; left: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 50; pointer-events: none; }
.toast { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 18px; max-width: 520px; font-size: 14.5px; box-shadow: 0 10px 40px rgba(0,0,0,.5); pointer-events: auto; animation: rise .25s ease; }
.toast.err { border-color: rgba(240,96,93,.6); }
.toast.ok { border-color: rgba(111,207,151,.5); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.empty { text-align: center; color: var(--ink-2); padding: 56px 20px; }
.empty .ico { width: 44px; height: 44px; margin: 0 auto 14px; border: 1px solid var(--line-2); border-radius: 50%; display: grid; place-items: center; color: var(--ink-2); }
.skeleton { height: 120px; border-radius: var(--r); background: linear-gradient(90deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: shimmer 1.4s infinite; margin-bottom: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- acceso ---------- */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.auth-brand { padding: 48px var(--gutter); display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line); background: radial-gradient(700px 500px at 20% 0, rgba(232,68,42,.08), transparent 70%), linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px) 0 0 / 100% 56px; }
.auth-brand h1 { font-size: clamp(38px, 4.6vw, 58px); max-width: 14ch; margin: 22px 0 18px; }
.auth-points { display: grid; gap: 14px; color: var(--ink-2); font-size: 15px; max-width: 44ch; }
.auth-points div { display: flex; gap: 12px; }
.auth-points div::before { content: ''; flex: none; width: 6px; height: 6px; margin-top: 10px; background: var(--ember); border-radius: 50%; }
.auth-form { display: grid; place-items: center; padding: 48px var(--gutter); }
.auth-form .box { width: 100%; max-width: 400px; }
.auth-form h2 { margin-bottom: 8px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-brand { border-right: 0; border-bottom: 1px solid var(--line); padding: 32px var(--gutter); gap: 28px; } .auth-brand h1 { margin: 16px 0 10px; } .auth-points { display: none; } .auth-form { padding: 36px var(--gutter) 56px; } }
