/* Sistema de diseño — replica los tokens de contabilidad.forexycfds.com
   Fuente Inter auto-alojada (la CSP de este sitio no permite CDNs externos). */

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/inter-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/inter-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --bg: #f1f5f9;
    --card: #ffffff;
    --card-hover: #f8fafc;
    --accent: #3b82f6;
    --accent2: #6366f1;
    --green: #16a34a;
    --red: #dc2626;
    --yellow: #d97706;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.05);
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ── Navegación ── */
.site-nav {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-nav .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text);
}
.site-nav .brand-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1rem;
    color: #fff;
}
.site-nav .brand-text {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.site-nav .brand-text span { color: var(--accent); }

.nav-links { display: flex; align-items: center; gap: 0.25rem; }
.nav-links a {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-links a:hover { color: var(--text); background: var(--bg); }
.nav-links a.active { color: var(--accent); background: rgba(59, 130, 246, 0.08); }
.nav-links a.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}
.nav-links .nav-icon { font-size: 1.1rem; line-height: 1; }

.nav-right { display: flex; align-items: center; gap: 1rem; }
.nav-date { color: var(--text-muted); font-size: 0.8rem; }

.nav-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    width: 40px; height: 40px;
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background 0.15s;
}
.nav-toggle:hover, .nav-toggle:active { background: var(--bg); }

/* ── Contenedor global: 85vw en PC, 100% en móvil ── */
.container { max-width: 85vw; margin: 0 auto; padding: 1.5rem 2rem; }
@media (max-width: 768px) { .container { max-width: 100%; padding: 1rem; } }

/* ── Tarjetas ── */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card > h2 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.01em;
}
.card-sub { color: var(--text-muted); font-size: 0.85rem; margin-top: -0.6rem; margin-bottom: 1rem; }

.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    border-left: 3px solid var(--accent);
}
.stat-card .label { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; line-height: 1.2; }
.stat-card .value.small { font-size: 1.05rem; }
.stat-card .value.green { color: var(--green); }
.stat-card .value.red { color: var(--red); }
.stat-card .value.yellow { color: var(--yellow); }
.stat-card .value.blue { color: var(--accent); }
.stat-card.green { border-left-color: var(--green); }
.stat-card.yellow { border-left-color: var(--yellow); }
.stat-card.red { border-left-color: var(--red); }

/* ── Pestañas de sesión ── */
.tabs { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.tabs a {
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    background: var(--card);
    color: var(--text-muted);
    border: 1px solid var(--border);
    transition: all 0.2s;
    box-shadow: var(--shadow);
}
.tabs a:hover { color: var(--text); background: var(--card-hover); }
.tabs a.act {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    border-color: transparent;
    font-weight: 600;
}

/* ── Lista de ejercicios ── */
.ejercicio {
    display: flex;
    gap: 1rem;
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
    align-items: center;
}
.ejercicio:last-child { border-bottom: none; }
.ejercicio img.thumb {
    width: 72px; height: 72px;
    object-fit: cover;
    border-radius: 10px;
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    cursor: zoom-in;
    transition: transform 0.15s, box-shadow 0.15s;
}
.ejercicio img.thumb:hover { transform: scale(1.04); box-shadow: var(--shadow-md); }
.ejercicio .ph {
    width: 72px; height: 72px;
    border-radius: 10px;
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    opacity: 0.4;
}
.ejercicio .info { min-width: 0; flex: 1; }
.ejercicio .info b { font-size: 0.95rem; font-weight: 600; display: block; }
.ejercicio .meta { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.pill {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.08);
    color: var(--accent);
}
.pill.grey { background: var(--bg); color: var(--text-muted); }
.ejercicio .nota-ej { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }

.aviso {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 3px solid var(--yellow);
    border-radius: 8px;
    font-size: 0.85rem;
    color: #92400e;
}

.reglas { list-style: none; }
.reglas li {
    font-size: 0.87rem;
    padding: 0.45rem 0 0.45rem 1.5rem;
    position: relative;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.reglas li:last-child { border-bottom: none; }
.reglas li::before { content: "!"; position: absolute; left: 0; top: 0.45rem; width: 1rem; height: 1rem; background: #fef2f2; color: var(--red); border-radius: 50%; font-size: 0.7rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.salud-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.25rem; }
.salud-item h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; margin-bottom: 0.4rem; }
.salud-item p { font-size: 0.87rem; line-height: 1.55; }

/* ── Formularios ── */
form.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
form.grid2 .full { grid-column: 1 / -1; }
label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
    display: block;
    margin-bottom: 0.4rem;
}
input[type=text], input[type=date], input[type=number], input[type=password], select, textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
textarea { resize: vertical; min-height: 70px; }
.chk { display: flex; align-items: center; gap: 0.5rem; font-size: 0.87rem; color: var(--text); }
.chk input { width: auto; }
.hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.3rem; }

.btn {
    padding: 0.6rem 1.5rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s;
}
.btn:hover { opacity: 0.9; }
.btn-ghost {
    padding: 0.35rem 0.7rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.78rem;
    font-family: inherit;
    transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--red); color: var(--red); }

/* ── Tablas ── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.data th {
    text-align: left;
    color: var(--text-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--card-hover); }

/* ── Mensajes ── */
.msg-ok, .msg-err {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.87rem;
    margin-bottom: 1rem;
    border: 1px solid;
}
.msg-ok { background: #f0fdf4; border-color: #bbf7d0; color: var(--green); }
.msg-err { background: #fef2f2; border-color: #fecaca; color: var(--red); }
.empty { color: var(--text-muted); font-size: 0.87rem; padding: 1.5rem 0; text-align: center; }

/* ── Galería de máquinas ── */
h2.cat { font-size: 0.95rem; font-weight: 700; margin: 1.75rem 0 0.9rem; }
h2.cat:first-child { margin-top: 0; }
h2.cat .count { color: var(--text-muted); font-weight: 500; font-size: 0.85rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.tile {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.tile img { width: 100%; height: 160px; object-fit: cover; display: block; background: var(--bg); cursor: zoom-in; }
.tile .body { padding: 0.85rem 1rem; }
.tile .num {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    margin-bottom: 0.4rem;
}
.tile p { font-size: 0.8rem; color: var(--text-muted); line-height: 1.45; }

/* ── Visor de fotos a pantalla completa ── */
#lightbox {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(4px);
}
#lightbox.open { display: flex; }
#lightbox img {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    object-fit: contain;
}
#lightbox .lb-caption {
    position: absolute;
    bottom: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 0.85rem;
    background: rgba(15, 23, 42, 0.75);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    max-width: 90%;
    text-align: center;
}
#lightbox .lb-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.25);
    color: #fff;
    width: 42px; height: 42px;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
    display: flex; align-items: center; justify-content: center;
}
#lightbox .lb-close:hover { background: rgba(255,255,255,0.22); }

/* ── Modal de confirmación / aviso (nunca alert() nativo) ── */
#modal-notify {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.3);
    z-index: 9500;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    backdrop-filter: blur(4px);
}
#modal-notify.open { display: flex; }
.modal-box {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}
.modal-box .modal-icon { font-size: 2.25rem; margin-bottom: 0.6rem; }
.modal-box h3 { font-size: 1.1rem; margin-bottom: 0.5rem; font-weight: 700; }
.modal-box p { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.25rem; }
.modal-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.modal-actions .btn-cancel {
    padding: 0.6rem 1.25rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
}
.modal-actions .btn-danger {
    padding: 0.6rem 1.25rem;
    background: var(--red);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .site-nav { padding: 0 1rem; height: 56px; position: relative; }
    .nav-toggle { display: inline-flex; }
    .nav-links {
        position: absolute;
        top: 56px;
        left: 0; right: 0;
        flex-direction: column;
        align-items: stretch;
        background: var(--card);
        border-bottom: 1px solid var(--border);
        box-shadow: var(--shadow-md);
        padding: 0.5rem;
        gap: 0.15rem;
        display: none;
        z-index: 99;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }
    .nav-links.open { display: flex; }
    .nav-links a { padding: 0.75rem 1rem; font-size: 0.95rem; border-radius: 6px; }
    .nav-links a.active::after { display: none; }
    .nav-links a.active { background: rgba(59, 130, 246, 0.12); }
    .nav-date { display: none; }
    .brand-text { font-size: 1rem; }
    form.grid2 { grid-template-columns: 1fr; }
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    select, textarea, .btn, button:not(.nav-toggle):not(.btn-ghost):not(.lb-close) { min-height: 40px; }
}
@media (max-width: 600px) {
    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
    .tile img { height: 120px; }
    .ejercicio img.thumb, .ejercicio .ph { width: 56px; height: 56px; }
    .card { padding: 1rem; }
}
@media (max-width: 480px) {
    .brand-text span { display: none; }
    .container { padding: 0.75rem; }
    .site-nav { padding: 0 0.75rem; }
    .brand-icon { width: 28px; height: 28px; }
}
