* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --primary: #0066a4;
    --primary-dark: #004a7a;
    --accent: #e63946;
    --bg: #f5f7fa;
    --white: #ffffff;
    --gray-light: #e9ecef;
    --gray: #6c757d;
    --text: #212529;
    --border: #ced4da;
    --triage-1: #dc3545;
    --triage-2: #fd7e14;
    --triage-3: #ffc107;
    --triage-4: #28a745;
    --triage-5: #007bff;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.4;
}
.container { max-width: 900px; margin: 0 auto; padding: 10px; }
.header {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--white); border: 2px solid var(--primary);
    border-radius: 8px; padding: 10px 15px; margin-bottom: 10px;
}
.header-logo { display: flex; align-items: center; gap: 10px; }
.header-logo svg { width: 60px; height: 60px; }
.header-title { text-align: center; flex: 1; }
.header-title h1 { font-size: 1.3rem; color: var(--primary); font-weight: 700; }
.header-title p { font-size: 0.75rem; color: var(--gray); }
.header-meta { display: flex; flex-direction: column; gap: 5px; }

.header-meta label { font-size: 0.7rem; font-weight: 600; color: var(--primary); }
.header-meta input { width: 130px; padding: 3px 6px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.8rem; }
.section { background: var(--white); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.section-header { background: var(--primary); color: white; padding: 8px 15px; font-weight: 600; font-size: 0.85rem; }
.section-body { padding: 12px 15px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 8px; }
.form-row-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 8px; }
.form-group { display: flex; flex-direction: column; }
.form-group label { font-size: 0.7rem; font-weight: 600; color: var(--primary-dark); margin-bottom: 2px; text-transform: uppercase; }
.form-group input, .form-group select, .form-group textarea {
    padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 0.85rem; transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0,102,164,0.1);
}
.form-group textarea { resize: vertical; min-height: 60px; }
.form-group-full { grid-column: 1 / -1; }
.checkbox-group { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.checkbox-group label {
    display: flex; align-items: center; gap: 4px; font-size: 0.8rem;
    font-weight: normal; color: var(--text); cursor: pointer; text-transform: none;
}
.checkbox-group input[type="checkbox"], .checkbox-group input[type="radio"] { width: 16px; height: 16px; cursor: pointer; }

/* Triage */
.triage-selector { display: flex; gap: 5px; flex-wrap: wrap; }
.triage-btn {
    padding: 8px 12px; border: 2px solid transparent; border-radius: 6px;
    cursor: pointer; font-weight: 600; font-size: 0.75rem; color: white;
    transition: all 0.2s; text-align: center; min-width: 70px;
    position: relative;
}
.triage-btn.t1 { background: var(--triage-1); }
.triage-btn.t2 { background: var(--triage-2); }
.triage-btn.t3 { background: var(--triage-3); color: #333; }
.triage-btn.t4 { background: var(--triage-4); }
.triage-btn.t5 { background: var(--triage-5); }
.triage-btn.active { border-color: #000; transform: scale(1.1); box-shadow: 0 2px 8px rgba(0,0,0,0.3); }
.triage-btn::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: #222;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 400;
    white-space: pre-line;
    text-align: left;
    width: 220px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    line-height: 1.4;
}
.triage-btn:hover::after, .triage-btn:focus::after {
    opacity: 1;
}
/* Body diagram */
.body-diagram-container { display: flex; justify-content: center; }
.body-img-wrap {
    position: relative; cursor: crosshair; display: inline-block;
    max-width: 100%; border: 1px solid var(--border); border-radius: 4px; overflow: hidden;
}
.body-img-wrap img {
    display: block; width: 100%; max-width: 500px; height: auto;
    user-select: none; -webkit-user-drag: none; pointer-events: none;
}
.body-svg-wrap { position: relative; flex: 0 0 auto; cursor: crosshair; }
.body-svg-wrap svg { width: 140px; height: 330px; }
.body-marker {
    position: absolute; width: 14px; height: 14px; background: var(--accent);
    border: 2px solid #fff; border-radius: 50%; transform: translate(-50%, -50%);
    pointer-events: none; box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.hallazgos-text { flex: 1; min-width: 200px; }
.btn-clear-markers { margin-top: 5px; }
/* Signature */
.signatures-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.signature-box { border: 1px solid var(--border); border-radius: 6px; padding: 10px; }
.signature-box h4 { font-size: 0.75rem; color: var(--primary-dark); margin-bottom: 6px; text-transform: uppercase; }
.signature-canvas { border: 1px dashed var(--border); border-radius: 4px; width: 100%; height: 80px; touch-action: none; cursor: crosshair; display: block; }
.signature-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 5px; }
.btn-sm { padding: 4px 10px; border: 1px solid var(--border); border-radius: 4px; background: var(--gray-light); cursor: pointer; font-size: 0.75rem; }
.btn-sm:hover { background: var(--border); }
.sig-file { font-size: 0.7rem; max-width: 120px; }

/* Buttons */
.actions-bar { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 15px 0; padding: 15px; background: var(--white); border-radius: 8px; border: 1px solid var(--border); }
.btn { padding: 12px 24px; border: none; border-radius: 6px; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: #28a745; color: white; }
.btn-success:hover { background: #1e7e34; }
.btn-danger { background: var(--accent); color: white; }
.btn-danger:hover { background: #c5303c; }
.btn-warning { background: #fd7e14; color: white; }
.btn-warning:hover { background: #e06c00; }
/* Records */
.records-section { margin-top: 15px; background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 15px; overflow-x: auto; }
.records-section h3 { color: var(--primary); margin-bottom: 10px; font-size: 1rem; }
.records-table { width: 100%; border-collapse: collapse; font-size: 0.72rem; }
.records-table th, .records-table td { padding: 5px 6px; border: 1px solid var(--border); text-align: left; white-space: nowrap; }
.records-table th { background: var(--primary); color: white; }
.records-table tr:nth-child(even) { background: var(--gray-light); }
.records-table .btn-edit, .records-table .btn-del { padding: 2px 6px; font-size: 0.7rem; cursor: pointer; border: none; border-radius: 3px; color: white; }
.records-table .btn-edit { background: var(--primary); }
.records-table .btn-del { background: var(--accent); }
/* Toast */
.toast { position: fixed; bottom: 20px; right: 20px; background: #333; color: white; padding: 12px 20px; border-radius: 6px; font-size: 0.85rem; z-index: 9999; opacity: 0; transition: opacity 0.3s; }
.toast.show { opacity: 1; }
/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 10000;
    display: flex; align-items: center; justify-content: center;
    padding: 15px;
}
.modal-box {
    background: white; border-radius: 10px; width: 100%; max-width: 450px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3); overflow: hidden;
}
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 18px; background: var(--primary); color: white;
}
.modal-header h3 { font-size: 0.95rem; margin: 0; }
.modal-close {
    background: none; border: none; color: white; font-size: 1.5rem;
    cursor: pointer; line-height: 1; padding: 0 4px;
}
.modal-body { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.modal-body .form-group label { font-size: 0.75rem; }
.modal-body .form-group input { padding: 8px 10px; font-size: 0.9rem; }
.modal-footer { padding: 12px 18px; display: flex; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--border); }
.modal-footer .btn { padding: 8px 18px; font-size: 0.85rem; }
/* Responsive */
@media (max-width: 768px) {
    .container { padding: 5px; }
    .header { flex-direction: column; text-align: center; gap: 8px; }
    .header-meta { flex-direction: row; }
    .form-row { grid-template-columns: 1fr 1fr; }
    .form-row-5 { grid-template-columns: repeat(3, 1fr); }
    .signatures-grid { grid-template-columns: 1fr; }
    .body-diagram-container { flex-direction: column; align-items: center; }
    .triage-btn { min-width: 55px; padding: 6px 8px; font-size: 0.7rem; }
}
@media (max-width: 480px) {
    .form-row { grid-template-columns: 1fr; }
    .form-row-5 { grid-template-columns: 1fr 1fr; }
    .header-title h1 { font-size: 1rem; }
}
@media print {
    body { font-size: 11px; }
    .actions-bar, .records-section { display: none !important; }
    .section { break-inside: avoid; }
    .btn-clear-markers { display: none; }
}
/* PDF compact mode - todo en 1 hoja */
.pdf-mode { max-width: 780px; font-size: 11px; }
.pdf-mode .section { margin-bottom: 2px; }
.pdf-mode .section-header { padding: 3px 8px; font-size: 0.65rem; }
.pdf-mode .section-body { padding: 4px 8px; }
.pdf-mode .form-row, .pdf-mode .form-row-5 { gap: 3px; margin-bottom: 2px; }
.pdf-mode .form-group label { font-size: 0.55rem; margin-bottom: 0; }
.pdf-mode .form-group input, .pdf-mode .form-group select, .pdf-mode .form-group textarea { padding: 2px 4px; font-size: 0.65rem; min-height: auto; }
.pdf-mode .form-group textarea { min-height: 30px; }
.pdf-mode .header { padding: 4px 8px; margin-bottom: 2px; }
.pdf-mode .header-title h1 { font-size: 0.85rem; }
.pdf-mode .header-title p { font-size: 0.55rem; }
.pdf-mode .header-meta input { width: 90px; padding: 2px 4px; font-size: 0.6rem; }
.pdf-mode .header-meta label { font-size: 0.55rem; }
.pdf-mode .header-logo svg { width: 40px; height: 40px; }
.pdf-mode .body-img-wrap img { max-width: 350px; }
.pdf-mode .body-diagram-container { gap: 4px; }
.pdf-mode .checkbox-group { gap: 4px; }
.pdf-mode .checkbox-group label { font-size: 0.6rem; }
.pdf-mode .checkbox-group input[type="checkbox"], .pdf-mode .checkbox-group input[type="radio"] { width: 12px; height: 12px; }
.pdf-mode .signatures-grid { gap: 4px; grid-template-columns: 1fr 1fr; }
.pdf-mode .signature-box { padding: 3px; }
.pdf-mode .signature-box h4 { font-size: 0.55rem; margin-bottom: 2px; }
.pdf-mode .signature-canvas { height: 35px; }
.pdf-mode .signature-actions { display: none; }
.pdf-mode .btn-clear-markers { display: none; }
.pdf-mode .triage-btn::after { display: none; }
.pdf-mode .triage-btn { padding: 3px 6px; font-size: 0.6rem; min-width: 40px; }
.pdf-mode .triage-selector { gap: 2px; }
