* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #f0f2f5;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    padding: 16px;
}

.app {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

@media (min-width: 1024px) {
    .app {
        flex-direction: row;
    }
    .form-panel {
        position: sticky;
        top: 20px;
        max-height: calc(100vh - 40px);
        overflow-y: auto;
    }
}

/* Form Panel */
.form-panel {
    background: white;
    border-radius: 28px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.08);
    padding: 20px;
}

.form-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #1e3a5f, #b22234);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 4px;
}

.sub {
    color: #5b6e8c;
    font-size: 0.8rem;
    margin-bottom: 20px;
    border-left: 3px solid #b22234;
    padding-left: 12px;
}

.form-section {
    margin-bottom: 24px;
    border-bottom: 1px solid #e9edf2;
    padding-bottom: 16px;
}

.form-section label {
    font-weight: 600;
    font-size: 0.9rem;
    color: #1e3a5f;
    display: block;
    margin-bottom: 10px;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.input-group input, .input-group select {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #cfdde6;
    border-radius: 14px;
    font-size: 0.9rem;
    background: #fff;
}

.checkbox {
    align-items: center;
    gap: 8px;
}
.checkbox input {
    width: 18px;
    margin: 0;
}
.checkbox label {
    margin: 0;
    font-weight: normal;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}
.icon-btn {
    background: #eef2ff;
    border: none;
    padding: 6px 14px;
    border-radius: 40px;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.8rem;
}

.table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
}
#salaryInputTable {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
    min-width: 500px;
}
#salaryInputTable th, #salaryInputTable td {
    border: 1px solid #e2e8f0;
    padding: 8px 4px;
    text-align: center;
}
#salaryInputTable input {
    width: 100%;
    min-width: 70px;
    padding: 4px;
    font-size: 0.7rem;
}
.delete-row {
    background: #fee2e2;
    border: none;
    border-radius: 30px;
    padding: 4px 8px;
    cursor: pointer;
}
.totals {
    background: #f1f5f9;
    padding: 10px;
    border-radius: 16px;
    font-weight: 700;
    text-align: center;
    font-size: 0.85rem;
}

.currency-box {
    background: #fefce8;
    border-radius: 20px;
    padding: 16px;
    border: 1px solid #fde047;
}
.exchange-info {
    font-size: 0.7rem;
    margin: 8px 0;
}
.converted {
    font-weight: 700;
    color: #0f3b2c;
}

.primary, .secondary {
    border: none;
    padding: 12px;
    border-radius: 40px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    font-size: 1rem;
}
.primary {
    background: #b22234;
    color: white;
}
.secondary {
    background: #e2e8f0;
}
.hint {
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 4px;
}

/* Preview Panel */
.preview-panel {
    background: #e4e7eb;
    border-radius: 28px;
    padding: 16px;
    display: flex;
    justify-content: center;
}
.a4-sheet {
    background: white;
    width: 100%;
    max-width: 210mm;
    min-height: 297mm;
    padding: 1in;
    box-shadow: 0 20px 35px rgba(0,0,0,0.2);
    border-radius: 4px;
    font-family: 'Times New Roman', 'Inter', serif;
    font-size: 12pt;
}

@media print {
    body { background: white; padding: 0; }
    .form-panel { display: none; }
    .preview-panel { padding: 0; background: white; }
    .a4-sheet { box-shadow: none; padding: 1in; margin: 0; }
}

/* Letterhead styles */
.letterhead {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #b22234;
    padding-bottom: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}
.left-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.logo-area img {
    width: 80px;
    height: auto;
}
.secretariat-text {
    display: flex;
    flex-direction: column;
}
.secretariat-name {
    font-weight: 800;
    font-size: 1.3rem;
    color: #1e3a5f;
}
.finance-section {
    font-size: 0.9rem;
    font-weight: 600;
    color: #2c3e66;
}
.right-header {
    text-align: right;
}
.address-right {
    font-size: 0.7rem;
    line-height: 1.3;
    color: #2c3e66;
    margin-bottom: 6px;
}
.date-right {
    font-size: 0.7rem;
    color: #b22234;
    font-weight: 500;
    border-top: 1px dashed #b22234;
    padding-top: 5px;
    margin-top: 4px;
}

.certify-text {
    margin: 20px 0;
    text-align: justify;
    font-size: 1rem;
}
.salary-table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    font-size: 0.8rem;
}
.salary-table th, .salary-table td {
    border: 1px solid #000;
    padding: 6px;
    text-align: right;
}
.salary-table th {
    background: #f1f1f1;
    text-align: center;
}
.salary-table td:first-child, .salary-table th:first-child {
    text-align: center;
}
.amount-words {
    margin: 12px 0;
    font-style: italic;
    border-left: 3px solid #b22234;
    padding-left: 12px;
}
.exchange-note {
    background: #fef3c7;
    padding: 8px;
    border-radius: 8px;
    font-size: 0.7rem;
    margin: 12px 0;
}
.tax-note {
    font-size: 0.75rem;
    margin: 10px 0;
}
.signature-area {
    margin-top: 40px;
    text-align: right;
}
.dotted-line {
    border-bottom: 1.5px dashed #333;
    width: 160px;
    margin-left: auto;
    margin-top: 30px;
    margin-bottom: 6px;
}
.sign-name {
    font-weight: bold;
}
.footer {
    margin-top: 32px;
    font-size: 0.65rem;
    text-align: center;
    border-top: 1px solid #aaa;
    padding-top: 10px;
}