/* Panel CRM: el mismo cristal, más denso y con el fondo atenuado para leer datos. */
:root {
  --chart-gold: #b38c00;
  --chart-gold-hover: #c99e00;
  --surface-chart: rgba(16, 16, 19, 0.55);
  --st-good: #46d27a;
  --st-warn: #f2b84b;
  --st-bad: #ff5a36;
}
.is-panel .shards { opacity: 0.5; }
.panel-auth { padding: 8vh 0 60px; }
.auth__logo { height: 44px; width: auto; margin: 0 auto 18px; }

.crm { display: grid; grid-template-columns: 240px 1fr; gap: 16px; padding: 16px; min-height: 100vh; }

/* Barra lateral */
.side { position: sticky; top: 16px; height: calc(100vh - 32px); display: flex; flex-direction: column; gap: 24px; padding: 22px 16px; border-radius: 24px; }
.side__brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 18px; }
.side__brand img { height: 26px; width: auto; }
.side__nav { display: grid; gap: 4px; }
.side__nav a { padding: 11px 14px; border-radius: 12px; color: var(--ash); text-decoration: none; font-weight: 500; }
.side__nav a:hover { color: var(--bone); background: rgba(255, 255, 255, 0.05); }
.side__nav a[aria-current='page'] { color: var(--bone); background: rgba(255, 255, 255, 0.1); box-shadow: inset 2px 0 0 var(--gold); }
.side__foot { margin-top: auto; display: grid; gap: 10px; padding: 0 8px; font-size: 14px; }
.side__foot a { color: var(--ash); text-decoration: none; }
.side__foot a:hover { color: var(--bone); }
.side__foot .textbtn { text-align: left; color: var(--ash); font-weight: 500; }
.side__who { font-size: 12px; overflow: hidden; text-overflow: ellipsis; }

.crm__main { min-width: 0; padding: 8px 8px 40px; }
.screen { display: grid; gap: 16px; }
.screen__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.screen__head h1 { font-size: 36px; }
.screen__lead { margin-top: -6px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.filters--row { justify-content: flex-start; }
.select {
  height: 44px;
  padding: 0 38px 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 10, 12, 0.7) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a3a1a8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 12px center / 16px no-repeat;
  appearance: none;
  color: var(--bone);
}
.input--small { height: 44px; font-size: 15px; border-radius: 12px; }
.btn--small { min-height: 44px; padding: 0 18px; font-size: 15px; }
.search { width: min(340px, 100%); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(10, 10, 12, 0.5); color: var(--ash); cursor: pointer; font-size: 14px; }
.chips button[aria-checked='true'] { color: var(--bone); border-color: rgba(255, 212, 0, 0.5); background: rgba(255, 212, 0, 0.08); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.kpi { padding: 18px 20px; border-radius: 20px; display: grid; gap: 6px; }
.kpi span { color: var(--ash); font-size: 14px; }
.kpi strong { font-family: var(--display); font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.05; }
.kpi small { color: var(--ash); font-size: 13px; }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 16px; align-items: start; }
.card { padding: 20px 22px; border-radius: 22px; min-width: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card__head h2 { font-size: 18px; font-family: var(--sans); font-weight: 600; letter-spacing: 0; }
.card__head .textbtn { font-size: 13px; color: var(--ash); text-decoration: none; }

/* Gráficas */
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: rgba(255, 255, 255, 0.07); }
.chart .axis text { fill: var(--ash); font-size: 11px; font-family: var(--sans); }
.chart .bar { fill: var(--chart-gold); transition: fill 0.15s; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .bar, .chart .hit:focus-visible + .bar, .chart .bar.is-hover { fill: var(--chart-gold-hover); }
.chart .hit:focus-visible { outline: none; }
.chart__empty { color: var(--ash); font-size: 14px; padding: 40px 0; text-align: center; }
.chart table { width: 100%; font-size: 13px; border-collapse: collapse; }
.chart th, .chart td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.chart .table-scroll { max-height: 240px; overflow: auto; }

.tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(14, 14, 16, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  font-size: 13px;
  display: grid;
  gap: 2px;
}
.tooltip strong { font-size: 15px; }
.tooltip span { color: var(--ash); }

/* Embudo */
.funnel { display: grid; gap: 14px; }
.funnel__row { display: grid; gap: 6px; }
.funnel__label { display: flex; justify-content: space-between; font-size: 14px; }
.funnel__label b { font-weight: 600; }
.funnel__track { height: 12px; border-radius: 6px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.funnel__bar { height: 100%; border-radius: 6px; background: var(--chart-gold); min-width: 2px; }
.funnel__rate { font-size: 12px; color: var(--ash); }

.mini-list, .feed { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.mini-list li:first-child { border-top: 0; }
.mini-list .muted { white-space: nowrap; }
.empty-line { color: var(--ash); font-size: 14px; padding: 8px 0; }

.feed li { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; align-items: start; padding: 12px 0; border-top: 1px solid var(--line); font-size: 14px; }
.feed li:first-child { border-top: 0; }
.feed .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; background: var(--ash); }
.feed .dot--compra { background: var(--gold); }
.feed .dot--certificado { background: var(--st-good); }
.feed .dot--examen { background: #8ab4ff; }
.feed .dot--nota { background: #c9a7ff; }
.feed time { color: var(--ash); font-size: 13px; white-space: nowrap; }
.feed button { background: none; border: 0; padding: 0; color: var(--bone); font-weight: 600; cursor: pointer; text-align: left; }
.feed button:hover { color: var(--gold); }
.feed p { color: var(--ash); margin-top: 2px; overflow-wrap: anywhere; }
.feed--mini li { padding: 9px 0; }

/* Tabla de alumnos */
.crm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.crm-table th { text-align: left; padding: 14px 16px; color: var(--ash); font-weight: 500; background: rgba(255, 255, 255, 0.03); border-bottom: 1px solid var(--line); white-space: nowrap; }
.crm-table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.crm-table tbody tr { cursor: pointer; transition: background 0.15s; }
.crm-table tbody tr:hover, .crm-table tbody tr:focus-visible { background: rgba(255, 255, 255, 0.05); outline: none; }
.crm-table td strong { display: block; font-weight: 600; }
.crm-table td span.muted { font-size: 13px; }
.empty { padding: 32px; text-align: center; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--inscrito { color: var(--bone); }
.badge--teorico { color: #8ab4ff; }
.badge--certificado { color: var(--st-good); }
.badge--caducado { color: var(--st-warn); }
.badge--revocado { color: var(--st-bad); }

/* Plataforma */
.health { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.check { padding: 20px; border-radius: 20px; display: grid; gap: 8px; align-content: start; }
.check h2 { font-family: var(--sans); font-size: 16px; font-weight: 600; letter-spacing: 0; }
.check p { color: var(--ash); font-size: 14px; }
.status { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.status svg { width: 18px; height: 18px; }
.status--ok { color: var(--st-good); }
.status--warn { color: var(--st-warn); }
.status--bad { color: var(--st-bad); }

/* Ficha */
.drawer-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.5); }
.drawer {
  position: fixed;
  z-index: 50;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: min(520px, calc(100% - 24px));
  overflow-y: auto;
  padding: 28px;
  border-radius: 24px;
  animation: entrar 0.3s var(--ease);
}
@keyframes entrar { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer__close { position: absolute; top: 16px; right: 16px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); font-size: 22px; line-height: 1; cursor: pointer; }
.drawer h2 { font-size: 28px; padding-right: 40px; }
.drawer h3 { font-family: var(--sans); font-size: 15px; font-weight: 600; letter-spacing: 0; color: var(--ash); margin: 26px 0 10px; }
.drawer__meta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.drawer__contact { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.drawer .btn--small { min-height: 38px; font-size: 14px; }
.drawer form { display: grid; gap: 10px; }
.drawer textarea { width: 100%; min-height: 80px; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(10, 10, 12, 0.7); resize: vertical; font: inherit; color: var(--bone); }
.drawer textarea:focus { outline: none; border-color: var(--ember); box-shadow: 0 0 0 4px rgba(255, 90, 54, 0.18); }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 14px; }
.rows li:first-child { border-top: 0; }
.note { padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, 0.04); font-size: 14px; }
.note + .note { margin-top: 8px; }
.note small { display: block; margin-top: 6px; color: var(--ash); font-size: 12px; }
.cert-box { padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(8, 8, 10, 0.4); display: grid; gap: 10px; }
.inline { display: flex; gap: 8px; }
.inline .input { flex: 1; }

/* Alta manual */
.modal { width: min(520px, calc(100% - 32px)); padding: 32px; color: var(--bone); }
.modal::backdrop { background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
.modal__form { display: grid; gap: 14px; }
.modal__form h2 { font-size: 28px; }
.modal__row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .crm { grid-template-columns: 1fr; padding: 10px; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px; gap: 12px; }
  .side__nav { display: flex; overflow-x: auto; gap: 2px; flex: 1; }
  .side__nav a { padding: 9px 12px; white-space: nowrap; }
  .side__foot { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .screen__head h1 { font-size: 28px; }
  .modal__row { grid-template-columns: 1fr; }
  .kpi strong { font-size: 26px; }
}
