@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #E4003A;
    --primary-dark: #b3002d;
    --secondary: #9B1745;
    --text: #333333;

    /* Alias usados por el diseño del login (mismo set de colores de marca) */
    --color-primary: #E4003A;
    --color-secondary: #9B1745;
    --color-dark: #1a1a1a;
    --color-text: #333333;
    --color-text-soft: #6b7280;
    --color-bg-soft: #fdf2f4;
    --color-border: #e5e7eb;
    --radius: 12px;
    --shadow: 0 10px 30px rgba(0,0,0,0.08);

    /* Identidad visual 2026-09-28 — dirección "empresarial", ver mockup aprobado */
    --sidebar-bg-start: #450c22;
    --sidebar-bg-end: #2f0817;
    --sidebar-text: #e9c3d0;
    --sidebar-text-dim: #9d5a71;
    --ink: #14161a;
    --ink-soft: #4b5058;
    --muted: #8b909a;
    --muted-soft: #9aa0ab;
    --surface: #f5f6f8;
    --line: #eceef1;
    --line-soft: #f2f3f5;
    --tint-primary: rgba(228,0,58,.08);
    /* --status-good corregido 2026-10-15: el valor original (#15803d)
       no lo usaba ningún archivo — el verde real que SÍ se repite a
       mano en 27 archivos del sistema (botones de "ganado", textos de
       éxito, etc.) es #1e7a34. Se corrige la variable para que
       coincida con el estándar real ya en uso, no con un valor
       huérfano que nadie llegó a consumir. */
    --status-good: #1e7a34;
    --status-good-bg: #ecfdf3;
    --status-bad: #b3261e;
    --status-bad-bg: #fdecea;
    --status-neutral: #4b5058;
    --status-neutral-bg: #f2f3f5;
    /* --status-warn nueva 2026-10-15 — el ámbar #b58900 ya se repetía
       a mano en 25 archivos (etapas "en curso"/pendientes) sin tener
       nunca una variable propia, a diferencia de good/bad/neutral. */
    --status-warn: #b58900;
    --status-warn-bg: #fdf6e3;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Montserrat', -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: var(--surface);
    color: var(--text);
}

.logo { display: block; margin: 0 auto 1.2rem; max-width: 160px; height: auto; }
.logo-small { height: 28px; width: auto; display: block; }

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--color-bg-soft, #fdf2f4);
}
.auth-logo { display: block; margin: 0 auto 1.2rem; max-width: 150px; width: 100%; height: auto; }

.auth-box {
    max-width: 380px;
    width: 90%;
    margin: 6vh auto;
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}
.auth-box h1 { margin: 0 0 0.25rem; font-size: 1.3rem; text-align: center; color: var(--text); font-weight: 700; }
.auth-box p { color: #666; margin-top: 0; text-align: center; font-size: 0.95rem; }

label { display: block; margin-top: 1rem; margin-bottom: 0.25rem; font-size: 0.9rem; color: var(--text); font-weight: 500; }
input, select, textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #d5d8dd;
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(228,0,58,0.12);
}

button, .btn {
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.75rem;
    border: none;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
}
button:hover, .btn:hover { background: var(--secondary); }

.msg-error { background: #fdeaea; color: #b3261e; padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.9rem; }
.msg-ok { background: #e8f6ec; color: #1e7a34; padding: 0.6rem 0.8rem; border-radius: 6px; font-size: 0.9rem; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--secondary);
    color: #fff;
    padding: 0.9rem 1.5rem;
    font-size: 0.95rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.topbar-brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; letter-spacing: 0.3px; }
.topbar a { color: #ffd9e2; text-decoration: none; }
.topbar a:hover { text-decoration: underline; }

.content { max-width: 900px; margin: 2rem auto; padding: 0 1.5rem; }
.wide-box { max-width: 900px; margin: 2rem auto; background:#fff; padding:2rem; border-radius:14px; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(16,24,40,.04); }

.cards { display: flex; gap: 1rem; margin-top: 1.5rem; flex-wrap: wrap; }
.card {
    background: #fff;
    border-radius: 14px;
    padding: 1.5rem;
    flex: 1 1 140px;
    min-width: 140px;
    border: 1px solid var(--line);
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
    text-align: center;
}
.card h2 { margin: 0; font-size: 2rem; color: var(--primary); }
.card p { margin: 0.3rem 0 0; color: #666; }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.7rem 0.6rem; border-bottom: 1px solid var(--line-soft); }
th {
    color: var(--muted-soft); font-weight: 700; font-size: 0.68rem;
    text-transform: uppercase; letter-spacing: 0.06em; background: #fafbfc;
}
tbody tr:hover { background: #fafbfc; }
code { background: #f2f2f2; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; background: #fff; border-radius: 14px; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.table-scroll table { margin-top: 0; }
.table-scroll th:first-child, .table-scroll td:first-child { padding-left: 1.2rem; }
.table-scroll th:last-child, .table-scroll td:last-child { padding-right: 1.2rem; }

/* ---------- Badges de estado (pills) ---------- */
.badge {
    display: inline-flex; align-items: center; font-size: 0.7rem; font-weight: 700; white-space: nowrap;
    padding: 3px 10px; border-radius: 999px; background: var(--status-neutral-bg); color: var(--status-neutral);
}
.badge.badge-primary { background: var(--tint-primary); color: var(--primary); }
.badge.badge-good { background: var(--status-good-bg); color: var(--status-good); }
.badge.badge-bad { background: var(--status-bad-bg); color: var(--status-bad); }
.badge.badge-warn { background: var(--status-warn-bg); color: var(--status-warn); }

/* ---------- Pantallas de detalle de 2 columnas (lead_view.php,
   opportunity_view.php) — el ancho de cada columna SÍ varía según el
   contenido de cada pantalla, así que .lead-grid queda sin
   grid-template-columns aquí; cada página solo define esa una línea
   localmente. ---------- */
.lead-grid { display:grid; gap:1.2rem; align-items:start; }
@media (max-width: 800px) { .lead-grid { grid-template-columns: 1fr; } }
.lead-grid .panel + .panel, .panel + .panel { margin-top: 1.2rem; }
.panel h3 { margin-top:0; color:var(--secondary); font-size:0.95rem; text-transform:uppercase; letter-spacing:0.03em; }
.info-row { display:flex; justify-content:space-between; padding:0.4rem 0; border-bottom:1px solid #f0f0f0; font-size:0.9rem; }
.info-row span:first-child { color:#888; }

.avatar-badge {
    width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.68rem; font-weight: 700; background: var(--tint-primary); color: var(--primary);
}

/* ---------- Layout con menú lateral fijo ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 258px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-bg-start), var(--sidebar-bg-end));
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 20;
    overflow: hidden; /* el scroll vive en .sidebar-nav, no acá — así logo/footer quedan fijos */
}
.sidebar-logo {
    padding: 1.5rem 1.3rem 1.2rem; flex-shrink: 0; display: flex; align-items: center; gap: 0.7rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-logo img { height: 24px; width: auto; display: block; }

.sidebar-nav {
    display: flex; flex-direction: column; padding: 0.9rem 0.7rem; gap: 1.1rem;
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* imprescindible en un flex column para que el hijo SÍ pueda encogerse y scrollear */
}
.nav-section { display: flex; flex-direction: column; gap: 2px; }
.nav-section-label {
    padding: 0 0.6rem 0.4rem; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.09em;
    text-transform: uppercase; color: var(--sidebar-text-dim);
}
.sidebar-footer { flex-shrink: 0; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 0.65rem;
    padding: 0.6rem 0.7rem; border-radius: 9px;
    color: var(--sidebar-text); text-decoration: none; font-size: 0.87rem; font-weight: 500;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.07); color: #fff; }
.sidebar-nav a.active {
    background: var(--primary); color: #fff; font-weight: 600;
    box-shadow: 0 4px 12px rgba(228,0,58,.35);
}
.sidebar-nav a.disabled { opacity: 0.4; cursor: not-allowed; }
.sidebar-nav a.disabled:hover { background: none; color: var(--sidebar-text); }
.nav-icon { display: flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex-shrink: 0; }
.nav-icon svg { width: 100%; height: 100%; }

/* Selector de idioma (ítem 18, piloto 2026-10-02) — arriba del pie del
   menú, mismo criterio visual que el resto del sidebar (fondo oscuro,
   texto tenue, el idioma activo resaltado en rojo de marca). */
.sidebar-lang-switch {
    flex-shrink: 0; display: flex; gap: 0.4rem; padding: 0 1.1rem 0.7rem;
}
.sidebar-lang-switch a {
    flex: 1; text-align: center; padding: 0.35rem 0; border-radius: 7px;
    font-size: 0.74rem; font-weight: 700; text-decoration: none;
    color: var(--sidebar-text-dim); border: 1px solid rgba(255,255,255,0.12);
}
.sidebar-lang-switch a.active { background: var(--primary); color: #fff; border-color: transparent; }
.sidebar-footer { padding: 0.9rem 1.1rem 1.1rem; border-top: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; gap: 0.6rem; }
.sidebar-avatar {
    width: 32px; height: 32px; border-radius: 999px; background: var(--primary); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700; color: #fff;
}
.sidebar-user { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.sidebar-user strong { font-size: 0.82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { font-size: 0.7rem; color: var(--sidebar-text-dim); }
.sidebar-logout { color: var(--sidebar-text); flex-shrink: 0; display: flex; align-items: center; }
.sidebar-logout svg { width: 16px; height: 16px; }
.sidebar-logout:hover { color: #fff; }

.sidebar-toggle {
    display: none; align-items: center; justify-content: center;
    position: fixed; top: 0.9rem; left: 0.9rem; z-index: 30;
    width: 40px; height: 40px; border-radius: 8px; border: none;
    background: var(--secondary); color: #fff; cursor: pointer;
}

.main-area { margin-left: 258px; flex: 1; padding: 2rem 2.2rem; min-width: 0; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { margin: 0; font-size: 1.4rem; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }
.page-header p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.88rem; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.2s ease; width: 250px; }
    .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.2); }
    .sidebar-toggle { display: flex; }
    .main-area { margin-left: 0; padding: 4.5rem 1.2rem 1.5rem; }
}

/* ---------- Tarjetas de KPI y gráficas ---------- */
/* grid (no flex) + auto-fill: con flex-wrap, una tarjeta sola en la
   última fila (ej. 9 KPIs en 2 filas de 7+1) se estiraba a todo el
   ancho por flex-grow — auto-fill deja las columnas vacías vacías en
   vez de repartir el espacio, y el ancho base más grande reduce
   cuántas columnas entran por fila (2026-09-29, pedido del usuario). */
.kpi-row { display:grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap:1rem; margin-bottom:1.5rem; }
.kpi-card {
    background:#fff; border-radius:14px; padding:1.15rem 1.3rem;
    border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(16,24,40,.04);
    display: block; text-decoration: none; color: inherit;
}
.kpi-card h2 { margin:0.7rem 0 0; font-size:1.75rem; font-weight: 800; color:var(--ink); }
.kpi-card p { margin:0.15rem 0 0; color:var(--muted); font-size:0.83rem; }
a.kpi-card { cursor: pointer; transition: box-shadow .15s ease, transform .15s ease; }
a.kpi-card:hover { box-shadow: 0 2px 4px rgba(16,24,40,.06), 0 10px 24px rgba(16,24,40,.09); transform: translateY(-1px); }
.kpi-icon {
    width: 38px; height: 38px; border-radius: 10px; background: var(--tint-primary);
    display: flex; align-items: center; justify-content: center; color: var(--primary);
}
.kpi-icon svg { width: 18px; height: 18px; }
.kpi-delta {
    display: inline-flex; align-items: center; gap: 4px; margin-top: 0.6rem;
    padding: 3px 9px; border-radius: 999px; font-size: 0.68rem; font-weight: 700;
    background: var(--status-neutral-bg); color: var(--status-neutral);
}
.kpi-delta.up { background: var(--status-good-bg); color: var(--status-good); }
.kpi-delta.down { background: var(--status-bad-bg); color: var(--status-bad); }
.kpi-delta svg { width: 11px; height: 11px; }

.charts-grid { display:grid; grid-template-columns: 1.3fr 1fr; gap:1.2rem; margin-bottom:1.5rem; }
@media (max-width: 900px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-card { background:#fff; border-radius:14px; padding:1.4rem; border: 1px solid var(--line); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.chart-card h3 { margin:0 0 1rem; font-size:0.78rem; font-weight: 700; color:var(--ink); text-transform:uppercase; letter-spacing:0.05em; }
.chart-card canvas { max-height: 260px; }

.activity-feed { list-style:none; margin:0; padding:0; }
.activity-feed li { padding:0.6rem 0; border-bottom:1px solid #f0f0f0; font-size:0.85rem; }
.activity-feed li:last-child { border-bottom:none; }
.activity-feed .when { color:#999; font-size:0.75rem; display:block; }

/* ---------- Componentes compartidos de listas/bandejas/formularios
   (2026-10-07) — consolidados acá desde ~20 archivos que cada uno
   redefinía su propia copia local, casi idéntica, de estas mismas
   reglas. Objetivo: un solo lugar de verdad, nunca un `<style>` local
   que reinvente lo que ya existe acá. ---------- */
.panel { background:#fff; border-radius:10px; padding:1.5rem; box-shadow:0 2px 8px rgba(0,0,0,.06); }

.case-card { background:#fff; border-radius:10px; padding:1.2rem 1.3rem; margin-bottom:1rem; box-shadow:0 2px 8px rgba(0,0,0,.06); border-left:4px solid var(--line); }
.case-card h3 { margin:0 0 0.3rem; }
.case-meta { color:#888; font-size:0.85rem; margin-bottom:0.6rem; }

.actions-row { display:flex; gap:0.6rem; align-items:center; margin-top:0.8rem; flex-wrap:wrap; }
.actions-row input, .actions-row select { padding:0.5rem; border:1px solid #d5d8dd; border-radius:6px; }
.actions-row input[type="text"] { flex:1; min-width:180px; }
.actions-row button { width:auto; margin:0; padding:0.55rem 1.1rem; }

.ok-sla { background:#e8f6ec; color:#1e7a34; padding:0.6rem 0.9rem; border-radius:6px; font-size:0.85rem; margin-bottom:1rem; }
.alert-sla { background:#fdeaea; color:#b3261e; padding:0.6rem 0.9rem; border-radius:6px; font-size:0.85rem; margin-bottom:1rem; }

.filters-panel { background:#fff; border-radius:10px; padding:1rem 1.2rem; margin-bottom:1rem; box-shadow:0 2px 8px rgba(0,0,0,.06); }
.filters-grid { display:grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap:0.6rem 1rem; align-items:end; }
.filters-grid label { font-size:0.78rem; color:#666; display:block; margin-bottom:0.15rem; }
.filters-grid input, .filters-grid select { width:100%; padding:0.45rem; border:1px solid #d5d8dd; border-radius:6px; }
.filters-actions { margin-top:0.8rem; display:flex; gap:0.6rem; flex-wrap:wrap; }

.material-card { background:#fff; border-radius:14px; padding:1.5rem; border:1px solid var(--line); box-shadow:0 1px 2px rgba(16,24,40,.04); margin-bottom:1.2rem; }

/* Mismo patrón de grid de 2 columnas que 3 archivos tenían con 3
   nombres distintos (.form-grid/.edit-grid/.approve-grid) para
   exactamente lo mismo — unificado acá bajo un solo nombre. */
.form-grid { display:grid; grid-template-columns: 1fr 1fr; gap:0.7rem 1.2rem; }
.form-grid label { font-size:0.85rem; color:#666; display:block; margin-bottom:0.3rem; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

.btn-inline { width:auto; margin:0; padding:0.55rem 1.1rem; }
.btn-secondary { background:#6c7280; width:auto; margin:0; padding:0.55rem 1.1rem; }
.btn-secondary:hover { background:#565b66; }
.btn-approve { background:#1e7a34; }
.btn-reject { background:#b3261e; }

.security-note { display:flex; gap:0.7rem; align-items:flex-start; background:#fff6e5; border:1px solid #f0d58a; color:#7a5b00; border-radius:10px; padding:0.8rem 1rem; margin-bottom:1rem; font-size:0.84rem; }
.checkbox-row { display:flex; align-items:center; gap:0.5rem; margin-top:0.8rem; }
.coming-soon { display:flex; align-items:center; gap:0.8rem; color:#9aa0ab; font-size:0.88rem; padding:0.8rem; background:#fafbfc; border-radius:8px; border:1px dashed #e0e2e6; }


@media (max-width: 640px) {
    .auth-box { margin: 4vh auto; padding: 1.5rem; width: 92%; }
    .topbar { padding: 0.8rem 1rem; font-size: 0.85rem; }
    .content, .wide-box { padding: 0 1rem; margin: 1.2rem auto; }
    .wide-box { padding: 1.25rem; }
    .cards { gap: 0.75rem; }
    .card { min-width: 100px; padding: 1rem; }
    .card h2 { font-size: 1.5rem; }
    table { font-size: 0.8rem; }
    th, td { padding: 0.45rem 0.35rem; }
}
