/* ============================================================================
   Design system copiado del Panel Coordinador de BODYTECH-CONSULTA
   (lenguaje editorial zinc/Inter — ver _tokens.tsx de ese repo).
   ============================================================================ */
:root {
    --accent: #1f3a8a;
    --accent-soft: #eef2ff;
    --surface: #fafaf9;
    --panel: #fcfcfb;
    --line: #e4e4e7;
    --zinc-50: #fafafa;
    --zinc-100: #f4f4f5;
    --zinc-200: #e4e4e7;
    --zinc-300: #d4d4d8;
    --zinc-400: #a1a1aa;
    --zinc-500: #71717a;
    --zinc-600: #52525b;
    --zinc-700: #3f3f46;
    --zinc-800: #27272a;
    --zinc-900: #18181b;
    --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font);
    background: var(--surface);
    color: var(--zinc-900);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- Sidebar (220px, panel claro, hairline) ---------- */
aside.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--zinc-200);
    min-height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
}
.sidebar .marca {
    padding: 18px 20px 14px;
    border-bottom: 1px solid var(--zinc-200);
}
.sidebar .marca .logo-img { display: block; height: 38px; max-width: 100%; object-fit: contain; object-position: left; }
.sidebar .marca .sub { font-size: 11px; color: var(--zinc-500); margin-top: 6px; letter-spacing: .02em; }
.sidebar nav { padding: 16px 12px 8px; flex: 1; overflow-y: auto; }
.seccion-label {
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--zinc-400);
    font-weight: 600;
    padding: 0 12px 8px;
}
.nav-grupo { margin-bottom: 20px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--zinc-600);
    text-decoration: none;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    transition: background-color .12s, color .12s;
}
.nav-item:hover { background: var(--zinc-100); color: var(--zinc-900); }
.nav-item.activo {
    background: #fff;
    color: var(--zinc-900);
    box-shadow: inset 0 0 0 1px var(--zinc-200);
}
.nav-item.activo::before {
    content: '';
    position: absolute;
    left: -12px; top: 8px; bottom: 8px;
    width: 2px;
    border-radius: 2px;
    background: var(--accent);
}
.nav-item svg { width: 15px; height: 15px; color: var(--zinc-500); flex-shrink: 0; }
.nav-item .badge { margin-left: auto; font-size: 10.5px; color: var(--zinc-400); font-family: var(--mono); }
.sidebar .usuario-footer {
    margin-top: auto;
    border-top: 1px solid var(--zinc-200);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar .usuario-footer .avatar {
    width: 28px; height: 28px;
    border-radius: 999px;
    background: var(--zinc-900);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.01em;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar .usuario-footer .info { min-width: 0; flex: 1; }
.sidebar .usuario-footer .nombre { font-size: 12.5px; font-weight: 500; color: var(--zinc-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .usuario-footer .rol { font-size: 11px; color: var(--zinc-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
    padding: 6px;
    border-radius: 4px;
    color: var(--zinc-400);
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    transition: color .12s, background-color .12s;
}
.icon-btn:hover { color: var(--zinc-800); background: var(--zinc-100); }
.icon-btn svg { width: 14px; height: 14px; }

/* ---------- Main ---------- */
main.principal { flex: 1; min-width: 0; padding: 24px 32px 32px; }

/* ---------- Card editorial (rounded-xl + inset hairline) ---------- */
.tarjeta {
    background: #fff;
    border-radius: 12px;
    box-shadow: inset 0 0 0 1px var(--zinc-200);
    overflow: hidden;
    margin-bottom: 16px;
}
.tarjeta .relleno { padding: 20px 32px; }

/* Header de página dentro de la card */
.page-header {
    padding: 24px 32px 20px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    flex-wrap: wrap;
}
.page-header .breadcrumb { font-size: 11px; color: var(--zinc-400); font-family: var(--mono); margin-bottom: 4px; }
.page-header h2 { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; color: var(--zinc-900); }
.page-header .sub { font-size: 13px; color: var(--zinc-500); margin-top: 2px; }
.page-header .acciones { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Filter strip */
.filtros-strip {
    padding: 12px 32px;
    border-top: 1px solid var(--zinc-200);
    border-bottom: 1px solid var(--zinc-200);
    background: var(--zinc-50);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.filtros-strip .resultado-count { margin-left: auto; font-size: 12px; color: var(--zinc-500); }
.filtros-strip .resultado-count b { font-family: var(--mono); font-weight: 500; color: var(--zinc-700); }

/* Filter chip (label: + control inline) */
.chip {
    position: relative;
    height: 30px;
    display: inline-flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--zinc-300);
    border-radius: 6px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--zinc-800);
    padding-left: 11px;
}
.chip.activo { border-color: var(--accent); background: var(--accent-soft); color: #1e3a8a; }
.chip .chip-label { color: var(--zinc-500); font-weight: 400; padding-right: 4px; }
.chip select, .chip input {
    border: none; background: transparent; font: inherit; color: inherit;
    padding: 0 10px 0 2px; height: 100%; outline: none; cursor: pointer;
}

/* ---------- Botones ---------- */
.boton {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: #fff;
    background: var(--accent);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background-color .12s;
}
.boton:hover { background: #1e3a8a; }
.boton:disabled { opacity: .55; cursor: default; }
.boton.secundario {
    color: var(--zinc-700);
    background: #fff;
    border: 1px solid var(--zinc-200);
}
.boton.secundario:hover { background: var(--zinc-50); }
.boton.peligro { background: #dc2626; }

/* ---------- Formularios ---------- */
label { display: block; font-size: 12px; font-weight: 500; margin-bottom: 5px; color: var(--zinc-600); }
input, select, textarea {
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--zinc-200);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    color: var(--zinc-900);
}
textarea { height: auto; padding: 8px 10px; }
input::placeholder { color: var(--zinc-400); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--zinc-400); }
.fila { display: grid; gap: 14px; margin-bottom: 16px; }
.fila.c2 { grid-template-columns: repeat(2, 1fr); }
.fila.c3 { grid-template-columns: repeat(3, 1fr); }
.fila.c4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Tabla ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--panel); border-bottom: 1px solid var(--zinc-200); }
th {
    text-align: left;
    padding: 9px 14px;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--zinc-400);
    font-weight: 600;
    white-space: nowrap;
}
td { padding: 10px 14px; border-bottom: 1px solid var(--zinc-100); vertical-align: middle; }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: var(--zinc-50); }
td .principal-linea { font-size: 14px; font-weight: 500; color: var(--zinc-900); white-space: nowrap; }
td .secundaria-linea { font-size: 11px; color: var(--zinc-500); font-family: var(--mono); white-space: nowrap; }
td { white-space: nowrap; }

/* Avatar de iniciales */
.avatar-ini {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border-radius: 999px;
    background: var(--zinc-100);
    color: var(--zinc-700);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.01em;
    box-shadow: inset 0 0 0 1px rgba(24,24,27,0.06);
    flex-shrink: 0;
}

/* ---------- Pills (badge con dot) ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 500;
    border: 1px solid;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 999px; }
.pill.ok    { background: #f0fdf4; color: #166534; border-color: #dcfce7; } .pill.ok::before    { background: #22c55e; }
.pill.warn  { background: #fffbeb; color: #92400e; border-color: #fef3c7; } .pill.warn::before  { background: #f59e0b; }
.pill.bad   { background: #fef2f2; color: #991b1b; border-color: #fee2e2; } .pill.bad::before   { background: #ef4444; }
.pill.mute  { background: var(--zinc-100); color: var(--zinc-600); border-color: var(--zinc-200); } .pill.mute::before { background: var(--zinc-400); }
.pill.now   { background: #eff6ff; color: #1e40af; border-color: #dbeafe; } .pill.now::before   { background: #3b82f6; }
a:has(.pill) { text-decoration: none; }

/* ---------- KPI cards (estilo Stripe, fila con separadores) ---------- */
.kpi-fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi {
    padding: 14px 24px;
    border-right: 1px solid var(--zinc-200);
}
.kpi:last-child { border-right: none; }
.kpi .valor {
    margin-top: 6px;
    font-size: 28px;
    font-weight: 600;
    line-height: 1;
    color: var(--zinc-900);
    font-variant-numeric: tabular-nums;
}
.kpi .delta { margin-top: 8px; font-size: 12px; font-family: var(--mono); color: var(--zinc-500); }
.kpi .delta.up { color: #15803d; }
.kpi .delta.down { color: #b91c1c; }

/* ---------- Avisos / toast ---------- */
.aviso {
    padding: 11px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin: 0 32px 16px;
    border: 1px solid;
}
.aviso.error { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.aviso.ok    { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.aviso.warn  { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* Acciones por fila */
.acciones-tabla { display: flex; gap: 2px; justify-content: flex-end; }

/* Spinner */
.spinner {
    width: 28px; height: 28px;
    border-radius: 999px;
    border: 2px solid transparent;
    border-bottom-color: var(--accent);
    animation: girar .8s linear infinite;
    margin: 48px auto;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* Scrollbar coherente */
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--zinc-300); border-radius: 4px; }

@media (max-width: 860px) {
    body { flex-direction: column; }
    aside.sidebar { width: 100%; min-height: 0; position: static; }
    main.principal { padding: 16px; }
    .fila.c3, .fila.c4 { grid-template-columns: 1fr 1fr; }
}
