/* =============================================================
   Malvon Design System v2.0
   Reference: portal.malvon.es (Linear / Stripe / Vercel inspired)
   This file contains only design tokens, base typography,
   background firma and reusable Malvon components.
   It does NOT touch existing dashboard markup; see
   malvon-overrides.css for re-theming of legacy classes.
   ============================================================= */

:root {
    /* ===== Colores base ===== */
    --bg-deep:    #04060c;
    --bg-base:    #07091300;
    --surface:    rgba(15, 22, 40, 0.72);
    --surface-2:  rgba(20, 28, 48, 0.55);
    --surface-3:  rgba(26, 36, 60, 0.85);

    --border-mv:        rgba(255, 255, 255, 0.07);
    --border-mv-strong: rgba(255, 255, 255, 0.14);
    --border-mv-glow:   rgba(245, 166, 35, 0.45);

    --text-mv:      #eef2fb;
    --text-soft:    #c3cce0;
    --muted:        #8390ad;

    /* ===== Acentos de marca Malvon ===== */
    --accent-mv:      #f5a623;
    --accent-mv-2:    #ffd089;
    --accent-mv-soft: rgba(245, 166, 35, 0.16);

    /* ===== Semánticos ===== */
    --mv-success: #34d399;
    --mv-info:    #60a5fa;
    --mv-danger:  #f87171;
    --mv-warn:    #fbbf24;

    /* ===== Radios ===== */
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    /* ===== Sombras ===== */
    --shadow-sm:   0 2px 8px rgba(0,0,0,0.25);
    --shadow-md:   0 12px 32px rgba(0,0,0,0.35);
    --shadow-lg:   0 28px 64px rgba(0,0,0,0.55);
    --shadow-glow: 0 0 0 1px rgba(245,166,35,0.25), 0 18px 50px -12px rgba(245,166,35,0.35);

    /* ===== Easings ===== */
    --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ===== Tipografía ===== */
    --font-mv:      "Inter", "Segoe UI", Tahoma, Arial, sans-serif;
    --font-mv-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
}

/* ===== Suavizado de fuente global ===== */
html, body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: "cv11","ss01","ss03";
}

/* ===== Background firma visual (3 capas) =====
   Aplicado al body de páginas Malvon. Los pseudo-elementos
   se montan en z-index 0; el contenido debe ir en z-index >=1. */
body.mv-themed {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font-mv);
    color: var(--text-mv);
    background-color: var(--bg-deep);
    background-image:
        radial-gradient(60rem 40rem at 12% 8%,   rgba(245,166,35,0.18), transparent 60%),
        radial-gradient(50rem 40rem at 92% 18%,  rgba(96,165,250,0.16), transparent 60%),
        radial-gradient(60rem 50rem at 80% 100%, rgba(167,139,250,0.14), transparent 65%),
        radial-gradient(40rem 30rem at 0% 100%,  rgba(52,211,153,0.10), transparent 60%),
        linear-gradient(180deg, #04060c 0%, #07091a 60%, #05070f 100%);
    background-attachment: fixed;
    overflow-x: hidden;
}

body.mv-themed::before {
    content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 56px 56px;
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 30%, transparent 80%);
            mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, #000 30%, transparent 80%);
    opacity: 0.45;
}

body.mv-themed::after {
    content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.06 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
    opacity: 0.5;
    mix-blend-mode: overlay;
}

/* ============================================================
   Animaciones globales
   ============================================================ */
@keyframes mvFadeUp   { from { opacity: 0; transform: translateY(14px); }
                        to   { opacity: 1; transform: translateY(0); } }
@keyframes mvFadeDown { from { opacity: 0; transform: translateY(-10px); }
                        to   { opacity: 1; transform: translateY(0); } }
@keyframes mvFadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes mvModalIn  { from { opacity: 0; transform: translateY(12px) scale(0.97); }
                        to   { opacity: 1; transform: translateY(0)    scale(1); } }
@keyframes mvPulse {
    0%   { box-shadow: 0 0 0 0 rgba(52,211,153,0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(52,211,153,0); }
    100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001s !important;
        transition-duration: 0.001s !important;
    }
}

/* ============================================================
   App shell (wrapper opcional)
   ============================================================ */
.app-shell {
    position: relative;
    z-index: 1;
    width: min(1340px, 100%);
    margin: 0 auto;
    padding: 24px clamp(16px, 3vw, 40px) 56px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* ============================================================
   App header (píldora glass)
   ============================================================ */
.app-header {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 12px 18px;
    border: 1px solid var(--border-mv);
    border-radius: 999px;
    background: linear-gradient(180deg, rgba(20,28,48,0.85), rgba(12,18,34,0.65));
    backdrop-filter: blur(18px) saturate(140%);
    -webkit-backdrop-filter: blur(18px) saturate(140%);
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,0.06);
    animation: mvFadeDown 0.7s var(--ease-out) both;
}

.brand { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: grid; place-items: center;
    background: conic-gradient(from 210deg, #ffd089, #f5a623, #b8740e, #f5a623);
    box-shadow: 0 6px 18px -4px rgba(245,166,35,0.55), inset 0 0 0 1px rgba(255,255,255,0.25);
    color: #1a0f00;
}
.brand-mark svg { width: 18px; height: 18px; color: #1a0f00; }
.brand-name { font-weight: 700; letter-spacing: 0.02em; font-size: 15px; }
.brand-name em { font-style: normal; color: var(--muted); font-weight: 500; margin-left: 6px; }

.nav-pills {
    display: flex; gap: 4px; padding: 4px;
    border-radius: 999px;
    border: 1px solid var(--border-mv);
    background: rgba(8,12,24,0.55);
}
.nav-pill {
    font: 500 12.5px/1 inherit; color: var(--text-soft);
    padding: 7px 14px; border-radius: 999px; cursor: pointer;
    border: 0; background: transparent;
    transition: color 0.2s, background 0.2s;
}
.nav-pill:hover  { color: var(--text-mv); background: rgba(255,255,255,0.04); }
.nav-pill.active {
    color: #1a1208;
    background: linear-gradient(180deg, #ffd089, #f5a623);
    box-shadow: 0 4px 14px -4px rgba(245,166,35,0.55);
}

/* ============================================================
   Status pill + reloj live
   ============================================================ */
.status-pill {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 999px;
    font-size: 12px; font-weight: 500; color: var(--text-soft);
    background: rgba(52,211,153,0.08);
    border: 1px solid rgba(52,211,153,0.25);
}
.status-pill.is-down {
    background: rgba(248,113,113,0.08);
    border-color: rgba(248,113,113,0.3);
    color: #ffd0d0;
}
.status-pill .status-dot-mv {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--mv-success);
    animation: mvPulse 2.2s infinite;
}
.status-pill.is-down .status-dot-mv {
    background: var(--mv-danger);
    animation: none;
}

.clock-mv {
    font-family: var(--font-mv-mono);
    font-size: 12.5px; color: var(--text-soft); letter-spacing: 0.04em;
    padding: 6px 12px; border-radius: 999px;
    border: 1px solid var(--border-mv); background: rgba(8,12,24,0.5);
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
    position: relative; text-align: center;
    padding: 48px clamp(16px, 4vw, 32px) 8px;
    animation: mvFadeUp 0.8s var(--ease-out) both;
}
.kicker {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 14px 6px 8px;
    border-radius: 999px;
    border: 1px solid rgba(245,166,35,0.3);
    background: linear-gradient(180deg, rgba(245,166,35,0.12), rgba(245,166,35,0.04));
    font-size: 12px; font-weight: 500; letter-spacing: 0.06em;
    text-transform: uppercase; color: var(--accent-mv-2);
    margin-bottom: 22px;
}
.kicker-dot {
    width: 18px; height: 18px; border-radius: 999px;
    background: linear-gradient(180deg, #ffd089, #f5a623);
    display: grid; place-items: center; color: #1a0f00; font-size: 11px;
}
.hero h1 {
    margin: 0 auto 14px; max-width: 880px;
    font-size: clamp(32px, 5.4vw, 56px);
    font-weight: 800; line-height: 1.05; letter-spacing: -0.02em;
    background: linear-gradient(180deg, #ffffff 0%, #cfd8ec 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero h1 .gradient-word {
    background: linear-gradient(135deg, #ffd089 0%, #f5a623 60%, #f47d3a 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}
.hero p.subtitle {
    margin: 0 auto; max-width: 620px;
    color: var(--text-soft); font-size: clamp(15px, 1.6vw, 17px); line-height: 1.55;
}

/* ============================================================
   Search box
   ============================================================ */
.mv-search-box { margin: 28px auto 4px; max-width: 520px; position: relative; }
.mv-search-box svg {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
.mv-search-box input {
    width: 100%; font-family: inherit; font-size: 14.5px; color: var(--text-mv);
    padding: 14px 64px 14px 46px;
    border-radius: 14px;
    border: 1px solid var(--border-mv-strong);
    background: rgba(10,16,30,0.7);
    backdrop-filter: blur(12px);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.mv-search-box input::placeholder { color: var(--muted); }
.mv-search-box input:focus {
    border-color: rgba(245,166,35,0.6);
    box-shadow: 0 0 0 4px rgba(245,166,35,0.12);
    background: rgba(12,18,34,0.85);
}
.mv-search-box kbd {
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
    font-family: var(--font-mv-mono); font-size: 11px; color: var(--muted);
    padding: 3px 8px; border-radius: 6px;
    border: 1px solid var(--border-mv-strong);
    background: rgba(255,255,255,0.04);
}

/* ============================================================
   Section header
   ============================================================ */
.section-head {
    display: flex; align-items: end; justify-content: space-between; gap: 16px;
    margin: 8px 4px 0;
    animation: mvFadeUp 0.9s var(--ease-out) both; animation-delay: 0.1s;
}
.section-head h2 {
    margin: 0; font-size: 13px; font-weight: 600;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.section-head .legend { font-size: 12.5px; color: var(--muted); }
.section-head .legend strong { color: var(--text-soft); font-weight: 600; }

/* ============================================================
   Cards (módulo / departamento)
   ============================================================ */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}
.mv-card {
    --dept: #f5a623;
    position: relative; isolation: isolate;
    text-decoration: none; color: var(--text-mv);
    border-radius: var(--radius-lg);
    padding: 22px 22px 20px;
    display: flex; flex-direction: column; gap: 14px;
    min-height: 200px;
    background: linear-gradient(180deg, rgba(22,30,52,0.92) 0%, rgba(14,20,38,0.92) 100%);
    border: 1px solid var(--border-mv);
    box-shadow: var(--shadow-md), inset 0 1px 0 rgba(255,255,255,0.04);
    overflow: hidden;
    transition:
        transform 0.45s var(--ease-spring),
        border-color 0.3s ease,
        box-shadow 0.4s ease;
    animation: mvFadeUp 0.7s var(--ease-out) both;
}
.mv-card::before {
    content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px;
    background: linear-gradient(140deg,
        color-mix(in srgb, var(--dept) 70%, transparent) 0%,
        rgba(255,255,255,0.08) 30%, transparent 70%);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
            mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    opacity: 0.65; transition: opacity 0.4s ease; pointer-events: none;
}
.mv-card::after {
    content: ""; position: absolute;
    width: 220px; height: 220px; border-radius: 50%;
    top: -120px; right: -100px;
    background: radial-gradient(closest-side,
        color-mix(in srgb, var(--dept) 55%, transparent), transparent 70%);
    opacity: 0.55; filter: blur(8px);
    transition: opacity 0.5s ease, transform 0.6s var(--ease-out);
    pointer-events: none; z-index: -1;
}
.mv-card:hover {
    transform: translateY(-6px);
    border-color: color-mix(in srgb, var(--dept) 55%, transparent);
    box-shadow:
        0 24px 60px -20px color-mix(in srgb, var(--dept) 50%, transparent),
        0 8px 20px -8px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.07);
}
.mv-card:hover::before { opacity: 1; }
.mv-card:hover::after  { opacity: 0.85; transform: scale(1.15) translateY(10px); }
.mv-card:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--dept) 60%, transparent);
}

.cards .mv-card:nth-child(1) { animation-delay: 0.05s; }
.cards .mv-card:nth-child(2) { animation-delay: 0.10s; }
.cards .mv-card:nth-child(3) { animation-delay: 0.15s; }
.cards .mv-card:nth-child(4) { animation-delay: 0.20s; }
.cards .mv-card:nth-child(5) { animation-delay: 0.25s; }
.cards .mv-card:nth-child(6) { animation-delay: 0.30s; }
.cards .mv-card:nth-child(7) { animation-delay: 0.35s; }

/* ============================================================
   Botones
   ============================================================ */
.mv-btn {
    font: 500 13px/1 inherit;
    border: 1px solid var(--border-mv-strong);
    background: rgba(255,255,255,0.04);
    color: var(--text-mv);
    border-radius: 10px; padding: 9px 14px; cursor: pointer;
    transition: background 0.2s, border-color 0.2s, transform 0.15s;
    display: inline-flex; align-items: center; gap: 8px;
}
.mv-btn:hover  { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.22); }
.mv-btn:active { transform: translateY(1px); }
.mv-btn.primary {
    border-color: rgba(245,166,35,0.5);
    background: linear-gradient(180deg, #ffd089 0%, #f5a623 60%, #d8890d 100%);
    color: #1c1100; font-weight: 700;
    box-shadow: 0 8px 22px -8px rgba(245,166,35,0.6);
}
.mv-btn.primary:hover { filter: brightness(1.06); }

/* ============================================================
   KPI cards
   ============================================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; }
@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2,1fr); } }
@media (max-width: 560px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card {
    position: relative; overflow: hidden;
    background: linear-gradient(180deg, rgba(22,30,52,0.85), rgba(14,20,38,0.85));
    border: 1px solid var(--border-mv);
    border-radius: 14px; padding: 16px 18px;
    transition: transform 0.3s var(--ease-out), border-color 0.3s;
}
.kpi-card::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(80% 80% at 100% 0%, rgba(245,166,35,0.08), transparent 60%);
}
.kpi-card:hover { transform: translateY(-2px); border-color: var(--border-mv-strong); }
.kpi-card h4 {
    margin: 0 0 8px; font-size: 11.5px; color: var(--muted);
    font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
}
.kpi-card strong {
    font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
    background: linear-gradient(180deg, #fff 0%, #ffd089 110%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* ============================================================
   Footer
   ============================================================ */
.app-footer {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; padding: 18px 4px 0;
    color: var(--muted); font-size: 12.5px;
    animation: mvFadeUp 1s var(--ease-out) both; animation-delay: 0.4s;
    position: relative; z-index: 1;
}
.app-footer a { color: var(--text-soft); text-decoration: none; transition: color 0.2s; }
.app-footer a:hover { color: var(--accent-mv-2); }
.app-footer .foot-dot { color: rgba(255,255,255,0.18); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 760px) {
    .app-shell  { padding: 16px 14px 32px; gap: 18px; }
    .app-header { padding: 8px 10px 8px 12px; border-radius: 18px; }
    .hero       { padding-top: 24px; }
    .cards      { gap: 12px; }
    .mv-card    { min-height: 168px; padding: 18px 16px; }
}
