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

:root {
    --sidebar-bg: #0f2035;
    --sidebar-item-active: #1a3a5c;
    --gold-primary: #c9a227;
    --gold-hover: #b8911f;
    --text-primary: #1a2332;
    --text-secondary: #5a6577;
    --text-light: #8a95a5;
    --text-sidebar: #c5d0dc;
    --border-color: #e5e9ef;
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-hover: #f0f4f8;
    --bg-gold-light: #fdf9ed;
    --success: #28a745;
    --success-bg: #d4edda;
    --success-text: #155724;
    --danger: #dc3545;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;
    --warning: #ffc107;
    --warning-bg: #fff3cd;
    --warning-text: #856404;
    --info: #3B82F6;
    --info-bg: #d1ecf9;
    --info-text: #0c5460;
    --whatsapp: #25D366;
    --email: #6c757d;
    --sidebar-width: 260px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 14px; }
body { font-family: 'Inter', sans-serif; background: var(--bg-primary); color: var(--text-primary); line-height: 1.5; }
.app { display: flex; min-height: 100vh; }

/* ============ Sidebar ============ */
.sidebar { width: var(--sidebar-width); background: var(--sidebar-bg); color: var(--text-sidebar); display: flex; flex-direction: column; position: fixed; height: 100vh; overflow-y: auto; z-index: 100; transition: transform 0.3s ease; }
.sidebar-header { padding: 20px 16px; border-bottom: 1px solid rgba(255, 255, 255, 0.08); }
.logo { display: flex; align-items: center; gap: 12px; }
.logo-img { width: 42px; height: 42px; object-fit: contain; border-radius: 6px; background: rgba(255, 255, 255, 0.95); padding: 4px; }
.logo-text h1 { font-family: 'Playfair Display', serif; font-size: 18px; font-weight: 700; color: var(--gold-primary); letter-spacing: 1.5px; }
.logo-text span { font-size: 11px; color: var(--text-light); }
.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav ul { list-style: none; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 11px 20px; color: var(--text-sidebar); text-decoration: none; transition: var(--transition); font-size: 14px; border-left: 3px solid transparent; margin: 0 8px; border-radius: 6px; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.05); color: #fff; }
.sidebar-nav li.active a { background: var(--sidebar-item-active); color: var(--gold-primary); border-left: 3px solid var(--gold-primary); font-weight: 600; }
.sidebar-nav .icon { width: 18px; display: inline-flex; justify-content: center; font-size: 15px; }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255, 255, 255, 0.08); margin-top: auto; }
.ambiente { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-light); }
.dot { width: 8px; height: 8px; background: var(--success); border-radius: 50%; box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.2); }

/* ============ Main Content ============ */
.main-content { flex: 1; margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin 0.3s ease; }
.header { background: var(--bg-secondary); border-bottom: 1px solid var(--border-color); padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow-sm); gap: 12px; }
.header-left { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.header-subtitle { font-family: 'Playfair Display', serif; font-size: 11px; font-weight: 600; color: var(--gold-primary); letter-spacing: 2px; text-transform: uppercase; }
.page-title { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ============ Buttons ============ */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 500; cursor: pointer; transition: var(--transition); font-family: inherit; text-decoration: none; white-space: nowrap; }
.btn-search { background: var(--bg-secondary); border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-search:hover { background: var(--bg-primary); }
.btn-primary { background: var(--gold-primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--gold-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(201, 162, 39, 0.3); }
.btn-secondary { background: var(--bg-primary); border: 1px solid var(--border-color); color: var(--text-primary); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--gold-primary); color: var(--gold-primary); }
.btn-success { background: var(--success); color: #fff; font-weight: 600; }
.btn-success:hover { background: #218838; transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover { background: #c82333; transform: translateY(-1px); }
.btn-whatsapp { background: var(--whatsapp); color: #fff; font-weight: 600; }
.btn-whatsapp:hover { background: #1da851; transform: translateY(-1px); }
.btn-email { background: var(--email); color: #fff; font-weight: 600; }
.btn-email:hover { background: #5a6268; transform: translateY(-1px); }
.btn-icon { width: 40px; height: 40px; border: 1px solid var(--border-color); background: var(--bg-secondary); border-radius: var(--radius); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; transition: var(--transition); flex-shrink: 0; }
.btn-icon:hover { background: var(--bg-primary); border-color: var(--gold-primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; justify-content: center; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 24px; }
.avatar { width: 32px; height: 32px; background: var(--sidebar-bg); color: var(--gold-primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex-shrink: 0; }

/* ============ Content & Cards ============ */
.content { padding: 32px; flex: 1; }
.card { background: var(--bg-secondary); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); overflow: hidden; margin-bottom: 24px; }
.card-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.card-header h2 { font-size: 18px; font-weight: 600; }
.card-body { padding: 24px; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 24px; }
.stat-card { background: var(--bg-secondary); padding: 24px; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); display: flex; align-items: center; gap: 16px; transition: var(--transition); }
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-icon { width: 52px; height: 52px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 24px; color: white; flex-shrink: 0; }
.stat-info { min-width: 0; flex: 1; }
.stat-info h3 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.stat-info span { font-size: 13px; color: var(--text-secondary); }

/* ============ Tables ============ */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 12px 16px; text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border-color); background: var(--bg-primary); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
.table tbody tr { transition: var(--transition); }
.table tbody tr:hover { background: var(--bg-primary); }
.table tbody tr:last-child td { border-bottom: none; }
.status { display: inline-flex; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.status-pendente { background: var(--warning-bg); color: var(--warning-text); }
.status-aprovado { background: var(--success-bg); color: var(--success-text); }
.status-cancelado { background: var(--danger-bg); color: var(--danger-text); }
.status-rascunho { background: #e2e8f0; color: #475569; }
.status-vencido { background: var(--danger); color: #fff; font-weight: 700; }

/* ============ BUG #13: Módulo Fiscal ============ */
/* Stat card de "Emitidas este mês" — verde destaque */
.stat-card.stat-card-success {
    border-left: 4px solid var(--success);
}
/* Tarja "CANCELADA" no PDF da NF */
.print-section h3 {
    /* mantém o estilo já definido em @media print */
}
/* Em telas pequenas, a tabela Fiscal não quebra o layout */
@media (max-width: 768px) {
    #tableFiscal th, #tableFiscal td { padding: 8px 6px; font-size: 12px; }
}

/* ============ BUG #12: Indicador visual de parcela vencida ============ */
/* Linha inteira da tabela com destaque vermelho claro + borda esquerda */
.table tbody tr.parcela-vencida {
    background: var(--danger-bg) !important;
    border-left: 4px solid var(--danger);
}
.table tbody tr.parcela-vencida td:first-child {
    border-left: none; /* evita double border com a borda esquerda da tr */
}
/* Hover da linha vencida — fica um pouco mais forte */
.table tbody tr.parcela-vencida:hover {
    background: #f8c8cd !important;
}
/* Badge "VENCIDA" — bolinha vermelha sólida */
.badge-vencida {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--danger);
    color: #fff;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-left: 6px;
    white-space: nowrap;
    animation: pulseVencida 2s ease-in-out infinite;
}
@keyframes pulseVencida {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    50%       { opacity: 0.85; box-shadow: 0 0 0 5px rgba(220, 53, 69, 0); }
}
/* Botão de filtro "Mostrar apenas vencidas" */
.filtro-vencidas {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}
.filtro-vencidas:hover {
    border-color: var(--danger);
    color: var(--danger);
}
.filtro-vencidas.ativo {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
}
.filtro-vencidas .filtro-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--danger-bg);
    color: var(--danger);
    font-size: 11px;
    font-weight: 700;
}
.filtro-vencidas.ativo .filtro-count {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}
/* Stat card "Vencidas" — sombra vermelha */
.stat-card.stat-card-danger {
    border-left: 4px solid var(--danger);
}
/* No print, esconde o indicador visual (não faz sentido no PDF) */
@media print {
    .badge-vencida, .filtro-vencidas { display: none !important; }
    .table tbody tr.parcela-vencida { background: #fff !important; border-left: none !important; }
}

/* ============ Empty State ============ */
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-light); }
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; opacity: 0.6; }
.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; font-weight: 600; }
.empty-state p { font-size: 14px; margin-bottom: 20px; max-width: 400px; margin-left: auto; margin-right: auto; }
.empty-state .btn { margin: 0 auto; }

/* ============ Action group ============ */
.action-group { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ============ Forms & Modals ============ */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 32, 53, 0.6); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal.active { display: flex; animation: fadeIn 0.2s ease; }
.modal-content { background: var(--bg-secondary); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; width: 100%; animation: slideUp 0.25s ease; }
.modal-large { max-width: 600px; }
.modal-xl { max-width: 1000px; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--bg-secondary); z-index: 10; gap: 12px; }
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; position: sticky; bottom: 0; background: var(--bg-secondary); flex-wrap: wrap; }
.btn-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-light); transition: var(--transition); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 6px; flex-shrink: 0; }
.btn-close:hover { background: var(--bg-primary); color: var(--text-primary); }
.form-section { margin-bottom: 24px; }
.form-section:last-child { margin-bottom: 0; }
.form-section h3 { font-size: 13px; font-weight: 600; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color); text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }
.form-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.form-group label .required { color: var(--danger); }
.form-group input, .form-group select, .form-group textarea { padding: 10px 12px; border: 1px solid var(--border-color); border-radius: var(--radius); font-size: 14px; font-family: inherit; background: var(--bg-secondary); color: var(--text-primary); transition: var(--transition); width: 100%; }
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--gold-primary); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.1); }
.form-group input[readonly], .form-group input:disabled { background: var(--bg-primary); color: var(--text-secondary); cursor: not-allowed; }
.form-group .hint { font-size: 11px; color: var(--text-light); margin-top: 2px; }
.form-group.has-error input, .form-group.has-error select { border-color: var(--danger); }
.form-group .error-msg { font-size: 11px; color: var(--danger); margin-top: 2px; display: none; }
.form-group.has-error .error-msg { display: block; }
.field-error-msg { color: var(--danger); font-size: 11px; margin-top: 4px; display: block; font-weight: 500; }

/* ============ Itens dinÃ¢micos (tabela de serviÃ§os) ============ */
.itens-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.itens-table th { background: var(--bg-primary); padding: 8px 6px; font-size: 11px; text-transform: uppercase; color: var(--text-secondary); font-weight: 600; text-align: left; border-bottom: 1px solid var(--border-color); }
.itens-table td { padding: 6px; border-bottom: 1px solid var(--border-color); }
.itens-table input { padding: 6px 8px; border: 1px solid var(--border-color); border-radius: 4px; font-size: 13px; width: 100%; font-family: inherit; }
.itens-table input:focus { outline: none; border-color: var(--gold-primary); }
.itens-table .col-num { width: 36px; text-align: center; color: var(--text-light); font-weight: 600; }
.itens-table .col-desc { min-width: 180px; }
.itens-table .col-qtd, .itens-table .col-valor { width: 110px; }
.itens-table .col-total { width: 120px; }
.itens-table .col-action { width: 40px; text-align: center; }
.itens-table .btn-remove { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 18px; padding: 4px 8px; border-radius: 4px; transition: var(--transition); }
.itens-table .btn-remove:hover { background: var(--danger-bg); }
.itens-total { display: flex; justify-content: flex-end; margin-top: 12px; padding-top: 12px; border-top: 2px solid var(--gold-primary); }
.itens-total .total-label { font-weight: 600; color: var(--text-secondary); margin-right: 12px; align-self: center; }
.itens-total .total-value { font-size: 18px; font-weight: 700; color: var(--gold-primary); }

/* ============ Search ============ */
.search-box { position: relative; }
.search-box input { padding: 8px 12px 8px 36px; border: 1px solid var(--border-color); border-radius: var(--radius); width: 260px; max-width: 100%; font-family: inherit; font-size: 14px; transition: var(--transition); }
.search-box input:focus { outline: none; border-color: var(--gold-primary); box-shadow: 0 0 0 3px rgba(201, 162, 39, 0.1); }
.search-box .search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-light); font-size: 14px; pointer-events: none; }

/* ============ Cliente Autocomplete (datalist custom) ============ */
.cliente-input-wrapper { position: relative; }
.cliente-input-wrapper input { padding-right: 32px; }
.cliente-input-wrapper .clear-cliente-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--text-light); cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 4px; transition: var(--transition); display: none; line-height: 1; }
.cliente-input-wrapper .clear-cliente-btn:hover { background: var(--bg-primary); color: var(--danger); }
.cliente-input-wrapper.has-selection .clear-cliente-btn { display: block; }
.cliente-suggestions { position: absolute; top: 100%; left: 0; right: 0; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius); box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; z-index: 200; display: none; margin-top: 4px; }
.cliente-suggestions.open { display: block; animation: slideUp 0.15s ease; }
.cliente-suggestion-item { padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border-color); font-size: 13px; transition: var(--transition); display: flex; flex-direction: column; gap: 2px; }
.cliente-suggestion-item:last-child { border-bottom: none; }
.cliente-suggestion-item:hover, .cliente-suggestion-item.highlighted { background: var(--bg-gold-light); }
.cliente-suggestion-item .sug-name { font-weight: 600; color: var(--text-primary); }
.cliente-suggestion-item .sug-meta { font-size: 11px; color: var(--text-light); display: flex; gap: 10px; flex-wrap: wrap; }
.cliente-suggestion-item .sug-meta span { display: inline-flex; align-items: center; gap: 4px; }
.cliente-suggestion-empty { padding: 16px; text-align: center; color: var(--text-light); font-size: 13px; }
.cliente-suggestion-empty a { color: var(--gold-primary); font-weight: 600; text-decoration: none; }
.cliente-suggestion-empty a:hover { text-decoration: underline; }


/* ============ Toasts ============ */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; max-width: calc(100% - 40px); }
.toast { padding: 14px 20px; color: white; border-radius: var(--radius); box-shadow: var(--shadow-lg); font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 10px; animation: slideIn 0.3s ease; min-width: 280px; max-width: 380px; }
.toast.info { background: var(--info); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: #42310b; }
.toast.hide { opacity: 0; transition: opacity 0.3s; }

/* ============ Animations ============ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ Mobile ============ */
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--border-color); background: var(--bg-secondary); border-radius: var(--radius); cursor: pointer; font-size: 20px; margin-right: 8px; flex-shrink: 0; align-items: center; justify-content: center; }
.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 99; }

/* Tablet (1024px) */
@media (max-width: 1024px) {
    .content { padding: 24px; }
    .modal-xl { max-width: 95%; }
    .header { padding: 14px 24px; }
    .page-title { font-size: 22px; }
}

/* Mobile (768px) */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: flex; }
    .sidebar-overlay.active { display: block; }
    .header { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .header-left { flex: 1; min-width: 0; }
    .page-title { font-size: 22px; }
    .header-right { width: 100%; justify-content: flex-end; gap: 8px; }
    .btn { padding: 8px 12px; font-size: 13px; }
    .btn-search span, .btn-primary span:not(:first-child) { display: none; }
    .btn-search, .btn-primary { padding: 8px 12px; }
    .content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px; gap: 12px; }
    .stat-icon { width: 42px; height: 42px; font-size: 18px; border-radius: 8px; }
    .stat-info h3 { font-size: 18px; }
    .stat-info span { font-size: 11px; }
    .search-box input { width: 100%; }
    .modal { padding: 12px; }
    .modal-content { max-height: 95vh; }
    .modal-large, .modal-xl { max-width: 100%; }
    .modal-body, .modal-header, .modal-footer { padding: 16px; }
    .form-row { grid-template-columns: 1fr; gap: 12px; }
    .card-header { padding: 16px; flex-direction: column; align-items: stretch; }
    .card-body { padding: 16px; }
    .table th, .table td { padding: 10px 8px; font-size: 13px; }
    .itens-table { font-size: 12px; }
    .itens-table .col-qtd, .itens-table .col-valor, .itens-table .col-total { width: 80px; }
    .itens-table input { font-size: 12px; padding: 4px 6px; }
}

/* Mobile pequeno (480px) */
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .header-right .btn span { display: none; }
    .header-right .btn { padding: 8px 10px; }
    .user-chip .user-name { display: none; }
    .toast { min-width: auto; width: 100%; }
    .toast-container { left: 12px; right: 12px; top: 12px; }
    .modal-footer { flex-direction: column-reverse; }
    .modal-footer .btn { width: 100%; justify-content: center; }
    .action-group { gap: 4px; }
    .action-group .btn-sm { padding: 4px 8px; font-size: 11px; }
}

/* ============================================================
   PRINT STYLES â€” Layout A4 (corrigido)
   ============================================================ */
.print-only { display: none; }

@media print {
    body > * { display: none !important; }
    body { background: #fff !important; }

    .print-only {
        display: block !important;
        font-family: 'Inter', sans-serif;
        color: var(--text-primary);
        font-size: 10.5pt;
        line-height: 1.6;
        padding: 0;
        margin: 0;
    }

    .page-break-before {
        page-break-before: always;
    }



    @page { size: A4; margin: 2cm 1.8cm 2.5cm 1.8cm; }
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

    /* Controle de linhas Ã³rfÃ£s/viÃºvas */
    p { orphans: 3; widows: 3; }
    h3 { orphans: 4; widows: 4; page-break-after: avoid; }

    /* ===== CabeÃ§alho fixo (repete em todas as pÃ¡ginas) ===== */
    .print-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 10px;
        margin-bottom: 0;
        border-bottom: 2px solid var(--gold-primary);
        background: #fff;
    }
    .print-header .header-left-side {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    .print-header .logo-print {
        max-height: 50px;
        width: auto;
        object-fit: contain;
    }
    .print-header .brand-info {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    .print-header .brand-name {
        font-family: 'Playfair Display', serif;
        font-size: 13pt;
        font-weight: 700;
        color: var(--sidebar-bg);
        letter-spacing: 1px;
    }
    .print-header .brand-tagline {
        font-size: 8pt;
        color: var(--gold-primary);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
    .print-header .doc-info {
        text-align: right;
        font-size: 8pt;
        color: var(--text-secondary);
    }
    .print-header .doc-info .doc-type {
        font-family: 'Playfair Display', serif;
        color: var(--sidebar-bg);
        font-size: 11pt;
        font-weight: 700;
        margin-bottom: 2px;
        letter-spacing: 1px;
        text-transform: uppercase;
    }
    .print-header .doc-info .doc-number { font-size: 9pt; color: var(--gold-primary); font-weight: 600; }
    .print-header .doc-info .doc-date { font-size: 8pt; color: var(--text-light); margin-top: 2px; }

    .print-content-wrapper { padding-top: 80px; }

    .print-gold-bar {
        height: 2px;
        background: var(--gold-primary);
        margin-bottom: 16px;
    }

    .print-section { margin-bottom: 16px; }
    .print-section > h3 {
        font-size: 11pt;
        font-weight: 700;
        color: var(--sidebar-bg);
        padding: 5px 10px;
        margin-bottom: 10px;
        background: var(--bg-gold-light);
        border-left: 4px solid var(--gold-primary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    .print-section p { margin-bottom: 6px; text-align: justify; font-size: 10pt; line-height: 1.45; }
    .print-section ul { padding-left: 20px; margin-bottom: 8px; }
    .print-section li { margin-bottom: 4px; font-size: 10pt; line-height: 1.45; text-align: justify; }

    .print-parties, .print-representative, .print-signatures {
        page-break-inside: avoid;
    }

    .print-parties {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px;
        margin-bottom: 14px;
    }
    .print-party-card {
        border: 1px solid var(--border-color);
        border-radius: 6px;
        padding: 10px 12px;
        background: #fafbfc;
    }
    .print-party-card .party-label {
        font-size: 9pt;
        font-weight: 700;
        color: var(--gold-primary);
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-bottom: 6px;
        padding-bottom: 4px;
        border-bottom: 1px solid var(--border-color);
    }
    .print-party-card .party-row {
        display: flex;
        gap: 6px;
        margin-bottom: 3px;
        font-size: 9pt;
    }
    .print-party-card .party-row .label {
        font-weight: 600;
        color: var(--text-secondary);
        min-width: 65px;
    }
    .print-party-card .party-row .value {
        color: var(--text-primary);
        flex: 1;
    }

    .print-info-grid {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
        margin-bottom: 12px;
    }
    .print-info-grid .info-item {
        border: 1px solid var(--border-color);
        border-radius: 4px;
        padding: 6px 8px;
        background: #fafbfc;
    }
    .print-info-grid .info-item .info-label {
        font-size: 7.5pt;
        font-weight: 600;
        color: var(--text-light);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 3px;
    }
    .print-info-grid .info-item .info-value {
        font-size: 9.5pt;
        color: var(--text-primary);
        font-weight: 500;
    }

    .print-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 9.5pt; }
    .print-table thead { display: table-header-group; }
    .print-table th {
        background: var(--sidebar-bg) !important;
        color: #fff !important;
        padding: 7px 8px;
        text-align: left;
        font-weight: 600;
        text-transform: uppercase;
        font-size: 8pt;
        letter-spacing: 0.5px;
        border: 1px solid var(--sidebar-bg);
    }
    .print-table th.center, .print-table td.center { text-align: center; }
    .print-table th.right, .print-table td.right { text-align: right; }
    .print-table td {
        padding: 7px 8px;
        border: 1px solid var(--border-color);
        vertical-align: top;
    }
    .print-table tbody tr { page-break-inside: avoid; }
    .print-table tbody tr:nth-child(even) td { background: #fafbfc; }
    .print-table .item-num { text-align: center; font-weight: 600; color: var(--gold-primary); width: 30px; }
    .print-table .col-valor { white-space: nowrap; }

    .print-total-row {
        display: flex;
        justify-content: flex-end;
        margin-top: 10px;
        page-break-inside: avoid;
    }
    .print-total-box {
        background: var(--sidebar-bg);
        color: #fff;
        padding: 8px 18px;
        border-radius: 4px;
        display: flex;
        align-items: center;
        gap: 12px;
    }
    .print-total-box .total-label {
        font-size: 9pt;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 1px;
    }
    .print-total-box .total-value {
        font-size: 13pt;
        font-weight: 700;
        color: var(--gold-primary);
    }

    .print-conditions {
        background: var(--bg-gold-light);
        border-left: 3px solid var(--gold-primary);
        padding: 10px 14px;
        margin: 8px 0 10px;
        border-radius: 0 4px 4px 0;
        page-break-inside: avoid;
    }
    .print-conditions ul { padding-left: 18px; margin: 0; }
    .print-conditions li { margin-bottom: 4px; font-size: 10pt; }

    /* AJUSTE PDF (propostas): Declarações — usa list-style nativo (decimal)
       em vez de CSS counter. O counter-reset estava sendo renderizado fora de
       ordem em modo print (números apareciam depois das assinaturas). */
    .print-declarations {
        padding-left: 22px;
        margin: 8px 0 12px;
        list-style: decimal;
    }
    .print-declarations li {
        margin-bottom: 7px;
        font-size: 10pt;
        text-align: justify;
        padding-left: 4px;
    }
    .print-declarations li::marker {
        font-weight: 700;
        color: var(--gold-primary);
    }

    .print-representative {
        background: #fafbfc;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        padding: 10px 14px;
        margin: 10px 0;
    }
    .print-representative .rep-title {
        font-size: 9pt;
        font-weight: 700;
        color: var(--gold-primary);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 6px;
    }
    .print-representative .rep-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 4px 14px;
        font-size: 9.5pt;
    }
    .print-representative .rep-grid .rep-item { display: flex; gap: 6px; }
    .print-representative .rep-grid .rep-item .label { font-weight: 600; color: var(--text-secondary); min-width: 75px; }
    .print-representative .rep-grid .rep-item .value { color: var(--text-primary); }

    .print-signatures {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 50px;
        margin-top: 50px;
    }
    .print-signatures .signature-block { text-align: center; }
    .print-signatures .signature-line {
        border-top: 1.5px solid var(--text-primary);
        margin-bottom: 6px;
        padding-top: 36px;
    }
    .print-signatures .signature-name {
        font-size: 10pt;
        font-weight: 700;
        color: var(--text-primary);
    }
    .print-signatures .signature-doc {
        font-size: 9pt;
        color: var(--text-secondary);
        margin-top: 2px;
    }
    .print-signatures .signature-role {
        font-size: 9pt;
        color: var(--gold-primary);
        font-weight: 600;
        margin-top: 4px;
    }
    .print-signatures .signature-reg {
        font-size: 8.5pt;
        color: var(--text-light);
        margin-top: 2px;
    }

    .print-local-date {
        text-align: center;
        margin-top: 20px;
        margin-bottom: 10px;
        font-size: 10pt;
        color: var(--text-secondary);
        font-style: italic;
    }

    .print-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 8pt;
        color: var(--text-light);
        padding: 6px 0 0;
        border-top: 1px solid var(--border-color);
        background: #fff;
    }

    .page-break { page-break-before: always; }
    .page-break-before {
        page-break-before: always;
    }
    .no-break {
        page-break-inside: avoid;
    }
    .no-break { page-break-inside: avoid; }

    
}

/* ============================================================
   MELHORIA #14: CHAVE SELETORA DE STATUS (Propostas) + SINO
   ============================================================ */

/* --- Chave seletora de status (tabela de Propostas) --- */
.switch-status-wrap { display: inline-flex; align-items: center; gap: 8px; }

.switch-status {
    width: 52px; height: 26px; border-radius: 999px; border: none; cursor: pointer;
    position: relative; flex-shrink: 0; padding: 0; transition: background 0.25s ease;
}
.switch-status:focus-visible { outline: 2px solid var(--gold-primary); outline-offset: 2px; }
.switch-status:active { transform: scale(0.96); }

.switch-knob {
    position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
    background: #ffffff; display: flex; align-items: center; justify-content: center;
    font-size: 10px; line-height: 1; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    transition: left 0.25s ease;
}

.switch-status.st-rascunho  { background: #9ca3af; }
.switch-status.st-pendente  { background: #f59e0b; }
.switch-status.st-aprovada  { background: #10b981; }
.switch-status.st-reprovada { background: #ef4444; }

.switch-status.st-aprovada .switch-knob,
.switch-status.st-reprovada .switch-knob { left: 29px; }

.switch-status-label { font-size: 12px; font-weight: 700; white-space: nowrap; }
.lbl-rascunho  { color: #6b7280; }
.lbl-pendente  { color: #b45309; }
.lbl-aprovada  { color: #047857; }
.lbl-reprovada { color: #b91c1c; }

/* --- Sino: badge vermelho com contador (não altera o layout) --- */
.btn-icon { position: relative; }
.notif-badge {
    position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px;
    border-radius: 999px; background: #ef4444; color: #ffffff; font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; padding: 0 5px;
    border: 2px solid var(--bg-secondary); box-sizing: content-box; z-index: 5;
    animation: notif-pop 0.25s ease;
}
@keyframes notif-pop { from { transform: scale(0); } to { transform: scale(1); } }

/* --- Painel de notificações do sino --- */
.notif-panel {
    position: fixed; top: 78px; right: 20px; width: 380px; max-width: calc(100vw - 24px);
    background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 32, 53, 0.18); z-index: 3000; overflow: hidden;
}
.notif-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border-color); background: var(--bg-gold-light);
}
.notif-header h3 { margin: 0; font-size: 14px; color: var(--text-primary); }
.notif-fechar {
    background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer;
    color: var(--text-secondary); padding: 0 2px;
}
.notif-fechar:hover { color: var(--text-primary); }
.notif-lista { max-height: 420px; overflow-y: auto; }
.notif-item {
    display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--bg-hover);
    cursor: pointer; font-size: 13px; line-height: 1.45; border-left: 3px solid transparent;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--bg-hover); }
.notif-icone { flex-shrink: 0; font-size: 15px; }
.notif-texto { color: var(--text-primary); }
.notif-item.sev-danger  { border-left-color: #ef4444; }
.notif-item.sev-warning { border-left-color: #f59e0b; }
.notif-item.sev-success { border-left-color: #10b981; }
.notif-item.sev-info    { border-left-color: #3b82f6; }
.notif-vazio { padding: 28px 16px; text-align: center; color: var(--text-secondary); }
.notif-vazio span { font-size: 28px; }
.notif-vazio p { margin: 8px 0 2px; font-weight: 600; color: var(--text-primary); }
.notif-vazio small { font-size: 12px; }

@media (max-width: 768px) {
    .notif-panel { top: 64px; right: 8px; }
    .switch-status-label { display: none; }
}
/* ===================== FIM MELHORIA #14 ===================== */

/* ============================================================
   MELHORIA #15: CATÁLOGO DE SERVIÇOS VIVO
   ============================================================ */

/* Barra do seletor de catálogo dentro do modal da Proposta
   (seção "3. Investimento (Serviços)") */
.catalogo-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.catalogo-bar select {
    flex: 1;
    min-width: 220px;
    max-width: 460px;
}

/* Valor sugerido em "R$ X / unidade" na página Serviços */
#tabelaServicos td:nth-child(3) {
    white-space: nowrap;
}

@media (max-width: 768px) {
    .catalogo-bar select {
        max-width: 100%;
    }
}
/* ===================== FIM MELHORIA #15 ===================== */

/* ============================================================
   AJUSTE IMÓVEL — Seção 2 da Proposta
   1) Grade 3x3 na IMPRESSÃO: 9 blocos do mesmo tamanho
      (Coordenadas deixa de ficar órfã na última linha)
   2) Bloco "Mapa / Localização" no PDF
   3) Área de upload/cola do mapa no FORMULÁRIO
   ============================================================ */

/* --- Impressão: grade 3x3 uniforme --- */
.print-info-grid-9 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
}
.print-info-grid-9 .info-item {
    display: flex;
    flex-direction: column;
    min-height: 52px;
    overflow: hidden;
}
.print-info-grid-9 .info-item .info-value {
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* --- Impressão: grade 3x2 (6 blocos) — versão enxuta da grade 9 --- */
.print-info-grid-6 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: stretch;
}
.print-info-grid-6 .info-item {
    display: flex;
    flex-direction: column;
    min-height: 48px;
    overflow: hidden;
}
.print-info-grid-6 .info-item .info-value {
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

/* --- Impressão: bloco do mapa/print da localização --- */
.print-mapa {
    margin-top: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 8px 8px;
    background: #fff;
    page-break-inside: avoid;
}
.print-mapa-label {
    font-size: 7.5pt;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}
/* Mapa redimensionado para caber na mesma página que "1. Partes" + "2. Imóvel".
   Altura máxima reduzida de 9cm para 5.5cm — quando impresso, ocupa ~metade da página. */
.print-mapa img {
    width: 100%;
    max-height: 5.5cm;
    object-fit: contain;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: block;
    background: #fff;
}
@media print {
    .print-mapa img { max-height: 5cm; }
}

/* --- Formulário: área de colar/enviar o mapa --- */
.mapa-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-secondary, #fafbfc);
    cursor: pointer;
    transition: var(--transition);
    min-height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}
.mapa-upload:hover,
.mapa-upload.drag {
    border-color: var(--gold-primary);
    background: var(--bg-gold-light);
}
.mapa-upload-vazio {
    display: flex;
    align-items: center;
    gap: 14px;
    text-align: left;
    color: var(--text-light);
    font-size: 13px;
}
.mapa-upload-vazio small { color: var(--text-light); opacity: .85; }
.mapa-upload-icon { font-size: 30px; line-height: 1; }
.mapa-upload-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}
.mapa-upload-preview img {
    max-width: 100%;
    max-height: 260px;
    object-fit: contain;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #fff;
}
.mapa-upload-acoes { display: flex; gap: 8px; }

@media (max-width: 768px) {
    .mapa-upload-vazio { flex-direction: column; text-align: center; }
}

/* --- Página Serviços: barra da tagline do PDF --- */
.tagline-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}
.tagline-info {
    display: flex;
    flex-direction: column;
    min-width: 260px;
    flex: 1;
}
.tagline-info strong { color: var(--text-primary); font-size: 14px; }
.tagline-info span { color: var(--text-light); font-size: 12.5px; }
.tagline-bar input {
    flex: 1;
    min-width: 240px;
    max-width: 520px;
}
.tagline-bar .btn { flex-shrink: 0; }
