:root {
    --bg: #f3f5f8;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text: #111827;
    --muted: #667085;
    --line: #d8dee8;
    --line-strong: #202733;
    --primary: #111827;
    --primary-hover: #252f3f;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --focus: #2563eb;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 20% -10%, rgba(148, 163, 184, 0.18), transparent 34rem),
        var(--bg);
    -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
button, select { touch-action: manipulation; }

.app-shell {
    width: min(1500px, 100%);
    margin: 0 auto;
    padding: 24px clamp(12px, 3vw, 36px) 42px;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}
.brand-block { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark {
    width: 46px; height: 46px; flex: 0 0 46px;
    display: grid; place-items: center;
    border-radius: 14px;
    background: var(--primary);
    color: white;
    box-shadow: 0 8px 18px rgba(17, 24, 39, 0.16);
}
.brand-mark svg { width: 26px; height: 26px; }
.eyebrow {
    margin: 0 0 3px;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}
.app-header h1 { margin: 0; font-size: clamp(1.22rem, 2vw, 1.65rem); letter-spacing: -0.025em; }

.save-state {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 7px 11px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255,255,255,0.8);
    color: var(--muted);
    font-size: 0.83rem;
    font-weight: 700;
    white-space: nowrap;
}
.save-dot { width: 8px; height: 8px; border-radius: 50%; background: #98a2b3; }
.save-state[data-state="saved"] .save-dot { background: #12b76a; }
.save-state[data-state="saving"] .save-dot { background: #f79009; animation: pulse 1s infinite ease-in-out; }
.save-state[data-state="pending"] .save-dot { background: #fdb022; }
.save-state[data-state="error"] { color: #b42318; border-color: #fecdca; background: #fff6f5; }
.save-state[data-state="error"] .save-dot { background: #f04438; }
@keyframes pulse { 50% { opacity: 0.35; } }

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    padding: 10px;
    border: 1px solid rgba(216, 222, 232, 0.9);
    border-radius: 16px;
    background: rgba(255,255,255,0.9);
    box-shadow: 0 8px 24px rgba(15,23,42,0.04);
    backdrop-filter: blur(10px);
}
.page-nav, .toolbar-actions { display: flex; align-items: center; gap: 8px; }
.page-select-wrap {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 5px 0 12px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
}
.page-select-wrap select {
    min-width: 72px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
    padding: 0 30px 0 10px;
    font-weight: 800;
    outline: none;
}
.page-count { color: var(--muted); font-size: 0.84rem; font-weight: 700; margin-left: 2px; }

.icon-button, .button {
    border: 0;
    border-radius: 11px;
    min-height: 42px;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}
.icon-button:active, .button:active { transform: translateY(1px); }
.icon-button:focus-visible, .button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid rgba(37,99,235,0.2);
    outline-offset: 1px;
}
.icon-button {
    width: 42px;
    display: grid;
    place-items: center;
    background: var(--surface-soft);
    color: var(--text);
    border: 1px solid var(--line);
}
.icon-button:hover:not(:disabled) { background: #eef2f6; }
.icon-button:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-button svg, .button svg { width: 19px; height: 19px; }
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 14px;
    font-size: 0.88rem;
    font-weight: 800;
}
.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover { background: var(--primary-hover); }
.button-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecdca; }
.button-danger:hover { background: #ffe6e3; }
.button-secondary { background: #f2f4f7; color: var(--text); border: 1px solid var(--line); }

.print-clone { display: none; }

.paper {
    width: 100%;
    background: var(--surface);
    border: 1px solid #e0e5ec;
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: clamp(18px, 2.4vw, 34px);
    overflow: hidden;
}
.paper-heading {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-bottom: 14px;
    text-align: center;
}
.screen-kicker { margin: 0 0 5px; font-size: 0.72rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 800; }
.paper-heading h2 { margin: 0; font-size: clamp(1.08rem, 2.1vw, 1.5rem); letter-spacing: 0.01em; }
.print-page-number { position: absolute; right: 0; top: 3px; color: var(--muted); font-size: 0.78rem; font-weight: 700; }

.year-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 12px;
    font-weight: 800;
    font-size: 0.94rem;
}
.year-row input {
    width: min(220px, 58vw);
    height: 38px;
    border: 0;
    border-bottom: 2px solid #1f2937;
    border-radius: 0;
    background: transparent;
    padding: 0 6px;
    color: var(--text);
    font-weight: 750;
    outline: none;
}
.year-row input::placeholder { color: #98a2b3; font-weight: 500; }
.year-row input:focus { border-bottom-color: var(--focus); }

.table-scroll { width: 100%; overflow: visible; }
.registry-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    border: 2px solid var(--line-strong);
    background: #fff;
}
.registry-table .col-territory { width: 7%; }
.registry-table .col-last { width: 12%; }
.registry-table .col-assignment { width: 20.25%; }
.registry-table th,
.registry-table td {
    border: 1px solid var(--line-strong);
    padding: 0;
    vertical-align: stretch;
}
.registry-table th {
    background: #f1f3f6;
    color: #303846;
    text-align: center;
    font-size: clamp(0.61rem, 0.75vw, 0.78rem);
    line-height: 1.12;
    font-weight: 800;
    padding: 7px 3px;
}
.registry-table thead tr:first-child th:nth-child(n+3) { border-bottom-width: 1px; padding-bottom: 7px; }
.registry-table .date-head-row th { border-top-width: 0; padding: 0; }
.registry-table .date-head-row th:nth-child(-n+2) { background: #f1f3f6; border-top: 1px solid var(--line-strong); }
.head-date-grid { display: grid; grid-template-columns: 1fr 1fr; min-height: 36px; border-top: 1px solid var(--line-strong); }
.head-date-grid span { display: grid; place-items: center; padding: 4px 2px; }
.head-date-grid span + span { border-left: 1px solid var(--line-strong); }

.registry-row { height: 60px; }
.registry-table input {
    width: 100%;
    min-width: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #101828;
    outline: none;
    text-align: center;
}
.registry-table input:hover { background-color: #f8fafc; }
.registry-table input:focus { background-color: #eff6ff; box-shadow: inset 0 0 0 2px rgba(37,99,235,0.55); }
.territory-cell input, .last-cell input { height: 100%; min-height: 60px; padding: 5px; font-weight: 750; }
.assignment-box { height: 100%; min-height: 60px; display: grid; grid-template-rows: 1fr 1fr; }
.assignment-box label { min-width: 0; }
.assigned-to { border-bottom: 1px solid var(--line-strong); }
.assigned-to input { height: 100%; padding: 4px 6px; font-weight: 700; }
.date-grid { display: grid; grid-template-columns: 1fr 1fr; min-height: 29px; }
.date-grid label { display: block; min-width: 0; }
.date-grid label + label { border-left: 1px solid var(--line-strong); }
.date-grid input { height: 100%; padding: 2px 24px 2px 3px; font-size: clamp(0.58rem, 0.7vw, 0.76rem); }

/* El navegador suele escribir dd/mm/aaaa en los campos vacíos.
   Se usa un icono propio para que, cuando no haya fecha, la casilla quede limpia. */
.registry-table input[type="date"] {
    position: relative;
    padding-right: 25px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23586679' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='5.5' width='17' height='15' rx='2'/%3E%3Cpath d='M8 3.5v4M16 3.5v4M3.5 10h17'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 14px 14px;
    background-position: right 6px center;
}
.registry-table input[type="date"] {
    cursor: pointer;
    caret-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}
.registry-table input[type="date"]::-webkit-calendar-picker-indicator {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
}
.registry-table input[type="date"].date-empty {
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
}
.registry-table input[type="date"].date-empty::selection { background: transparent; }
.mobile-label { display: none; }

.paper-footer { margin-top: 7px; color: #313947; }
.paper-footer p { margin: 0; font-size: 0.77rem; line-height: 1.3; }
.footer-meta { display: flex; justify-content: space-between; margin-top: 7px; font-size: 0.7rem; color: var(--muted); font-weight: 700; }

.confirm-dialog {
    width: min(420px, calc(100% - 28px));
    border: 0;
    border-radius: 20px;
    padding: 0;
    box-shadow: 0 24px 80px rgba(15,23,42,0.28);
}
.confirm-dialog::backdrop { background: rgba(15,23,42,0.45); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: 24px; text-align: center; }
.dialog-icon { width: 48px; height: 48px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 50%; background: var(--danger-soft); color: var(--danger); }
.dialog-icon svg { width: 25px; height: 25px; }
.confirm-dialog h3 { margin: 0 0 8px; font-size: 1.15rem; }
.confirm-dialog p { margin: 0; color: var(--muted); line-height: 1.5; font-size: 0.92rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 20px; }

@media (max-width: 900px) {
    .app-shell { padding-inline: 10px; }
    .toolbar { align-items: stretch; }
    .toolbar, .toolbar-actions { flex-wrap: wrap; }
    .toolbar-actions { justify-content: flex-end; }
    .paper { border-radius: 16px; padding: 18px 12px; overflow: visible; }

    /* En móvil/tablet la tabla se convierte en tarjetas legibles.
       La impresión vuelve a la tabla original mediante @media print. */
    .table-scroll { overflow: visible; }
    .registry-table { display: block; border: 0; background: transparent; }
    .registry-table colgroup, .registry-table thead { display: none; }
    .registry-table tbody { display: grid; gap: 14px; }
    .registry-row {
        position: relative;
        display: grid;
        grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
        gap: 10px;
        height: auto;
        padding: 41px 11px 11px;
        border: 1px solid #d8dee8;
        border-radius: 16px;
        background: #fff;
        box-shadow: 0 5px 16px rgba(15,23,42,0.055);
        overflow: visible;
    }
    .registry-row::before {
        content: "ENTRADA " attr(data-entry);
        position: absolute;
        inset: 0 0 auto 0;
        height: 31px;
        display: flex;
        align-items: center;
        padding: 0 12px;
        border-radius: 15px 15px 0 0;
        border-bottom: 1px solid #e4e7ec;
        background: #f5f7fa;
        color: #667085;
        font-size: 0.67rem;
        font-weight: 850;
        letter-spacing: 0.075em;
    }
    .registry-table td {
        display: block;
        min-width: 0;
        padding: 0;
        border: 0 !important;
        background: transparent !important;
    }
    .registry-table td::before {
        content: attr(data-label);
        display: block;
        margin: 0 0 5px;
        color: #667085;
        font-size: 0.67rem;
        line-height: 1.2;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.045em;
    }
    .territory-cell, .last-cell { min-width: 0; overflow: hidden; }
    .territory-cell input, .last-cell input {
        display: block;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 44px;
        height: 44px;
        border: 1px solid #cfd6df;
        border-radius: 10px;
        background-color: #fff;
        padding: 7px 10px;
        font-size: 0.94rem;
        font-weight: 750;
        box-sizing: border-box;
    }
    .last-cell input[type="date"] {
        display: block;
        inline-size: 100%;
        max-inline-size: 100%;
        min-inline-size: 0;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding-right: 38px;
        background-size: 18px 18px;
        background-position: right 11px center;
        -webkit-appearance: none;
        appearance: none;
        overflow: hidden;
    }
    .last-cell input[type="date"]::-webkit-calendar-picker-indicator { width: 100%; }
    .last-cell input[type="date"]::-webkit-datetime-edit {
        min-width: 0;
        max-width: 100%;
        overflow: hidden;
    }

    .assignment-cell {
        grid-column: 1 / -1;
        padding: 10px !important;
        border: 1px solid #e1e6ed !important;
        border-radius: 12px;
        background: #fafbfc !important;
    }
    .assignment-cell::before {
        margin-bottom: 8px !important;
        color: #344054 !important;
        font-size: 0.7rem !important;
    }
    .assignment-box {
        display: grid;
        grid-template-rows: auto auto;
        gap: 8px;
        min-height: 0;
        height: auto;
    }
    .assigned-to { display: block; border: 0; }
    .mobile-label {
        display: block;
        margin: 0 0 5px;
        color: #667085;
        font-size: 0.69rem;
        line-height: 1.2;
        font-weight: 750;
    }
    .assignment-box input {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        height: 42px;
        border: 1px solid #cfd6df;
        border-radius: 9px;
        background-color: #fff;
        padding: 6px 10px;
        text-align: left;
        font-size: 0.88rem;
    }
    .date-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        gap: 8px;
        margin: 0;
        min-height: 0;
    }
    .date-grid label { display: block; min-width: 0; overflow: hidden; }
    .date-grid label + label { border: 0; }
    .date-grid input[type="date"] {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        height: 42px;
        padding: 6px 37px 6px 8px;
        text-align: left;
        font-size: 0.82rem;
        background-size: 17px 17px;
        background-position: right 10px center;
        appearance: none;
        -webkit-appearance: none;
    }
    .date-grid input[type="date"]::-webkit-calendar-picker-indicator { width: 100%; }
    .paper-footer { margin-top: 14px; }
}

@media (max-width: 700px) {
    .registry-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .territory-cell, .last-cell { grid-column: 1 / -1; }
    .assignment-cell { padding: 10px !important; }
    .date-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .date-grid .mobile-label { min-height: 0; }
}

@media (max-width: 640px) {
    .app-shell { padding-top: 14px; }
    .app-header { align-items: flex-start; }
    .brand-mark { width: 40px; height: 40px; flex-basis: 40px; border-radius: 12px; }
    .brand-mark svg { width: 23px; height: 23px; }
    .save-state {
        position: absolute;
        right: 10px;
        top: 64px;
        z-index: 2;
        max-width: calc(100vw - 20px);
        min-height: 30px;
        font-size: 0.73rem;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .toolbar { margin-top: 41px; padding: 8px; }
    .page-nav { width: 100%; display: grid; grid-template-columns: 42px minmax(0, 1fr) 42px auto; }
    .page-select-wrap { min-width: 0; justify-content: space-between; }
    .toolbar-actions { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
    .button { padding-inline: 10px; }
    .paper-heading { justify-content: flex-start; text-align: left; padding-right: 56px; }
    .print-page-number { font-size: 0.72rem; }
    .year-row { align-items: flex-end; flex-wrap: wrap; }
    .year-row input { width: 100%; }

    .registry-row {
        gap: 9px;
        padding: 40px 9px 9px;
        border-radius: 14px;
    }
    .registry-row::before { border-radius: 13px 13px 0 0; }
    .assignment-cell { padding: 9px !important; }
    .date-grid .mobile-label { min-height: 0; }
    .assignment-box input { font-size: 0.86rem; }
    .paper { padding-inline: 9px; }
}

@media (max-width: 390px) {
    .toolbar-actions .button { font-size: 0.8rem; }
    .page-count { font-size: 0.77rem; }
    .registry-row { grid-template-columns: 1fr; }
    .territory-cell, .last-cell { grid-column: 1 / -1; }
    .date-grid { grid-template-columns: 1fr; }
}

@media print {
    @page { size: Letter portrait; margin: 0.28in 0.25in; }

    html, body { width: 100%; min-width: 0; margin: 0; padding: 0; background: #fff !important; }
    body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .no-print, .confirm-dialog, .original-paper { display: none !important; }
    .print-clone { display: block !important; }
    .app-shell { width: 100%; max-width: none; margin: 0; padding: 0; }
    .paper {
        width: 100%;
        margin: 0 auto;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        overflow: visible;
    }
    .paper-heading { margin: 0 0 0.09in; min-height: 0.31in; align-items: center; }
    .paper-heading h2 { font-size: 12.8pt; line-height: 1.1; }
    .print-page-number { top: 0.02in; right: 0; font-size: 6.6pt; color: #333; }
    .year-row { margin: 0 0 0.09in; gap: 0.08in; font-size: 8.5pt; line-height: 1; }
    .year-row input, .year-row .print-value {
        display: inline-flex;
        align-items: center;
        width: 1.35in;
        height: 0.2in;
        padding: 0 0.03in;
        border-bottom: 1.4pt solid #111;
        font-size: 8.5pt;
        font-weight: 700;
        color: #000;
    }
    .year-row input::placeholder { color: transparent; }

    .table-scroll { overflow: visible; }
    .registry-table {
        display: table !important;
        width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        border: 1.5pt solid #111 !important;
    }
    .registry-table colgroup { display: table-column-group !important; }
    .registry-table thead { display: table-header-group !important; }
    .registry-table tbody { display: table-row-group !important; }
    .registry-table tr { display: table-row !important; }
    .registry-table th, .registry-table td {
        display: table-cell !important;
        border: 0.75pt solid #111 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        background: #fff !important;
        vertical-align: middle !important;
    }
    .registry-table th {
        background: #e7ebf0 !important;
        box-shadow: inset 0 0 0 1000px #e7ebf0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        height: 0.24in;
        font-size: 6pt;
        line-height: 1.02;
        font-weight: 700;
        color: #111;
        padding: 0.015in !important;
    }
    .registry-table thead tr:first-child th:nth-child(n+3) { border-bottom-width: 0.75pt !important; }
    .registry-table .date-head-row th { border-top-width: 0 !important; }
    .registry-table .date-head-row th:nth-child(-n+2) { border-top: 0.75pt solid #111 !important; }
    .head-date-grid { min-height: 0.23in; border-top: 0.75pt solid #111 !important; }
    .head-date-grid span { padding: 0.012in 0.006in; }
    .head-date-grid span + span { border-left: 0.75pt solid #111; }

    .registry-row { height: 0.405in !important; break-inside: avoid; page-break-inside: avoid; }
    .registry-row::before { display: none !important; content: none !important; }
    .registry-table td::before, .mobile-label { display: none !important; }
    .territory-cell, .last-cell, .assignment-cell { padding: 0 !important; background: #fff !important; }
    .last-cell { border-left: 0.75pt solid #111 !important; }
    .assignment-cell { border-top: 0.75pt solid #111 !important; }
    .registry-table input, .registry-table .print-value {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        background: transparent !important;
        box-shadow: none !important;
        border: 0 !important;
        border-radius: 0 !important;
        color: #000 !important;
        padding: 0.01in 0.02in !important;
        text-align: center !important;
        font-family: Arial, Helvetica, sans-serif;
        font-size: 6.7pt !important;
        line-height: 1 !important;
        appearance: none;
        -webkit-appearance: none;
    }
    .registry-table input[type="date"] { background-image: none !important; -webkit-text-fill-color: #000 !important; color: #000 !important; }
    input[type="date"]::-webkit-calendar-picker-indicator { display: none !important; -webkit-appearance: none; }
    .territory-cell input, .last-cell input, .territory-cell .print-value, .last-cell .print-value { height: 0.405in !important; min-height: 0 !important; font-weight: 700; }
    .assignment-box { display: grid !important; grid-template-rows: 0.205in 0.2in !important; min-height: 0 !important; height: 0.405in !important; }
    .assigned-to { display: block !important; border-bottom: 0.75pt solid #111 !important; }
    .assigned-to input, .assigned-to .print-value { height: 0.205in !important; }
    .date-grid { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 0 !important; margin: 0 !important; min-height: 0 !important; height: 0.2in !important; }
    .date-grid label { display: block !important; }
    .date-grid label + label { border-left: 0.75pt solid #111 !important; }
    .date-grid input, .date-grid .print-value { height: 0.2in !important; font-size: 6.2pt !important; }

    .paper-footer { margin-top: 0.055in; color: #111; }
    .paper-footer p { margin: 0; font-size: 6.8pt; line-height: 1.15; }
    .footer-meta { margin-top: 0.035in; font-size: 6.2pt; color: #333; }
}

/* Mantiene en papel el mismo aspecto de la tabla mostrada en pantalla. */
@media print {
    @page { size: Letter portrait; margin: 0.28in 0.25in; }

    .registry-table th {
        font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important;
        font-size: 6.6pt !important;
        font-weight: 800 !important;
        color: #111827 !important;
        background: #f1f3f6 !important;
        box-shadow: inset 0 0 0 1000px #f1f3f6 !important;
        text-align: center !important;
        vertical-align: middle !important;
    }

    .registry-table input,
    .registry-table .print-value {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
        font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif !important;
        font-size: 7.2pt !important;
        line-height: 1 !important;
        color: #000 !important;
        text-align: center !important;
    }

    .head-date-grid span {
        display: grid !important;
        place-items: center !important;
        text-align: center !important;
    }

    .year-row .print-value {
        justify-content: center !important;
        text-align: center !important;
    }

    .territory-cell input,
    .territory-cell .print-value,
    .last-cell input,
    .last-cell .print-value {
        font-size: 7.8pt !important;
        font-weight: 750 !important;
    }

    .assigned-to input,
    .assigned-to .print-value {
        height: 100% !important;
        padding: 0.01in 0.02in !important;
        font-size: 7.6pt !important;
        font-weight: 750 !important;
    }

    .assigned-to,
    .date-grid label {
        display: flex !important;
        align-items: stretch !important;
        justify-content: center !important;
        width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    .assigned-to {
        height: 0.205in !important;
    }

    .date-grid label {
        height: 0.2in !important;
        display: block !important;
        position: static !important;
    }

    .date-grid input,
    .date-grid .print-value {
        width: 100% !important;
        height: 100% !important;
        padding: 0.01in 0.02in !important;
        font-size: 6.3pt !important;
    }

    .assignment-box,
    .date-grid {
        overflow: hidden !important;
    }

    .date-grid {
        position: relative !important;
    }

    .date-grid label + label {
        border-left: 0 !important;
    }

    .date-grid::after {
        content: none !important;
        display: none !important;
    }

    .assignment-box {
        position: relative !important;
    }

    .assignment-box::after {
        content: "" !important;
        display: block !important;
        position: absolute !important;
        z-index: 10 !important;
        top: 50.617% !important;
        bottom: auto !important;
        left: 50% !important;
        width: 0.75pt !important;
        height: 49.383% !important;
        border: 0 !important;
        background: var(--line-strong) !important;
        pointer-events: none !important;
    }

    .date-grid .print-value {
        display: block !important;
        position: static !important;
        width: 100% !important;
        height: 0.2in !important;
        margin: 0 !important;
        padding: 0 0.015in !important;
        line-height: 0.2in !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-align: center !important;
        transform: translateY(-0.055in) !important;
    }

    .registry-table .last-cell input[type="date"],
    .registry-table .last-cell .print-value,
    .registry-table .date-grid input[type="date"],
    .registry-table .date-grid .print-value {
        background-color: transparent !important;
        background-image: none !important;
        -webkit-text-fill-color: #000 !important;
    }
}

/* Tamaño de lectura equivalente a la vista del navegador.
   El registro continúa en una segunda hoja vertical cuando es necesario. */
@media print {
    @page { size: Letter portrait; margin: 0.28in 0.25in; }

    .paper {
        break-inside: auto !important;
        page-break-inside: auto !important;
        overflow: visible !important;
    }

    .print-clone .screen-kicker {
        display: block !important;
        margin: 0 0 0.035in !important;
        font-size: 7.5pt !important;
        line-height: 1 !important;
    }

    .paper-heading {
        margin-bottom: 0.12in !important;
        min-height: 0.4in !important;
    }

    .paper-heading h2 {
        font-size: 16pt !important;
        line-height: 1.08 !important;
    }

    .print-page-number {
        font-size: 7.5pt !important;
    }

    .year-row {
        margin-bottom: 0.12in !important;
        font-size: 10.5pt !important;
    }

    .year-row input,
    .year-row .print-value {
        width: 1.8in !important;
        height: 0.28in !important;
        font-size: 10.5pt !important;
    }

    .registry-table {
        height: auto !important;
        break-inside: auto !important;
        page-break-inside: auto !important;
    }

    .registry-table thead {
        display: table-header-group !important;
    }

    .registry-table tbody {
        break-inside: auto !important;
        page-break-inside: auto !important;
    }

    .registry-table th {
        height: 0.3in !important;
        padding: 0.025in 0.015in !important;
        font-size: 7.4pt !important;
        line-height: 1.08 !important;
    }

    .head-date-grid {
        min-height: 0.3in !important;
    }

    .registry-row {
        height: 0.62in !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .territory-cell input,
    .territory-cell .print-value,
    .last-cell input,
    .last-cell .print-value {
        height: 0.62in !important;
        font-size: 10pt !important;
    }

    .assignment-box {
        height: 0.62in !important;
        grid-template-rows: 0.31in 0.31in !important;
    }

    .assigned-to {
        height: 0.31in !important;
    }

    .assigned-to input,
    .assigned-to .print-value {
        height: 0.31in !important;
        font-size: 10pt !important;
    }

    .date-grid,
    .date-grid label {
        height: 0.31in !important;
    }

    .date-grid input,
    .date-grid .print-value {
        height: 0.31in !important;
        font-size: 7.5pt !important;
    }

    .date-grid .print-value {
        line-height: 0.31in !important;
        transform: translateY(-0.055in) !important;
    }

    .assignment-box::after {
        top: 50% !important;
        height: 50% !important;
    }

    .paper-footer p {
        font-size: 8pt !important;
    }

    .footer-meta {
        font-size: 7.5pt !important;
    }
}

/* Impresión final: una página carta vertical, siguiendo las proporciones del S-13-S. */
@media print {
    @page { size: Letter portrait; margin: 0.18in 0.20in; }

    html,
    body,
    .app-shell {
        width: 8.10in !important;
        min-width: 8.10in !important;
        max-width: 8.10in !important;
        margin: 0 auto !important;
        padding: 0 !important;
    }

    .paper {
        width: 8.10in !important;
        max-width: 8.10in !important;
        margin: 0 auto !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
        overflow: visible !important;
    }

    .print-clone .screen-kicker {
        display: none !important;
    }

    .paper-heading {
        min-height: 0.30in !important;
        margin: 0 0 0.06in !important;
    }

    .paper-heading h2 {
        font-size: 14pt !important;
        line-height: 1.05 !important;
    }

    .print-page-number {
        top: 0 !important;
        font-size: 6.8pt !important;
    }

    .year-row {
        margin: 0 0 0.07in !important;
        gap: 0.08in !important;
        font-size: 9pt !important;
        line-height: 1 !important;
    }

    .year-row input,
    .year-row .print-value {
        width: 1.55in !important;
        height: 0.21in !important;
        font-size: 9pt !important;
    }

    .registry-table,
    .registry-table tbody {
        height: auto !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    .registry-table th {
        height: 0.245in !important;
        padding: 0.012in 0.008in !important;
        font-size: 6.8pt !important;
        line-height: 1.02 !important;
    }

    .head-date-grid {
        min-height: 0.245in !important;
    }

    .registry-row {
        height: 0.425in !important;
        break-inside: avoid !important;
        page-break-inside: avoid !important;
    }

    /* Destaca solamente la separación entre un territorio y el siguiente. */
    .registry-row + .registry-row > td {
        border-top: 1.5pt solid #111 !important;
    }

    .territory-cell input,
    .territory-cell .print-value,
    .last-cell input,
    .last-cell .print-value {
        height: 0.425in !important;
        font-size: 8.4pt !important;
    }

    .assignment-box {
        height: 0.425in !important;
        grid-template-rows: 0.215in 0.210in !important;
    }

    .assigned-to {
        height: 0.215in !important;
    }

    .assigned-to input,
    .assigned-to .print-value {
        height: 0.215in !important;
        padding: 0 0.018in !important;
        font-size: 8.2pt !important;
        line-height: 0.215in !important;
    }

    .date-grid,
    .date-grid label {
        height: 0.210in !important;
    }

    .date-grid input,
    .date-grid .print-value {
        height: 0.210in !important;
        padding: 0 0.012in !important;
        font-size: 6.6pt !important;
    }

    .date-grid .print-value {
        line-height: 0.210in !important;
        transform: translateY(-0.045in) !important;
    }

    .assignment-box::after {
        top: 50.588% !important;
        height: 49.412% !important;
    }

    .paper-footer {
        margin-top: 0.04in !important;
    }

    .paper-footer p {
        font-size: 6.9pt !important;
        line-height: 1.08 !important;
    }

    .footer-meta {
        margin-top: 0.025in !important;
        font-size: 6.4pt !important;
    }
}
