:root {
    --green-900: #1b4332;
    --green-700: #2d6a4f;
    --green-500: #40916c;
    --red-600: #c1121f;
    --red-500: #e63946;
    --bg: #f4f7f5;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #627d7a;
    --border: #d8e2dc;
    --shadow: 0 10px 30px rgba(27, 67, 50, 0.08);
    --radius: 14px;
    --sidebar-width: 260px;
    --sidebar-width-collapsed: 76px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--green-700); text-decoration: none; }
a:hover { color: var(--red-600); }

.app-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
    transition: grid-template-columns .22s ease;
}
html.sidebar-collapsed .app-layout {
    grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}
.sidebar {
    background: linear-gradient(180deg, var(--green-900), #163728);
    color: #fff;
    padding: 1.25rem .85rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: 1.5rem;
}
.sidebar-brand { display: flex; gap: .75rem; align-items: center; min-width: 0; flex: 1; }
.brand-text { min-width: 0; overflow: hidden; white-space: nowrap; }
.sidebar-brand strong { display: block; font-size: 1.1rem; }
.sidebar-brand span { color: #b7e4c7; font-size: .85rem; display: block; }
.sidebar-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0;
    border: 1px solid rgba(255,255,255,.18); border-radius: 10px;
    background: rgba(255,255,255,.08); color: #d8f3dc; cursor: pointer;
    transition: background .15s ease, transform .22s ease;
}
.sidebar-toggle svg { width: 18px; height: 18px; fill: currentColor; }
.sidebar-toggle:hover { background: rgba(255,255,255,.16); color: #fff; }
html.sidebar-collapsed .sidebar-toggle { transform: rotate(180deg); }
.sidebar-nav { display: grid; gap: .35rem; }
.sidebar-link {
    display: flex; align-items: center; gap: .75rem;
    color: #d8f3dc; padding: .7rem .85rem; border-radius: 10px;
    min-height: 44px; transition: background .15s ease, padding .22s ease;
}
.sidebar-link.active, .sidebar-link:hover {
    background: rgba(255,255,255,.12); color: #fff;
}
.sidebar-icon {
    width: 22px; height: 22px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
}
.sidebar-icon svg { width: 100%; height: 100%; fill: currentColor; }
.sidebar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
html.sidebar-collapsed .brand-text,
html.sidebar-collapsed .sidebar-label {
    opacity: 0; width: 0; overflow: hidden; pointer-events: none;
}
html.sidebar-collapsed .sidebar-brand { justify-content: center; }
html.sidebar-collapsed .sidebar-top {
    flex-direction: column; align-items: center; gap: .75rem;
}
html.sidebar-collapsed .sidebar-link {
    justify-content: center; padding-left: .7rem; padding-right: .7rem;
}
html.sidebar-collapsed .sidebar-logout {
    width: 44px; height: 44px; padding: 0; justify-content: center;
}
html.sidebar-collapsed .user-chip { display: none; }
.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,.12); }
.user-chip { margin-bottom: .75rem; }
.user-chip small { color: #b7e4c7; display: block; }
.sidebar-logout { width: 100%; gap: .5rem; }

.main-content { padding: 1.5rem 2rem; }
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: 1rem; margin-bottom: 1.25rem;
}
.page-header h1 { margin: 0; font-size: 1.75rem; color: var(--green-900); }
.page-header p { margin: .25rem 0 0; color: var(--muted); }

.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 1.25rem; margin-bottom: 1rem;
}
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.card-header h2 { margin: 0; font-size: 1.1rem; }

.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem; margin-bottom: 1rem;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.1rem;
}
.stat-card span { color: var(--muted); font-size: .9rem; }
.stat-card strong { display: block; font-size: 1.5rem; margin-top: .25rem; color: var(--green-900); }
.stat-card small { color: var(--muted); }
.stat-card.accent strong { color: var(--red-600); }
.finance-stats-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.stat-card-link:hover {
    color: inherit;
    transform: translateY(-2px);
    border-color: var(--green-500);
    box-shadow: 0 8px 20px rgba(15, 55, 40, .08);
}
.stat-card.stat-danger { border-left: 4px solid var(--red-600); }
.stat-card.stat-danger strong { color: var(--red-600); }
.stat-card.stat-warning { border-left: 4px solid #d89b17; }
.stat-card.stat-warning strong { color: #9a6900; }
.stat-card.stat-info { border-left: 4px solid #3b82a0; }
.stat-card.stat-info strong { color: #23647d; }
.stat-card.stat-success { border-left: 4px solid var(--green-500); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .75rem .5rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.table th { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
.table-responsive { overflow-x: auto; }
.table-toolbar {
    display: flex; justify-content: space-between; align-items: center;
    gap: .75rem; margin-bottom: .75rem; color: var(--muted); font-size: .92rem;
}
.table-clear-filters { font-weight: 600; }
.table-managed-form { margin: 0; }
.table-managed .table-head-sort th { vertical-align: middle; padding-bottom: .35rem; }
.table-managed .table-head-filter th { padding-top: 0; padding-bottom: .85rem; }
.th-sort {
    display: inline-flex; align-items: center; gap: .35rem;
    color: var(--green-900); font-weight: 700; text-decoration: none;
}
.th-sort:hover { color: var(--red-600); }
.sort-indicator { font-size: .78rem; color: var(--green-500); line-height: 1; }
.table-filter {
    width: 100%; min-width: 110px; padding: .45rem .55rem;
    border: 1px solid var(--border); border-radius: 8px;
    font: inherit; font-size: .82rem; text-transform: none; letter-spacing: normal;
    background: #fff; color: var(--text);
}
.table-filter:focus {
    outline: none; border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
}
.payments-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .85rem;
}
.payments-filter-grid {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) repeat(6, minmax(135px, 1fr));
    gap: .7rem;
    align-items: end;
}
.payments-filter-grid .form-group { min-width: 0; }
.payments-filter-grid .form-group label {
    font-size: .78rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}
.payments-filter-grid input,
.payments-filter-grid select {
    width: 100%;
    min-width: 0;
    height: 40px;
}
.payments-live-search {
    min-width: 0;
    max-width: none;
    padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 8px;
    font: inherit; font-size: .92rem;
}
.payments-live-search:focus {
    outline: none; border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
}
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (max-width: 1250px) {
    .payments-filter-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); }
    .payment-filter-search { grid-column: span 2; }
}
@media (max-width: 720px) {
    .payments-filter-grid { grid-template-columns: 1fr 1fr; }
    .payment-filter-search { grid-column: 1 / -1; }
}
.th-money, .td-money { width: 7.5rem; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.th-actions { width: 168px; text-align: right; }
.row-actions {
    display: flex; justify-content: flex-end; align-items: center; gap: .25rem;
}
.row-action-form { display: inline-flex; margin: 0; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border: 1px solid var(--border);
    border-radius: 9px; background: #fff; color: var(--green-700);
    cursor: pointer; padding: 0; text-decoration: none;
}
.icon-btn svg { width: 17px; height: 17px; fill: currentColor; }
.icon-btn:hover { border-color: var(--green-500); color: var(--green-900); background: #f7fbf8; }
.icon-btn-danger { color: var(--red-600); }
.icon-btn-danger:hover { border-color: var(--red-500); color: var(--red-600); background: #fff5f5; }
.icon-btn-success { color: var(--green-700); }
.row-muted td { opacity: .72; }
.actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.badge {
    display: inline-block; padding: .2rem .55rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600;
}
.badge-success { background: #d8f3dc; color: var(--green-900); }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-muted { background: #e9ecef; color: #495057; }
.badge-default { background: #edf2f0; color: var(--muted); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 10px; padding: .65rem 1rem;
    font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-900); color: #fff; }
.btn-secondary { background: #edf2f0; color: var(--green-900); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.25); }
.btn-sm { padding: .35rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; }

.form { display: grid; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.form-group { display: grid; gap: .35rem; }
.form-group label { font-weight: 600; font-size: .92rem; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: .7rem .8rem; border: 1px solid var(--border);
    border-radius: 10px; font: inherit; background: #fff;
}
.checkbox-group label { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.form-actions { display: flex; gap: .75rem; justify-content: flex-end; }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.pay-batch-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border);
}
.pay-col-check { width: 2.5rem; text-align: center; vertical-align: middle; }
.payments-managed-table { min-width: 1180px; }
.payments-head-filter .table-filter {
    min-width: 85px;
    padding: .4rem .45rem;
    font-size: .78rem;
}
.payments-head-filter th:nth-child(4) .table-filter { min-width: 170px; }
.payment-form input, .payment-form select { max-width: 120px; }
.payment-row-actions { min-width: 280px; }
.payment-row-main-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .35rem;
}
.payment-delete-form { display: inline-flex; margin: 0; }
.payment-patient-cell {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.payment-patient-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex: 0 0 24px;
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--green-700);
    background: #fff;
}
.payment-patient-open:hover {
    color: var(--green-900);
    border-color: var(--green-500);
    background: rgba(64, 145, 108, .08);
}
.payment-patient-open svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
}
.pay-package-drilldown {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    max-width: 100%;
    padding: .25rem .4rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--green-900);
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.pay-package-drilldown:hover { background: rgba(64, 145, 108, .1); }
.pay-package-drilldown svg {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    transition: transform .15s ease;
}
.pay-package-drilldown[aria-expanded="true"] svg { transform: rotate(90deg); }
.pay-package-drilldown small {
    color: var(--muted);
    white-space: nowrap;
}
.payment-package-row td {
    padding: 0 1rem 1rem;
    background: rgba(64, 145, 108, .035);
}
.payment-package-panel {
    margin-left: 2.5rem;
    padding: .9rem 1rem;
    border-left: 3px solid var(--green-500);
    border-radius: 0 10px 10px 0;
    background: #fff;
}
.payment-package-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .65rem;
}
.payment-package-panel-header div { display: grid; gap: .15rem; }
.payment-package-panel-header small { color: var(--muted); }
.payment-package-members {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: .4rem;
}
.payment-package-member {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .6rem .7rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    text-decoration: none;
}
.payment-package-member:hover {
    border-color: var(--green-500);
    background: rgba(64, 145, 108, .06);
}
.payment-package-member > span:first-child { display: grid; gap: .1rem; }
.payment-package-member small { color: var(--muted); }
.payment-package-member-open { color: var(--green-700); font-size: .82rem; white-space: nowrap; }
.payment-edit-row td {
    background: rgba(64, 145, 108, .05);
    padding: .85rem 1rem;
}
.payment-edit-form {
    display: grid;
    grid-template-columns: minmax(140px, .8fr) minmax(140px, .8fr) minmax(140px, .8fr) minmax(220px, 1.5fr) auto;
    gap: .75rem;
    align-items: end;
}
.payment-edit-form .form-group { margin: 0; }
.payment-edit-form input { width: 100%; }
.payment-edit-buttons {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding-bottom: 1px;
}

@media (max-width: 1050px) {
    .payment-edit-form { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .payment-edit-notes { grid-column: 1 / -1; }
    .payment-edit-buttons { justify-content: flex-end; grid-column: 1 / -1; }
    .payment-package-panel { margin-left: 0; }
}

.alert { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1rem; }
.alert-success { background: #d8f3dc; color: var(--green-900); }
.alert-error { background: #fde8ea; color: #9b1c1c; }
.empty-state, .hint { color: var(--muted); }
.hint { margin-top: .5rem; font-size: .92rem; }

.auth-page {
    min-height: 100vh; display: grid; place-items: center;
    background: radial-gradient(circle at top left, #40916c 0, transparent 35%),
                radial-gradient(circle at bottom right, #c1121f 0, transparent 30%),
                var(--green-900);
}
.auth-card {
    width: min(420px, 92vw); background: #fff; border-radius: 18px;
    padding: 2rem; box-shadow: var(--shadow);
}
.auth-brand { text-align: center; margin-bottom: 1.5rem; }
.auth-brand h1 { margin: .5rem 0 0; color: var(--green-900); }
.brand-logo { display: block; object-fit: contain; }
.brand-logo-auth { width: min(280px, 90%); height: auto; margin: 0 auto 1rem; }
.brand-logo-sidebar {
    width: auto;
    max-width: 100%;
    height: 42px;
    border-radius: 0;
    flex-shrink: 0;
}
html.sidebar-collapsed .brand-logo-sidebar {
    width: auto;
    height: 38px;
    max-width: 44px;
    object-fit: contain;
}

@media (max-width: 900px) {
    .app-layout,
    html.sidebar-collapsed .app-layout {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 1rem;
        transition: padding .2s ease;
    }
    .sidebar-top { margin-bottom: 1rem; flex-direction: row; align-items: center; }
    .sidebar-toggle {
        display: inline-flex;
    }
    html.sidebar-collapsed .sidebar-toggle {
        transform: none;
    }
    .sidebar-toggle svg {
        transform: rotate(-90deg);
        transition: transform .2s ease;
    }
    html.sidebar-menu-collapsed .sidebar-toggle svg {
        transform: rotate(90deg);
    }
    html.sidebar-menu-collapsed .sidebar-nav,
    html.sidebar-menu-collapsed .sidebar-footer {
        display: none;
    }
    html.sidebar-menu-collapsed .sidebar-top {
        margin-bottom: 0;
    }
    html.sidebar-menu-collapsed .sidebar {
        padding-top: .65rem;
        padding-bottom: .65rem;
    }
    .sidebar-nav { grid-template-columns: repeat(3, 1fr); }
    .sidebar-link { flex-direction: column; gap: .25rem; padding: .55rem .35rem; font-size: .72rem; text-align: center; }
    .sidebar-icon { width: 20px; height: 20px; }
    .brand-text,
    .sidebar-label,
    html.sidebar-collapsed .brand-text,
    html.sidebar-collapsed .sidebar-label {
        opacity: 1; width: auto; overflow: visible; pointer-events: auto;
    }
    .sidebar-logout { width: 100%; height: auto; padding: .35rem .65rem; }
    .main-content { padding: 1rem; }
}

/* Agenda — calendário (estilo painel EDUCA) */
.age-grade {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 400px);
    gap: 1rem;
    align-items: start;
}
.age-calendario { padding: 1rem .9rem .85rem; min-width: 0; }
.age-cal-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .85rem;
}
.age-week-banner {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem .75rem;
    padding: .55rem .75rem;
    border-radius: 10px;
    background: linear-gradient(135deg, #e8f5e9, #f1f8f4);
    border: 1px solid #c8e6c9;
    font-size: .9rem;
}
.age-week-banner.is-closed {
    background: linear-gradient(135deg, #fff3e0, #fff8e1);
    border-color: #ffcc80;
}
#ageWeekLabel { color: #1b4332; }
.age-week-missing {
    color: #9a3412;
    font-size: .85rem;
}
.age-week-admin {
    margin-left: auto;
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
}
.age-week-status-select {
    font: inherit;
    font-size: .85rem;
    padding: .25rem .45rem;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.age-blocks-panel {
    flex: 1 1 100%;
    font-size: .85rem;
}
.age-blocks-panel summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--green-900);
}
.age-blocks-hint { margin: .35rem 0 .5rem; }
.age-blocks-list {
    list-style: none;
    margin: 0 0 .5rem;
    padding: 0;
}
.age-blocks-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem .5rem;
    margin-bottom: .35rem;
}
.age-blocks-form {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    align-items: center;
}
.age-blocks-form input[type="time"],
.age-blocks-form input[type="text"],
.age-blocks-form select {
    font: inherit;
    font-size: .82rem;
    padding: .2rem .35rem;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.age-week-blockout {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 1;
    background: repeating-linear-gradient(
        -45deg,
        rgba(120, 120, 120, .12),
        rgba(120, 120, 120, .12) 6px,
        rgba(180, 180, 180, .08) 6px,
        rgba(180, 180, 180, .08) 12px
    );
    border-top: 1px dashed rgba(90, 90, 90, .35);
    border-bottom: 1px dashed rgba(90, 90, 90, .35);
    pointer-events: none;
    overflow: hidden;
}
.age-week-blockout span {
    display: block;
    font-size: .62rem;
    color: #666;
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.age-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, .45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.age-modal[hidden] { display: none !important; }
.age-modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 1.25rem 1.35rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.age-modal-box h4 { margin: 0 0 .5rem; }
.age-modal-box p { margin: 0 0 1rem; color: var(--muted); font-size: .92rem; }
.age-modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.age-week-block.is-avulso { outline: 2px dashed rgba(0,0,0,.25); outline-offset: -2px; }
.age-week-block.is-retorno { outline: 2px dotted rgba(27, 67, 50, .45); outline-offset: -2px; }
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    border: 0;
}
.age-view-toggle {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.age-view-btn {
    border: none;
    background: transparent;
    padding: .45rem .85rem;
    font: inherit;
    font-weight: 600;
    font-size: .88rem;
    color: var(--muted);
    cursor: pointer;
}
.age-view-btn.is-active {
    background: var(--green-700);
    color: #fff;
}
.age-cal-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem;
}
.age-period-title {
    margin: 0;
    min-width: 160px;
    text-align: center;
    font-size: 1.05rem;
    color: var(--green-900);
}
.age-cal-semana,
.age-cal-dias {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
    overflow: visible;
}
.age-cal-semana {
    margin-bottom: 6px;
    color: var(--muted);
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-align: center;
}
.age-dia {
    min-height: 92px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfcfa;
    padding: 6px;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
    font: inherit;
    color: inherit;
    position: relative;
}
.age-dia:focus-visible { outline: 2px solid var(--green-500); outline-offset: 1px; }
.age-dia-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 4px;
    min-height: 1.1rem;
}
.age-dia-expand {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin: -2px -2px 0 0;
    padding: 2px 4px;
    border: none;
    border-radius: 6px;
    background: rgba(27, 67, 50, .08);
    color: var(--green-800);
    cursor: pointer;
    line-height: 1;
}
.age-dia-expand:hover,
.age-dia-expand:focus-visible {
    background: rgba(27, 67, 50, .16);
    outline: none;
    box-shadow: 0 0 0 2px rgba(64, 145, 108, .35);
}
.age-dia-expand.is-open {
    background: var(--green-700);
    color: #fff;
}
.age-dia-expand-more {
    font-size: .62rem;
    font-weight: 700;
}
.age-dia.is-exploded {
    z-index: 25;
    overflow: visible;
}
.age-dia.is-exploded .age-dia-ev-preview {
    visibility: hidden;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}
.age-dia-burst {
    position: absolute;
    left: -4px;
    right: -4px;
    top: -4px;
    z-index: 2;
    padding: 6px;
    border-radius: 10px;
    border: 2px solid var(--green-500);
    background: #fff;
    box-shadow: 0 10px 28px rgba(20, 40, 30, .18);
    max-height: min(280px, 50vh);
    overflow-y: auto;
    cursor: default;
}
.age-dia-burst-head {
    font-size: .72rem;
    font-weight: 700;
    color: var(--green-900);
    margin-bottom: 6px;
    padding-right: 28px;
}
.age-dia-ev-all { gap: 4px; }
.age-dia-vazio { background: transparent; border-color: transparent; min-height: 92px; pointer-events: none; }
.age-dia-n { font-weight: 700; font-size: .82rem; }
.age-dia.tem-evento { background: #f3f8f1; }
.age-dia.is-hoje { outline: 2px solid var(--green-500); }
.age-dia.is-sel { background: #e7f3d8; border-color: var(--green-500); }
.age-dia-ev { display: grid; gap: 3px; min-width: 0; }
.age-chip {
    display: block;
    font-size: .68rem;
    line-height: 1.2;
    padding: 2px 5px;
    border-radius: 6px;
    background: var(--age-cor, var(--green-700));
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.age-chip-ev { cursor: pointer; }
.age-chip-ev.is-ev-sel { outline: 2px solid #fff; box-shadow: 0 0 0 2px var(--green-700); }
.age-mais { font-size: .68rem; color: var(--muted); }
.age-legenda {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    color: var(--muted);
    font-size: .78rem;
}
.age-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: -1px;
}
.age-dot.st-agendado { background: #40916c; }
.age-dot.st-confirmado { background: #2d6a4f; }
.age-dot.st-realizado { background: #627d7a; }
.age-dot.st-falta { background: #c1121f; }
.age-dot.st-cancelado { background: #adb5bd; }

.age-week-layout {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 6px;
    row-gap: 4px;
    align-items: stretch;
    --age-slot-px: 14px;
}
.age-week-gutter,
.age-week-main {
    display: contents;
}
.age-week-gutter-head {
    grid-column: 1;
    grid-row: 1;
    min-height: 52px;
    box-sizing: border-box;
}
.age-week-head {
    grid-column: 2;
    grid-row: 1;
    margin-bottom: 0;
    display: grid;
    grid-template-columns: repeat(7, minmax(72px, 1fr));
    gap: 4px;
    min-height: 52px;
    box-sizing: border-box;
}
.age-week-gutter-times {
    grid-column: 1;
    grid-row: 2;
    position: relative;
    overflow: hidden;
    max-height: min(780px, calc(100vh - 220px));
    min-height: 0;
    padding-right: 0;
}
.age-week-gutter-times-track {
    position: relative;
    will-change: transform;
}
.age-week-scroll {
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    overflow-x: auto;
    overflow-y: auto;
    max-height: min(780px, calc(100vh - 220px));
}
.age-week-time-label {
    position: absolute;
    left: 0;
    right: 4px;
    margin: 0;
    padding: 0;
    line-height: 1;
    font-size: .68rem;
    color: var(--muted);
    text-align: right;
    transform: translateY(-50%);
    pointer-events: none;
    border: none;
}
.age-week-head-cell {
    text-align: center;
    padding: .35rem .25rem;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
}
.age-week-head-cell.is-hoje { outline: 2px solid var(--green-500); outline-offset: -1px; }
.age-week-head-cell.is-sel,
.age-week-head-cell:hover { background: #e7f3d8; border-color: var(--border); }
.age-week-head-cell strong { display: block; font-size: 1.1rem; line-height: 1.1; }
.age-week-head-cell small { color: var(--muted); font-size: .72rem; }
.age-week-dow { display: block; font-size: .68rem; text-transform: uppercase; color: var(--muted); }
.age-week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(72px, 1fr));
    gap: 4px;
}
.age-week-day-col {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fbfcfa;
    cursor: pointer;
    min-width: 72px;
}
.age-week-day-col.is-sel { border-color: var(--green-500); background: #f3f8f1; }
.age-week-track {
    position: relative;
    background-color: #fff;
    border-radius: 0 0 9px 9px;
}
.age-week-slot-grid {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    /* Hora cheia — linha contínua (ex.: 13:00) */
    background-image: repeating-linear-gradient(
        to bottom,
        rgba(27, 67, 50, .34) 0,
        rgba(27, 67, 50, .34) 2px,
        transparent 2px,
        transparent calc(var(--age-slot-px) * 4)
    );
}
.age-week-slot-grid::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    /* Meia hora — linha contínua mais suave (ex.: 13:30) */
    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent calc(var(--age-slot-px) * 2),
        rgba(27, 67, 50, .17) calc(var(--age-slot-px) * 2),
        rgba(27, 67, 50, .17) calc(var(--age-slot-px) * 2 + 1px),
        transparent calc(var(--age-slot-px) * 2 + 1px),
        transparent calc(var(--age-slot-px) * 4)
    );
}
.age-week-slot-grid::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    /* 15 min (:15 e :45) — tracejado fino suave */
    background-image:
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent var(--age-slot-px),
            rgba(27, 67, 50, .12) var(--age-slot-px),
            rgba(27, 67, 50, .12) calc(var(--age-slot-px) + 1px),
            transparent calc(var(--age-slot-px) + 1px),
            transparent calc(var(--age-slot-px) * 4)
        ),
        repeating-linear-gradient(
            to bottom,
            transparent 0,
            transparent calc(var(--age-slot-px) * 3),
            rgba(27, 67, 50, .12) calc(var(--age-slot-px) * 3),
            rgba(27, 67, 50, .12) calc(var(--age-slot-px) * 3 + 1px),
            transparent calc(var(--age-slot-px) * 3 + 1px),
            transparent calc(var(--age-slot-px) * 4)
        );
    -webkit-mask: repeating-linear-gradient(to right, #000 0 4px, transparent 4px 9px);
    mask: repeating-linear-gradient(to right, #000 0 4px, transparent 4px 9px);
}
.age-week-block-wrap {
    position: absolute;
    left: 3px;
    right: 3px;
    z-index: 2;
    min-height: 18px;
}
.age-week-block {
    display: flex;
    flex-direction: column;
    gap: 1px;
    width: 100%;
    height: 100%;
    text-align: left;
    border: 1px solid rgba(27, 67, 50, .12);
    border-left: 4px solid var(--age-cor, var(--green-700));
    border-radius: 8px;
    background: rgba(255, 255, 255, .96);
    padding: 3px 5px;
    cursor: grab;
    touch-action: none;
    font: inherit;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(27, 67, 50, .08);
}
.age-week-block:active { cursor: grabbing; }
.age-week-block-wrap.is-dragging {
    opacity: .45;
    pointer-events: none;
}
.age-week-drag-ghost {
    position: fixed;
    z-index: 9999;
    max-width: min(320px, 92vw);
    padding: 8px 12px;
    border-radius: 8px;
    background: var(--green-900);
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.35;
    pointer-events: none;
    box-shadow: var(--shadow);
}
.age-week-drag-ghost.is-invalid {
    background: #495057;
    font-weight: 500;
}
.age-week-block.is-ev-sel {
    box-shadow: 0 0 0 2px var(--green-700);
}
.age-week-block-time {
    display: none;
    font-size: .68rem;
    font-weight: 700;
    color: var(--green-900);
    line-height: 1.1;
    flex-shrink: 0;
}
.age-week-block:hover .age-week-block-time,
.age-week-block:focus-visible .age-week-block-time {
    display: block;
}
.age-week-block-title {
    font-size: .72rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    flex: 1;
    min-height: 0;
}
.age-week-block:hover .age-week-block-title,
.age-week-block:focus-visible .age-week-block-title {
    -webkit-line-clamp: 2;
}

.age-detail-card {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}
.age-patient-upcoming {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.age-patient-upcoming-title {
    margin: 0 0 .5rem;
    font-size: .92rem;
    color: var(--green-900);
}
.age-day-list { display: grid; gap: .35rem; margin-top: .35rem; max-height: 280px; overflow-y: auto; }
.age-day-pick {
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: .45rem .6rem;
    font: inherit;
    font-size: .82rem;
    cursor: pointer;
}
.age-day-pick span { font-weight: 700; color: var(--green-800); margin-right: .35rem; }
.age-day-pick.is-active,
.age-day-pick:hover { background: #e7f3d8; border-color: var(--green-500); }

.age-patient-search-wrap { position: relative; }
.age-patient-search {
    width: 100%; padding: .55rem .65rem; border: 1px solid var(--border);
    border-radius: 8px; font: inherit; font-size: .92rem;
}
.age-patient-search:focus {
    outline: none; border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(64, 145, 108, 0.15);
}
.age-patient-search-results {
    position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
    max-height: 220px; overflow-y: auto; margin: 0; padding: .35rem 0;
    list-style: none; background: #fff; border: 1px solid var(--border);
    border-radius: 8px; box-shadow: 0 8px 24px rgba(15, 23, 42, .12);
}
.age-patient-search-results li button {
    display: block; width: 100%; text-align: left; padding: .45rem .75rem;
    border: none; background: transparent; font: inherit; cursor: pointer;
}
.age-patient-search-results li button:hover,
.age-patient-search-results li button:focus {
    background: rgba(64, 145, 108, 0.1);
}
.age-patient-search-empty {
    padding: .5rem .75rem; color: var(--muted); font-size: .88rem;
}
.age-detail-form { margin-top: .5rem; }
.age-detail-grid { grid-template-columns: 1fr 1fr; }
.age-detail-actions { flex-wrap: wrap; }

.age-lista-card h3 { margin-top: 0; }
@media (max-width: 980px) {
    .age-grade { grid-template-columns: 1fr; }
    .age-dia { min-height: 72px; }
    .age-detail-card { position: static; }
    .age-detail-grid { grid-template-columns: 1fr; }
}

