@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: #f1f5f9;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1e293b;
    min-height: 100vh;
}

/* Estrutura Geral: Barra Lateral + Área de Trabalho */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ===================================================
   Barra Lateral (Sidebar Moderna)
=================================================== */
.sidebar {
    width: 330px;
    min-width: 330px;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(15, 23, 42, 0.03);
    z-index: 50;
}

.sidebar-header {
    padding-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
}

.brand-title {
    font-weight: 800;
    font-size: 18px;
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.3px;
}

.brand-title i {
    color: #2563eb;
    font-size: 20px;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-section-title {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-label {
    font-size: 13px;
    font-weight: 600;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Campo de Busca */
.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-search {
    width: 100%;
    padding: 9px 32px 9px 12px;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #1e293b;
    outline: none;
    transition: all 0.2s;
}

.input-search:focus {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.btn-clear-search {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-clear-search:hover {
    color: #0f172a;
    background: #e2e8f0;
}

.sidebar-counter {
    font-size: 11.5px;
    color: #64748b;
    text-align: right;
    font-weight: 500;
}

.select-saved {
    width: 100%;
    padding: 9px 12px;
    font-size: 13.5px;
    font-family: 'Inter', sans-serif;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    outline: none;
    transition: all 0.2s;
    color: #334155;
    font-weight: 500;
    cursor: pointer;
}

.select-saved:focus, .select-saved:hover {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

/* ===================================================
   Card Totalizador Financeiro (Novo)
=================================================== */
.finance-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    gap: 10px;
}

.finance-card .sidebar-section-title {
    color: #2563eb;
}

.finance-display {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.finance-label {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.finance-value-box {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.finance-currency {
    font-size: 15px;
    font-weight: 700;
    color: #059669;
}

.finance-amount {
    font-size: 23px;
    font-weight: 800;
    color: #059669;
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.5px;
}

.finance-subtext {
    font-size: 11.5px;
    color: #94a3b8;
    font-weight: 500;
}

/* Botões da Barra Lateral */
.btn-sidebar {
    width: 100%;
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-sidebar:hover {
    transform: translateY(-1.5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}

.btn-sidebar:active {
    transform: translateY(0);
}

.btn-new { background: #d97706; }
.btn-new:hover { background: #b45309; }

.btn-save { background: #059669; }
.btn-save:hover { background: #047857; }

.btn-import { background: #0284c7; }
.btn-import:hover { background: #0369a1; }

.btn-manage { background: #475569; }
.btn-manage:hover { background: #334155; }

.btn-print { background: #2563eb; }
.btn-print:hover { background: #1d4ed8; }

.btn-print-all { background: #7c3aed; }
.btn-print-all:hover { background: #6d28d9; }

/* ===================================================
   Área de Conteúdo (Área de Trabalho da Folha)
=================================================== */
.content-area {
    flex-grow: 1;
    padding: 36px 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
}

/* ===================================================
   Moldura da Folha (Estilo do Talão)
=================================================== */
.talao-page {
    background: #ffffff;
    width: 100%;
    max-width: 860px;
    padding: 32px 30px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    page-break-after: always;
    break-after: page;
    font-family: Arial, Helvetica, sans-serif;
    color: #000000;
}

.talao-page:last-child {
    page-break-after: avoid;
    break-after: avoid;
}

.talao-page * {
    color: #000000;
}

/* Cabeçalho */
.header-border {
    border: 2px solid #000000;
    padding: 6px 12px;
    margin-bottom: 8px;
}

.header-table {
    width: 100%;
    border-collapse: collapse;
}

.header-logo-td {
    width: 40%;
    vertical-align: middle;
    text-align: left;
    padding: 4px;
}

.header-logo-td img {
    width: 100%;
    max-width: 280px;
    height: auto;
    display: block;
}

.header-info-td {
    width: 60%;
    vertical-align: middle;
    text-align: right;
    font-size: 13px;
    line-height: 1.35;
    padding: 4px;
}

.company-name {
    font-size: 18.5px;
    font-weight: 900;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    white-space: nowrap;
}

.cnpj {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 2px;
    white-space: nowrap;
}

.header-info-td div i {
    font-size: 13px;
    margin-right: 4px;
}

/* Faixa NOTA DE SERVIÇO e Numeração */
.title-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 16px 0 18px 0;
}

.spacer-box {
    flex: 1;
}

.title-box {
    border: 2px solid #000000;
    padding: 6px 36px;
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 1.5px;
    text-align: center;
    background: #f8fafc;
}

.invoice-number-box {
    flex: 1;
    color: #dc2626 !important;
    font-size: 24px;
    font-weight: 900;
    text-align: right;
    letter-spacing: 0.5px;
}

.invoice-number-box span {
    color: inherit;
    outline: none;
    border-bottom: 1px dashed transparent;
}

.invoice-number-box span:focus {
    border-bottom-color: #dc2626;
    background: rgba(220, 38, 38, 0.05);
}

/* Campos de Identificação */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
    font-size: 13.5px;
}

.form-row {
    display: flex;
    align-items: flex-end;
    width: 100%;
}

.form-label {
    font-weight: bold;
    font-size: 13.5px;
    margin-right: 6px;
    white-space: nowrap;
}

.form-input-line {
    flex-grow: 1;
    border: none;
    border-bottom: 1.5px solid #000000;
    outline: none;
    font-size: 14.5px;
    padding: 3px 6px;
    background: transparent;
    font-family: Arial, Helvetica, sans-serif;
    transition: background-color 0.2s, border-color 0.2s;
}

.form-input-line:hover, .form-input-line:focus {
    background: rgba(37, 99, 235, 0.05);
    border-bottom-color: #2563eb;
}

.form-row-multi {
    display: flex;
    gap: 20px;
    width: 100%;
}

/* Tabela de Itens */
.service-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 6px;
}

.service-table th {
    border: 2px solid #000000;
    padding: 7px 8px;
    font-size: 12.5px;
    font-weight: 900;
    text-align: center;
    background: #f1f5f9;
}

.service-table td {
    border: 1.5px solid #000000;
    padding: 0;
    height: 32px;
}

.col-disc { width: 55%; }
.col-qtd { width: 14%; }
.col-unit { width: 15%; }
.col-total { width: 16%; }

.table-input {
    width: 100%;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13.5px;
    font-family: Arial, Helvetica, sans-serif;
    padding: 4px 8px;
    transition: background-color 0.15s;
}

.table-input:hover, .table-input:focus {
    background: rgba(37, 99, 235, 0.06);
}

.table-input.center { text-align: center; }
.table-input.right { text-align: right; font-weight: bold; }

.btn-add-row {
    margin-top: 10px;
    padding: 7px 14px;
    background: #f8fafc;
    color: #475569;
    border: 1.5px dashed #94a3b8;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-add-row:hover {
    background: #e2e8f0;
    border-color: #64748b;
    color: #0f172a;
}

/* Rodapé: Total e Agradecimento */
.footer-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 18px;
    border: 2px solid #000000;
    padding: 8px 16px;
    background: #f8fafc;
}

.thanks-text {
    font-size: 14px;
    font-weight: bold;
    font-style: italic;
}

.total-container {
    font-size: 15.5px;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 8px;
}

.total-amount {
    font-size: 19px;
    border-bottom: 2px solid #000000;
    min-width: 120px;
    text-align: right;
    padding-right: 4px;
    display: inline-block;
}

/* Assinaturas */
.signatures-area {
    display: flex;
    justify-content: space-around;
    margin-top: 48px;
    margin-bottom: 8px;
    padding: 10px 20px;
}

.signature-item {
    width: 250px;
    text-align: center;
}

.sig-line {
    border-top: 1.5px solid #000000;
    margin-bottom: 5px;
}

.sig-label {
    font-size: 13px;
    font-weight: bold;
}

#printBatchArea {
    display: none;
}

/* ===================================================
   Modais
=================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-box {
    background: #ffffff;
    width: 100%;
    max-width: 740px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
    display: flex;
    flex-direction: column;
    max-height: 85vh;
    overflow: hidden;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

.modal-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    color: #0f172a;
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}

.modal-header h3 i {
    color: #2563eb;
}

.modal-header .btn-close {
    background: #f1f5f9;
    border: none;
    color: #64748b;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-header .btn-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex-grow: 1;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.select-all-label {
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge-counter {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 20px;
}

.modal-list-table {
    width: 100%;
    border-collapse: collapse;
}

.modal-list-table th, .modal-list-table td {
    padding: 11px 12px;
    font-size: 13.5px;
    border-bottom: 1px solid #f1f5f9;
    text-align: left;
}

.modal-list-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
}

.modal-list-table tr:hover td {
    background: #f8fafc;
}

.badge-numero {
    background: #fee2e2;
    color: #991b1b;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12.5px;
}

.modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-modal-del {
    background: #ef4444;
    color: #ffffff;
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    gap: 7px;
    align-items: center;
}

.btn-modal-del:hover {
    background: #dc2626;
    box-shadow: 0 4px 10px rgba(220, 38, 38, 0.2);
}

.btn-modal-cancel {
    background: #e2e8f0;
    color: #334155;
    padding: 9px 18px;
    border: none;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-modal-cancel:hover {
    background: #cbd5e1;
}

/* Modal de Confirmação */
.modal-box-confirm {
    max-width: 420px;
    text-align: center;
    padding: 24px;
    border-radius: 18px;
}

.modal-confirm-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.modal-confirm-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 4px;
}

.modal-confirm-body h3 {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.modal-confirm-body p {
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

.modal-footer-confirm {
    background: transparent !important;
    border-top: none !important;
    padding: 16px 0 0 0 !important;
    justify-content: center !important;
    gap: 14px !important;
}

/* ===================================================
   Notificações Toast
=================================================== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 100000;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: #ffffff;
    color: #1e293b;
    padding: 14px 18px;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 420px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    border-left: 5px solid #3b82f6;
    animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.toast-success { border-left-color: #10b981; }
.toast.toast-success i { color: #10b981; }

.toast.toast-warning { border-left-color: #f59e0b; }
.toast.toast-warning i { color: #f59e0b; }

.toast.toast-error { border-left-color: #ef4444; }
.toast.toast-error i { color: #ef4444; }

.toast i { font-size: 18px; }

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(50px) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ===================================================
   Regras de Impressão (A4 Limpo e Sem Sidebar)
=================================================== */
@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    body {
        background: #ffffff !important;
        padding: 0 !important;
    }

    .app-layout {
        display: block !important;
    }

    .sidebar, .btn-add-row, .modal-overlay, .toast-container {
        display: none !important;
    }

    .content-area {
        padding: 0 !important;
        display: block !important;
    }
    
    body.print-all-mode #folhaImpressao {
        display: none !important;
    }

    body.print-all-mode #printBatchArea {
        display: block !important;
    }
    
    .talao-page {
        width: 100% !important;
        max-width: 100% !important;
        border: 1px solid #000000 !important;
        padding: 20px !important;
        box-shadow: none !important;
        margin-bottom: 0 !important;
        border-radius: 0 !important;
    }
    
    .form-input-line, .table-input {
        background: transparent !important;
        border-bottom-color: #000000 !important;
    }
    
    .service-table th {
        background: #e5e7eb !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    input, .invoice-number-box {
        color: #000000 !important;
    }
    
    .invoice-number-box {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color: #dc2626 !important; 
    }
}
body.is-mecanico .admin-only {
    display: none !important;
}

body.is-mecanico .col-disc { width: 80% !important; }
body.is-mecanico .col-qtd { width: 20% !important; }