:root {
    --primary: #104C70;
    --primary-dark: #0a3550;
    --accent: #2DA8D3;
    --accent-light: #e0f4fc;
    --bg-body: #F0F4F8;
    --white: #ffffff;
    --text: #334155;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --danger: #ef4444;
    --gold: #d4af37;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

* { box-sizing: border-box; outline: none; }

body {
    font-family: 'Open Sans', sans-serif;
    background-color: var(--bg-body);
    color: var(--text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
}

h1, h2, h3, h4 { font-family: 'Montserrat', sans-serif; margin: 0; color: var(--primary); font-weight: 700; }

/* HEADER */
.brand-header {
    background: var(--white); padding: 1rem 0; text-align: center; border-bottom: 1px solid var(--border); box-shadow: var(--shadow); position: relative; z-index: 10;
}
.logo-area { display: flex; justify-content: center; }
.brand-logo { max-height: 140px; width: auto; display: block; }

/* NAVBAR */
.navbar {
    background: var(--primary); padding: 1rem; display: flex; justify-content: center; gap: 15px; position: sticky; top: 0; z-index: 100; box-shadow: var(--shadow);
}
.nav-btn {
    background: rgba(255, 255, 255, 0.1); color: var(--white); border: none; padding: 10px 20px; border-radius: 50px; font-weight: 600; cursor: pointer; transition: all 0.3s ease; display: flex; align-items: center; gap: 8px; font-family: 'Montserrat', sans-serif; font-size: 0.9rem;
}
.nav-btn:hover, .nav-btn.active { background: var(--white); color: var(--primary); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.highlight-btn { background: var(--accent); }
.highlight-btn:hover { background: #228bae; color: white; }

/* CONTAINER & SCREENS */
.main-content { max-width: 1200px; margin: 30px auto; padding: 0 20px; padding-bottom: 80px; }
.screen { display: none; }
.screen.active { display: block; }
.fade-in { animation: fadeIn 0.4s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* CARDS & BOXES */
.card-box {
    background: var(--white); border-radius: var(--radius); padding: 30px; box-shadow: var(--shadow); margin-bottom: 25px; border: 1px solid var(--border);
}
.header-flex { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; margin-bottom: 20px; }
.action-buttons { display: flex; gap: 10px; }
.info-text { font-size: 0.85rem; color: var(--text-light); margin-bottom: 15px; display: block; }

/* INPUTS */
.input-wrapper { display: flex; flex-direction: column; gap: 6px; width: 100%; margin-bottom: 5px; }
.input-wrapper label { font-size: 0.8rem; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; }
input[type="text"], input[type="number"], select, .styled-select {
    padding: 12px 15px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1rem; color: var(--text); background: #f8fafc; width: 100%; transition: all 0.2s ease;
}
input:focus, select:focus { border-color: var(--accent); background: var(--white); box-shadow: 0 0 0 3px rgba(45, 168, 211, 0.2); }

/* SELECTION GRID */
.complaint-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 15px; }
.checkbox-item {
    background: var(--white); border: 1px solid var(--border); padding: 12px 15px; border-radius: 8px; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--text); user-select: none;
}
.checkbox-item:hover { border-color: var(--accent); background: var(--accent-light); color: var(--primary); }
.checkbox-item input { margin: 0; width: 18px; height: 18px; accent-color: var(--primary); }

/* PROCEDURES GRID */
.grid-filtered { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 15px; margin-top: 15px; }
.proc-card-select {
    background: var(--white); border: 1px solid var(--border); padding: 15px; border-radius: var(--radius); display: flex; align-items: center; gap: 15px; cursor: pointer; transition: 0.2s; position: relative; overflow: hidden;
}
.proc-card-select:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.proc-card-select input { width: 20px; height: 20px; accent-color: var(--success); }
.proc-info { display: flex; flex-direction: column; gap: 2px; }
.proc-info div:first-child { font-weight: 700; color: var(--primary); font-size: 0.95rem; }
.proc-info div:last-child { color: var(--success); font-weight: 600; font-size: 0.9rem; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 30px; color: var(--text-light); background: #f8fafc; border-radius: var(--radius); border: 1px dashed #cbd5e1; }
.empty-state i { font-size: 2.5rem; margin-bottom: 10px; color: #cbd5e1; display: block; }

/* BUTTONS */
.btn { border: none; padding: 10px 20px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; font-size: 0.9rem; display: inline-flex; align-items: center; gap: 6px; justify-content: center; font-family: 'Open Sans', sans-serif; }
.btn-primary-lg { background: var(--primary); color: white; width: 100%; padding: 16px; font-size: 1.1rem; border-radius: 50px; margin-top: 30px; text-transform: uppercase; letter-spacing: 1px; box-shadow: 0 4px 10px rgba(16, 76, 112, 0.2); }
.btn-primary-lg:hover { background: var(--primary-dark); transform: translateY(-2px); }
.btn-add { background: var(--success); color: white; height: 46px; }
.btn-add:hover { background: #059669; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--white); }
.btn-text { background: transparent; color: var(--text-light); text-decoration: underline; border: none; padding: 5px 10px; }
.btn-text:hover { color: var(--danger); }
.btn-save { background: var(--primary); color: white; width: 100%; padding: 14px; border-radius: 50px; font-size: 1rem; }
.btn-save:hover { background: var(--primary-dark); }
.link-action { color: var(--accent); text-decoration: none; font-weight: 600; font-size: 0.85rem; }
.link-action:hover { text-decoration: underline; }

/* TABLES */
.table-container { padding: 0; overflow: hidden; margin-top: 20px; }
table { width: 100%; border-collapse: collapse; }
th { background: #f1f5f9; padding: 15px 20px; text-align: left; color: var(--primary); font-weight: 700; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.5px; }
td { padding: 15px 20px; border-bottom: 1px solid var(--border); color: var(--text); font-size: 0.95rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* BUDGET CARDS ALINHADOS */
.budget-container { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 30px; 
    align-items: stretch; /* Cards mesma altura */
}

.budget-card {
    background: var(--white);
    border-radius: 16px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column; 
    overflow: visible; 
    box-shadow: var(--shadow);
    transition: transform 0.3s;
    height: 100%; 
}

.budget-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }

.card-header { padding: 20px; text-align: center; color: white; border-radius: 16px 16px 0 0; flex-shrink: 0; }
.card-header i { font-size: 1.8rem; margin-bottom: 8px; display: block; opacity: 0.9; }
.card-header h4 { color: white; font-size: 1.1rem; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; margin: 0; }

.budget-card.premium .card-header { background: linear-gradient(135deg, #104C70, #0f2d40); }
.budget-card.standard .card-header { background: linear-gradient(135deg, #2DA8D3, #1c7fa1); }
.budget-card.basic .card-header { background: linear-gradient(135deg, #94a3b8, #475569); }

.list-area { 
    padding: 20px; 
    flex-grow: 1; /* Cresce para ocupar espaço */
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.budget-item-row { 
    display: flex; 
    justify-content: space-between; 
    align-items: flex-start;
    font-size: 0.9rem; 
    border-bottom: 1px dashed #e2e8f0; 
    padding-bottom: 8px; 
}
.budget-item-row span:first-child { flex: 1; padding-right: 10px; line-height: 1.4; word-wrap: break-word; text-align: left; }
.budget-item-row span:last-child { font-weight: 700; color: var(--primary); white-space: nowrap; display: flex; align-items: center; gap: 5px; }

/* RODAPÉ DO CARD */
.card-footer {
    background: #f8fafc;
    border-top: 1px solid var(--border);
    padding: 20px;
    margin-top: auto; 
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-radius: 0 0 16px 16px;
}

.btn-dashed { 
    border: 1px dashed #cbd5e1; background: var(--white); width: 100%; color: var(--text-light); padding: 8px; margin: 0; 
    cursor: pointer; border-radius: 8px;
}
.btn-dashed:hover { border-color: var(--accent); color: var(--accent); }

.total-row { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.total-label { font-size: 0.75rem; text-transform: uppercase; color: var(--text-light); font-weight: 700; letter-spacing: 1px; }
.total-box { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1; }

.input-disc { margin: 0; width: 100%; text-align: center; font-size: 0.9rem; border-style: solid; background: var(--white); }

/* MODALS */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.75); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; }
.modal-content { background: var(--white); border-radius: 16px; width: 650px; max-width: 95%; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); overflow: hidden; display: flex; flex-direction: column; max-height: 90vh; animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.modal-content.small-modal { width: 500px; height: auto; max-height: none; overflow: visible; }
.modal-header { background: var(--primary); padding: 20px 30px; display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { color: var(--white); font-size: 1.2rem; margin: 0; }
.close-btn { font-size: 1.8rem; cursor: pointer; color: rgba(255,255,255,0.7); transition: 0.2s; line-height: 1; }
.close-btn:hover { color: var(--white); }
.modal-body { padding: 30px; overflow-y: auto; }
.small-modal .modal-body { padding: 30px 25px; overflow: visible; }
.modal-footer { padding: 20px 30px; background: #f8fafc; text-align: right; display: flex; justify-content: flex-end; gap: 12px; border-top: 1px solid var(--border); }
.photo-section { background: #f0f9ff; border: 1px dashed var(--accent); padding: 20px; border-radius: 10px; margin-top: 20px; }
.photo-section h4 { font-size: 0.9rem; margin-bottom: 15px; display: flex; align-items: center; gap: 8px; }
.small-grid { grid-template-columns: 1fr 1fr; font-size: 0.9rem; }
.divider { height: 1px; background: var(--border); margin: 35px 0; }
.grid-patient { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-add { display: grid; grid-template-columns: 3fr 1fr 1fr auto; gap: 15px; align-items: end; }

@media print { .navbar, .btn, .no-print, .action-buttons { display: none !important; } }
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }