@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&family=Fraunces:opsz,wght@9..144,400;9..144,500&display=swap');

:root {
    --bg: #FAF8F4;
    --surface: #FFFFFF;
    --surface-alt: #F5F1EA;
    --border: #E8E1D3;
    --border-strong: #D4CAB6;

    --text: #1F1B16;
    --text-muted: #6B6157;
    --text-dim: #9A9086;

    --brand: #B08D57;
    --brand-dark: #8B6D3F;
    --brand-soft: rgba(176, 141, 87, 0.1);

    --success: #3D7A4E;
    --success-soft: rgba(61, 122, 78, 0.1);
    --warn: #C77A2E;
    --warn-soft: rgba(199, 122, 46, 0.12);
    --danger: #B04A34;
    --danger-soft: rgba(176, 74, 52, 0.1);
    --info: #4A6B8A;
    --info-soft: rgba(74, 107, 138, 0.1);

    --sidebar-bg: #1F1B16;
    --sidebar-text: rgba(255, 255, 255, 0.75);
    --sidebar-active: #B08D57;

    /* Usada por los hero oscuros de clientes, cotizador, finanzas y reportes.
       Faltaba definirla: el degradado quedaba inválido y el texto blanco caía
       sobre fondo blanco. */
    --carbon: #1F1B16;

    --sans: 'Inter', -apple-system, system-ui, sans-serif;
    --mono: 'IBM Plex Mono', monospace;
    --display: 'Fraunces', Georgia, serif;

    --radius: 6px;
    --radius-sm: 4px;

    --shadow-sm: 0 1px 2px rgba(31, 27, 22, 0.04);
    --shadow: 0 1px 3px rgba(31, 27, 22, 0.06), 0 1px 2px rgba(31, 27, 22, 0.04);
}

/* Tema oscuro — override de tokens en runtime */
:root[data-theme="dark"] {
    --bg: #17140F;
    --surface: #1F1B16;
    --surface-alt: #2A241E;
    --border: #352E26;
    --border-strong: #4A4137;

    --text: #F5EFE6;
    --text-muted: #B5AA9C;
    --text-dim: #8A7F73;

    --brand: #C9AB7C;
    --brand-dark: #B08D57;
    --brand-soft: rgba(201, 171, 124, 0.14);

    --success: #6FBF84;
    --success-soft: rgba(111, 191, 132, 0.14);
    --warn: #E0A15C;
    --warn-soft: rgba(224, 161, 92, 0.16);
    --danger: #E58270;
    --danger-soft: rgba(229, 130, 112, 0.14);
    --info: #7FA8CC;
    --info-soft: rgba(127, 168, 204, 0.14);

    --sidebar-bg: #100E0B;
    --carbon: #100E0B;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
}
:root[data-theme="dark"] .kpi-spark polyline { opacity: 0.9; }
:root[data-theme="dark"] img { filter: brightness(0.92); }

/* En oscuro el fondo de .btn-primary se aclara: el texto debe oscurecerse
   para no perder contraste (WCAG AA). */
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .btn-primary:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: #17140F;
}
:root[data-theme="dark"] .sidebar-nav a.active { color: #fff; }
:root[data-theme="dark"] .table thead th { background: var(--surface-alt); }
:root[data-theme="dark"] .pill-neutral { background: var(--surface-alt); color: var(--text-muted); }

/* Toast compartido (lo crea portal.js si la página no trae uno) */
.success-toast {
    position: fixed;
    bottom: 22px;
    right: 22px;
    z-index: 1200;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.85rem 1.1rem;
    background: var(--sidebar-bg);
    color: #fff;
    border-radius: var(--radius);
    font-family: var(--sans);
    font-size: 0.85rem;
    max-width: min(420px, calc(100vw - 24px));
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px);
    transition: opacity .22s, transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s .22s;
}
.success-toast.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
    transition: opacity .22s, transform .28s cubic-bezier(.2,.8,.2,1), visibility 0s;
}
.success-toast .check { color: #4ade80; font-weight: 700; flex-shrink: 0; }

@media (max-width: 900px) {
    .success-toast { left: 12px; right: 12px; bottom: 78px; max-width: none; }
}

/* Estado activo de grupos toggleables (período / filtros) */
[data-toggle-item].is-active {
    background: var(--surface-alt);
    border-color: var(--border-strong);
    color: var(--text);
    font-weight: 600;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--sans);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { color: var(--brand); }

/* LAYOUT */
.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

/* La barra inferior es solo de móvil. Sin esta regla base queda SIN estilo
   en escritorio y se dibuja como links sueltos al final del body: se nota
   apenas el contenido no llena la pantalla. Todas sus demás reglas viven
   dentro de @media (max-width: 900px). */
.mobile-bottom-nav { display: none; }

/* SIDEBAR */
.sidebar {
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1rem;
}
.sidebar-brand a {
    font-family: var(--display);
    font-size: 1.2rem;
    color: #fff;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-weight: 500;
}
.sidebar-brand small {
    display: block;
    font-family: var(--mono);
    font-size: 0.65rem;
    color: rgba(255,255,255,0.4);
    letter-spacing: 0.1em;
    margin-top: 0.25rem;
    text-transform: uppercase;
}

.sidebar-section {
    padding: 1rem 0 0.5rem;
}
.sidebar-label {
    font-family: var(--mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    color: rgba(255,255,255,0.35);
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
}

.sidebar-nav {
    list-style: none;
}
.sidebar-nav a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.5rem;
    color: var(--sidebar-text);
    font-size: 0.87rem;
    font-weight: 400;
    /* Explícito en vez de `all`: `all` anima también propiedades de layout
       y encarece cada hover sin necesidad. */
    transition: background 0.15s, color 0.15s;
}
/* El indicador de activo va en ::before para poder animarlo desde el centro;
   como border-left no se podía. */
.sidebar-nav a::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 2px;
    height: 0;
    background: var(--sidebar-active);
    border-radius: 0 2px 2px 0;
    transform: translateY(-50%);
    transition: height 0.18s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sidebar-nav a.active::before { height: 60%; }
.sidebar-nav a:hover::before { height: 30%; background: rgba(255, 255, 255, 0.25); }
.sidebar-nav a.active:hover::before { height: 60%; background: var(--sidebar-active); }
.sidebar-nav a svg {
    stroke-width: 1.5;
    color: currentColor;
    opacity: 0.75;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.sidebar-nav a:hover svg { opacity: 1; }
.sidebar-nav a.active svg { opacity: 1; color: var(--sidebar-active); }
.sidebar-nav a:hover {
    background: rgba(255,255,255,0.04);
    color: #fff;
}
.sidebar-nav a.active {
    background: rgba(176, 141, 87, 0.15);
    color: #fff;
    font-weight: 500;
}
.sidebar-nav .icon {
    width: 16px;
    height: 16px;
    opacity: 0.7;
    flex-shrink: 0;
}
.sidebar-nav a.active .icon { opacity: 1; }
/* Texto oscuro sobre el dorado: blanco sobre --brand da ~2.8:1 y no pasa
   AA en un tamaño de 0.65rem. Con el carbón del sidebar sube a ~5.5:1. */
.sidebar-nav .badge {
    margin-left: auto;
    background: var(--brand);
    color: var(--sidebar-bg);
    font-family: var(--mono);
    font-size: 0.65rem;
    line-height: 1;
    padding: 0.2rem 0.4rem;
    border-radius: 10px;
    font-weight: 600;
}

.sidebar-user {
    margin-top: auto;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 0.75rem;
    font-weight: 600;
}
.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}
.sidebar-user .user-name {
    color: #fff;
    font-size: 0.82rem;
    font-weight: 500;
}
.sidebar-user .user-role {
    color: rgba(255,255,255,0.5);
    font-size: 0.7rem;
}

/* ------------------------------------------------------
   Sidebar: accesibilidad y detalles que faltaban
   ------------------------------------------------------ */

/* Sin esto, navegar con Tab por el sidebar no muestra NADA: el anillo por
   defecto del navegador es azul y se pierde sobre el fondo oscuro. */
.sidebar a:focus-visible,
.sidebar button:focus-visible {
    outline: 2px solid var(--sidebar-active);
    outline-offset: -2px;
    border-radius: 2px;
}
.sidebar-brand a:focus-visible { outline-offset: 2px; }

/* Scrollbar fina y a tono: la del sistema aparece clara y ancha sobre el
   panel oscuro cuando el menú no cabe. */
.sidebar { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.18) transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    border-radius: 3px;
}
.sidebar:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.24); }

/* El bloque de usuario se lee como interactivo: hoy no responde a nada. */
.sidebar-user {
    cursor: pointer;
    transition: background 0.15s;
}
.sidebar-user:hover { background: rgba(255, 255, 255, 0.04); }
.sidebar-user .avatar { flex-shrink: 0; }

/* La marca también responde al hover. */
.sidebar-brand a { transition: color 0.15s; }
.sidebar-brand a:hover { color: var(--sidebar-active); }

@media (prefers-reduced-motion: reduce) {
    .sidebar-nav a,
    .sidebar-nav a::before,
    .sidebar-user,
    .sidebar-brand a { transition: none; }
}


/* MAIN */
.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    gap: 2rem;
}

.breadcrumb {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.breadcrumb strong {
    color: var(--text);
    font-weight: 600;
}

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

.search {
    position: relative;
    width: 320px;
}
.search input {
    width: 100%;
    padding: 0.55rem 0.75rem 0.55rem 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--sans);
    font-size: 0.85rem;
    background: var(--bg);
    color: var(--text);
}
.search input:focus { outline: none; border-color: var(--brand); background: #fff; }
.search::before {
    content: '⌕';
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 1rem;
}

/* CONTENT */
.content {
    padding: 2rem;
    max-width: 1600px;
    width: 100%;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 2rem;
    gap: 2rem;
}
.page-title {
    font-family: var(--display);
    font-size: 1.75rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-bottom: 0.35rem;
}
.page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    font-family: var(--sans);
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-primary {
    background: var(--text);
    color: #fff;
    border-color: var(--text);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-outline {
    background: transparent;
    color: var(--text);
    border-color: var(--border-strong);
}
.btn-outline:hover { background: var(--surface-alt); }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 0.4rem 0.6rem;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-alt); }

/* KPI CARDS */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    position: relative;
}
.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.kpi-value {
    font-family: var(--display);
    font-size: 1.75rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--text);
    display: block;
    line-height: 1.1;
}
.kpi-delta {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--mono);
}
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.flat { color: var(--text-muted); }
.kpi-spark {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 80px;
    height: 32px;
    opacity: 0.7;
}

/* GRID */
.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}
.grid-full { grid-column: 1 / -1; }

/* CARD */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}
.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}
.card-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}
.card-body {
    padding: 1.25rem;
}
.card-body.compact { padding: 0; }

/* TABLE */
.table {
    width: 100%;
    border-collapse: collapse;
}
.table th {
    text-align: left;
    padding: 0.7rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.87rem;
    vertical-align: middle;
}
.table tbody tr:hover { background: var(--surface-alt); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num, .table .amount {
    font-family: var(--mono);
    font-variant-numeric: tabular-nums;
    text-align: right;
}
.table .amount { font-weight: 500; }

/* STATUS PILLS */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 500;
    border-radius: 100px;
    line-height: 1.4;
    white-space: nowrap;
}
.pill::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-neutral { background: var(--surface-alt); color: var(--text-muted); }
.pill-brand { background: var(--brand-soft); color: var(--brand-dark); }

/* ACTIVITY / TIMELINE */
.timeline {
    display: flex;
    flex-direction: column;
}
.timeline-item {
    display: flex;
    gap: 0.85rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--brand);
    margin-top: 0.5rem;
    flex-shrink: 0;
}
.timeline-dot.success { background: var(--success); }
.timeline-dot.warn { background: var(--warn); }
.timeline-dot.danger { background: var(--danger); }
.timeline-content {
    flex: 1;
    min-width: 0;
}
.timeline-title {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.15rem;
}
.timeline-title strong { font-weight: 600; }
.timeline-meta {
    font-size: 0.72rem;
    color: var(--text-dim);
    font-family: var(--mono);
}

/* PROGRESS */
.progress {
    height: 6px;
    background: var(--surface-alt);
    border-radius: 100px;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: var(--brand);
    border-radius: 100px;
    transition: width 0.4s;
}
.progress-bar.success { background: var(--success); }
.progress-bar.warn { background: var(--warn); }

/* CHART */
.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    height: 180px;
    padding: 1rem 0;
}
.bar-chart-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}
.bar {
    width: 100%;
    background: var(--brand);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: opacity 0.15s;
}
.bar:hover { opacity: 0.8; }
.bar-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--mono);
}

/* KANBAN */
.kanban {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.kanban-col {
    background: var(--surface-alt);
    border-radius: var(--radius);
    padding: 0.75rem;
    min-height: 300px;
}
.kanban-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 0.25rem 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.kanban-title {
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.kanban-count {
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.68rem;
    padding: 0.1rem 0.45rem;
    border-radius: 100px;
    font-weight: 500;
    font-family: var(--mono);
}
.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s;
}
.kanban-card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}
.kanban-card-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.35rem;
}
.kanban-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: var(--mono);
    margin-top: 0.5rem;
}
.kanban-card-amount {
    font-weight: 600;
    color: var(--text);
}

/* SPARKLINE */
.spark {
    display: block;
    width: 100%;
    height: 40px;
}

/* AVATAR STACK */
.avatar-stack {
    display: inline-flex;
}
.avatar-stack .avatar {
    width: 24px;
    height: 24px;
    font-size: 0.65rem;
    border: 2px solid var(--surface);
    margin-left: -6px;
}
.avatar-stack .avatar:first-child { margin-left: 0; }

/* METRIC ROW (finanzas) */
.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.metric-row:last-child { border-bottom: none; }
.metric-row .label { font-size: 0.85rem; color: var(--text-muted); }
.metric-row .value {
    font-family: var(--mono);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

/* TABS */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.5rem;
    gap: 0;
}
.tab {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--text);
    border-bottom-color: var(--brand);
}

/* ALERT */
.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    margin-bottom: 1rem;
    border-left: 3px solid;
}
.alert-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.alert-info { background: var(--info-soft); border-color: var(--info); color: var(--info); }

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }

/* ---------------------------------------------------- */
/* MOBILE — sidebar drawer + responsive layout            */
/* ---------------------------------------------------- */

.mobile-topbar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    background: var(--sidebar-bg);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 90;
}
.mobile-topbar .menu-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
}
.mobile-topbar .m-brand {
    font-family: var(--display);
    font-size: 1.1rem;
    color: #fff;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    font-weight: 500;
}
.mobile-topbar .m-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.mobile-topbar .m-actions button {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
}

.sidebar-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(31, 27, 22, 0.6);
    z-index: 95;
    backdrop-filter: blur(2px);
}
.sidebar-scrim.active { display: block; }

/* Close button visible only on mobile viewport */
.sidebar-close-mobile { display: none; }

@media (max-width: 900px) {
    .app {
        grid-template-columns: 1fr;
    }
    .mobile-topbar {
        display: flex;
        padding: env(safe-area-inset-top, 0) 1rem 0 1rem;
        min-height: calc(56px + env(safe-area-inset-top, 0));
        align-items: center;
        padding-top: max(12px, env(safe-area-inset-top, 0));
        padding-bottom: 12px;
    }
    .mobile-topbar .menu-btn {
        min-width: 44px;
        min-height: 44px;
        display: grid;
        place-items: center;
    }
    .mobile-topbar .m-actions button {
        min-width: 44px;
        min-height: 44px;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(.2,.7,.2,1);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
        padding-top: max(1.5rem, env(safe-area-inset-top));
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-brand {
        position: relative;
    }
    .sidebar-close-mobile {
        position: absolute;
        top: -0.35rem;
        right: 0.75rem;
        width: 40px;
        height: 40px;
        background: rgba(255,255,255,0.08);
        border: none;
        color: rgba(255,255,255,0.7);
        border-radius: 50%;
        font-size: 1.35rem;
        cursor: pointer;
        display: grid;
        place-items: center;
    }
    .sidebar-close-mobile:hover { background: rgba(255,255,255,0.15); }
    .sidebar-nav a { min-height: 44px; padding: 0.75rem 1.5rem; }

    .topbar {
        flex-wrap: wrap;
        padding: 0.85rem 1rem;
        gap: 0.75rem;
    }
    .topbar-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    .topbar-actions .search { width: 100% !important; order: -1; }
    .breadcrumb { font-size: 0.8rem; }

    .content { padding: 1rem; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    .page-title { font-size: 1.4rem; }
    .page-subtitle { font-size: 0.82rem; }

    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .kpi { padding: 0.85rem; }
    .kpi-value { font-size: 1.3rem; }
    .kpi-spark { display: none; }

    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }

    .kanban,
    .kanban-crm.res,
    .kanban-crm.b2b {
        grid-template-columns: 88% !important;
        grid-auto-flow: column;
        grid-auto-columns: 88%;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1rem;
    }
    .kanban-col {
        scroll-snap-align: start;
        min-height: auto;
    }

    .table {
        font-size: 0.8rem;
    }
    .table th, .table td {
        padding: 0.55rem 0.75rem;
    }

    .card-body.compact table {
        min-width: 600px;
    }
    .card-body.compact {
        overflow-x: auto;
    }

    .table-wrap { overflow-x: auto; }

    .cotizador-layout {
        grid-template-columns: 1fr !important;
    }
    .cotizador-side {
        position: static !important;
    }
    .catalog-grid { grid-template-columns: repeat(2, 1fr) !important; }
    .templates { grid-template-columns: 1fr !important; }

    .footer-bottom { flex-direction: column; gap: 0.5rem; text-align: center; }

    /* Mobile-first CRM improvements */
    .anchor-nav {
        overflow-x: auto;
        gap: 0.35rem !important;
        padding: 0.4rem;
    }
    .anchor-nav a {
        font-size: 0.75rem !important;
        padding: 0.45rem 0.75rem !important;
        white-space: nowrap;
    }

    .kpi .kpi-label { font-size: 0.68rem; }
    .kpi .kpi-delta { font-size: 0.68rem; }

    .kanban-card { padding: 0.65rem; }
    .kanban-card-title { font-size: 0.82rem; }
    .kanban-card-meta { font-size: 0.68rem; }

    /* Mobile bottom nav — primary destinations */
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--surface);
        border-top: 1px solid var(--border);
        z-index: 80;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .mobile-bottom-nav a {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 0.55rem 0.25rem;
        font-size: 0.65rem;
        color: var(--text-muted);
        text-decoration: none;
        gap: 0.15rem;
        min-height: 56px;
        position: relative;
    }
    .mobile-bottom-nav a .ic {
        font-size: 1.15rem;
        font-family: var(--display);
        line-height: 1;
    }
    .mobile-bottom-nav a.active {
        color: var(--brand-dark);
    }
    .mobile-bottom-nav a.active::before {
        content: '';
        position: absolute;
        top: 0;
        left: 20%;
        right: 20%;
        height: 2px;
        background: var(--brand);
        border-radius: 0 0 3px 3px;
    }
    .mobile-bottom-nav .badge-dot {
        position: absolute;
        top: 6px;
        right: calc(50% - 15px);
        min-width: 16px;
        height: 16px;
        background: var(--danger);
        color: #fff;
        border-radius: 100px;
        font-size: 0.6rem;
        font-weight: 700;
        display: grid;
        place-items: center;
        padding: 0 4px;
    }

    body { padding-bottom: 68px; }

    /* Mobile FAB (Floating Action Button) */
    .mobile-fab {
        display: flex;
        position: fixed;
        bottom: calc(80px + env(safe-area-inset-bottom, 0));
        right: 1rem;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, var(--brand), var(--brand-dark));
        color: #fff;
        border: none;
        box-shadow: 0 6px 20px rgba(139, 109, 63, 0.4);
        z-index: 79;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        font-family: var(--display);
        font-size: 1.6rem;
        font-weight: 300;
        line-height: 1;
    }
    .mobile-fab:active { transform: scale(0.95); }

    /* Kanban scroll indicator dots */
    .kanban-crm { padding-bottom: 1.5rem !important; position: relative; }
    .kanban-scroll-indicator {
        display: flex;
        gap: 6px;
        justify-content: center;
        padding: 0.5rem 0 0;
        position: sticky;
        bottom: 0;
    }
    .kanban-scroll-indicator .dot {
        width: 6px;
        height: 6px;
        background: var(--border-strong);
        border-radius: 50%;
        transition: all 0.2s;
    }
    .kanban-scroll-indicator .dot.active {
        background: var(--brand);
        width: 16px;
        border-radius: 100px;
    }

    /* Mobile search prominence */
    .topbar-actions .search input {
        min-height: 44px;
        font-size: 16px !important; /* Prevents iOS zoom on focus */
    }

    /* Kanban card better tap targets */
    .kanban-card {
        padding: 0.85rem !important;
        min-height: 88px;
    }
    .kanban-card:active { transform: scale(0.98); background: var(--surface-alt); }

    /* Alert action button bigger */
    .alert button {
        min-height: 40px;
    }

    /* View switcher scroll */
    .view-switcher { overflow-x: auto; }
    .view-btn { white-space: nowrap; }

    /* Quote meta stacking */
    .quote-meta { grid-template-columns: 1fr 1fr !important; }
    .quote-meta .field { padding: 0.6rem 0.85rem; }

    /* Clientes 360 layout */
    .clientes-layout {
        grid-template-columns: 1fr !important;
    }
    .clientes-list .cliente-list-items { max-height: 300px; }
    .contact-360 {
        grid-template-columns: 1fr !important;
    }
    .ficha-hero {
        grid-template-columns: 1fr !important;
        text-align: center;
        padding: 1.25rem;
    }
    .ficha-avatar { margin: 0 auto; }
    .ficha-actions { flex-direction: row; }
    .cliente-kpis { grid-template-columns: repeat(2, 1fr) !important; }
    .ficha-grid { grid-template-columns: 1fr !important; }
    .contact-360, .ficha { border-radius: 0; margin: 0 -1rem; }

    /* Etapas stack */
    .etapas { grid-template-columns: 1fr 1fr !important; }

    /* Insights */
    .insight-grid { grid-template-columns: 1fr !important; }

    /* Media studio */
    .media-preview-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

@media (max-width: 500px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .catalog-grid { grid-template-columns: 1fr !important; }
    .cliente-kpis { grid-template-columns: 1fr !important; }
    .kanban-crm.res,
    .kanban-crm.b2b {
        grid-auto-columns: 92%;
    }
}

/* ---------------------------------------------------- */
/* Table wrap for horizontal scroll                       */
/* ---------------------------------------------------- */
@media (max-width: 900px) {
    table { min-width: 600px; }
    .kanban { padding-bottom: 0.5rem; }
}

/* ====================================================== */
/* XChart — gráficos compartidos (charts.js)              */
/* ====================================================== */
.xc { margin: 0; }
.xc-svg { width: 100%; height: 220px; display: block; overflow: visible; }

.xc-grid line { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.xc-axis, .xc-label {
    font-family: var(--mono);
    font-size: 10px;
    fill: var(--text-dim);
}
.xc-label { font-size: 10px; }

.xc-bar {
    fill: var(--brand);
    cursor: pointer;
    transition: fill .15s;
}
.xc-bar:hover, .xc-bar.activa { fill: var(--brand-dark); }
.xc-bar-alt { fill: var(--info); opacity: .75; }
.xc-bar:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

.xc-line {
    fill: none;
    stroke: var(--brand-dark);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
    vector-effect: non-scaling-stroke;
}
.xc-line-proy { stroke: var(--info); stroke-dasharray: 5 4; }
.xc-proy { fill: var(--surface-alt); opacity: .55; }
.xc-dot { fill: var(--brand-dark); cursor: pointer; transition: r .12s; }
.xc-dot-proy { fill: var(--info); }
.xc-dot:hover, .xc-dot.activa { r: 6.5; }
.xc-dot:focus-visible { outline: 2px solid var(--text); outline-offset: 1px; }

.xc-slice { cursor: pointer; transition: opacity .15s; }
.xc-slice:hover, .xc-slice.activa { opacity: .78; }
.xc-slice:focus-visible { outline: 2px solid var(--text); }
.xc-svg-dona { width: 180px; height: 180px; flex-shrink: 0; }
.xc-dona-wrap { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.xc-dona-total { font-family: var(--display); font-size: 22px; font-weight: 600; fill: var(--text); }
.xc-dona-sub { font-family: var(--mono); font-size: 9px; fill: var(--text-dim); text-transform: uppercase; letter-spacing: .1em; }
.xc-leyenda { list-style: none; flex: 1; min-width: 180px; }
.xc-leyenda li {
    display: flex; align-items: center; gap: .5rem;
    padding: .35rem 0; font-size: .82rem;
    border-bottom: 1px solid var(--border);
}
.xc-leyenda li:last-child { border-bottom: none; }
.xc-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.xc-leg-txt { flex: 1; color: var(--text-muted); }
.xc-leg-val { font-family: var(--mono); font-weight: 600; }

.xc-spark-line { fill: none; stroke: var(--brand); stroke-width: 1.6; vector-effect: non-scaling-stroke; }

.xc-tip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    padding: .45rem .6rem;
    background: var(--text);
    color: var(--bg);
    border-radius: var(--radius-sm);
    font-size: .76rem;
    line-height: 1.45;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(3px);
    transition: opacity .12s, transform .12s;
    max-width: 240px;
}
.xc-tip.visible { opacity: 1; transform: translateY(0); }
.xc-tip strong { font-weight: 600; }
.xc-tip em { opacity: .75; font-style: normal; }

/* Tabla equivalente solo para lectores de pantalla */
.xc-sr {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
    min-width: 0;
}

@media (max-width: 900px) {
    .xc-svg { height: 190px; }
    .xc-dona-wrap { gap: 1rem; }
    .xc-svg-dona { width: 150px; height: 150px; margin: 0 auto; }
    .xc-leyenda { min-width: 100%; }
}
@media (max-width: 500px) {
    .xc-svg { height: 165px; }
    .xc-axis, .xc-label { font-size: 12px; }
}

/* ====================================================== */
/* Modal compartido (clientes.js / inventario.js)         */
/* ====================================================== */
.x-modal {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    width: min(880px, calc(100vw - 2rem));
    max-height: calc(100vh - 4rem);
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.x-modal::backdrop { background: rgba(20, 16, 12, .45); }
.x-modal-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--border);
}
.x-modal-title { font-family: var(--display); font-size: 1.05rem; font-weight: 500; }
.x-modal-sub { font-size: .8rem; color: var(--text-muted); margin-top: .2rem; }
.x-modal-x {
    width: 34px; height: 34px; flex-shrink: 0;
    border: 1px solid var(--border); background: var(--surface-alt);
    color: var(--text-muted); border-radius: 50%; font-size: 1.1rem; cursor: pointer;
}
.x-modal-x:hover { color: var(--text); border-color: var(--border-strong); }
.x-modal-body { padding: 1.25rem; overflow-y: auto; max-height: calc(100vh - 16rem); }
.x-modal-foot {
    display: flex; align-items: center; gap: .6rem; justify-content: flex-end;
    padding: .9rem 1.25rem; border-top: 1px solid var(--border);
    background: var(--surface-alt); font-size: .8rem; flex-wrap: wrap;
}

/* ====================================================== */
/* Expediente digital de clientes (clientes.js)           */
/* ====================================================== */
.cli-empty {
    padding: 1.5rem 1rem; text-align: center;
    color: var(--text-muted); font-size: .85rem; line-height: 1.6;
}
.cli-vacio { color: var(--text-dim); font-style: normal; }
.cli-meta { font-size: .72rem; color: var(--text-dim); font-family: var(--mono); }
.cli-hint {
    margin-top: .85rem; padding: .6rem .75rem; background: var(--surface-alt);
    border-radius: var(--radius-sm); font-size: .75rem; color: var(--text-muted); line-height: 1.5;
}
.cli-lista-pie {
    padding: .6rem .9rem; border-top: 1px solid var(--border);
    font-family: var(--mono); font-size: .7rem; color: var(--text-dim);
}
/* Maestro-detalle en TODOS los anchos: la lista y el expediente se turnan,
   así el expediente siempre dispone del ancho completo. */
.cli-volver {
    display: inline-flex; align-items: center; gap: .35rem;
    margin-bottom: .85rem; padding: .4rem .7rem;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); border-radius: var(--radius-sm);
    font-family: inherit; font-size: .8rem; cursor: pointer;
}
.cli-volver:hover { border-color: var(--border-strong); color: var(--text); }
body.cli-detalle .clientes-list { display: none; }
body:not(.cli-detalle) .ficha { display: none; }

/* --- campos editables --- */
.cli-campo {
    display: flex; align-items: center; gap: .6rem;
    padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .84rem;
}
.cli-campo:last-child { border-bottom: none; }
.cli-campo-lbl { color: var(--text-muted); min-width: 40%; flex-shrink: 0; }
.cli-campo-val { flex: 1; min-width: 0; word-break: break-word; }
.cli-campo-val.editable { cursor: text; border-radius: 3px; padding: .15rem .3rem; margin: -.15rem -.3rem; }
.cli-campo-val.editable:hover { background: var(--surface-alt); box-shadow: inset 0 0 0 1px var(--border); }
.cli-campo-val.editable:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.cli-input {
    flex: 1; min-width: 0; padding: .25rem .4rem;
    border: 1px solid var(--brand); border-radius: 3px;
    font-family: inherit; font-size: .84rem;
    background: var(--surface); color: var(--text);
}
.cli-x {
    width: 22px; height: 22px; flex-shrink: 0; line-height: 1;
    border: none; background: none; color: var(--text-dim);
    border-radius: 50%; cursor: pointer; font-size: 1rem;
}
.cli-x:hover { background: var(--danger-soft); color: var(--danger); }
.cli-add {
    margin-left: auto; padding: .25rem .6rem;
    border: 1px solid var(--border); background: var(--surface);
    color: var(--text-muted); border-radius: 100px;
    font-family: inherit; font-size: .72rem; cursor: pointer; text-decoration: none;
}
.cli-add:hover { background: var(--surface-alt); color: var(--text); border-color: var(--border-strong); }

/* --- paneles --- */
.cli-panel { display: none; }
.cli-panel.active { display: block; }
.cli-panel-head {
    display: flex; align-items: center; gap: .75rem;
    margin-bottom: .85rem; flex-wrap: wrap;
}
.cli-panel-head h4 {
    font-family: var(--display); font-size: .95rem; font-weight: 500;
    display: flex; align-items: center; gap: .5rem; margin: 0;
}
.cli-tabla { overflow-x: auto; }
.cli-tabla .table { min-width: 520px; }

/* --- timeline de actividades --- */
.cli-timeline { list-style: none; }
.cli-timeline li {
    display: flex; gap: .75rem; align-items: flex-start;
    padding: .75rem 0; border-bottom: 1px solid var(--border);
}
.cli-timeline li:last-child { border-bottom: none; }
.cli-timeline li > div { flex: 1; min-width: 0; }
.cli-tl-ic {
    width: 28px; height: 28px; flex-shrink: 0; display: grid; place-items: center;
    background: var(--surface-alt); border-radius: 50%;
    color: var(--text-muted); font-size: .8rem;
}
.cli-tl-tit { font-weight: 600; font-size: .86rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.cli-timeline p { font-size: .8rem; color: var(--text-muted); margin: .2rem 0 .3rem; line-height: 1.5; }

/* --- contactos --- */
.cli-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.cli-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem; }
.cli-card-top { display: flex; gap: .6rem; align-items: flex-start; }
.cli-card-top > div { flex: 1; min-width: 0; }
.cli-card-top strong { font-size: .86rem; margin-right: .35rem; }
.cli-card-body { margin-top: .5rem; display: flex; flex-direction: column; gap: .15rem; font-size: .78rem; }
.cli-card-body a { color: var(--brand-dark); word-break: break-all; }
.avatar-sm {
    width: 26px; height: 26px; flex-shrink: 0; display: inline-grid; place-items: center;
    background: var(--brand); color: #fff; border-radius: 50%;
    font-size: .66rem; font-weight: 600; font-family: var(--mono);
}

/* --- relaciones --- */
.cli-rels { display: flex; flex-direction: column; gap: .5rem; }
.cli-rel {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
    padding: .6rem .75rem; background: var(--surface-alt); border-radius: var(--radius-sm);
}
.cli-rel .cli-meta { flex: 1; min-width: 120px; }
.cli-rel-mini { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; flex-wrap: wrap; }
.cli-link {
    display: inline-flex; align-items: center; gap: .4rem;
    border: none; background: none; padding: 0; cursor: pointer;
    font-family: inherit; font-size: .84rem; font-weight: 600;
    color: var(--brand-dark); text-align: left;
}
.cli-link:hover { text-decoration: underline; }

/* --- documentos y notas --- */
.cli-docs { list-style: none; }
.cli-docs li {
    display: flex; align-items: center; gap: .75rem;
    padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.cli-docs li:last-child { border-bottom: none; }
.cli-docs li > div { flex: 1; min-width: 0; }
.cli-docs strong { font-size: .84rem; font-weight: 500; }
.cli-doc-ic {
    width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center;
    background: var(--surface-alt); border-radius: var(--radius-sm); color: var(--text-muted);
}
.cli-nota {
    position: relative; padding: .7rem .85rem; padding-right: 2rem;
    background: var(--surface-alt); border-radius: var(--radius-sm);
    border-left: 3px solid var(--brand); margin-bottom: .5rem;
}
.cli-nota p { font-size: .83rem; line-height: 1.55; margin-bottom: .3rem; }
.cli-nota .cli-x { position: absolute; top: .4rem; right: .4rem; }

/* --- formularios de los diálogos --- */
.cli-form { display: contents; }
.cli-f { display: block; margin-bottom: .85rem; }
.cli-f > span { display: block; font-size: .76rem; color: var(--text-muted); margin-bottom: .25rem; }
.cli-f input, .cli-f select, .cli-f textarea {
    width: 100%; padding: .5rem .65rem;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: inherit; font-size: .86rem;
    background: var(--surface); color: var(--text);
}
.cli-f textarea { resize: vertical; }
.cli-f-check { display: flex; align-items: center; gap: .5rem; }
.cli-f-check input { width: auto; }
.cli-f-check > span { margin: 0; }

/* --- maestro-detalle en móvil --- */
/* El expediente necesita ~520px para que el hero no se aplaste. Con la
   lista al lado eso solo cabe arriba de ~1100px; debajo, maestro-detalle. */
@media (max-width: 1100px) {
    .ficha-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .ficha-tab { white-space: nowrap; }
}

/* Apilar etiqueta y valor solo cuando de verdad no caben lado a lado. */
@media (max-width: 900px) {
    .cli-campo { flex-wrap: wrap; }
    .cli-campo-lbl { min-width: 100%; font-size: .72rem; }
    .cli-cards { grid-template-columns: 1fr; }
}

/* Kanban alimentado por XDB (crm.js) */
a.kanban-card { display: block; text-decoration: none; color: inherit; }
a.kanban-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.kanban-vacio {
    padding: 1.25rem .5rem; text-align: center;
    color: var(--text-dim); font-size: .75rem;
}

/* Historial del cliente dentro del cotizador (cotizador.js) */
.cot-historial {
    margin-top: 1rem; padding: .85rem 1rem;
    background: var(--surface-alt); border-radius: var(--radius-sm);
    border-left: 3px solid var(--brand);
}
.cot-hist-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 1rem; margin-bottom: .5rem; font-size: .9rem;
}
.cot-hist-head a { font-size: .75rem; color: var(--brand-dark); }
.cot-hist-kpis {
    display: flex; gap: 1.25rem; flex-wrap: wrap;
    font-size: .76rem; color: var(--text-muted); margin-bottom: .6rem;
}
.cot-hist-kpis b { font-family: var(--mono); color: var(--text); margin-left: .25rem; }
.cot-mora b { color: var(--danger); }
.cot-hist-lista { list-style: none; }
.cot-hist-lista li {
    display: grid; grid-template-columns: 4.5rem 1fr auto auto;
    gap: .6rem; align-items: center;
    padding: .35rem 0; font-size: .76rem;
    border-top: 1px solid var(--border);
}
.cot-hist-vacio { font-size: .78rem; color: var(--text-dim); }
@media (max-width: 900px) {
    .cot-hist-lista li { grid-template-columns: 4.5rem 1fr auto; }
    .cot-hist-lista li .pill { grid-column: 2 / -1; justify-self: start; }
}

/* Gráfico que llena la altura de su tarjeta.
   Sin esto, en un grid con align-items:stretch la tarjeta se estira para
   igualar a su vecina y el gráfico queda flotando con un hueco debajo. */
.card.xc-fill { display: flex; flex-direction: column; }
.card.xc-fill > .card-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.card.xc-fill .xc { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.card.xc-fill .xc-svg { flex: 1; height: auto; min-height: 200px; }

/* Feed de actividad del dashboard */
.dash-feed { list-style: none; }
.dash-feed li {
    display: flex; gap: .7rem; align-items: flex-start;
    padding: .6rem 0; border-bottom: 1px solid var(--border);
}
.dash-feed li:last-child { border-bottom: none; }
.dash-feed li > div { flex: 1; min-width: 0; }
.dash-ic {
    width: 24px; height: 24px; flex-shrink: 0; display: grid; place-items: center;
    background: var(--surface-alt); border-radius: 50%;
    color: var(--text-muted); font-size: .72rem;
}
.dash-tit { font-size: .84rem; font-weight: 500; line-height: 1.35; }
.alert-danger { background: var(--danger-soft); border-color: var(--danger); }
.alert-success { background: var(--success-soft); border-color: var(--success); }

/* Campo «Tela» en piezas que no llevan tapizado. Ocupa el mismo alto que
   el <select> de acabado para que la fila no quede desalineada. */
.sin-tela {
    display: flex;
    align-items: center;
    min-height: 33px;
    padding: 0 .6rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    font-size: .78rem;
    color: var(--text-dim);
}

/* Procedencia de cada línea del P&L: la tabla mezcla venta real con
   estructura de costo presupuestada y el lector debe poder distinguirlas. */
.pl-src {
    display: inline-block;
    margin-left: .4rem;
    padding: .05rem .34rem;
    border-radius: 3px;
    font-family: var(--mono);
    font-size: .6rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    vertical-align: middle;
    cursor: help;
}
.pl-src-libro    { background: var(--success-soft); color: var(--success); }
.pl-src-catalogo { background: var(--info-soft);    color: var(--info); }
.pl-src-ppto     { background: var(--warn-soft);    color: var(--warn); }
.pl-src-derivado { background: var(--surface-alt);  color: var(--text-dim); }

.pl-nota {
    padding: .9rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    font-size: .78rem;
    line-height: 1.6;
    color: var(--text-muted);
}
.pl-nota strong { color: var(--text); }
.fin-aviso { margin-bottom: 1.25rem; }
