/* ── Base ── */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100dvh; }
body { font-family: 'Montserrat', sans-serif; background: #f0f2f5; display: flex; flex-direction: column; }

.trunc {max-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* ── Header & Nav ── */
header { background: #2c2c2e; padding: 1rem; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 1px 4px rgba(0,0,0,.08); position: relative; }
header h3 { color: #fff; }
header nav { display: flex; align-items: center; }
header nav > a { color: #aaa; text-decoration: none; font-size: .9rem; margin-left: 1.2rem; }
header nav > a:hover, header nav > a.active { color: #fff; }
header nav > a.active { font-weight: 600; }

/* ── Main layout ── */
#app { flex: 1; overflow:hidden }
main { max-width: 1200px; width:100%; height: 100%; padding:0 1rem 1rem 1rem; margin:0 auto}

/* ── Buttons ── */
.btn { padding: .5rem 1.1rem; border-radius: 4px; font-size: .9rem; text-decoration: none; cursor: pointer; border: 1px solid #ccc; display: inline-block; font-family: inherit; }
.btn-primary { background: #4f8ef7; color: #fff; }
.btn-primary:hover { background: #3a7be0; }
.btn-secondary { background: #eee; color: #555; }
.btn-secondary:hover { background: #ddd; }
.btn-sm { padding: .3rem .7rem; font-size: .82rem; }
.btn-edit { background: #f39c12; color: #fff; }
.btn-edit:hover { background: #d68910; }
.btn-del { background: #e74c3c; color: #fff; }
.btn-del:hover { background: #c0392b; }
.btn-success { background: #27ae60; color: #fff; }
.btn-success:hover { background: #1e8449; }
.btn-warning { background: #e67e22; color: #fff; font-size: .82rem; }
.btn-warning:hover { background: #ca6f1e; }
.btn-outline { background: transparent; color: #555; border: 1px solid #ccc; }
.btn-outline:hover { border-color: #888; color: #333; }

/* ── Forms ── */
label { display: block; font-size: .8rem; color: #555; margin-bottom: .3rem; }
input, select, textarea { width: 100%; padding: .6rem .8rem; border: 1px solid #ccc; border-radius: 4px; font-size: .95rem; margin-bottom: 1rem; font-family: inherit; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #4f8ef7; }
input[readonly] { background: #f5f5f5; color: #999; cursor: default; }
textarea { resize: vertical; min-height: 80px; }
input[type=file] { padding: .5rem; border: 1px dashed #ccc; background: #fafafa; }

/* ── Messages ── */
.error { background: #fdecea; color: #c0392b; padding: .6rem .8rem; border-radius: 4px; margin-bottom: 1rem; font-size: .9rem; }
.exito { background: #eafaf1; color: #1e8449; padding: .6rem .8rem; border-radius: 4px; margin-bottom: 1rem; font-size: .9rem; }
.exito a { color: #1e8449; }
.aviso { background: #fff8e1; color: #7d6608; padding: .6rem .8rem; border-radius: 4px; font-size: .85rem; margin-bottom: 1rem; }
.msg { padding: .5rem .8rem; border-radius: 4px; margin-bottom: 1rem; font-size: .85rem; display: none; }
.msg.ok  { background: #eafaf1; color: #1e8449; }
.msg.err { background: #fdecea; color: #c0392b; }
.sin-clientes { background: #fff8e1; color: #856404; padding: .6rem .8rem; border-radius: 4px; margin-bottom: 1rem; font-size: .9rem; }
.sin-clientes a { color: #856404; }

/* ── Cards (form frame) ── */
.card { background: #fff; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.06); padding: 1.5rem; margin-bottom: 1.2rem; }
.card h3 { font-size: .9rem; text-transform: uppercase; letter-spacing: .05em; color: #aaa; margin-bottom: 1.2rem; padding-bottom: .6rem; border-bottom: 1px solid #f0f2f5; }
a.card { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: .4rem; transition: box-shadow .15s; }
a.card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.card .icon { font-size: 1.8rem; }
.card .label { font-size: 1rem; font-weight: 600; color: #333; }
.card .desc { font-size: .82rem; color: #999; }

/* ── Tables ── */
.wrapper { height: 100%; border-radius: 8px; min-width: 0; flex:1; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #f7f9fc; text-align: left; padding: .75rem 1rem; font-size: .82rem; color: #888; letter-spacing: .04em; white-space: nowrap; position: sticky;top: 0;}
td { padding: .75rem 1rem; border-top: 1px solid #f0f2f5; font-size: .92rem; color: #444; vertical-align: middle; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
tr:hover td { background: #fafbfd; }
tfoot td { background: #f7f9fc; font-weight: 600; border-top: 2px solid #e0e4ea; }
.empty { text-align: center; padding: 3rem; color: #aaa; }
.monto { font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ── Layout helpers ── */
.win-out {display:flex;flex-direction:column; max-width:600px; margin:0 auto}
.win {padding: 1rem; overflow-y: auto}
.frame {background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.06); border-radius:1rem; overflow-y:auto}

.row { display: flex; gap: 1rem; } /* fieldcontainers */
.row > div { flex: 1; } /* hijos del fieldcontainer */

.top { padding:1rem; display: flex; justify-content: space-between; align-items: center}

.actions {width:100%; display: flex; gap: .8rem; margin-top: 1rem; }
.actions-row { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
code { background: #f5f5f5; padding: .1rem .3rem; border-radius: 3px; font-size: .85em; }

/* ── Loading overlay & Confirm modal ── */
#loading-overlay, #confirm-modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 9999; align-items: center; justify-content: center; }
#confirm-modal { flex-direction: column; }
.confirm-card { background: #fff; border-radius: 10px; padding: 1.5rem 1.8rem; max-width: 360px; width: 90%; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.confirm-msg { font-size: .95rem; color: #333; margin-bottom: 1.3rem; line-height: 1.5; }
.confirm-actions { display: flex; gap: .6rem; justify-content: flex-end; }
#loading-overlay { flex-direction: column; gap: 1rem; }
.overlay-spinner { width: 38px; height: 38px; border: 4px solid rgba(0,0,0,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
#loading-overlay span { font-size: 1rem; }

/* ── Bottom nav (mobile) ── */
.bottom-nav { display: none; }

/* ── PWA + Responsive overrides ── */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: .35rem .45rem;
    color: #555;
    font-size: 1.5rem;
    line-height: 1;
    margin-left: auto;
    flex-shrink: 0;
}

@media (display-mode: standalone) {
    body { padding-top: env(safe-area-inset-top, 0); }
}

@media (min-width: 1024px) {
    .movil {display:none}
}

@media (max-width: 1024px) {
    .desk {display:none}
    
    main {max-width:600px}

    .nav-toggle { display: none; }

    header nav { display: none !important; }

    .bottom-nav {
        display: flex;
        background: #2c2c2e;
        box-shadow: 0 -2px 10px rgba(0,0,0,.25);
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: .25rem;
        padding: .75rem 0 .6rem;
        text-decoration: none;
        color: #888;
        font-size: .68rem;
    }

    .bottom-nav-item svg { width: 22px; height: 22px; }
    .bottom-nav-item.active { color: #4f8ef7; }

    .row { flex-direction: column; gap: 0; }

    .wrapper {
        -webkit-overflow-scrolling: touch;
    }

    .wrapper thead { display:none }

    .card { padding: 1.2rem; }

    .actions { flex-wrap: wrap; }
}

/* Instructivo certificado */
.instructivo { display: flex; flex-direction: column; gap: 1.2rem; margin-top: .8rem; }
.inst-bloque { background: #f8f9fa; border-radius: 8px; padding: 1rem 1.2rem; }
.inst-subtitulo { font-weight: 600; font-size: .9rem; margin-bottom: .6rem; color: #333; }
.inst-bloque ol { margin: 0; padding-left: 1.3rem; }
.inst-bloque ol li { margin-bottom: .4rem; font-size: .88rem; line-height: 1.5; }
.inst-tabla { width: 100%; border-collapse: collapse; font-size: .85rem; }
.inst-tabla th { text-align: left; padding: .4rem .6rem; background: #eee; font-weight: 600; }
.inst-tabla td { padding: .4rem .6rem; border-bottom: 1px solid #e5e5e5; }
.inst-tabla tr:last-child td { border-bottom: none; }
