/* Red de seguridad: ningún ícono de mock sin tamaño explícito puede crecer (especificidad 0) */
:where(.app) :where(svg:not([width])) { width: 1em; height: 1em; flex: none; }

/* ============ MOCK PRIMITIVES (emulan la UI de Gestión Digital) ============ */
/* Escala ~0.75x de la app real (Tailwind 4 + tokens de globals.css).
   text-sm 14px -> 10.5px · text-xs 12px -> 9px · h-9 36px -> 27px ·
   rounded-md 6px -> 4.5px · rounded-lg 8px -> 6px · rounded-xl 12px -> 9px */
.app {
    display: grid;
    grid-template-columns: 167px 1fr; /* SIDEBAR_WIDTH 13.9rem */
    min-height: 100%;
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans);
    font-size: 10.5px;
    line-height: 1.43;
    text-align: left;
}
.app.no-side { grid-template-columns: 1fr; }
/* Pantallas mobile (teléfono): barra superior + contenido; sin sidebar */
.app.mob { grid-template-columns: 1fr; grid-template-rows: auto 1fr; height: 100%; font-size: 13px; }
.app.mob > .app-main { min-height: 0; overflow: hidden; }

/* Sidebar desktop: bg-card (con degradé) border-r, nav p-4 space-y-1 */
.app-side {
    background-color: var(--card);
    background-image: linear-gradient(145deg, var(--card) 0%, var(--card-gradient-end) 100%);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}
/* Marca (en la app vive en el Topbar h-16: ícono h-6 + nombre text-xl font-bold) */
.app-side .side-logo {
    display: flex; align-items: center; gap: 6px;
    height: 48px; padding: 0 12px; flex: none;
    border-bottom: 1px solid var(--border);
    font-size: 13px; font-weight: 700; color: var(--foreground); white-space: nowrap;
}
.app-side .side-logo svg { width: 18px; height: 18px; flex: none; }
.app-side .side-nav { flex: 1; padding: 12px; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.side-item {
    display: flex; align-items: center; gap: 9px;
    padding: 6px 9px; border-radius: 6px;
    font-size: 10.5px; font-weight: 500; line-height: 1.43;
    color: var(--muted-foreground); white-space: nowrap;
}
.side-item svg { width: 15px; height: 15px; flex: none; }
.side-item.active {
    color: var(--primary-foreground);
    background-color: var(--primary);
    background-image: linear-gradient(145deg, var(--primary) 0%, var(--primary-gradient-end) 100%);
}
/* Footer: border-t p-4, link Configuración (rounded-md px-4 py-2 text-sm font-medium muted, ícono h-4) */
.app-side .side-foot { flex: none; border-top: 1px solid var(--border); padding: 12px; }
.app-side .side-foot .side-item { border-radius: 4.5px; padding: 6px 12px; }
.app-side .side-foot .side-item svg { width: 12px; height: 12px; }

/* PageLayout: p-6, header mb-5, h1 text-2xl/3xl font-semibold tracking-tight, p mt-2 text-sm muted */
.app-main { padding: 18px; display: flex; flex-direction: column; gap: 15px; min-width: 0; position: relative; }
.app-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.app-title { font-size: 20px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.2; color: var(--foreground); }
.app-sub { color: var(--muted-foreground); font-size: 10.5px; margin-top: 6px; }

/* Card: bg-card (degradé 145deg) rounded-xl border p-6 shadow-sm */
.m-card {
    background-color: var(--card);
    background-image: linear-gradient(145deg, var(--card) 0%, var(--card-gradient-end) 100%);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 18px;
    color: var(--card-foreground);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
    min-width: 0;
}
.m-grid { display: grid; gap: 12px; } /* gap-4 */
.m-grid.c2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.m-grid.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.m-grid.c4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
/* MetricCardsGrid: título text-sm font-medium muted (+ícono h-4), header pb-3 + gap-6, valor text-2xl font-bold,
   subtítulo text-xs muted mt-1 (tendencia: green-600 / red-600) */
.m-kpi .lbl { color: var(--muted-foreground); font-size: 10.5px; font-weight: 500; line-height: 1; display: flex; align-items: center; gap: 6px; }
.m-kpi .lbl svg { width: 12px; height: 12px; flex: none; }
.m-kpi .val { font-size: 18px; font-weight: 700; line-height: 1.33; margin-top: 27px; }
.m-kpi .delta { font-size: 9px; margin-top: 3px; color: var(--muted-foreground); }
.m-kpi .delta.up { color: #16a34a; }
.m-kpi .delta.down { color: #dc2626; }
html.dark .m-kpi .delta.up { color: #22c55e; }
html.dark .m-kpi .delta.down { color: #ef4444; }

/* Button default: h-9 px-4 rounded-md text-sm font-medium gap-2 shadow-xs, bg-primary con degradé */
.m-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 27px; padding: 0 12px; border-radius: 4.5px;
    font-size: 10.5px; font-weight: 500; white-space: nowrap; flex-shrink: 0;
    border: 0;
    background-color: var(--primary);
    background-image: linear-gradient(145deg, var(--primary) 0%, var(--primary-gradient-end) 100%);
    color: var(--primary-foreground);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);
}
.m-btn svg { width: 12px; height: 12px; flex: none; }
.m-btn:has(> svg) { padding: 0 9px; }
.m-btn.outline {
    background: var(--background); color: var(--foreground);
    border: 1px solid var(--border);
}
html.dark .m-btn.outline { background: color-mix(in srgb, var(--input) 30%, transparent); border-color: var(--input); }
.m-btn.ghost { background: transparent; color: var(--foreground); box-shadow: none; }
.m-btn.danger { background: var(--destructive); color: #fff; }
html.dark .m-btn.danger { background: color-mix(in srgb, var(--destructive) 60%, transparent); }

/* Input: h-9 rounded-md border-input bg-transparent px-3 py-1 text-sm shadow-xs (dark: bg-input/30) */
.m-input {
    height: 27px; border: 1px solid var(--input); border-radius: 4.5px;
    padding: 0 9px; display: flex; align-items: center; gap: 6px;
    background: transparent; color: var(--foreground); font-size: 10.5px;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / .05); min-width: 0;
}
html.dark .m-input { background: color-mix(in srgb, var(--input) 30%, transparent); }
.m-input svg { width: 12px; height: 12px; color: #9ca3af; flex: none; }
.m-input.placeholder { color: var(--muted-foreground); }
/* Label: flex gap-2 text-sm leading-none font-medium (mb-2 en filtros de PageLayout) */
.m-label { font-size: 10.5px; font-weight: 500; line-height: 1; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }

/* Table: text-sm; th h-10 px-2 font-medium text-foreground; td p-2; tr border-b; última fila sin borde */
.m-table { width: 100%; border-collapse: collapse; font-size: 10.5px; caption-side: bottom; }
.m-table th { text-align: left; vertical-align: middle; font-weight: 500; color: var(--foreground); height: 30px; padding: 0 6px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.m-table td { padding: 6px; vertical-align: middle; border-bottom: 1px solid var(--border); white-space: nowrap; }
.m-table tr:last-child td { border-bottom: 0; }
.m-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badge + StatusBadge: rounded-md border px-2 py-0.5 text-xs font-medium gap-1, ícono h-3.
   Base = gris (inactivo / cerrada); ok = verde; warn = ámbar; err = rojo; info = azul (presupuesto) */
.m-badge {
    display: inline-flex; align-items: center; justify-content: center; gap: 3px;
    width: fit-content; white-space: nowrap; flex-shrink: 0; overflow: hidden;
    padding: 1.5px 6px; border-radius: 4.5px; border: 1px solid #d1d5db;
    font-size: 9px; font-weight: 500; line-height: 1.33;
    background: #f3f4f6; color: #374151;
}
.m-badge svg { width: 9px; height: 9px; flex: none; }
.m-badge.ok { background: #dcfce7; color: #166534; border-color: #86efac; }
.m-badge.warn { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.m-badge.err { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.m-badge.info { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
html.dark .m-badge { background: rgb(107 114 128 / .15); color: #9ca3af; border-color: rgb(107 114 128 / .25); }
html.dark .m-badge.ok { background: rgb(34 197 94 / .15); color: #4ade80; border-color: rgb(34 197 94 / .3); }
html.dark .m-badge.warn { background: rgb(245 158 11 / .15); color: #fbbf24; border-color: rgb(245 158 11 / .3); }
html.dark .m-badge.err { background: rgb(239 68 68 / .15); color: #f87171; border-color: rgb(239 68 68 / .3); }
html.dark .m-badge.info { background: rgb(59 130 246 / .15); color: #60a5fa; border-color: rgb(59 130 246 / .3); }

/* Tabs: lista bg-muted h-9 rounded-lg p-[3px]; trigger flex-1 px-2 py-1 rounded-md text-sm font-medium muted;
   activo = degradé primary + text-primary-foreground + shadow-sm */
.m-tabs {
    display: inline-flex; align-items: center; justify-content: center; width: fit-content;
    height: 27px; padding: 2.25px; border-radius: 6px;
    background: var(--muted); color: var(--muted-foreground);
}
.m-tabs span {
    flex: 1; height: calc(100% - 1px); display: inline-flex; align-items: center; justify-content: center; gap: 4.5px;
    padding: 3px 6px; border-radius: 4.5px; border: 1px solid transparent;
    font-size: 10.5px; font-weight: 500; white-space: nowrap; color: var(--muted-foreground);
}
.m-tabs span svg { width: 12px; height: 12px; }
.m-tabs span.on {
    color: var(--primary-foreground);
    background-image: linear-gradient(145deg, var(--primary) 0%, var(--primary-gradient-end) 100%);
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
}

/* Dialog: bg-background rounded-lg border p-6 gap-4 shadow-lg; título text-lg leading-none font-semibold; overlay bg-black/50 */
.m-dialog {
    background: var(--background); color: var(--foreground);
    border: 1px solid var(--border); border-radius: 6px;
    padding: 18px; display: grid; gap: 12px;
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
}
.m-dialog-title { font-weight: 600; font-size: 13.5px; line-height: 1; }
.m-overlay { position: absolute; inset: 0; background: rgb(0 0 0 / .5); display: grid; place-items: center; padding: 12px; }

/* Switch: h-[1.15rem] w-8 rounded-full border-transparent shadow-xs; off bg-input (dark /80), on bg-primary (degradé);
   thumb size-4 bg-background (dark: foreground / primary-foreground), checked translate-x-[calc(100%-2px)] */
.m-switch {
    width: 24px; height: 13.8px; border-radius: 999px; border: 1px solid transparent;
    background: var(--input); position: relative; flex: none; display: inline-flex; align-items: center;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);
}
html.dark .m-switch { background: color-mix(in srgb, var(--input) 80%, transparent); }
.m-switch::after { content: ""; display: block; width: 12px; height: 12px; border-radius: 50%; background: var(--background); transition: transform .2s; }
html.dark .m-switch::after { background: var(--foreground); }
.m-switch.on, html.dark .m-switch.on {
    background-color: var(--primary);
    background-image: linear-gradient(145deg, var(--primary) 0%, var(--primary-gradient-end) 100%);
}
.m-switch.on::after { transform: translateX(10px); }
html.dark .m-switch.on::after { background: var(--primary-foreground); }

.m-muted { color: var(--muted-foreground); }
.m-primary { color: var(--primary); }
.m-row { display: flex; align-items: center; gap: 6px; }
.m-between { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.m-sep { height: 1px; background: var(--border); flex: none; } /* Separator: bg-border h-px */
.m-bar { height: 6px; border-radius: 999px; background: var(--muted); overflow: hidden; }
.m-bar > i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }

/* Animaciones de entrada: el ancestro [data-chapter] recibe .in-view */
.m-stagger > * { opacity: 0; transform: translateY(8px); transition: opacity .5s ease, transform .5s ease; }
.in-view .m-stagger > * { opacity: 1; transform: none; }
.in-view .m-stagger > *:nth-child(2) { transition-delay: .08s; }
.in-view .m-stagger > *:nth-child(3) { transition-delay: .16s; }
.in-view .m-stagger > *:nth-child(4) { transition-delay: .24s; }
.in-view .m-stagger > *:nth-child(5) { transition-delay: .32s; }
.in-view .m-stagger > *:nth-child(6) { transition-delay: .40s; }
.in-view .m-stagger > *:nth-child(n+7) { transition-delay: .48s; }
@media (prefers-reduced-motion: reduce) {
    .m-stagger > * { opacity: 1; transform: none; transition: none; }
}
