/* Casos de éxito · Reparación — estilos */

:root {
  --bg: #F2F4F7; --card: #FFFFFF; --border: #E4E7EC; --text: #0B1220; --muted: #475467; --soft: #F8FAFC;
  --green: #15803D; --green-1: #22C55E; --green-2: #16A34A; --green-bg: #DCFCE7;
  --red: #D92D20; --red-1: #F04438; --red-bg: #FEE4E2; --track: #E9EDF2; --dark: #0B1220;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; text-align: left;
}
h1, h2, h3, p { margin: 0; }
.wrap { padding: 28px 32px 40px; }
@media (max-width: 760px) { .wrap { padding: 20px 16px 32px; } }

/* ---------- Encabezado ---------- */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.top h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.top p { margin-top: 2px; color: var(--muted); }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500; background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 5px 11px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--green-1); }

/* ---------- Totales de arriba ---------- */
.kpis-t { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: 12px; margin-bottom: 22px; }
.kpi { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi .value { font-size: 34px; font-weight: 800; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi.dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.kpi.dark .label { color: #CBD5E1; }
.kpi.hero { background: linear-gradient(135deg, #16A34A 0%, #22C55E 60%, #4ADE80 100%); border: none; color: #fff; box-shadow: 0 10px 24px -10px rgba(22,163,74,.6); }
.kpi.hero .label { color: #F0FDF4; }
.kpi.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,.12); }
.kpi .value.accent { color: var(--green-1); }

.section-title { font-size: 15px; font-weight: 700; margin-bottom: 10px; }

/* ---------- Tarjetas de casos ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.case {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px; cursor: pointer; text-align: left; font: inherit; color: inherit; width: 100%; margin: 0;
  display: flex; flex-direction: column; gap: 14px;
  opacity: 0; transform: translateY(14px);
}
.case.in { opacity: 1; transform: none; transition: opacity .6s var(--ease), transform .6s var(--ease), box-shadow .25s, border-color .25s; }
.case.in:hover { transform: translateY(-3px); border-color: #B8C0CC; box-shadow: 0 12px 24px -12px rgba(11,18,32,.25); }
.case:focus-visible { outline: 3px solid var(--green-1); outline-offset: 2px; }
.case-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg, #16A34A, #22C55E); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.who { display: flex; gap: 10px; align-items: center; }
.who b { display: block; font-size: 16px; font-weight: 700; }
.who span { color: var(--muted); font-size: 12px; }
.chip { font-size: 12px; font-weight: 600; border-radius: 999px; padding: 4px 10px; background: var(--dark); color: #fff; white-space: nowrap; }

/* Barras de puntaje antes → después */
.scores { display: flex; flex-direction: column; gap: 10px; }
.score-row { display: grid; grid-template-columns: 28px 1fr 58px; align-items: center; gap: 10px; }
.bureau { font-size: 12px; font-weight: 700; color: var(--muted); }
.bar { position: relative; height: 26px; background: var(--track); border-radius: 7px; }
.bar .after, .bar .before { position: absolute; top: 0; bottom: 0; left: 0; width: 0; border-radius: 7px; display: flex; align-items: center; justify-content: flex-end; font-size: 12px; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.bar .after { background: linear-gradient(90deg, var(--green-2), var(--green-1)); transition: width 1.1s var(--ease); }
.bar .before { background: linear-gradient(90deg, var(--red), var(--red-1)); border-radius: 7px 0 0 7px; padding-right: 7px; transition: width .7s var(--ease); }
.bar .after span { position: absolute; left: 100%; padding-left: 7px; color: var(--text); white-space: nowrap; opacity: 0; transition: opacity .4s; }
.bar .before span { opacity: 0; transition: opacity .3s; }
.bar.show .before span, .bar.show .after span { opacity: 1; }
.delta { justify-self: end; font-weight: 800; font-size: 13px; color: var(--green); background: var(--green-bg); border-radius: 999px; padding: 3px 8px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); font-weight: 500; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend .l-b::before { background: var(--red-1); }
.legend .l-a::before { background: var(--green-1); }

/* Subida del 1er mes */
.jump { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.jump div { background: var(--green-bg); border-radius: 10px; padding: 12px 8px; text-align: center; }
.jump b { display: block; font-size: 24px; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.jump span { font-size: 12px; color: var(--muted); font-weight: 500; }

/* Reporte 100% limpio */
.clean { background: linear-gradient(135deg, #16A34A, #22C55E); color: #fff; border-radius: 10px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.clean b { display: block; font-size: 16px; font-weight: 800; }
.clean span { font-size: 12px; color: #F0FDF4; }
.check { flex: none; }
.check path { stroke-dasharray: 20; stroke-dashoffset: 20; transition: stroke-dashoffset .6s var(--ease) .3s; }
.case.in .check path { stroke-dashoffset: 0; }

/* Antes / Después dentro de cada tarjeta */
.phase { border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.phase.antes { background: #FEF3F2; border: 1px solid #FECDCA; }
.phase.despues { background: #F0FDF4; border: 1px solid #BBF7D0; }
.phase-t { font-size: 11px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.antes .phase-t { color: var(--red); }
.despues .phase-t { color: var(--green); }
.big { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }
.big em { font-style: normal; color: var(--red); }
.pts { display: flex; gap: 6px; flex-wrap: wrap; }
.pts span { background: #fff; border: 1px solid #FECDCA; border-radius: 7px; padding: 3px 8px; font-size: 12px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.pts b { color: var(--red); font-weight: 800; }
.acc { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.acc li { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.acc li > span:first-child { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc .m { font-weight: 700; color: var(--red); font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-mas { font-size: 12px; color: var(--muted); font-weight: 500; }
.despues .jump div { background: #fff; }
.case-foot { display: flex; gap: 8px; border-top: 1px solid #BBF7D0; padding-top: 10px; }
.stat { flex: 1; }
.stat b { display: block; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat b.g { color: var(--green); }
.stat > span { font-size: 12px; color: var(--muted); }
.more { align-self: flex-end; font-size: 12px; font-weight: 600; color: var(--green); white-space: nowrap; }

/* ---------- Detalle (<dialog> nativo) ---------- */
dialog { border: none; padding: 0; border-radius: 14px; width: calc(100% - 32px); max-width: 580px; max-height: 88vh; overflow: auto; background: var(--card); color: var(--text); box-shadow: 0 24px 48px rgba(11,18,32,.3); opacity: 0; transform: translateY(20px) scale(.98); transition: opacity .25s, transform .35s var(--ease); }
dialog.open { opacity: 1; transform: none; }
dialog::backdrop { background: rgba(11,18,32,.55); }
.panel-head { padding: 18px 20px; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; position: sticky; top: 0; background: var(--dark); color: #fff; z-index: 1; }
.panel-head h2 { font-size: 18px; font-weight: 700; color: #fff; }
.panel-head p { margin-top: 2px; color: #CBD5E1; font-size: 13px; }
.x { border: 1px solid rgba(255,255,255,.25); background: transparent; border-radius: 8px; width: 32px; height: 32px; cursor: pointer; font-size: 18px; line-height: 1; color: #fff; flex: none; padding: 0; }
.panel-body { padding: 18px 20px 22px; display: flex; flex-direction: column; gap: 20px; }
h3 { font-size: 12px; font-weight: 700; margin-bottom: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mini { display: flex; flex-direction: column; gap: 10px; }
.mini .score-row { grid-template-columns: 84px 1fr 58px; }
.mini .bureau { font-size: 13px; color: var(--text); font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border); }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--soft); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { opacity: 0; transform: translateX(-8px); }
dialog.open tbody tr { animation: rowin .4s var(--ease) forwards; }
@keyframes rowin { to { opacity: 1; transform: none; } }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--red-bg); color: #B42318; white-space: nowrap; }
.ok { display: inline-flex; align-items: center; gap: 4px; color: var(--green); font-weight: 700; white-space: nowrap; }
tfoot td { font-weight: 800; border-bottom: none; font-size: 14px; }
tfoot td.num { color: var(--green); }
.extra { display: flex; flex-direction: column; gap: 6px; }
.extra div { display: flex; justify-content: space-between; gap: 10px; background: var(--soft); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; font-weight: 500; }
.extra .from { color: var(--red); font-weight: 700; }
.extra .to { color: var(--green); font-weight: 800; }

/* ---------- Celular ---------- */
@media (max-width: 760px) {
  .kpis { grid-template-columns: 1fr; }
  .grid { grid-template-columns: 1fr; }
  .kpi .value { font-size: 28px; }
  .hide-sm { display: none; }
}

/* ---------- Sin animaciones si el usuario lo pide ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .case { opacity: 1; transform: none; }
  tbody tr { opacity: 1; transform: none; }
  .check path { stroke-dashoffset: 0; }
  dialog { opacity: 1; transform: none; }
}
