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

:root {
    --bgbody: #f8fafc;
    --bgcard: #ffffff;
    --bordercolor: #e2e8f0;
    --textmain: #0f172a;
    --textmuted: #64748b;
    --colorprimary: #2563eb;
    --colorprimaryhover: #1d4ed8;
    --colorprimarylight: #eef2ff;
    --colorsuccess: #10b981;
    --colorwarning: #f59e0b;
    --colordanger: #ef4444;
    --colorpurple: #9333ea;
    --fontfamily: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --shadowsm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadowmd: 0 4px 12px rgba(0, 0, 0, 0.07);
    --shadowlg: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
    --radiusxl: 14px;
    --radiusmd: 8px;
    --radiussm: 6px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--fontfamily);
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: var(--fontfamily);
    background-color: var(--bgbody);
    color: var(--textmain);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
    transition: var(--transition);
}

button,
input,
select,
textarea {
    font-family: var(--fontfamily);
    font-size: 0.875rem;
}

.crmshell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOP BAR */
.crmtopbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    height: 64px;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--bordercolor);
    box-shadow: var(--shadowsm);
}

.crmbrandwrap {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.crmbrandlogo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #2563eb, #f97316);
    border-radius: var(--radiussm);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
    flex-shrink: 0;
}

.crmbrandtext {
    font-size: 1.18rem;
    letter-spacing: -0.02em;
}

.crmbranddark {
    font-weight: 800;
    color: #0f172a;
}

.crmbrandblue {
    font-weight: 700;
    color: var(--colorprimary);
}

.crmtopactions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.crmbcvpill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.32rem 0.85rem;
    background-color: #f1f5f9;
    border: 1px solid var(--bordercolor);
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #334155;
}

.crmplanbadge {
    display: inline-flex;
    align-items: center;
    padding: 0.32rem 0.75rem;
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
    border-radius: 9999px;
    font-size: 0.78rem;
    font-weight: 700;
}

.crmcopilotbtn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 0.95rem;
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
    color: #ffffff;
    border: none;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(236, 72, 153, 0.3);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.crmcopilotbtn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4);
}

.crmsearchinputwrap {
    position: relative;
    display: flex;
    align-items: center;
}

.crmsearchinput {
    width: 270px;
    padding: 0.45rem 2.2rem 0.45rem 0.85rem;
    background-color: #f8fafc;
    border: 1px solid var(--bordercolor);
    border-radius: var(--radiussm);
    font-size: 0.85rem;
    color: var(--textmain);
    outline: none;
    transition: border-color 0.15s, background-color 0.15s;
}

.crmsearchinput:focus {
    background-color: #ffffff;
    border-color: var(--colorprimary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.crmsearchkey {
    position: absolute;
    right: 0.6rem;
    padding: 0.15rem 0.35rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--textmuted);
    background-color: #e2e8f0;
    border-radius: 4px;
}

.crmuserwrap {
    position: relative;
}

.crmuserbtn {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radiussm);
    transition: background-color 0.15s;
}

.crmuserbtn:hover {
    background-color: #f1f5f9;
}

.crmuseravatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: #2563eb;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
}

.crmusername {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--textmain);
    line-height: 1.2;
}

.crmlayout {
    display: flex;
    flex: 1;
    min-height: calc(100vh - 64px);
}

/* SIDEBAR HOMOLOGADO AL SISTEMA ADMINISTRATIVO */
.crmsidebar {
    width: 256px;
    min-width: 256px;
    background-color: #ffffff;
    border-right: 1px solid var(--bordercolor);
    padding: 1rem 0.75rem 0.75rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1), padding 0.25s ease;
    overflow-x: hidden;
    overflow-y: auto;
    user-select: none;
}

/* Sidebar Company Box */
.crmsidebarcompanybox {
    margin-bottom: 0.65rem;
    cursor: pointer;
}

.crmsidebarcompanytitle {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    padding: 0.2rem 0.25rem 0.35rem;
}

.crmsidebarcompanybadge {
    padding: 0.5rem 0.75rem;
    background: #eef2ff;
    color: #4338ca;
    font-weight: 700;
    border-radius: var(--radiussm);
    font-size: 0.85rem;
    border: 1px solid #e0e7ff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    transition: background-color 0.15s ease;
}

.crmsidebarcompanybadge:hover {
    background: #e0e7ff;
}

.crmsidebarcompanyname {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crmsidebarcompanytax {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

/* Botón Contraer / Expandir Todos los Submenús */
.crmsidebarcollapseallcontainer {
    margin: 0.25rem 0 0.75rem 0;
}

.crmsidebarcollapseallbtn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.42rem 0.65rem;
    background: #f8fafc;
    border: 1px solid var(--bordercolor);
    border-radius: var(--radiussm);
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--textmuted);
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    line-height: 1;
}

.crmsidebarcollapseallbtn:hover {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: var(--colorprimary);
    transform: translateY(-1px);
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.08);
}

.crmsidebarcollapseallbtn:active {
    transform: translateY(0);
}

/* Grupos Retráctiles de Menú */
.crmsidebargroup {
    margin-bottom: 0.15rem;
}

.crmsidebargroupheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    border-radius: 7px;
    padding: 0.48rem 0.65rem;
    font-size: 0.76rem;
    font-weight: 700;
    color: #475569;
    letter-spacing: 0.035em;
    text-transform: uppercase;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.crmsidebargroup:not(.collapsed)>.crmsidebargroupheader {
    color: #0f172a;
}

.crmsidebargroupheader:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.crmgroupchevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: #94a3b8;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease;
    flex-shrink: 0;
}

.crmsidebargroupheader:hover .crmgroupchevron,
.crmsidebargroup:not(.collapsed)>.crmsidebargroupheader .crmgroupchevron {
    color: #475569;
}

.crmsidebargroup.collapsed .crmgroupchevron {
    transform: rotate(-90deg);
}

.crmsidebargroupitems {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 2px;
    margin-bottom: 0.35rem;
}

.crmsidebargroup.collapsed .crmsidebargroupitems {
    display: none;
}

/* Items individuales del menú */
.crmsidebaritem {
    display: flex;
    align-items: center;
    gap: 0.68rem;
    padding: 0.46rem 0.65rem;
    color: #1e293b;
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.35;
    border-radius: 7px;
    transition: background-color 0.14s ease, color 0.14s ease;
    text-decoration: none;
    cursor: pointer;
}

.crmsidebartext {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.crmsidebaricon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: #64748b;
    transition: color 0.14s ease;
}

.crmsidebaricon svg,
.crmsidebaricon.lucide,
.crmsidebaricon [data-lucide] {
    width: 17px;
    height: 17px;
    stroke-width: 1.75;
    stroke: currentColor;
}

.crmsidebaritem:hover {
    background-color: #f1f5f9;
    color: #0f172a;
}

.crmsidebaritem:hover .crmsidebaricon {
    color: #334155;
}

.crmsidebaritem.active {
    background-color: #f1f5f9;
    color: #0f172a;
    font-weight: 600;
}

.crmsidebaritem.active .crmsidebaricon {
    color: var(--colorprimary);
}

/* Barra inferior del Sidebar (Comprimir / Expandir) */
.crmsidebarfooterbar {
    margin-top: auto;
    padding-top: 0.65rem;
    border-top: 1px solid var(--bordercolor);
    display: flex;
    align-items: center;
}

.crmsidebarfootertogglebtn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.42rem 0.55rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 7px;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    width: 100%;
}

.crmsidebarfootertogglebtn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.crmsidebarfootertogglebtn svg {
    flex-shrink: 0;
    color: #475569;
}

/* Modo Comprimido del Sidebar */
.crmsidebar.collapsed {
    width: 76px;
    min-width: 76px;
    padding: 0.75rem 0.35rem 2rem 0.35rem;
}

.crmsidebar.collapsed .crmsidebarcompanybox,
.crmsidebar.collapsed .crmsidebarcollapseallcontainer,
.crmsidebar.collapsed .crmsidebarfootertoggletext,
.crmsidebar.collapsed .crmsidebargroupheader span:first-child,
.crmsidebar.collapsed .crmgroupchevron,
.crmsidebar.collapsed .crmsidebartext {
    display: none !important;
}

.crmsidebar.collapsed .crmsidebargroupitems {
    display: flex !important;
    align-items: center;
}

.crmsidebar.collapsed .crmsidebaritem {
    justify-content: center;
    padding: 0.5rem 0;
    width: 100%;
}

.crmsidebar.collapsed .crmsidebarfootertogglebtn {
    justify-content: center;
    padding: 0.4rem 0;
}

/* MAIN CONTENT */
.crmmaincontainer {
    flex: 1;
    min-width: 0;
    padding: 1.5rem 1.75rem;
    overflow-y: auto;
}

/* CARDS */
.crmcard {
    background-color: var(--bgcard);
    border: 1px solid var(--bordercolor);
    border-radius: var(--radiusxl);
    box-shadow: var(--shadowsm);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

/* BUTTONS */
.crmbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.48rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radiussm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}

.crmbtnprimary {
    background-color: var(--colorprimary);
    color: #ffffff;
}

.crmbtnprimary:hover {
    background-color: var(--colorprimaryhover);
}

.crmbtnsecondary {
    background-color: #ffffff;
    border-color: var(--bordercolor);
    color: #334155;
}

.crmbtnsecondary:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.crmbtndanger {
    background-color: var(--colordanger);
    color: #ffffff;
}

.crmbtndanger:hover {
    background-color: #dc2626;
}

/* TABLES */
.crmtablewrapper {
    overflow-x: auto;
    border: 1px solid var(--bordercolor);
    border-radius: var(--radiusxl);
    background-color: #ffffff;
}

.crmtable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    text-align: left;
}

.crmtable th {
    background-color: #f8fafc;
    padding: 0.75rem 1rem;
    font-weight: 700;
    color: #475569;
    border-bottom: 1px solid var(--bordercolor);
    white-space: nowrap;
}

.crmtable td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--bordercolor);
    color: var(--textmain);
}

.crmtable tr:last-child td {
    border-bottom: none;
}

.crmtable tr:hover td {
    background-color: #f8fafc;
}

/* COMPACT RESPONSIVE TABLE OVERRIDES */
#crmsellerstable th,
#crmsellerstable td,
#crmleadstable th,
#crmleadstable td {
    padding: 0.55rem 0.65rem;
}

/* BADGES */
.crmbadge {
    display: inline-flex;
    align-items: center;
    padding: 0.22rem 0.55rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.crmbadggreen {
    background-color: #ecfdf5;
    color: #065f46;
}

.crmbadgblue {
    background-color: #eff6ff;
    color: #1e40af;
}

.crmbadgamber {
    background-color: #fffbeb;
    color: #92400e;
}

.crmbadgred {
    background-color: #fef2f2;
    color: #991b1b;
}

.crmbadgpurple {
    background-color: #faf5ff;
    color: #6b21a8;
}

.crmbadggray {
    background-color: #f1f5f9;
    color: #475569;
}

/* MODALS */
.crmmodalbackdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.crmmodalbackdrop.active {
    display: flex;
}

.crmmodalbox {
    background-color: var(--bgcard);
    border-radius: var(--radiusxl);
    width: 90%;
    max-width: 520px;
    box-shadow: var(--shadowlg);
    border: 1px solid var(--bordercolor);
    overflow: hidden;
    animation: modalappear 0.2s ease-out;
}

.crmmodalheader {
    padding: 1.15rem 1.5rem;
    border-bottom: 1px solid var(--bordercolor);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.crmmodaltitle {
    font-size: 1.05rem;
    font-weight: 700;
}

.crmmodalbody {
    padding: 1.5rem;
    max-height: 75vh;
    overflow-y: auto;
}

.crmmodalfooter {
    padding: 0.9rem 1.5rem;
    border-top: 1px solid var(--bordercolor);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    background-color: #f8fafc;
}

/* FORMS */
.crmformgroup {
    margin-bottom: 1.1rem;
}

.crmformlabel {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.35rem;
}

.crmforminput,
.crmformselect,
.crmformtextarea {
    width: 100%;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--bordercolor);
    border-radius: var(--radiussm);
    background-color: #ffffff;
    color: var(--textmain);
    outline: none;
    font-size: 0.875rem;
    transition: border-color 0.15s;
}

.crmforminput:focus,
.crmformselect:focus,
.crmformtextarea:focus {
    border-color: var(--colorprimary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* TOASTS */
.crmtoastcontainer {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.crmtoast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1.25rem;
    background-color: #0f172a;
    color: #ffffff;
    border-radius: var(--radiussm);
    font-size: 0.875rem;
    box-shadow: var(--shadowlg);
    animation: toastslide 0.25s ease-out;
}

.crmtoastsuccess {
    background-color: #065f46;
}

.crmtoasterror {
    background-color: #991b1b;
}

@keyframes modalappear {
    from {
        transform: scale(0.96);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes toastslide {
    from {
        transform: translateY(15px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}