:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    padding: 2rem;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
}

header {
    margin-bottom: 2rem;
    text-align: center;
}

h1 {
    font-size: 2rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.date-input-group {
    display: flex;
    gap: 0.5rem;
}

.date-input-group>div {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.date-input-group small {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.date-input-group input {
    text-align: center;
    padding: 0.5rem 0.25rem;
}

#nasc_dia,
#nasc_mes {
    width: 45px;
}

#nasc_ano {
    width: 75px;
    flex-grow: 1;
}

.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
}

input,
select {
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn:active {
    transform: scale(0.98);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-xs {
    padding: 0.6rem 1.25rem;
    font-size: 0.75rem;
    border-radius: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 140px;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.hidden {
    display: none !important;
}

/* Profile View Styles */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2rem;
}

@media (max-width: 768px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 1600px) {
    .profile-grid {
        grid-template-columns: 1fr 450px;
    }
}

@media (min-width: 1920px) {
    body {
        padding: 4rem;
        font-size: 1.1rem;
    }
}

.profile-info h4 {
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    margin-top: 1.5rem;
}

.profile-info p {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-main);
}

.doc-center {
    background: #f1f5f9;
    padding: 1.5rem;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.doc-center h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    text-align: center;
}

.btn-doc {
    justify-content: flex-start;
    padding: 1rem;
    text-align: left;
    width: 100%;
}

.section-title-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.profile-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.4rem;
    margin-top: 1rem;
}

.header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.global-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 0.25rem;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ===== Configurações ===== */
.config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    background: #f8fafc;
    transition: background 0.2s;
}

.config-item:hover {
    background: #f1f5f9;
}

.config-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.config-item-label {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.95rem;
}

.config-item-value {
    font-size: 0.82rem;
    color: #64748b;
}

.config-edit-form {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 1rem 1.25rem;
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
}

.config-edit-form label {
    font-weight: 600;
    font-size: 0.88rem;
    color: #0369a1;
}

/* Tabela de configuração de courier */
.config-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.config-table thead tr {
    background: var(--primary);
    color: white;
}

.config-table thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
}

.config-table tbody tr {
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.15s;
}

.config-table tbody tr:hover {
    background: #f8fafc;
}

.config-table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
}

.config-price-display {
    display: inline-block;
    border-radius: 4px;
    font-weight: 700;
    transition: background 0.2s;
}

.config-price-input {
    padding: 0.4rem 0.65rem;
    border: 1.5px solid var(--primary);
    border-radius: 6px;
    font-size: 0.9rem;
    width: 130px;
    outline: none;
}

.header-actions h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}

.btn-close:hover {
    color: var(--text-main);
}

.form-footer {
    margin-top: 2.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.plus-icon {
    font-size: 1.25rem;
    font-weight: 500;
    margin-right: 0.25rem;
}

.client-list {
    margin-top: 0;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

th,
td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 600;
    color: var(--text-muted);
}

.actions {
    padding: 0.5rem !important;
}

.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Print Styles */
.print-doc {
    display: none;
}

/* Login Screen Styles */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 2.5rem;
    border-radius: 20px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    width: 60px;
    height: 60px;
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 15px;
    margin: 0 auto 1rem;
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.4);
}

.login-header h2 {
    font-size: 1.5rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.login-header p {
    color: #64748b;
    font-size: 0.9rem;
}

.btn-full {
    width: 100%;
    margin-top: 1rem;
    padding: 0.9rem !important;
}

.error-message {
    color: #ef4444;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    text-align: center;
    font-weight: 500;
}

@media print {
    /* Critical: Hide ALL direct children by default */
    body>* {
        display: none !important;
    }

    /* Universal Print Settings */
    .print-doc strong {
        font-weight: bold;
    }

    /* --- IRPF Document Logic --- */
    body.printing-irpf #print-section {
        display: block !important;
        visibility: visible !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 40px;
        background: white;
        color: black;
        min-height: 100%;
        font-family: 'Times New Roman', Times, serif;
        font-size: 12pt;
        line-height: 1.8;
    }

    #print-section .doc-header {
        text-align: center;
        font-weight: bold;
        font-size: 16pt;
        margin-bottom: 30pt;
    }

    #print-section .doc-content {
        text-align: justify;
    }

    #print-section .doc-footer {
        margin-top: 50pt;
        text-align: center;
    }

    #print-section .signature-line {
        margin-top: 60pt;
        border-top: 1px solid black;
        width: 300px;
        margin-left: auto;
        margin-right: auto;
        padding-top: 5px;
    }

    #print-section .doc-small-text {
        font-size: 8pt;
        margin-top: 20pt;
        color: #333;
        text-align: justify;
    }

    #print-section .doc-law-text {
        font-size: 7pt;
        margin-top: 15pt;
        color: #444;
        text-align: justify;
    }

    /* Hide legacy VFS print sections */
    #print-vfs-section {
        display: none !important;
    }

    /* --- Taxas de Visto Print Logic --- */
    body.printing-taxa > * {
        display: none !important;
    }

    body.printing-taxa #print-taxa-section {
        display: block !important;
        visibility: visible !important;
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        padding: 60px 40px;
        background: white;
        color: black;
        min-height: 100%;
        font-family: Arial, sans-serif;
    }
}