* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Arial, sans-serif; background: #f3f4f6; color: #222; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 24px; background: #1d4e89; color: #fff;
    box-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.topbar .brand strong { display: block; font-size: 16px; letter-spacing: .5px; }
.topbar .brand span  { font-size: 12px; opacity: .85; }
.topbar nav a {
    color: #fff; text-decoration: none; margin-left: 18px;
    padding: 6px 10px; border-radius: 4px; font-size: 14px;
}
.topbar nav a:hover { background: rgba(255,255,255,.12); }

.container { max-width: 1600px; margin: 20px auto; padding: 0 20px; }
.bottombar { text-align: center; padding: 14px; color: #777; font-size: 12px; }

.card { background: #fff; border: 1px solid #e2e5ea; border-radius: 6px;
        padding: 18px 20px; margin-bottom: 18px; }
.card h2 { margin: 0 0 12px; font-size: 16px; color: #1d4e89;
           border-bottom: 1px solid #eef0f4; padding-bottom: 8px; }

.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 12px; color: #555;
                   text-transform: uppercase; margin-bottom: 4px; letter-spacing: .3px; }
.form-grid input, .form-grid select, .form-grid textarea {
    width: 100%; padding: 8px 10px; font-size: 14px;
    border: 1px solid #ccd0d6; border-radius: 4px; background: #fff;
}
.form-grid textarea { min-height: 60px; resize: vertical; }

.button-row { display: flex; gap: 10px; margin-top: 14px; }
.button-row button, .button-row a {
    padding: 9px 16px; border-radius: 4px; border: 1px solid #1d4e89;
    background: #1d4e89; color: #fff; font-size: 14px; cursor: pointer;
    text-decoration: none; display: inline-block;
}
.button-row button.secondary, .button-row a.secondary {
    background: #fff; color: #1d4e89;
}
.button-row button.danger {
    background: #b33a3a; border-color: #b33a3a;
}

.totals-strip {
    display: flex; gap: 24px; margin-top: 12px; padding: 12px 14px;
    background: #f6f8fa; border: 1px dashed #ccd0d6; border-radius: 4px;
}
.totals-strip div { font-size: 13px; }
.totals-strip strong { display: block; font-size: 16px; color: #1d4e89; }

/* ============  Print view (Form 38(A) replica)  ============ */
.print-sheet {
    width: 11in; margin: 12px auto; background: #fff; color: #000;
    padding: 18px 22px; font-family: "Times New Roman", serif; font-size: 11px;
    border: 1px solid #999;
}
.print-sheet h1, .print-sheet h2, .print-sheet h3 {
    text-align: center; margin: 2px 0; font-weight: bold;
}
.print-sheet h1 { font-size: 13px; }
.print-sheet h2 { font-size: 12px; }
.print-sheet h3 { font-size: 12px; text-decoration: underline; }
.print-sheet .meta { display: flex; justify-content: space-between;
                     font-size: 10px; margin: 10px 2px; }
.print-sheet .ack  { font-size: 10px; margin: 8px 0; text-align: justify; }

table.form38 { width: 100%; border-collapse: collapse; font-size: 9px; }
table.form38 th, table.form38 td {
    border: 1px solid #000; padding: 3px 4px; vertical-align: middle;
    text-align: center;
}
table.form38 th { background: #eef0f4; font-weight: bold; }
table.form38 td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.form38 td.name { text-align: left; white-space: nowrap; }
table.form38 tfoot td { font-weight: bold; background: #f6f8fa; }

.cert-block { margin-top: 18px; display: grid;
              grid-template-columns: 1fr 1fr; gap: 18px; font-size: 10px; }
.cert-block .cert { border: 1px solid #000; padding: 10px; }
.cert-block .cert h4 { margin: 0 0 6px; font-size: 10px; text-transform: uppercase; }
.sig-line { display: inline-block; margin-top: 26px; border-top: 1px solid #000;
            min-width: 200px; text-align: center; padding-top: 2px; font-weight: bold; }
.sig-line em { display: block; font-style: normal; font-weight: normal; font-size: 9px; }

@media print {
    body { background: #fff; }
    .topbar, .bottombar, .button-row, .no-print { display: none !important; }
    .container { max-width: none; padding: 0; margin: 0; }
    .print-sheet { border: none; margin: 0; }
}

/* ============ Toolbar (Month / Year / Quincena / buttons) ============ */
.toolbar {
    display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
    padding: 12px 14px; background: #f6f8fa; border: 1px solid #e0e4ea;
    border-radius: 5px;
}
.toolbar label {
    display: block; font-size: 11px; color: #555;
    text-transform: uppercase; margin-bottom: 3px; letter-spacing: .3px;
}
.toolbar select, .toolbar input[type=text] {
    padding: 7px 10px; font-size: 14px; min-width: 150px;
    border: 1px solid #ccd0d6; border-radius: 4px; background: #fff;
}
.toolbar-buttons { margin-left: auto; display: flex; gap: 8px; }

/* Unified button style */
.btn {
    padding: 8px 14px; border-radius: 4px; border: 1px solid #1d4e89;
    background: #fff; color: #1d4e89; font-size: 14px; cursor: pointer;
    text-decoration: none; display: inline-block;
}
.btn.primary  { background: #1d4e89; color: #fff; }
.btn.secondary{ background: #fff; color: #1d4e89; }
.btn.danger   { background: #b33a3a; border-color: #b33a3a; color: #fff; }
.btn:hover    { opacity: .9; }

/* Metadata details panel */
.meta-row summary {
    cursor: pointer; color: #1d4e89; font-size: 13px;
    padding: 8px 0; user-select: none;
}
.hint { color: #666; font-size: 12px; margin: 4px 0 10px; }

/* Computed-cell visual */
.cell-computed { background-color: #f0f4fa !important; color: #1d4e89 !important; font-style: italic; }
.cell-net      { background-color: #e8f1e4 !important; color: #2a5d25 !important; font-weight: bold; }

/* ============ Modals ============ */
.modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,.5); z-index: 9000;
    align-items: center; justify-content: center;
}
.modal.open { display: flex; }
.modal-body {
    background: #fff; border-radius: 6px; width: 900px; max-width: 95vw;
    max-height: 92vh; display: flex; flex-direction: column;
    box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid #e2e5ea; background: #1d4e89;
    color: #fff; border-radius: 6px 6px 0 0;
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-close {
    background: transparent; border: none; color: #fff;
    font-size: 24px; cursor: pointer; line-height: 1;
}
.modal-toolbar {
    padding: 10px 14px; border-bottom: 1px solid #eef0f4;
}
.modal-toolbar input {
    width: 100%; padding: 8px 10px; font-size: 14px;
    border: 1px solid #ccd0d6; border-radius: 4px;
}
.modal-body #empGrid, .modal-body #officeGrid { margin: 0 14px; }
.modal-foot {
    padding: 12px 16px; border-top: 1px solid #e2e5ea;
    display: flex; justify-content: flex-end; gap: 8px;
}
