/* ============================================================
   Plataforma MiG — sistema de diseño (dark fintech)
   ============================================================ */
:root {
    --bg:        #0a0e13;
    --bg-grid:   rgba(255,255,255,0.018);
    --surface:   #11161e;
    --surface-2: #161d27;
    --surface-3: #1c2531;
    --border:    rgba(255,255,255,0.07);
    --border-strong: rgba(255,255,255,0.12);

    --text:      #e8eef5;
    --text-soft: #aab6c4;
    --muted:     #6f7c8d;

    --accent:    #2dd4bf;   /* teal de marca */
    --accent-2:  #14b8a6;
    --accent-soft: rgba(45,212,191,0.12);
    --accent-glow: rgba(45,212,191,0.35);

    --prod:      #34d399;   /* producción = verde */
    --prod-soft: rgba(52,211,153,0.13);
    --prueba:    #fbbf24;   /* pruebas = ámbar */
    --prueba-soft: rgba(251,191,36,0.13);

    --radius:    14px;
    --radius-sm: 10px;
    --shadow:    0 16px 40px -18px rgba(0,0,0,0.7);

    --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
    --font-body:    'Manrope', system-ui, sans-serif;
    --font-mono:    'JetBrains Mono', ui-monospace, monospace;

    --sidebar-w: 264px;
}

/* ---------- base ---------- */
html, body {
    font-family: var(--font-body);
    background-color: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

body {
    background-image:
        radial-gradient(900px 500px at 18% -8%, rgba(45,212,191,0.10), transparent 60%),
        radial-gradient(700px 500px at 100% 0%, rgba(56,103,214,0.08), transparent 55%),
        linear-gradient(var(--bg-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
    background-size: 100% 100%, 100% 100%, 34px 34px, 34px 34px;
    background-attachment: fixed;
    min-height: 100vh;
}

::selection { background: var(--accent-soft); color: #fff; }

h1, h2, h3, h4, .display { font-family: var(--font-display); letter-spacing: -0.01em; }

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

/* scrollbar */
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 20px; border: 3px solid var(--bg); }
*::-webkit-scrollbar-thumb:hover { background: #2b3645; }

/* ---------- layout ---------- */
.page { position: relative; display: flex; flex-direction: column; }

.sidebar {
    background: linear-gradient(180deg, #0d131b 0%, #0a0e13 100%);
    border-right: 1px solid var(--border);
}

main { flex: 1; min-width: 0; }

.topbar {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    background: rgba(10,14,19,0.72);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 20;
}
.topbar .eyebrow {
    font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
    color: var(--muted); font-weight: 600;
}
.status-pill {
    display: inline-flex; align-items: center; gap: .5rem;
    font-size: .78rem; color: var(--text-soft);
    background: var(--surface); border: 1px solid var(--border);
    padding: .35rem .7rem; border-radius: 999px;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--prod); box-shadow: 0 0 0 3px var(--prod-soft); }

.content { padding: 1.9rem 1.75rem 3rem; max-width: 1280px; }

@media (min-width: 641px) {
    .page { flex-direction: row; }
    .sidebar { width: var(--sidebar-w); height: 100vh; position: sticky; top: 0; }
}

/* ---------- sidebar / nav ---------- */
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.35rem 1.25rem 1.25rem; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 12px; flex: none;
    display: grid; place-items: center;
    font-family: var(--font-display); font-weight: 700; font-size: 1.2rem; color: #06201c;
    background: linear-gradient(145deg, var(--accent), var(--accent-2));
    box-shadow: 0 8px 22px -6px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,.4);
}
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.brand-sub  { font-size: .7rem; color: var(--muted); letter-spacing: .04em; }

.nav-section { padding: .5rem .85rem; }
.nav-label { font-size: .68rem; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); padding: .5rem .65rem; font-weight: 600; }

.nav-scrollable { display: flex; flex-direction: column; height: 100%; }

.nav-link.mig {
    display: flex; align-items: center; gap: .8rem;
    color: var(--text-soft); font-weight: 500; font-size: .92rem;
    padding: .62rem .7rem; margin: .12rem 0; border-radius: var(--radius-sm);
    position: relative; transition: background .15s, color .15s;
}
.nav-link.mig i { font-size: 1.05rem; width: 1.3rem; text-align: center; color: var(--muted); transition: color .15s; }
.nav-link.mig:hover { background: var(--surface); color: var(--text); }
.nav-link.mig:hover i { color: var(--text-soft); }
.nav-link.mig.active {
    background: var(--accent-soft); color: #eafffb;
}
.nav-link.mig.active i { color: var(--accent); }
.nav-link.mig.active::before {
    content: ""; position: absolute; left: -.85rem; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.sidebar-foot { margin-top: auto; padding: 1rem 1.4rem; border-top: 1px solid var(--border); font-size: .72rem; color: var(--muted); }

/* ---------- page header ---------- */
.page-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: 1.6rem; }
.page-head .ph-icon {
    width: 48px; height: 48px; border-radius: 13px; flex: none; display: grid; place-items: center;
    background: var(--surface-2); border: 1px solid var(--border); color: var(--accent); font-size: 1.4rem;
}
.page-head h1 { font-size: 1.6rem; margin: 0; font-weight: 700; }
.page-head p { color: var(--muted); margin: .25rem 0 0; font-size: .92rem; }

/* ---------- cards ---------- */
.mig-card {
    background: linear-gradient(180deg, var(--surface), var(--surface) 60%, rgba(22,29,39,.6));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.mig-card.pad { padding: 1.15rem 1.25rem; }

/* ---------- toolbar / filtros ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; padding: 1.1rem 1.25rem; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field > label { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.mig-input, .mig-select {
    background: var(--bg); color: var(--text);
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: .55rem .8rem; font-family: var(--font-body); font-size: .92rem; font-weight: 500;
    outline: none; transition: border-color .15s, box-shadow .15s;
}
.mig-input:focus, .mig-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mig-select { cursor: pointer; min-width: 150px; }
.mig-input { width: 110px; font-family: var(--font-mono); }

/* control segmentado ambiente */
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 4px; gap: 4px; }
.seg-btn {
    display: inline-flex; align-items: center; gap: .45rem;
    border: 0; background: transparent; color: var(--text-soft);
    font-family: var(--font-body); font-weight: 600; font-size: .86rem;
    padding: .42rem .85rem; border-radius: 7px; cursor: pointer; transition: all .15s;
}
.seg-btn i { font-size: .95rem; }
.seg-btn:hover { color: var(--text); }
.seg-btn.on.prueba { background: var(--prueba-soft); color: #ffd97a; box-shadow: inset 0 0 0 1px rgba(251,191,36,.35); }
.seg-btn.on.prod   { background: var(--prod-soft);   color: #7df0c0; box-shadow: inset 0 0 0 1px rgba(52,211,153,.35); }

/* ---------- botones ---------- */
.mig-btn {
    display: inline-flex; align-items: center; gap: .5rem;
    font-family: var(--font-body); font-weight: 600; font-size: .9rem;
    padding: .58rem 1.05rem; border-radius: var(--radius-sm); border: 1px solid transparent;
    cursor: pointer; transition: transform .08s, filter .15s, background .15s; white-space: nowrap;
}
.mig-btn:active { transform: translateY(1px); }
.mig-btn-primary { background: linear-gradient(145deg, var(--accent), var(--accent-2)); color: #042620; box-shadow: 0 8px 20px -8px var(--accent-glow); }
.mig-btn-primary:hover { filter: brightness(1.08); color: #042620; }
.mig-btn-primary:disabled { opacity: .55; cursor: default; }
.mig-btn-excel { background: var(--surface-2); color: #7df0c0; border-color: rgba(52,211,153,.3); }
.mig-btn-excel:hover { background: var(--surface-3); color: #7df0c0; }
.mig-btn-ghost { background: var(--surface); color: var(--text-soft); border-color: var(--border); }
.mig-btn-ghost:hover { background: var(--surface-2); color: var(--text); }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin: 1.4rem 0; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: 1rem; position: relative; overflow: hidden;
}
.stat .s-icon { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.stat .s-icon.teal  { background: var(--accent-soft); color: var(--accent); }
.stat .s-icon.green { background: var(--prod-soft); color: var(--prod); }
.stat .s-icon.amber { background: var(--prueba-soft); color: var(--prueba); }
.stat .s-val { font-family: var(--font-mono); font-size: 1.7rem; font-weight: 600; line-height: 1; letter-spacing: -.02em; }
.stat .s-lbl { font-size: .78rem; color: var(--muted); margin-top: .3rem; }

/* ---------- badges ---------- */
.amb-badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .76rem; font-weight: 700; letter-spacing: .04em; padding: .28rem .65rem; border-radius: 999px; }
.amb-badge.prueba { background: var(--prueba-soft); color: #ffd97a; }
.amb-badge.prod   { background: var(--prod-soft); color: #7df0c0; }

.doc-badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .78rem; font-weight: 600; padding: .2rem .55rem; border-radius: 7px; background: var(--surface-3); color: var(--text-soft); }

/* ---------- tabla ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.mig-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.mig-table thead th {
    text-align: left; font-family: var(--font-body); font-weight: 600;
    font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
    background: var(--surface-2); padding: .8rem 1rem; border-bottom: 1px solid var(--border);
}
.mig-table tbody td { padding: .72rem 1rem; border-bottom: 1px solid var(--border); color: var(--text-soft); }
.mig-table tbody tr { background: var(--surface); transition: background .12s; }
.mig-table tbody tr:hover { background: var(--surface-2); }
.mig-table tbody tr:last-child td { border-bottom: 0; }
.mig-table .org { color: var(--text); font-weight: 600; }
.mig-table .num { font-family: var(--font-mono); text-align: right; color: var(--text); font-weight: 600; }
.mig-table .mono { font-family: var(--font-mono); font-size: .85rem; color: var(--text-soft); }
.mig-table tfoot td { padding: .8rem 1rem; background: var(--surface-2); font-weight: 700; color: var(--text); border-top: 1px solid var(--border-strong); }
.mig-table tfoot .num { font-family: var(--font-mono); text-align: right; color: var(--accent); font-size: 1.05rem; }

/* estado vacío */
.empty { text-align: center; padding: 3.5rem 1rem; color: var(--muted); }
.empty i { font-size: 2.4rem; color: var(--surface-3); display: block; margin-bottom: .8rem; }

/* ---------- home / dashboard ---------- */
.hero { padding: .5rem 0 1.5rem; }
.hero h1 { font-size: 2.1rem; font-weight: 700; margin: 0 0 .4rem; }
.hero .lead { color: var(--text-soft); font-size: 1.02rem; max-width: 620px; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: 1.1rem; margin-top: 1.6rem; }
.tile { display: block; padding: 1.4rem; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); transition: transform .12s, border-color .15s; }
.tile:hover { transform: translateY(-3px); border-color: var(--border-strong); }
.tile .t-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; background: var(--accent-soft); color: var(--accent); margin-bottom: .9rem; }
.tile h3 { font-size: 1.1rem; margin: 0 0 .35rem; color: var(--text); }
.tile p { color: var(--muted); font-size: .9rem; margin: 0; }

/* ---------- animaciones ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise { animation: rise .45s cubic-bezier(.2,.7,.2,1) both; }
.rise-1 { animation-delay: .05s; } .rise-2 { animation-delay: .12s; } .rise-3 { animation-delay: .19s; }

/* ---------- topbar usuario ---------- */
.topbar-user { color: var(--text-soft); font-size: .85rem; display: inline-flex; align-items: center; gap: .4rem; }
.topbar-user i { color: var(--accent); font-size: 1rem; }
.topbar-logout { padding: .4rem .65rem !important; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2rem; gap: 1rem; }
.login-card {
    width: 100%; max-width: 380px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 2.2rem 2rem; display: flex; flex-direction: column;
}
.login-logo { margin: 0 auto .9rem; width: 52px; height: 52px; font-size: 1.5rem; }
.login-card h1 { text-align: center; font-size: 1.4rem; margin: 0 0 .25rem; }
.login-sub { text-align: center; color: var(--muted); font-size: .82rem; margin: 0 0 1.4rem; }
.login-card label { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: .85rem 0 .35rem; }
.mig-input.full { width: 100%; font-family: var(--font-body); }
.login-btn { width: 100%; justify-content: center; margin-top: 1.5rem; padding: .7rem; }
.login-error { background: rgba(248,113,113,.12); color: #fca5a5; border: 1px solid rgba(248,113,113,.3); border-radius: var(--radius-sm); padding: .6rem .8rem; font-size: .85rem; display: flex; align-items: center; gap: .5rem; margin-bottom: .3rem; }
.login-foot { color: var(--muted); font-size: .75rem; }

/* ---------- error ui ---------- */
#blazor-error-ui {
    background: #1a1410; color: #ffd97a; border-top: 1px solid rgba(251,191,36,.3);
    bottom: 0; box-shadow: 0 -8px 30px rgba(0,0,0,.5); display: none;
    left: 0; padding: .75rem 1.25rem; position: fixed; width: 100%; z-index: 1000;
    font-size: .9rem;
}
#blazor-error-ui .reload { color: var(--accent); margin-left: 1rem; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; color: var(--muted); }

/* ============================================================
   Logo (placa blanca para que luzca sobre el tema oscuro)
   ============================================================ */
.logo-plate {
    background: #fff; border-radius: 12px; padding: .7rem .9rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 20px -10px rgba(0,0,0,.55);
}
.logo-plate img { display: block; width: 100%; height: auto; }
.brand { display: flex; flex-direction: column; align-items: stretch; gap: .55rem; }
.brand-logo { width: 100%; }
.brand-cap { font-size: .66rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); text-align: center; font-weight: 600; }
.login-logo-plate { width: 210px; margin: 0 auto 1.2rem; }

/* ============================================================
   Tabla con scroll horizontal (móvil)
   ============================================================ */
.table-wrap { overflow-x: auto; }
.mig-table { min-width: 680px; }

/* ============================================================
   Responsive — sidebar off-canvas con hamburguesa (CSS puro)
   ============================================================ */
.nav-toggle-cb { display: none; }
.hamburger { display: none; }
.nav-overlay { display: none; }

@media (max-width: 640px) {
    .hamburger {
        display: grid; place-items: center; width: 40px; height: 40px;
        border-radius: 10px; background: var(--surface); border: 1px solid var(--border);
        color: var(--text); font-size: 1.35rem; cursor: pointer; flex: none;
    }
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; width: 262px; z-index: 60;
        transform: translateX(-100%); transition: transform .25s ease;
        box-shadow: 14px 0 50px rgba(0,0,0,.55);
    }
    .nav-toggle-cb:checked ~ .sidebar { transform: translateX(0); }
    .nav-toggle-cb:checked ~ .nav-overlay {
        display: block; position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 55;
    }

    .content { padding: 1.2rem 1rem 2.5rem; }
    .topbar { padding: 0 1rem; }
    .eyebrow { display: none; }
    .status-txt { display: none; }
    .status-pill { padding: .35rem .45rem; }

    .page-head { gap: .75rem; margin-bottom: 1.2rem; }
    .page-head .ph-icon { width: 40px; height: 40px; font-size: 1.2rem; }
    .page-head h1 { font-size: 1.3rem; }
    .hero h1 { font-size: 1.6rem; }

    .toolbar { padding: 1rem; gap: .85rem; }
    .field { flex: 1 1 100%; }
    .mig-input, .mig-select { width: 100%; }
    .seg { width: 100%; }
    .seg-btn { flex: 1; justify-content: center; }
    .stats { grid-template-columns: 1fr; }
    .mig-btn { width: 100%; justify-content: center; }
    .toolbar .field[style*="margin-left"] { margin-left: 0 !important; }
}

/* ============================================================
   Certificados
   ============================================================ */
.cert-status { display: inline-flex; align-items: center; gap: .4rem; font-size: .75rem; font-weight: 700; letter-spacing: .03em; padding: .28rem .6rem; border-radius: 999px; white-space: nowrap; }
.cert-status.ok   { background: var(--prod-soft);   color: #7df0c0; }
.cert-status.warn { background: var(--prueba-soft); color: #ffd97a; }
.cert-status.crit { background: rgba(248,113,113,.14); color: #fca5a5; }
.cert-dias { font-family: var(--font-mono); font-weight: 600; }

.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .upload-grid { grid-template-columns: 1fr; } }
.mig-file { background: var(--bg); color: var(--text-soft); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); padding: .6rem .8rem; width: 100%; font-size: .88rem; cursor: pointer; }
.mig-file::file-selector-button { background: var(--surface-3); color: var(--text); border: 0; border-radius: 7px; padding: .35rem .7rem; margin-right: .7rem; cursor: pointer; font-family: var(--font-body); }
.alert-ok  { background: var(--prod-soft); color: #7df0c0; border: 1px solid rgba(52,211,153,.3); border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .88rem; display: flex; align-items: center; gap: .5rem; }
.alert-err { background: rgba(248,113,113,.12); color: #fca5a5; border: 1px solid rgba(248,113,113,.3); border-radius: var(--radius-sm); padding: .7rem .9rem; font-size: .88rem; display: flex; align-items: center; gap: .5rem; }
