/* =====================================================================
   IsFood · estilos base y panel de la aplicación
   ===================================================================== */

/* Tipografía: Inter (variable), alojada en /fonts en vez de Google Fonts.
   Un solo archivo woff2 cubre todos los pesos usados (200 a 800). Licencia
   SIL Open Font License en fonts/inter/OFL.txt. */
@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/inter/Inter-Variable.woff2") format("woff2");
}

:root {
    --green: #1faa4b;
    --green-dark: #168a3b;
    --green-soft: #e9f8ef;
    --orange: #f0a13c;
    --red: #e03a3e;
    --red-dark: #c52f33;
    --red-soft: #fdecec;
    --blue: #1a8fe3;
    --amber: #b7791f;
    --amber-soft: #fdf4e3;

    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-soft: #eef0ff;
    --pink: #ec5f8a;
    --teal: #2cc9a6;

    --text: #16181d;
    --muted: #6b7280;
    --border: #e8eaee;
    --input: #f3f4f6;
    --surface: #ffffff;
    --page: #ffffff;
    --soft: #f8f9fb;

    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 10px rgba(16, 24, 40, .04);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .12);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text);
    background: var(--page);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; }
img { max-width: 100%; }
.icon { flex-shrink: 0; vertical-align: middle; }
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- Marca (logo oficial, img/logo.png) ---------- */
.brand { display: inline-flex; text-decoration: none !important; }
.brand img { display: block; width: 190px; height: auto; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px;
    border: 1px solid transparent; border-radius: 10px;
    font: inherit; font-weight: 500; cursor: pointer;
    text-decoration: none !important; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn:focus-visible, .icon-btn:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid rgba(99, 102, 241, .35); outline-offset: 2px; }
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); }
.btn-indigo { background: var(--primary); color: #fff; }
.btn-indigo:hover { background: var(--primary-dark); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: var(--green-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--input); }
.btn-soft { background: var(--primary-soft); color: var(--primary-dark); }
.btn-soft:hover { background: #e0e3ff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--input); color: var(--text); }
.btn-danger-text { background: transparent; color: var(--red); }
.btn-danger-text:hover { background: var(--red-soft); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-peligro { background: var(--red); color: #fff; }
.btn-peligro:hover { background: var(--red-dark); }
.link-btn { padding: 0; border: 0; background: none; font: inherit; color: var(--blue); text-decoration: underline; cursor: pointer; }

/* ---------- Emergencia sanitaria ---------- */
.btn-emergencia {
    position: relative; display: inline-flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 16px 0 6px; margin-right: 8px;
    border: 0; border-radius: 999px; color: #fff; cursor: pointer;
    background: linear-gradient(180deg, #f2555a 0%, #d8343a 100%);
    font: inherit; font-size: 13px; font-weight: 600; letter-spacing: .02em;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 4px 12px rgba(224, 58, 62, .32);
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
/* El pulso va en un pseudo-elemento para no pisar la sombra del botón. */
.btn-emergencia::before {
    content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
    animation: emergencia-pulso 2.4s ease-out infinite;
}
.btn-emergencia:hover {
    transform: translateY(-1px); filter: brightness(1.04);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 7px 18px rgba(224, 58, 62, .42);
}
.btn-emergencia:active { transform: translateY(0); filter: brightness(.96); }
.btn-emergencia:focus-visible { outline: 3px solid rgba(224, 58, 62, .4); outline-offset: 3px; }
.btn-emergencia-icono {
    display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255, 255, 255, .2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
@keyframes emergencia-pulso {
    0% { box-shadow: 0 0 0 0 rgba(224, 58, 62, .5); }
    70% { box-shadow: 0 0 0 10px rgba(224, 58, 62, 0); }
    100% { box-shadow: 0 0 0 0 rgba(224, 58, 62, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .btn-emergencia::before { animation: none; }
    .btn-emergencia, .btn-emergencia:hover { transform: none; }
}

/* Modal de activación con cuenta regresiva */
.dialogo.dialogo-emergencia { padding: 0; overflow: hidden; }
.dialogo.dialogo-emergencia::backdrop { background: rgba(120, 20, 24, .38); }
.emergencia-cabecera {
    display: flex; align-items: center; gap: 12px; padding: 16px 22px;
    background: linear-gradient(180deg, #f2555a 0%, #d8343a 100%); color: #fff;
}
.emergencia-cabecera h2 { margin: 0; font-size: 16px; font-weight: 600; }
.emergencia-cabecera .btn-emergencia-icono { width: 34px; height: 34px; }
.emergencia-cuerpo { padding: 20px 22px 22px; }
.emergencia-cuenta { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.cuenta-anillo { position: relative; flex-shrink: 0; width: 84px; height: 84px; }
.cuenta-anillo svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.cuenta-anillo circle { fill: none; stroke-width: 7; }
.cuenta-fondo { stroke: var(--red-soft); }
.cuenta-progreso { stroke: var(--red); stroke-linecap: round; stroke-dasharray: 213.63; stroke-dashoffset: 0; }
.dialogo-emergencia.contando .cuenta-progreso { animation: cuenta-vaciar 10s linear forwards; }
@keyframes cuenta-vaciar { to { stroke-dashoffset: 213.63; } }
.cuenta-numero {
    position: absolute; inset: 0; display: grid; place-items: center;
    font-size: 30px; font-weight: 700; color: var(--red-dark); font-variant-numeric: tabular-nums;
}
.emergencia-cuenta p { margin: 0; line-height: 1.5; }
.emergencia-cuenta p strong { color: var(--red-dark); }
.emergencia-cuenta p [hidden] { display: none; }
.emergencia-camara {
    display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding: 10px 12px;
    border-radius: var(--radius); background: var(--soft); border: 1px solid var(--border);
}
.emergencia-camara p { margin: 0; color: var(--muted); line-height: 1.45; }
.emergencia-camara video {
    flex-shrink: 0; width: 88px; height: 66px; border-radius: 8px; object-fit: cover; background: #111;
    transform: scaleX(-1); /* vista espejo, más natural para quien se ve; la foto se guarda sin espejar */
}
.emergencia-camara video[hidden], .emergencia-camara-icono[hidden] { display: none; }
.emergencia-camara-icono {
    flex-shrink: 0; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
    background: var(--red-soft); color: var(--red-dark);
}
.alerta-foto { display: block; width: 100%; max-height: 240px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; background: #111; }
.emergencia-foto-mini { display: block; width: 56px; height: 42px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
@media (prefers-reduced-motion: reduce) { .dialogo-emergencia.contando .cuenta-progreso { animation: none; } }

.dialogo {
    width: min(480px, calc(100vw - 32px)); padding: 22px; border: 0; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); color: var(--text);
}
.dialogo::backdrop { background: rgba(16, 24, 40, .45); }
.dialogo-cabecera { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.dialogo-cabecera h2 { margin: 0; font-size: 17px; }
.dialogo-peligro { color: var(--red); }
.dialogo-acciones { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.dialogo-alerta { border-top: 6px solid var(--red); }
.dialogo-alerta::backdrop { background: rgba(197, 47, 51, .35); }
.alerta-item { padding: 12px 14px; margin-top: 10px; border-radius: var(--radius); background: var(--red-soft); }
.alerta-item p { margin: 0 0 6px; font-weight: 600; line-height: 1.5; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 10px; }

.icon-btn {
    position: relative; display: inline-grid; place-items: center;
    width: 38px; height: 38px; border: 0; border-radius: 10px;
    background: transparent; color: #374151; cursor: pointer; list-style: none;
}
.icon-btn:hover { background: var(--input); text-decoration: none; }
.icon-btn .dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--red); border: 2px solid #fff; }

/* ---------- Formularios ---------- */
.field { margin-bottom: 16px; }
.field label, .label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: #374151; }
.field .hint { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.input, select.input, textarea.input {
    width: 100%; height: 42px; padding: 0 14px;
    border: 1px solid transparent; border-radius: 10px;
    background: var(--input); font: inherit; color: var(--text);
    transition: border-color .15s, background-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 90px; padding: 10px 14px; resize: vertical; }
.input::placeholder { color: #9ca3af; }
.input:focus { outline: none; background: #fff; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
.input-sm { height: 34px; font-size: 13px; padding: 0 10px; border-radius: 8px; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: #6b7280; pointer-events: none; }
.input-icon .input { padding-left: 46px; }
.input-icon .input.has-action { padding-right: 48px; }
.input-action {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    display: grid; place-items: center; width: 34px; height: 34px;
    border: 0; border-radius: 8px; background: transparent; color: #6b7280; cursor: pointer;
}
.input-action:hover { background: #e5e7eb; color: var(--text); }
.checkbox { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.checkbox input { width: 17px; height: 17px; margin: 0; accent-color: var(--blue); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; flex-wrap: wrap; }

/* Interruptor */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; vertical-align: middle; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: #d4d7de; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 3px solid rgba(99, 102, 241, .35); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; }
.switch input:disabled + .track { opacity: .6; }

/* Zona de carga */
.dropzone {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    padding: 26px 16px; border: 2px dashed #cfd3dc; border-radius: 14px;
    background: var(--soft); color: var(--muted); text-align: center; cursor: pointer;
    transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); }
.dropzone strong { color: var(--text); }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone .file-name { font-weight: 600; color: var(--primary-dark); }

/* ---------- Alertas y badges ---------- */
.alert { padding: 11px 14px; margin-bottom: 16px; border-radius: 10px; font-size: 14px; border: 1px solid transparent; }
.alert-error { background: var(--red-soft); color: #9b1c1f; border-color: #f7c9ca; }
.alert-success { background: var(--green-soft); color: #14622d; border-color: #bfe6cc; }
.alert-info { background: #eaf4fd; color: #0f5b93; border-color: #c4e0f7; }
.alert-warning { background: var(--amber-soft); color: #8a5a12; border-color: #f4dcae; }
.alert ul { margin: 0; padding-left: 18px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: #16803c; }
.badge-amber { background: var(--amber-soft); color: #a8660d; }
.badge-gray { background: #f0f1f3; color: #4b5563; }
.badge-red { background: var(--red-soft); color: #c0292d; }
.badge-blue { background: #e9f3fe; color: #1f6fc0; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: 12px; font-weight: 500; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 600; }
.delta.up { color: #16a34a; }
.delta.down { color: #e03a3e; }

.stars { display: inline-flex; gap: 1px; color: #fbbf24; }
.stars .off { color: #e2e5ea; }

/* Avatares */
.avatar { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; font-weight: 700; flex-shrink: 0; background: #e5e7eb; color: #374151; }
.avatar.tone-0 { background: #fde2e4; color: #b4234b; }
.avatar.tone-1 { background: #dff3ff; color: #0b6aa2; }
.avatar.tone-2 { background: #e5f7ea; color: #187a3b; }
.avatar.tone-3 { background: #fff1d6; color: #9a5b00; }
.avatar.tone-4 { background: #ece8ff; color: #5a3fd6; }
.avatar.tone-5 { background: #dcf7f2; color: #0f766e; }
.person { display: inline-flex; align-items: center; gap: 10px; }

.thumb { width: 64px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--soft); }
.thumb-sm { width: 48px; height: 36px; border-radius: 8px; object-fit: cover; background: var(--soft); }
.thumb-lg { width: 100%; max-width: 220px; aspect-ratio: 4 / 3; border-radius: 14px; object-fit: cover; background: var(--soft); display: block; }

/* ---------- Tarjetas y tablas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.card-header h2 { font-size: 16px; margin: 0; font-weight: 700; }
.card-header p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: #374151; padding: 10px 12px; background: var(--soft); white-space: nowrap; }
.table th:first-child { border-top-left-radius: 10px; }
.table th:last-child { border-top-right-radius: 10px; }
.table td { padding: 11px 12px; border-bottom: 1px solid #f0f1f3; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .center { text-align: center; }
.table .actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.table-grid { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.table-grid .table th, .table-grid .table td { border: 1px solid var(--border); }
.table-grid .table tr > :first-child { border-left: 0; }
.table-grid .table tr > :last-child { border-right: 0; }
.table-grid .table thead th { border-top: 0; border-radius: 0; background: #fff; text-align: center; padding: 14px 10px; }
.table-grid .table tbody tr:last-child td { border-bottom: 0; }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty .icon { display: block; margin: 0 auto 8px; color: #c2c7d0; }

/* ---------- Layout del panel ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    position: sticky; top: 0; display: flex; flex-direction: column;
    width: 236px; height: 100vh; padding: 16px 12px 14px;
    background: #fff; border-right: 1px solid var(--border); flex-shrink: 0; overflow-y: auto;
}
.sidebar-brand { padding: 2px 8px 16px; }
.sidebar .brand img { width: 140px; }
.config-pill {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 12px;
    border-radius: 12px; background: var(--primary); color: #fff !important; font-weight: 600; font-size: 13.5px;
    text-decoration: none !important; box-shadow: 0 4px 12px rgba(99, 102, 241, .28);
}
.config-pill:hover { background: var(--primary-dark); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    position: relative; display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; border-radius: 10px;
    font-size: 13.5px; font-weight: 500; color: #374151; text-decoration: none;
}
.nav a:hover { background: var(--soft); color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); }
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }

.members { margin-top: auto; padding: 18px 8px 12px; }
.members-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; font-weight: 600; margin-bottom: 10px; }
.members-head a { font-weight: 500; }
.members-list { display: flex; align-items: flex-start; gap: 10px; }
.member { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); max-width: 44px; text-align: center; overflow: hidden; }
.member span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 44px; }
.member-add { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); }
.user-card {
    display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px;
    background: var(--soft); color: var(--text) !important; text-decoration: none !important;
}
.user-card:hover { background: var(--input); }
.user-card-text { min-width: 0; line-height: 1.25; }
.user-card-text strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-text small { display: block; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: #fff; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 28px;
    background: rgba(255, 255, 255, .96); border-bottom: 1px solid var(--border);
}
.topbar-search { display: flex; align-items: center; gap: 8px; width: 100%; min-width: 0; max-width: 330px; height: 38px; padding: 0 12px; border-radius: 10px; background: var(--input); color: var(--muted); }
.topbar-search input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--text); outline: none; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.avatar-btn { list-style: none; cursor: pointer; border-radius: 50%; padding: 2px; margin-left: 6px; }
.avatar-btn::-webkit-details-marker, .icon-btn::-webkit-details-marker { display: none; }
.dropdown { position: relative; }
.dropdown summary { list-style: none; }
.dropdown-panel {
    position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; width: 280px;
    padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.dropdown-title { display: block; font-size: 13.5px; margin: 2px 4px 8px; }
.dropdown-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px;
    border: 0; border-radius: 8px; background: none; font: inherit; font-size: 13.5px;
    color: var(--text); text-align: left; cursor: pointer; text-decoration: none !important;
}
.dropdown-item:hover { background: var(--soft); }
.menu-toggle { display: none; }

.content { padding: 24px 28px 40px; width: 100%; max-width: 1400px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: -.4px; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; margin-bottom: 8px; }

/* Pestañas */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-size: 13.5px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

/* ---------- Métricas ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 26px; }
.kpi {
    display: block; position: relative; padding: 18px 18px 16px; border-radius: 14px;
    border: 1.5px solid; text-decoration: none !important; color: var(--text) !important; transition: transform .15s, box-shadow .15s;
}
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.kpi-title { font-weight: 700; font-size: 14px; }
.kpi-value { margin-top: 16px; font-size: 30px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi-icon { position: absolute; top: 14px; right: 14px; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: #fff; }
.kpi.blue { background: #eef5ff; border-color: #a9c9f6; }
.kpi.blue .kpi-value { color: #2f6fdb; } .kpi.blue .kpi-icon { background: #3b82f6; }
.kpi.yellow { background: #fff8e9; border-color: #f5cb7a; }
.kpi.yellow .kpi-value { color: #e2a012; } .kpi.yellow .kpi-icon { background: #f5a524; }
.kpi.green { background: #eefaf2; border-color: #8fdcaa; }
.kpi.green .kpi-value { color: #1f9d55; } .kpi.green .kpi-icon { background: #22c55e; }
.kpi.pink { background: #fdf0f3; border-color: #f2a9ba; }
.kpi.pink .kpi-value { color: #e0557a; } .kpi.pink .kpi-icon { background: #f0557a; }
.kpi.is-active { box-shadow: 0 0 0 3px rgba(99, 102, 241, .25); }

.metric { padding: 18px; border-radius: 16px; }
.metric + .metric { margin-top: 16px; }
.metric-top { display: flex; justify-content: space-between; align-items: flex-start; }
.metric-label { margin-top: 12px; font-size: 12.5px; color: #4b5563; }
.metric-value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.metric.lavender { background: #eef0fb; } .metric.lavender .metric-icon { color: #6366f1; }
.metric.rose { background: #fdeff3; } .metric.rose .metric-icon { color: #ec5f8a; }
.metric.mint { background: #eaf8f4; } .metric.mint .metric-icon { color: #2cc9a6; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
.stats.cols-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1200px) { .stats.cols-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stats.cols-5 { grid-template-columns: minmax(0, 1fr); } }
.stat { display: flex; align-items: center; gap: 14px; padding: 16px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.stat-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; }
.stat-icon.green { background: var(--green-soft); color: var(--green-dark); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-icon.gray { background: #f0f1f3; color: #4b5563; }
.stat-icon.blue { background: #eaf4fd; color: #0f5b93; }
.stat-icon.indigo { background: var(--primary-soft); color: var(--primary); }
.stat-icon.red { background: var(--red-soft); color: var(--red); }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 13px; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; }
.grid-2 > .card + .card, .grid-side > .card + .card { margin-top: 0; }
.grid-side { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.grid-fabrica { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; }
.grid-fabrica > .card + .card { margin-top: 0; }

.progress { height: 8px; background: #eef0f3; border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.progress.indigo > span { background: var(--primary); }
.split-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden; background: #eef0f3; min-width: 120px; }
.split-bar .s-exporta { background: var(--green); }
.split-bar .s-proceso { background: var(--orange); }
.split-bar .s-no { background: #cfd4dc; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); justify-content: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 170px; }
.chart-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.chart-tooltip {
    position: absolute; pointer-events: none; z-index: 5; min-width: 150px; padding: 12px 14px;
    background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); font-size: 12.5px; transition: opacity .1s;
}
.chart-tooltip strong { display: block; font-size: 18px; margin: 2px 0; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin: 0; min-width: 160px; flex: 1; }
.filters .field.grow { flex: 2; min-width: 220px; }

.details-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 24px; margin: 0; }
.details-grid dt { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.details-grid dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }

.pagination { display: flex; gap: 4px; justify-content: flex-end; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.pagination a, .pagination span {
    display: grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px;
    border-radius: 50%; color: var(--text); font-size: 12.5px; text-decoration: none;
}
.pagination a:hover { background: var(--soft); }
.pagination .current { background: var(--primary); color: #fff; }
.pager-info { margin-right: auto; font-size: 12.5px; color: var(--muted); }

.inline-form { display: inline; }
details.collapse > summary { list-style: none; cursor: pointer; }
details.collapse > summary::-webkit-details-marker { display: none; }

/* Menú de acciones (⋮) */
.kebab { position: relative; display: inline-block; }
.kebab summary { list-style: none; cursor: pointer; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); }
.kebab summary::-webkit-details-marker { display: none; }
.kebab summary:hover { background: var(--soft); color: var(--text); }
.kebab-panel { position: absolute; right: 0; top: 34px; z-index: 10; min-width: 150px; padding: 6px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); }

/* ---------- Feed de solicitudes ---------- */
.feed-group { margin: 16px 0 8px; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.feed-item { display: flex; gap: 10px; padding: 10px 0; }
.feed-body { flex: 1; min-width: 0; }
.feed-who { font-size: 13px; font-weight: 600; }
.feed-when { font-size: 11.5px; color: var(--muted); }
.feed-card { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: var(--soft); font-size: 12.5px; }
.feed-card strong { display: block; font-weight: 600; margin-bottom: 2px; }
.feed-file { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12.5px; color: var(--primary-dark); }
.prio-change { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; }

/* ---------- Mensajes ---------- */
.chat-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 0; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; min-height: 560px; background: #fff; }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; max-height: 70vh; }
.chat-list a { display: flex; gap: 10px; align-items: center; padding: 12px 14px; color: var(--text); text-decoration: none; border-bottom: 1px solid #f3f4f6; }
.chat-list a:hover { background: var(--soft); }
.chat-list a.active { background: var(--primary-soft); }
.chat-list .preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-list .unread { margin-left: auto; min-width: 20px; height: 20px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 6px; }
.chat-thread { display: flex; flex-direction: column; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-messages { flex: 1; padding: 18px; overflow-y: auto; max-height: 58vh; display: flex; flex-direction: column; gap: 10px; background: var(--soft); }
.bubble { max-width: 72%; padding: 10px 14px; border-radius: 14px; background: #fff; border: 1px solid var(--border); font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--primary); color: #fff; border-color: var(--primary); }
.bubble time { display: block; margin-top: 4px; font-size: 11px; opacity: .7; }
.chat-form { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--border); }
.chat-form textarea { flex: 1; min-height: 44px; height: 44px; resize: none; }

/* ---------- IA ---------- */
.ia-chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 480px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: #fff; }
.ia-messages { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; background: var(--soft); }
.ia-msg { max-width: 80%; padding: 12px 16px; border-radius: 14px; font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; }
.ia-msg.user { align-self: flex-end; background: var(--primary); color: #fff; white-space: pre-wrap; }
.ia-msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--border); }
.ia-msg.assistant p { margin: 0 0 8px; } .ia-msg.assistant p:last-child { margin: 0; }
.ia-msg.assistant ul, .ia-msg.assistant ol { margin: 0 0 8px; padding-left: 20px; }
.ia-msg.error { align-self: center; background: var(--red-soft); color: #9b1c1f; font-size: 13px; }
.ia-typing { align-self: flex-start; color: var(--muted); font-size: 13px; }
.ia-suggestions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.ia-suggestions button { border: 1px solid var(--border); background: #fff; border-radius: 999px; padding: 8px 14px; font: inherit; font-size: 13px; cursor: pointer; }
.ia-suggestions button:hover { border-color: var(--primary); color: var(--primary-dark); }
.ia-welcome { margin: auto; text-align: center; max-width: 520px; color: var(--muted); }
.ia-welcome .icon { color: var(--primary); }
.ia-welcome h2 { color: var(--text); font-size: 20px; margin: 10px 0 6px; }

/* ---------- Calendario ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.cal-dow { padding: 10px; background: var(--soft); font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; border-bottom: 1px solid var(--border); }
.cal-day { min-height: 108px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 12px; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.out { background: #fbfbfc; color: #b8bdc7; }
.cal-num { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; font-weight: 600; margin-bottom: 4px; }
.cal-day.today .cal-num { background: var(--primary); color: #fff; }
.cal-ev { display: block; margin-bottom: 3px; padding: 2px 6px; border-radius: 6px; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--primary-soft); color: var(--primary-dark); }
.cal-ev.t-auditoria { background: #fdeff3; color: #c23a64; }
.cal-ev.t-visita { background: #e9f3fe; color: #1f6fc0; }
.cal-ev.t-capacitacion { background: #eaf8f4; color: #0f766e; }
.cal-ev.t-embarque { background: #fff4e0; color: #a8660d; }
.cal-ev.t-vencimiento { background: var(--red-soft); color: #c0292d; }

/* ---------- Línea de tiempo ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 28px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .tl-dot { position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--primary); background: var(--primary); }
.timeline .tl-dot.green { box-shadow: 0 0 0 2px var(--green); background: var(--green); }
.timeline .tl-dot.red { box-shadow: 0 0 0 2px var(--red); background: var(--red); }
.timeline .tl-dot.amber { box-shadow: 0 0 0 2px var(--orange); background: var(--orange); }
.timeline .tl-dot.gray { box-shadow: 0 0 0 2px #9ca3af; background: #9ca3af; }

/* ---------- Tarjetas de personal ---------- */
.people { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.person-card { padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.person-card h3 { font-size: 15px; margin: 0; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.checks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px 12px; margin-top: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { padding: 3px 10px; border-radius: 999px; background: var(--soft); border: 1px solid var(--border); font-size: 12px; color: #374151; text-decoration: none !important; }

/* ---------- Medios (procedimiento de calidad) ---------- */
.media-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.media-grid video, .media-grid img { width: 100%; aspect-ratio: 16 / 11; object-fit: cover; border-radius: 14px; background: #111; display: block; }
.media-placeholder { display: grid; place-items: center; aspect-ratio: 16 / 11; border-radius: 14px; background: var(--soft); border: 2px dashed var(--border); color: var(--muted); text-align: center; padding: 16px; }
.section-title { text-align: center; font-size: 22px; font-weight: 800; margin: 40px 0 20px; }

/* 2FA */
.qr-box { display: inline-block; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 14px; }
.secret { font-family: ui-monospace, Consolas, monospace; font-size: 14px; letter-spacing: 1px; padding: 8px 12px; background: var(--soft); border-radius: 8px; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
.codes span { padding: 8px 10px; background: var(--soft); border-radius: 8px; text-align: center; }
.otp-input { letter-spacing: 10px; font-size: 22px !important; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- Instalador ---------- */
.install-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; background: var(--soft); }
.install-card { max-width: 600px; width: 100%; }
.install-card ul { padding-left: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
    .kpis, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-2, .grid-side { grid-template-columns: minmax(0, 1fr); }
    .details-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 960px) {
    .grid-fabrica { grid-template-columns: minmax(0, 1fr); }
    .metric-stack { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
    .metric-stack .metric + .metric { margin-top: 0; }
    .chat-layout { grid-template-columns: minmax(0, 1fr); }
    .chat-list { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--border); }
}
@media (max-width: 860px) {
    .sidebar { position: fixed; z-index: 40; left: 0; transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .15); }
    .app.nav-open .sidebar { transform: translateX(0); }
    .sidebar .brand img { width: 115px; }
    .btn-emergencia { width: 38px; padding: 0; margin-right: 4px; justify-content: center; }
    .btn-emergencia .btn-emergencia-texto { display: none; }
    .btn-emergencia .btn-emergencia-icono { background: none; box-shadow: none; }
    .menu-toggle { display: inline-grid; }
    .topbar { padding: 0 12px; gap: 6px; }
    .content { padding: 18px 16px 32px; }
    .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0, 1fr); }
    .table-wrap { margin: 0 -16px; padding: 0 16px; }
    .card { padding: 16px; }
    .media-grid { grid-template-columns: minmax(0, 1fr); }
    .cal-day { min-height: 70px; }
    .cal-ev { font-size: 10px; }
    .page-head h1 { font-size: 22px; }
    .dropdown-panel { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
}
@media (max-width: 560px) {
    .kpis, .stats, .metric-stack { grid-template-columns: minmax(0, 1fr); }
    .details-grid { grid-template-columns: minmax(0, 1fr); }
    .kpi-value { font-size: 26px; }
    .bubble, .ia-msg { max-width: 92%; }
    .topbar-search { max-width: none; }
    .topbar-search input { width: 100%; }
    .topbar-ayuda { display: none; } /* en el celular no entra: deja lugar al botón de emergencia y al avatar */
}
