:root{
    --bg:#f4f7fb;
    --dark:#0f172a;
    --muted:#64748b;
    --card:#ffffff;
    --primary:#2563eb;
    --primary2:#1d4ed8;
    --success:#16a34a;
    --danger:#dc2626;
    --border:#e2e8f0;
    --radius:18px;
}

*{
    box-sizing:border-box;
}

body{
    margin:0;
    font-family:Arial, sans-serif;
    background:var(--bg);
    color:var(--dark);
}

#app{
    display:none;
}

#loader{
    position:fixed;
    inset:0;
    background:#0f172a;
    color:white;
    display:flex;
    align-items:center;
    justify-content:center;
    font-size:18px;
    z-index:9999;
}

.screen,
.view,
.step{
    display:none;
}

.screen.active,
.view.active,
.step.active{
    display:block;
}

.login-wrap{
    min-height:100vh;
    display:flex;
    flex-direction:column;
    justify-content:center;
    padding:22px;
    background:linear-gradient(160deg,#0f172a,#1e3a8a);
}

.brand-card{
    color:white;
    margin-bottom:22px;
}

.brand-icon{
    width:58px;
    height:58px;
    border-radius:18px;
    display:grid;
    place-items:center;
    background:rgba(255,255,255,.15);
    font-size:30px;
    margin-bottom:14px;
}

.brand-card h1{
    margin:0;
    font-size:28px;
}

.brand-card p{
    margin:8px 0 0;
    opacity:.8;
}

.auth-card,
.status-card,
.profile-card,
.action-card,
.list-card{
    background:var(--card);
    border-radius:var(--radius);
    box-shadow:0 12px 35px rgba(15,23,42,.08);
}

.auth-card{
    padding:22px;
}

label{
    display:block;
    font-size:14px;
    margin:14px 0 7px;
    color:#334155;
    font-weight:700;
}

input,
select{
    width:100%;
    border:1px solid var(--border);
    border-radius:14px;
    padding:14px;
    font-size:16px;
    background:#fff;
}

input:focus,
select:focus{
    outline:2px solid rgba(37,99,235,.2);
    border-color:var(--primary);
}

input:invalid{
    border:2px solid #dc2626;
}

.required-mark{
    color:#dc2626;
    font-weight:700;
    font-size:1.1em;
}

.check-row{
    display:flex;
    align-items:center;
    gap:10px;
    font-weight:400;
}

.check-row input{
    width:auto;
}

.btn-primary,
.btn-secondary,
.btn-small,
.btn-icon,
.btn-back{
    border:0;
    border-radius:14px;
    padding:14px 16px;
    font-weight:800;
    cursor:pointer;
}

.btn-primary{
    width:100%;
    background:linear-gradient(135deg,var(--primary),var(--primary2));
    color:white;
    margin-top:18px;
}

.btn-secondary{
    width:100%;
    background:#e2e8f0;
    color:#0f172a;
    margin-top:18px;
}

.btn-small{
    background:var(--dark);
    color:white;
    padding:10px 14px;
}

.btn-icon{
    background:#fee2e2;
    color:var(--danger);
}

.btn-back{
    width:42px;
    height:42px;
    padding:0;
    background:#e2e8f0;
}

.msg{
    margin-top:12px;
    font-size:14px;
    color:var(--danger);
}

.offline-note{
    margin-top:18px;
    color:var(--muted);
    font-size:13px;
    text-align:center;
}

.app-header{
    position:sticky;
    top:0;
    z-index:5;
    background:white;
    padding:16px;
    display:flex;
    justify-content:space-between;
    align-items:center;
    border-bottom:1px solid var(--border);
}

.app-header small{
    color:var(--muted);
}

.app-header h2{
    margin:3px 0 0;
    font-size:20px;
}

.app-main{
    padding:16px;
}

.status-card{
    padding:16px;
    display:flex;
    justify-content:space-between;
    align-items:center;
    margin-bottom:16px;
}

.status-card span{
    display:block;
    color:var(--muted);
    font-size:13px;
    margin-top:4px;
}

.grid-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:14px;
}

.action-card{
    border:0;
    min-height:130px;
    padding:18px;
    text-align:left;
    font-size:16px;
    font-weight:800;
    color:var(--dark);
}

.action-card span{
    display:block;
    font-size:34px;
    margin-bottom:14px;
}

.view{
    margin-top:16px;
}

.view-head{
    display:flex;
    align-items:center;
    gap:12px;
    margin-bottom:16px;
}

.view-head h3{
    margin:0;
    font-size:22px;
}

.steps{
    background:white;
    padding:18px;
    border-radius:var(--radius);
    box-shadow:0 12px 35px rgba(15,23,42,.08);
}

.step h4{
    margin:0 0 14px;
    font-size:20px;
}

.row-actions{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px;
}

.hidden{
    display:none;
}

canvas{
    width:100%;
    height:230px;
    background:white;
    border:2px dashed #cbd5e1;
    border-radius:16px;
    touch-action:none;
}

.list{
    display:grid;
    gap:12px;
}

.list-card{
    padding:16px;
}

.list-card h4{
    margin:0 0 6px;
}

.list-card p{
    margin:4px 0;
    color:var(--muted);
    font-size:14px;
}

.badge{
    display:inline-block;
    padding:5px 10px;
    border-radius:999px;
    font-size:12px;
    font-weight:800;
    background:#fef3c7;
    color:#92400e;
}

.empty{
    color:var(--muted);
    text-align:center;
    margin-top:40px;
}

.profile-card{
    padding:18px;
}

@media(min-width:768px){
    .app-main{
        max-width:900px;
        margin:auto;
    }

    .login-wrap{
        align-items:center;
    }

    .brand-card,
    .auth-card{
        width:430px;
    }

    .grid-actions{
        grid-template-columns:repeat(4,1fr);
    }
}

.summary-card,
.detail-card{
    background:#fff;
    border-radius:18px;
    padding:16px;
    box-shadow:0 12px 35px rgba(15,23,42,.08);
}

.summary-row{
    padding:10px 0;
    border-bottom:1px solid #e2e8f0;
}

.summary-row:last-child{
    border-bottom:0;
}

.summary-row span{
    display:block;
    color:#64748b;
    font-size:13px;
    margin-bottom:3px;
}

.summary-row strong{
    font-size:15px;
}

.detail-actions{
    display:grid;
    gap:10px;
    margin-top:16px;
}

.signature-preview{
    width:100%;
    max-height:180px;
    object-fit:contain;
    background:#fff;
    border:1px dashed #cbd5e1;
    border-radius:14px;
    margin-top:10px;
}

.contract-progress{
    margin-bottom:14px;
}

.contract-progress span{
    display:block;
    font-size:13px;
    color:#64748b;
    margin-bottom:8px;
    font-weight:700;
}

.progress-bar{
    width:100%;
    height:8px;
    border-radius:999px;
    background:#e2e8f0;
    overflow:hidden;
}

#progressFill{
    height:100%;
    width:0%;
    background:linear-gradient(135deg,#2563eb,#1d4ed8);
    transition:.25s ease;
}

.field-box{
    margin-bottom:14px;
}

.field-box.hidden{
    display:none;
}

.field-error{
    color:#dc2626;
    font-size:13px;
    margin-top:5px;
    display:none;
}

.field-box.error input,
.field-box.error select,
.field-box.error textarea{
    border:2px solid #dc2626;
}

.field-box.error .field-error{
    display:block;
}

textarea{
    width:100%;
    border:1px solid var(--border);
    border-radius:14px;
    padding:14px;
    font-size:16px;
    resize:vertical;
    min-height:110px;
}

.image-preview{
    width:100%;
    border-radius:14px;
    margin-top:10px;
    border:1px solid #e2e8f0;
}

.check-row{
    display:flex;
    align-items:center;
    gap:10px;
    font-weight:500;
    margin-top:8px;
}

.check-row input{
    transform:scale(1.2);
}

input[type="file"]{
    padding:10px;
    background:#f1f5f9;
    border:1px dashed #94a3b8;
}

input[type="radio"],
input[type="checkbox"]{
    width:auto;
}

.field-box{
    margin-bottom:16px;
}

.field-box label{
    font-weight:700;
}

.field-box.error input,
.field-box.error select,
.field-box.error textarea{
    border:2px solid #dc2626;
}

.detail-section-title{
    margin:18px 0 8px;
    padding:10px 12px;
    border-radius:12px;
    background:#f1f5f9;
    color:#0f172a;
    font-weight:800;
    font-size:14px;
}

.image-dropdown{
    margin-top:10px;
}

.image-dropdown summary{
    cursor:pointer;
    font-weight:800;
    color:#2563eb;
    padding:10px 12px;
    background:#eff6ff;
    border-radius:12px;
}

.image-dropdown[open] summary{
    margin-bottom:10px;
}

.location-card{
    background:#f8fafc;
    border:1px solid #e2e8f0;
    border-radius:16px;
    padding:14px;
}

.location-card p{
    margin:6px 0;
    color:#334155;
}

.muted{
    color:#64748b;
}

.graduacion-input-group{
    display:flex;
    flex-direction:column;
    gap:6px;
}

.graduacion-signos{
    display:flex;
    gap:8px;
    justify-content:center;
    font-size:13px;
}

.graduacion-signos label{
    display:flex;
    align-items:center;
    gap:3px;
}
.hi-index-alert{
    background:#fff7ed;
    border:1px solid #fdba74;
    color:#9a3412;
    padding:10px 12px;
    border-radius:10px;
    margin:10px 0;
    font-size:14px;
}

.hidden{
    display:none;
}

.signature-terms{
    background:#f8fafc;
    border:1px solid #e5e7eb;
    border-radius:10px;
    padding:10px;
    margin:10px 0;
    font-size:13px;
    color:#111827;
}

.signature-terms small{
    font-size:11px;
    color:#374151;
    line-height:1.4;
}


.print-modal{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.55);
    z-index:9999;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
}

.print-modal.hidden{
    display:none;
}

.print-modal-card{
    background:#fff;
    border-radius:18px;
    padding:22px;
    max-width:360px;
    width:100%;
    text-align:center;
}

.print-modal-card h3{
    margin-bottom:8px;
}

.print-modal-card p{
    font-size:14px;
    color:#555;
    margin-bottom:18px;
}