/*
 * App shell: top navbar + fixed sidebar + content area, plus a few MD3-flavoured
 * components. Bootstrap 5 provides the base; these rules theme it and add the
 * shell. (De-iframed adaptation of the health home shell.)
 */
* { box-sizing: border-box; }

body {
    font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--md-sys-color-background);
    color: var(--md-sys-color-on-background);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--md-sys-color-primary); }

/* Bootstrap primary -> brand colour */
.btn-primary {
    --bs-btn-bg: var(--md-sys-color-primary);
    --bs-btn-border-color: var(--md-sys-color-primary);
    --bs-btn-hover-bg: var(--app-primary-hover);
    --bs-btn-hover-border-color: var(--app-primary-hover);
    --bs-btn-active-bg: var(--app-primary-hover);
    --bs-btn-disabled-bg: var(--md-sys-color-primary);
    --bs-btn-disabled-border-color: var(--md-sys-color-primary);
}

/* ---- Navbar ------------------------------------------------------------- */
.app-navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 64px;
    background: var(--md-sys-color-surface);
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1050;
    box-shadow: var(--md-sys-elevation-1);
}
.navbar-left, .navbar-right { display: flex; align-items: center; gap: 12px; }
.logo-container { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.logo-avatar {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--app-grad-a) 0%, var(--app-grad-b) 100%);
    color: #fff; border-radius: var(--md-sys-shape-corner-full);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; letter-spacing: 0.5px;
}
img.logo-avatar { object-fit: cover; background: var(--md-sys-color-surface-container); } /* org logo */
.logo-name { font-size: 1.25rem; font-weight: 600; color: var(--md-sys-color-primary); }

.navbar-icon-btn, .mobile-menu-toggle {
    width: 40px; height: 40px;
    border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-surface-container);
    border: 1px solid var(--md-sys-color-outline-variant);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; text-decoration: none;
    transition: all 0.2s ease;
    color: var(--md-sys-color-on-surface);
}
.navbar-icon-btn:hover, .mobile-menu-toggle:hover {
    background: var(--md-sys-color-surface-container-highest);
    box-shadow: var(--md-sys-elevation-1);
}
.navbar-icon-btn { color: var(--app-navbar-icon); font-size: 18px; }
.navbar-icon-btn--danger { color: var(--md-sys-color-error); }
.mobile-menu-toggle { display: none; }
.mobile-menu-toggle i { font-size: 20px; }

.user-avatar {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, var(--app-grad-a) 0%, var(--app-grad-b) 100%);
    color: #fff; border: none; padding: 0; border-radius: var(--md-sys-shape-corner-full);
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; cursor: pointer;
    transition: box-shadow 0.2s ease;
}
.user-avatar:hover, .user-avatar:focus-visible, .user-avatar[aria-expanded="true"] {
    box-shadow: 0 0 0 2px var(--md-sys-color-surface), 0 0 0 4px var(--md-sys-color-primary);
    outline: none;
}

/* ---- Navbar user (account) dropdown ------------------------------------- */
.user-menu-dropdown {
    min-width: 224px; margin-top: 8px; padding: 8px;
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: var(--md-sys-elevation-2);
}
.user-menu-header { padding: 6px 12px 10px; }
.user-menu-name { font-weight: 600; font-size: 0.95rem; color: var(--md-sys-color-on-surface); }
.user-menu-role { font-size: 0.8rem; color: var(--md-sys-color-on-surface-variant); }
.user-menu-dropdown .dropdown-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--md-sys-shape-corner-small);
    color: var(--md-sys-color-on-surface);
}
.user-menu-dropdown .dropdown-item:hover,
.user-menu-dropdown .dropdown-item:focus {
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface);
}
.user-menu-dropdown .dropdown-item.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
}
.user-menu-dropdown .dropdown-item i { font-size: 16px; color: var(--md-sys-color-primary); }
.user-menu-dropdown .dropdown-item.active i { color: inherit; }
.user-menu-dropdown .dropdown-item--danger,
.user-menu-dropdown .dropdown-item--danger i { color: var(--md-sys-color-error); }
.user-menu-dropdown .dropdown-item--danger:hover,
.user-menu-dropdown .dropdown-item--danger:focus {
    background: var(--md-sys-color-error);
    color: var(--md-sys-color-on-error);
}
.user-menu-dropdown .dropdown-item--danger:hover i,
.user-menu-dropdown .dropdown-item--danger:focus i { color: var(--md-sys-color-on-error); }
.user-menu-dropdown .dropdown-divider {
    margin: 6px 4px; border-top-color: var(--md-sys-color-outline-variant); opacity: 1;
}

/* ---- Layout ------------------------------------------------------------- */
.app-container { display: flex; padding-top: 64px; min-height: 100vh; }

.sidebar {
    position: fixed; left: 0; top: 64px;
    width: 280px; height: calc(100vh - 64px);
    background: var(--md-sys-color-surface);
    border-right: 1px solid var(--md-sys-color-outline-variant);
    overflow-y: auto;
    z-index: 1040;
    transition: transform 0.3s ease;
}
.sidebar-menu { padding: 12px 0 80px; }
.sidebar-nav-list { list-style: none; margin: 0; padding: 0; }
.sidebar-nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 16px;
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}
.sidebar-nav-link:hover { background: var(--md-sys-color-surface-container); }
.sidebar-nav-link.active {
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-primary);
    border-left-color: var(--md-sys-color-primary);
    font-weight: 500;
}
.sidebar-nav-link i {
    font-size: 17px; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
}
.sidebar-nav-link span { font-size: 13px; font-weight: 500; }
.sidebar-section-label {
    padding: 16px 16px 4px;
    font-size: 10px; font-weight: 700; letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--md-sys-color-on-surface-variant);
    opacity: 0.6; list-style: none;
}
/* "Voltar" link at the top of a drill-in submenu (e.g. Banco de Dados). */
.sidebar-nav-back { color: var(--md-sys-color-on-surface-variant); }
.sidebar-nav-back:hover { color: var(--md-sys-color-on-surface); }

/* ---- Drill-in sidebar panels (main menu sections) ----------------------- */
.sidebar-nav { position: relative; overflow-x: hidden; }
.sidebar-panel { display: none; }
.sidebar-panel.active { display: block; animation: sidebar-panel-in 0.2s ease; }
@keyframes sidebar-panel-in {
    from { opacity: 0; transform: translateX(12px); }
    to   { opacity: 1; transform: none; }
}
/* Section buttons + back button are <button>s styled like the nav links. */
button.sidebar-nav-link {
    width: 100%; font: inherit; text-align: left; cursor: pointer;
    background: none; border: none; border-left: 3px solid transparent;
}
.sidebar-nav-chevron {
    margin-left: auto; width: auto !important; height: auto !important;
    font-size: 12px !important; opacity: 0.5;
}

.content-area {
    margin-left: 280px;
    flex: 1; padding: 24px;
    min-height: calc(100vh - 64px);
    background: var(--md-sys-color-background);
}
.content-header { margin-bottom: 24px; }
.content-header h1 { font-size: 1.6rem; font-weight: 600; margin: 0 0 6px; color: var(--md-sys-color-on-surface); }
.content-header p { font-size: 14px; color: var(--md-sys-color-on-surface-variant); margin: 0; }

/* ---- Cards & components ------------------------------------------------- */
.card {
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: var(--md-sys-elevation-1);
    padding: 24px;
    margin-bottom: 24px;
}
.card-title { font-size: 1.15rem; font-weight: 600; margin: 0 0 16px; color: var(--md-sys-color-on-surface); }
.card-text { font-size: 14px; color: var(--md-sys-color-on-surface-variant); }
/* Footer strip for panel action buttons: spans the card padding, sits flush at
   the bottom with a divider, buttons right-aligned (use .me-auto to push info left). */
.card-footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
    margin: 24px -24px -24px; padding: 16px 24px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
}
.card-footer form { margin: 0; }

/* Flash modal messages keep their line breaks (multi-field error lists,
   storage-value dumps from the Exemplos page). */
.flash-message { white-space: pre-line; }

/* ---- Realtime field validation states (core/forms.js) -------------------- */
/* Tokenized so all themes + dark mode work; Bootstrap's hardcoded red/green
   and background icons are overridden. Applied on blur, cleared on input. */
.form-control.is-invalid, .form-select.is-invalid {
    border-color: var(--md-sys-color-error);
    background-image: none;
}
.form-control.is-valid, .form-select.is-valid {
    border-color: var(--md-sys-color-primary);
    background-image: none;
}
.invalid-feedback { color: var(--md-sys-color-error); }

/* CEP auto-fill (ViaCEP): spinner pinned inside the field, hint below. */
.br-cep-wrap { position: relative; }
.br-cep-spinner {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--md-sys-color-primary);
}

/* ---- Password fields: live policy checklist ------------------------------ */
/* Show/hide comes from the shared .password-field / .password-toggle primitive
   (data-reveal, above). The checklist below mirrors App\Security\PasswordPolicy. */
.pw-checklist {
    list-style: none;
    margin: 8px 0 0;
    padding: 0;
    display: grid;
    gap: 4px;
    font-size: .8125rem;
    color: var(--md-sys-color-on-surface-variant);
}
.pw-checklist .bi { margin-right: 6px; }
.pw-checklist li.ok { color: var(--md-sys-color-primary); }
.pw-checklist li.bad { color: var(--md-sys-color-error); }

/* ---- Record-as-panel list primitive (copy across CRUD modules) ---------- */
/* Lists are a stack of .card panels — one per record — never a <table>. All
   colors flow through --md-sys-* tokens, so light + dark are automatic. Reuses
   the .card / .card-footer contract above. Canonical usage: templates/users/. */
.section-title { font-size: 1.15rem; font-weight: 600; margin: 24px 0 16px; color: var(--md-sys-color-on-surface); }

.list-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 16px; }
.list-search { position: relative; flex: 1 1 260px; min-width: 220px; }
.list-search .bi {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--md-sys-color-on-surface-variant); pointer-events: none;
}
.list-search .form-control { padding-left: 40px; border-radius: var(--md-sys-shape-corner-full); }
.list-org-filter { flex: 0 1 240px; min-width: 180px; border-radius: var(--md-sys-shape-corner-full); }
.list-count { margin: 0 0 12px; }

/* Password reveal toggle (data-reveal on the input; button injected by forms.js). */
.password-field { position: relative; }
.password-field .form-control { padding-right: 44px; }
.password-toggle {
    position: absolute; top: 0; right: 0; height: 100%; width: 44px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 0; padding: 0; cursor: pointer;
    color: var(--md-sys-color-on-surface-variant);
    border-radius: var(--md-sys-shape-corner-full);
}
.password-toggle:hover { color: var(--md-sys-color-on-surface); }
.password-toggle:focus-visible { outline: 2px solid var(--md-sys-color-primary); outline-offset: -2px; }

/* MD3 horizontal list item inside a .card */
.list-item { display: flex; align-items: center; gap: 16px; }
.list-avatar {
    flex: 0 0 auto; width: 48px; height: 48px;
    border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; letter-spacing: .5px;
}
.list-avatar .bi { font-size: 1.25rem; }
.list-body { flex: 1 1 auto; min-width: 0; }
.list-title {
    font-weight: 600; color: var(--md-sys-color-on-surface); line-height: 1.3;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-subtitle {
    font-size: .875rem; color: var(--md-sys-color-on-surface-variant);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.list-meta {
    flex: 0 0 auto; display: flex; flex-wrap: wrap; align-items: center;
    justify-content: flex-end; gap: 6px; max-width: 340px;
}
.list-time { font-size: .8125rem; color: var(--md-sys-color-on-surface-variant); white-space: nowrap; }

/* Role chips + status badge (token-driven, AA in light & dark; no green in palette) */
.chip {
    font-size: .75rem; font-weight: 500; padding: 3px 10px;
    border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant); white-space: nowrap;
}
.chip-org { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.status-badge {
    font-size: .75rem; font-weight: 600; padding: 3px 10px;
    border-radius: var(--md-sys-shape-corner-full); white-space: nowrap;
}
.status-badge.is-active { background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container); }
.status-badge.is-inactive {
    background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface-variant);
    border: 1px solid var(--md-sys-color-outline-variant);
}

/* Tokenize Bootstrap's outline button so the footer action themes with the app. */
.btn-outline-primary {
    --bs-btn-color: var(--md-sys-color-primary);
    --bs-btn-border-color: var(--md-sys-color-outline);
    --bs-btn-hover-color: var(--md-sys-color-primary);
    --bs-btn-hover-bg: var(--md-sys-color-surface-variant);
    --bs-btn-hover-border-color: var(--md-sys-color-primary);
    --bs-btn-active-color: var(--md-sys-color-primary);
    --bs-btn-active-bg: var(--md-sys-color-surface-variant);
    --bs-btn-active-border-color: var(--md-sys-color-primary);
}

.list-empty { text-align: center; padding: 32px 24px; color: var(--md-sys-color-on-surface-variant); }
.list-empty .bi { font-size: 2rem; color: var(--md-sys-color-outline); display: block; margin-bottom: 8px; }

.list-pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }
.list-pagination-info { font-size: 0.875rem; color: var(--md-sys-color-on-surface-variant); }

/* Narrow screens: drop the trailing meta below the text, aligned past the avatar. */
@media (max-width: 560px) {
    .list-item { flex-wrap: wrap; }
    .list-meta { width: 100%; justify-content: flex-start; padding-left: 64px; }
}

/* ---- Program cards — DTT Flow layout: colored domain tile + phase bar ------
   One-row card (tile · body · status+phase · actions). Token-driven, so it
   themes with the app and adapts to light/dark. Used by templates/programs/
   _card.view.php and mirrored in assets/js/pages/programs-list.js. */
.program-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.program-tile {
    flex: 0 0 auto; width: 48px; height: 48px;
    border-radius: var(--md-sys-shape-corner-medium);
    display: flex; align-items: center; justify-content: center;
    background: color-mix(in oklab, var(--tile-hue) 16%, var(--md-sys-color-surface));
    color: var(--tile-hue);
}
.program-tile .bi { font-size: 1.4rem; }
/* On the dark charcoal surface, deepen the wash and lift the icon so it reads. */
[data-bs-theme="dark"] .program-tile {
    background: color-mix(in oklab, var(--tile-hue) 26%, var(--md-sys-color-surface));
    color: color-mix(in oklab, var(--tile-hue) 62%, white);
}
.tile-green   { --tile-hue: #2e8b57; }
.tile-teal    { --tile-hue: #2f8f93; }
.tile-amber   { --tile-hue: #b7791f; }
.tile-blue    { --tile-hue: #3b82a6; }
.tile-purple  { --tile-hue: #7c74c9; }
.tile-pink    { --tile-hue: #b5638b; }
.tile-neutral { --tile-hue: #6b6459; }
.program-meta {
    font-size: .8125rem; color: var(--md-sys-color-on-surface-variant);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px;
}
.program-side {
    flex: 0 0 auto; display: flex; flex-direction: column; align-items: flex-end;
    gap: 8px; min-width: 148px;
}
.program-progress {
    width: 148px; height: 6px; border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-surface-container-highest); overflow: hidden;
}
.program-progress > span {
    display: block; height: 100%; border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-primary);
}
.program-actions { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 8px; }
/* Stack the trailing zones under the text on narrow screens. */
@media (max-width: 640px) {
    .program-row { align-items: flex-start; }
    .program-side { width: 100%; align-items: flex-start; }
    .program-progress { width: 100%; }
    .program-actions { width: 100%; }
}

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; margin-bottom: 24px; }

.stat-card {
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    box-shadow: var(--md-sys-elevation-1);
    padding: 20px; display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 56px; height: 56px;
    border-radius: var(--md-sys-shape-corner-medium);
    background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-primary);
    display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.stat-content h4 { font-size: 1.5rem; font-weight: 600; margin: 0 0 4px; color: var(--md-sys-color-on-surface); }
.stat-content p { font-size: 13px; color: var(--md-sys-color-on-surface-variant); margin: 0; }

/* ---- Sidebar overlay (mobile) ------------------------------------------ */
.sidebar-overlay {
    display: none; position: fixed; inset: 64px 0 0 0;
    background: rgba(0, 0, 0, 0.5); z-index: 1035; opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active { display: block; opacity: 1; }

@media (max-width: 1024px) {
    .sidebar { width: 240px; }
    .content-area { margin-left: 240px; }
}
@media (max-width: 768px) {
    .mobile-menu-toggle { display: flex; }
    .sidebar { transform: translateX(-100%); width: 280px; }
    .sidebar.mobile-open { transform: translateX(0); box-shadow: var(--md-sys-elevation-3); }
    .content-area { margin-left: 0; padding: 16px; }
    .logo-name { display: none; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---- Auth pages -------------------------------------------------------- */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: var(--md-sys-color-background); padding: 20px;
}
.auth-wrap { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large);
    box-shadow: var(--md-sys-elevation-2);
    padding: 32px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; justify-content: center; margin-bottom: 24px; }
.auth-title { font-size: 1.4rem; font-weight: 600; margin: 0 0 4px; color: var(--md-sys-color-on-surface); }
.auth-subtitle { font-size: 14px; color: var(--md-sys-color-on-surface-variant); margin: 0 0 20px; }
.auth-links { margin-top: 16px; text-align: center; font-size: 14px; }

/* ---- Chat (Conversas / WhatsApp) --------------------------------------- */
.chat-layout { display: flex; gap: 16px; align-items: stretch; height: calc(100vh - 210px); min-height: 420px; }
.chat-sidebar { width: 320px; flex-shrink: 0; display: flex; flex-direction: column; gap: 10px; }
.chat-sidebar-toolbar { display: flex; flex-direction: column; gap: 8px; }
/* .list-search has flex: 1 1 260px for row toolbars; inside this COLUMN
   toolbar that basis would become height — pin it to content size. */
.chat-search { flex: 0 0 auto; width: 100%; min-width: 0; }
.chat-conversations { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px; }
.chat-conversation {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer;
    background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large); text-align: left; width: 100%;
}
.chat-conversation:hover { background: var(--md-sys-color-surface-container); }
.chat-conversation.is-active { background: var(--md-sys-color-secondary-container); border-color: transparent; }
.chat-conversation .list-title { font-size: 14px; }
.chat-conversation .list-subtitle {
    font-size: 12.5px; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-unread {
    margin-left: auto; min-width: 22px; height: 22px; border-radius: 11px; padding: 0 6px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--md-sys-color-primary); color: #fff; font-size: 12px; font-weight: 600;
}
.chat-thread { flex: 1; display: flex; flex-direction: column; min-width: 0; padding: 0; overflow: hidden; }
.chat-thread-header {
    display: flex; align-items: center; gap: 12px; padding: 12px 16px;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
}
.chat-messages {
    flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px;
    background: var(--md-sys-color-surface-container);
}
.chat-empty { margin: auto; text-align: center; color: var(--md-sys-color-on-surface-variant); }
.chat-empty .bi { font-size: 2rem; color: var(--md-sys-color-outline); display: block; margin-bottom: 8px; }
.chat-bubble {
    max-width: min(75%, 560px); padding: 8px 12px; border-radius: 14px; font-size: 14px;
    white-space: pre-wrap; overflow-wrap: break-word;
}
.chat-bubble.is-in {
    align-self: flex-start; background: var(--md-sys-color-surface);
    border: 1px solid var(--md-sys-color-outline-variant); border-bottom-left-radius: 4px;
}
.chat-bubble.is-out {
    align-self: flex-end; background: var(--md-sys-color-primary-container);
    color: var(--md-sys-color-on-primary-container); border-bottom-right-radius: 4px;
}
.chat-bubble.is-failed { border: 1px solid var(--md-sys-color-error); }
.chat-bubble-sender { font-size: 12px; font-weight: 600; color: var(--md-sys-color-primary); margin-bottom: 2px; }
.chat-bubble-meta {
    display: flex; align-items: center; gap: 4px; justify-content: flex-end;
    font-size: 11px; color: var(--md-sys-color-on-surface-variant); margin-top: 2px;
}
.chat-bubble-meta .bi-check2-all.is-read { color: var(--md-sys-color-primary); }
.chat-bubble-meta .chat-seen { color: var(--md-sys-color-primary); font-weight: 600; }
.chat-bubble-meta .bi-exclamation-triangle-fill { color: var(--md-sys-color-error); }
.chat-bubble img.chat-image { max-width: 100%; max-height: 280px; border-radius: 8px; display: block; }
.chat-bubble .chat-video { max-width: 100%; max-height: 320px; border-radius: 8px; display: block; }
.chat-bubble .chat-audio { max-width: 100%; min-width: 220px; display: block; }
.chat-doc {
    display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px;
    background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant);
    color: inherit; text-decoration: none; font-size: 13.5px; max-width: 100%;
}
.chat-doc .bi { font-size: 1.3rem; }
.chat-composer { padding: 10px 12px; border-top: 1px solid var(--md-sys-color-outline-variant); }
.chat-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.chat-composer textarea { resize: none; max-height: 120px; }
.chat-attach-btn, .chat-send-btn, .chat-mic-btn, .chat-rec-btn {
    width: 42px; height: 42px; flex-shrink: 0; display: inline-flex;
    align-items: center; justify-content: center; padding: 0;
}
.chat-recording { display: flex; align-items: center; gap: 10px; padding: 4px 2px; }
.chat-rec-time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--md-sys-color-on-surface); }
.chat-rec-dot {
    width: 12px; height: 12px; border-radius: 50%; background: var(--md-sys-color-error);
    animation: chat-rec-pulse 1s ease-in-out infinite;
}
@keyframes chat-rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.chat-attachment { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
@media (max-width: 820px) {
    .chat-layout { flex-direction: column; height: auto; }
    .chat-sidebar { width: 100%; }
    .chat-conversations { max-height: 260px; }
    .chat-thread { min-height: 420px; }
}

/* ── Tabelas (dev DB row browser: templates/tables/) ────────────────────────
   Toolbar (table picker + column filter) over a real <table> data grid — a
   justified <table> case (raw DB rows). All colors flow through --md-sys-*
   tokens, so light + dark are automatic; the grid scrolls inside its own
   overflow-x wrapper so the page body never scrolls sideways. */
.tables-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 20px 24px; margin-bottom: 16px; }
.tables-toolbar .form-label { font-size: .8125rem; font-weight: 500; margin-bottom: 4px; color: var(--md-sys-color-on-surface-variant); }

.tables-picker { flex: 0 0 auto; }
.tables-picker-row { display: flex; gap: 8px; }
.tables-picker .form-select { min-width: 220px; border-radius: var(--md-sys-shape-corner-full); }

.tables-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; flex: 1 1 520px; }
.tables-filters .list-search { flex: 1 1 200px; min-width: 180px; margin: 0; }
.tables-filter-search { flex: 1 1 220px; min-width: 180px; }
.tables-filter-col { flex: 0 1 200px; min-width: 150px; }
.tables-filter-op { flex: 0 1 170px; min-width: 140px; }
.tables-filter-val { flex: 1 1 180px; min-width: 150px; }
.tables-filters .form-select { border-radius: var(--md-sys-shape-corner-full); }
.tables-filters .form-control { border-radius: var(--md-sys-shape-corner-full); }
.tables-filter-actions { display: flex; align-items: center; gap: 6px; }

/* Data grid — a real <table> in a horizontal-scroll wrapper. */
.data-grid-card { padding: 0; overflow: hidden; }
.data-grid-wrap { overflow-x: auto; width: 100%; }
.data-grid {
    --bs-table-bg: transparent;
    --bs-table-color: var(--md-sys-color-on-surface);
    --bs-table-hover-bg: var(--md-sys-color-surface-variant);
    --bs-table-hover-color: var(--md-sys-color-on-surface);
    --bs-table-border-color: var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface); font-size: 13px; margin: 0;
    font-variant-numeric: tabular-nums;
}
.data-grid thead th {
    background: var(--md-sys-color-surface-container-highest);
    border-bottom: 2px solid var(--md-sys-color-outline-variant);
    vertical-align: top; white-space: nowrap; padding: 8px 12px;
}
.data-grid tbody td {
    padding: 7px 12px; vertical-align: top;
    max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-grid thead th.is-sorted { background: var(--md-sys-color-secondary-container); }
.data-grid-sort {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--md-sys-color-on-surface); text-decoration: none; font-weight: 600;
}
.data-grid-sort:hover { color: var(--md-sys-color-primary); }
.data-grid-caret { font-size: .7rem; color: var(--md-sys-color-on-surface-variant); }
.data-grid-pk { font-size: .75rem; color: var(--md-sys-color-primary); }
.data-grid-type {
    display: block; font-weight: 400; font-size: .6875rem; margin-top: 2px;
    color: var(--md-sys-color-on-surface-variant); text-transform: none;
}
.cell-null { color: var(--md-sys-color-outline); font-style: italic; }
.cell-empty { color: var(--md-sys-color-outline); }
.cell-masked { color: var(--md-sys-color-on-surface-variant); white-space: nowrap; }
.cell-masked .bi { font-size: .75rem; }

@media (max-width: 720px) {
    .tables-picker, .tables-picker .form-select { width: 100%; }
    .tables-filters { flex: 1 1 100%; }
}

/* ---- Avaliações: score screen + VB-MAPP grid (Evaluations module) -------- */

/* Evaluation status badges beyond active/inactive (lifecycle colors). */
.status-badge.is-completed { background: var(--md-sys-color-secondary-container); color: var(--md-sys-color-on-secondary-container); }
.status-badge.is-reviewed { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }

/* Score screen — header progress bar */
.score-header { margin-bottom: 16px; }
.score-progress {
    height: 6px; border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-surface-variant); overflow: hidden;
}
.score-progress-bar {
    height: 100%; border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-primary); transition: width .2s ease;
}
.score-level-pills { gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.score-level-pills .nav-link { border-radius: var(--md-sys-shape-corner-full); color: var(--md-sys-color-on-surface-variant); }
.score-level-pills .nav-link.active { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); }

/* One card per domain; one row per item (mobile-first) */
.score-domain { margin-bottom: 16px; }
.score-domain-header {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin-bottom: 8px;
}
.score-item {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 10px 0; border-top: 1px solid var(--md-sys-color-outline-variant);
}
.score-code { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.score-name { flex: 1 1 220px; min-width: 180px; color: var(--md-sys-color-on-surface); }
.score-row { display: flex; flex-wrap: wrap; gap: 6px; }
.score-btn {
    min-width: 44px; min-height: 44px; padding: 6px 12px;
    border-radius: var(--md-sys-shape-corner-full); font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.score-row-lg .score-btn { min-width: 56px; font-size: 1.1rem; }
.score-hint { font-size: .75rem; color: var(--md-sys-color-error); white-space: nowrap; }
.score-value { font-weight: 600; }
.score-level-footer {
    display: flex; align-items: center; gap: 8px; margin-bottom: 16px;
}
@media (max-width: 560px) {
    .score-item { align-items: flex-start; }
    .score-row { width: 100%; }
}

/* VB-MAPP comparison grid — pure CSS grid matrix (deliberately NO <table>) */
.vbmapp-toolbar { margin-bottom: 16px; }
.vbmapp-band { margin-bottom: 16px; }
.vbmapp-grid-wrap { overflow-x: auto; } /* wide matrices scroll here, never the body */
.vbmapp-grid { display: grid; gap: 4px; min-width: 480px; align-items: stretch; }
.vbmapp-col-header {
    font-size: .75rem; font-weight: 600; color: var(--md-sys-color-on-surface-variant);
    text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 2px;
}
.vbmapp-row-label {
    display: flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 600; color: var(--md-sys-color-on-surface-variant);
    font-variant-numeric: tabular-nums;
}
.vbmapp-cell {
    display: flex; flex-direction: column; gap: 1px; min-height: 34px;
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: 4px; padding: 2px; background: var(--md-sys-color-surface);
}
.vbmapp-cell-empty { border-style: dashed; opacity: .35; }
.vbmapp-slice {
    flex: 1 1 0; min-height: 6px; border-radius: 2px;
    background: var(--md-sys-color-surface-variant);
}
.vbmapp-slice.is-full { background: var(--vb-slice-color); }
.vbmapp-slice.is-half { position: relative; overflow: hidden; }
.vbmapp-slice.is-half::before {
    content: ""; position: absolute; inset: 0; width: 50%;
    background: var(--vb-slice-color); border-radius: 2px 0 0 2px;
}
/* Fixed 4-color compare palette (distinct hues, AA on both themes). */
.vbmapp-c1 { --vb-slice-color: #1d6fae; }
.vbmapp-c2 { --vb-slice-color: #2e7d32; }
.vbmapp-c3 { --vb-slice-color: #b26a00; }
.vbmapp-c4 { --vb-slice-color: #7b4fa6; }
html[data-bs-theme="dark"] .vbmapp-c1 { --vb-slice-color: #64a8dc; }
html[data-bs-theme="dark"] .vbmapp-c2 { --vb-slice-color: #7cc47f; }
html[data-bs-theme="dark"] .vbmapp-c3 { --vb-slice-color: #e0a04a; }
html[data-bs-theme="dark"] .vbmapp-c4 { --vb-slice-color: #b48ad6; }
.vbmapp-legend { border-left: 10px solid var(--vb-slice-color); }
.vbmapp-band-totals {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px;
}
.vbmapp-flat-item {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 8px 0; border-top: 1px solid var(--md-sys-color-outline-variant);
}
.vbmapp-flat-values { display: flex; gap: 6px; }

/* ---- Sessões: DTT recorder + summary (Sessions module) -------------------- */

/* Recorder mode: full-width canvas — hide the sidebar, widen the content. */
body:has(.recorder-mode) .sidebar { display: none; }
body:has(.recorder-mode) .content-area { margin-left: 0; padding: 16px; }
/* Sessão guiada usa o MESMO truque imersivo do gravador (sem tocar no layout master). */
body:has(.flow-mode) .sidebar { display: none; }
body:has(.flow-mode) .content-area { margin-left: 0; padding: 16px; }

.recorder-header {
    position: sticky; top: 68px; z-index: 10;
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 12px 16px; margin-bottom: 12px;
}
.recorder-header-main { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; flex-wrap: wrap; }
.recorder-header-actions { display: flex; align-items: center; gap: 8px; }
.recorder-header form { margin: 0; }
.recorder-header .dropdown-item { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.recorder-header .dropdown-item--danger { color: var(--md-sys-color-error); }
.recorder-timer { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.05rem; color: var(--md-sys-color-on-surface); }

.recorder-sync { display: inline-flex; align-items: center; gap: 6px; }
.recorder-sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--md-sys-color-primary); }
.recorder-sync.is-sending .recorder-sync-dot { background: #b26a00; animation: chat-rec-pulse 1s ease-in-out infinite; }
.recorder-sync.is-error .recorder-sync-dot { background: var(--md-sys-color-error); animation: chat-rec-pulse 1s ease-in-out infinite; }
.recorder-sync-count { font-size: .75rem; font-weight: 600; color: var(--md-sys-color-error); }
.recorder-duration-chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.recorder-duration-chip { display: inline-flex; align-items: center; gap: 6px; }

.recorder-programs, .recorder-targets {
    display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; margin-bottom: 4px;
    -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.recorder-chip {
    border: 1px solid var(--md-sys-color-outline-variant); background: var(--md-sys-color-surface);
    cursor: pointer; white-space: nowrap; flex: 0 0 auto;
}
.recorder-chip.is-active { background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary); border-color: transparent; }
.recorder-chip-count { font-variant-numeric: tabular-nums; opacity: .85; }

.recorder-target-card { padding: 16px; }
.recorder-target-title { font-weight: 600; font-size: 1.1rem; color: var(--md-sys-color-on-surface); margin-bottom: 6px; }
.recorder-target-details summary { cursor: pointer; font-size: 14px; color: var(--md-sys-color-primary); }
.recorder-target-dl { margin: 8px 0 0; font-size: 13.5px; }
.recorder-target-dl dt { color: var(--md-sys-color-on-surface-variant); font-weight: 600; margin-top: 6px; }
.recorder-target-dl dd { margin: 0; color: var(--md-sys-color-on-surface); white-space: pre-line; }

/* Result palette: fixed hues w/ dark variants (same pattern as .vbmapp-c*). */
.recorder-mode { --rec-green: #2e7d32; --rec-amber: #b26a00; --rec-red: #c62828; --rec-grey: #9e9e9e; }
html[data-bs-theme="dark"] .recorder-mode { --rec-green: #7cc47f; --rec-amber: #e0a04a; --rec-red: #ef8383; --rec-grey: #8a8a8a; }

.recorder-block { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 4px; }
.recorder-dot { width: 18px; height: 18px; border-radius: 50%; background: transparent; border: 2px solid var(--md-sys-color-outline-variant); }
.recorder-dot.is-correct { background: var(--rec-green); border-color: var(--rec-green); }
.recorder-dot.is-prompted { background: var(--rec-amber); border-color: var(--rec-amber); }
.recorder-dot.is-incorrect { background: var(--rec-red); border-color: var(--rec-red); }
.recorder-dot.is-none { background: var(--rec-grey); border-color: var(--rec-grey); }
.recorder-dot.is-pending { opacity: .45; }
.recorder-block-label { font-size: .8125rem; color: var(--md-sys-color-on-surface-variant); margin-bottom: 8px; }

.recorder-iti { height: 4px; border-radius: 2px; background: var(--md-sys-color-surface-variant); overflow: hidden; margin: 4px 0 8px; }
.recorder-iti-bar { height: 100%; width: 100%; background: var(--md-sys-color-primary); }

/* Trial pad: 2×2 grid, thumb-sized targets. */
.recorder-pad { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.recorder-pad-btn {
    min-height: 88px; border-radius: 16px; border: none;
    font-size: 1.05rem; font-weight: 600; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px; cursor: pointer;
    -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none;
}
.recorder-pad-btn:active { filter: brightness(0.92); }
.recorder-pad-btn .bi { font-size: 1.4rem; }
.recorder-pad-btn.is-correct { background: var(--rec-green); color: #fff; }
.recorder-pad-btn.is-prompted { background: var(--rec-amber); color: #fff; }
.recorder-pad-btn.is-incorrect { background: var(--rec-red); color: #fff; }
.recorder-pad-btn.is-none { background: var(--md-sys-color-surface-variant); color: var(--md-sys-color-on-surface-variant); }
html[data-bs-theme="dark"] .recorder-pad-btn.is-correct,
html[data-bs-theme="dark"] .recorder-pad-btn.is-prompted,
html[data-bs-theme="dark"] .recorder-pad-btn.is-incorrect { color: #1c1b1f; }
.recorder-pad-sub { font-size: .75rem; font-weight: 500; opacity: .9; min-height: 1em; }

/* Frequência (contador) e Duração (cronômetro): telas alternativas ao pad DTT,
   escolhidas pelo kind da tarefa do alvo ativo. Token-driven → claro/escuro
   automáticos. */
.recorder-freq, .recorder-timer-box {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    margin-top: 12px; text-align: center;
}
.recorder-freq-count, .recorder-duration-clock {
    font-size: clamp(3rem, 14vw, 5rem); font-weight: 700; line-height: 1;
    color: var(--md-sys-color-primary); font-variant-numeric: tabular-nums;
}
.recorder-duration-clock { color: var(--md-sys-color-on-surface); }
.recorder-freq-label { color: var(--md-sys-color-on-surface-variant); font-size: .9rem; }
.recorder-freq-btn {
    margin-top: 6px; min-height: 64px; width: 100%; max-width: 420px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: none; border-radius: var(--md-sys-shape-corner-large);
    background: var(--rec-green); color: #fff; font-size: 1.15rem; font-weight: 600;
    cursor: pointer; box-shadow: var(--md-sys-elevation-1);
}
.recorder-freq-btn .bi { font-size: 1.5rem; }
.recorder-freq-btn:active { filter: brightness(0.92); }
.recorder-freq-btn.is-start { background: var(--rec-green); }
.recorder-freq-btn.is-running { background: var(--rec-red); }
html[data-bs-theme="dark"] .recorder-freq-btn { color: #1c1b1f; }

/* Undo chip (bottom-left) + behavior FAB (bottom-right). */
.recorder-undo {
    position: fixed; left: 16px; bottom: 16px; z-index: 1050;
    display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px;
    border: none; border-radius: var(--md-sys-shape-corner-full);
    background: var(--md-sys-color-on-surface); color: var(--md-sys-color-surface);
    font-weight: 600; box-shadow: var(--md-sys-elevation-2); cursor: pointer;
}
.recorder-fab {
    position: fixed; right: 16px; bottom: 16px; z-index: 1050;
    width: 56px; height: 56px; border-radius: 50%; border: none;
    background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
    font-size: 1.4rem; box-shadow: var(--md-sys-elevation-2); cursor: pointer;
}

/* Bottom sheets + scrim. */
.recorder-scrim { position: fixed; inset: 0; z-index: 1055; background: rgba(0,0,0,.4); opacity: 0; transition: opacity .2s ease; }
.recorder-scrim.is-open { opacity: 1; }
.recorder-sheet {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1060;
    background: var(--md-sys-color-surface); border-radius: 20px 20px 0 0;
    box-shadow: var(--md-sys-elevation-3); padding: 8px 16px 24px;
    max-height: 70vh; overflow-y: auto;
    transform: translateY(100%); transition: transform .2s ease;
}
.recorder-sheet.is-open { transform: translateY(0); }
.recorder-sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--md-sys-color-outline-variant); margin: 4px auto 12px; }
.recorder-sheet-title { font-size: 1.05rem; font-weight: 600; margin: 0 0 8px; color: var(--md-sys-color-on-surface); }
.recorder-sheet-row {
    display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px;
    padding: 8px 12px; border: none; background: transparent; text-align: left;
    border-top: 1px solid var(--md-sys-color-outline-variant); font-size: 15px;
    color: var(--md-sys-color-on-surface); cursor: pointer;
}
button.recorder-sheet-row:hover { background: var(--md-sys-color-surface-container); }
.recorder-behavior-row { cursor: default; justify-content: space-between; flex-wrap: wrap; }
.recorder-behavior-info { display: flex; flex-direction: column; gap: 2px; flex: 1 1 220px; min-width: 0; }
.recorder-behavior-name { font-weight: 600; }
.recorder-behavior-actions { display: flex; gap: 8px; align-items: center; }
.recorder-reinforcers { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* Session start: program checkbox cards. */
.session-start-program { margin-bottom: 12px; }
.session-start-program .form-check-label { display: flex; flex-direction: column; }
.session-start-targets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.session-start-config { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-top: 12px; }

/* Summary: conic-gradient % ring + per-target rows + mastery banner. */
.summary-program { margin-bottom: 16px; }
.summary-program-header { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.summary-ring {
    --ring-pct: 0;
    width: 72px; height: 72px; border-radius: 50%; flex: 0 0 auto;
    background: conic-gradient(var(--md-sys-color-primary) calc(var(--ring-pct) * 1%), var(--md-sys-color-surface-variant) 0);
    display: flex; align-items: center; justify-content: center; position: relative;
}
.summary-ring::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--md-sys-color-surface); }
.summary-ring-value { position: relative; font-weight: 700; font-size: .9rem; font-variant-numeric: tabular-nums; color: var(--md-sys-color-on-surface); }
.summary-counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.summary-target {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
    padding: 10px 0; border-top: 1px solid var(--md-sys-color-outline-variant);
}
.summary-target-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 500; color: var(--md-sys-color-on-surface); }
.summary-target-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.summary-mastery-banner { margin-bottom: 16px; border-left: 4px solid var(--md-sys-color-primary); }
.summary-mastery-icon { font-size: 1.3rem; color: var(--md-sys-color-primary); }
.summary-mastery-list { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--md-sys-color-on-surface); }
.summary-mastery-list li { margin-bottom: 4px; }

@media (max-width: 560px) {
    .recorder-header { top: 64px; }
    .recorder-pad-btn { min-height: 96px; }
}
/* ---- Mastery suggestion queue (templates/mastery/) ---------------------- */
.mastery-transition { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.mastery-transition .bi { color: var(--md-sys-color-on-surface-variant); }
.mastery-evidence { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.mastery-program-link { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.mastery-program-link:hover { color: var(--md-sys-color-primary); }
.mastery-reject-form { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mastery-reject-form .form-control { width: 240px; max-width: 100%; border-radius: var(--md-sys-shape-corner-full); }

/* ---- Objetivos do programa (templates/programs/_objective.view.php) ------
   O objetivo é a unidade clínica: um card por objetivo, com os alvos dele
   aninhados como linhas separadas por régua. Tudo em tokens — claro e escuro
   saem de graça. */
.program-objective-card .section-title { margin: 16px 0 8px; font-size: 1rem; }
.program-target-row { padding: 10px 0; border-top: 1px solid var(--md-sys-color-outline-variant); }
.program-target-row:first-child { border-top: 0; }
.program-target-row .list-item { gap: 12px; }
.program-target-row .list-title { font-weight: 500; }

/* Rótulo do objetivo dentro da faixa de alvos do gravador. A faixa é um
   scroller horizontal de uma linha só (.recorder-targets), então o rótulo é um
   separador INLINE que rola junto — nunca um bloco de largura total. */
.recorder-objective-label {
    flex: 0 0 auto; align-self: center; white-space: nowrap;
    font-size: 12px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
    color: var(--md-sys-color-on-surface-variant);
    padding-left: 8px; margin-left: 4px;
    border-left: 2px solid var(--md-sys-color-outline-variant);
}
.recorder-objective-label:first-child { border-left: 0; padding-left: 0; margin-left: 0; }

/* Lacunas que um programa sugerido resolve (templates/evaluations/suggestions). */
.suggestion-items { list-style: none; margin: 0; padding: 0; }
.suggestion-items li { padding: 8px 0; border-top: 1px solid var(--md-sys-color-outline-variant); font-size: 14px; }
.suggestion-items li:first-child { border-top: 0; padding-top: 0; }

/* ---- Aba "Plano" do aluno (templates/students/_tab_plan.view.php) --------
   A faixa colorida à esquerda codifica a urgência clínica da ação. */
.plan-stats { display: flex; flex-wrap: wrap; gap: 24px; }
.plan-stat { display: flex; flex-direction: column; min-width: 120px; }
.plan-stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; color: var(--md-sys-color-on-surface); font-variant-numeric: tabular-nums; }
.plan-stat-label { font-size: 13px; color: var(--md-sys-color-on-surface-variant); }
.plan-action { border-left: 4px solid var(--md-sys-color-outline-variant); }
.plan-action--urgent { border-left-color: var(--md-sys-color-error); }
.plan-action--action { border-left-color: var(--md-sys-color-primary); }
.plan-action--info { border-left-color: var(--md-sys-color-outline); }

/* ---- Tela da criança (templates/sessions/child.view.php) ------------------
   O tablet fica na mão da criança: alvos grandes, contraste alto e nenhuma
   navegação. A barra do adulto fica embaixo, discreta e fora do fluxo da
   tarefa. Tudo em tokens — claro e escuro saem de graça. */
.child-mode { display: flex; flex-direction: column; min-height: 78vh; }
.child-stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
.child-instruction {
    font-size: clamp(1.1rem, 2.6vw, 1.6rem); font-weight: 600; text-align: center;
    color: var(--md-sys-color-on-surface-variant); margin: 0;
}
.child-model {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 20px 40px; border-radius: var(--md-sys-shape-corner-medium);
    background: var(--md-sys-color-surface); border: 3px solid var(--md-sys-color-primary);
    min-width: min(420px, 80vw);
}
.child-model-emoji { font-size: clamp(3rem, 12vw, 6rem); line-height: 1; }
.child-model-text { font-size: clamp(1.4rem, 4vw, 2.4rem); font-weight: 700; text-align: center; color: var(--md-sys-color-on-surface); }

.child-comparisons { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px; width: 100%; }
.child-card {
    flex: 1 1 200px; max-width: 300px; min-height: clamp(140px, 22vh, 220px);
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    padding: 16px; cursor: pointer;
    background: var(--md-sys-color-surface); color: var(--md-sys-color-on-surface);
    border: 2px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    transition: transform .08s ease, border-color .12s ease;
}
.child-card:active { transform: scale(.97); }
.child-card.is-correct { border-color: var(--rec-green); box-shadow: 0 0 0 4px var(--rec-green); }
.child-card.is-incorrect { border-color: var(--rec-red); opacity: .75; }
.child-card-emoji { font-size: clamp(2.4rem, 9vw, 4.5rem); line-height: 1; }
.child-card-text { font-size: clamp(1rem, 2.6vw, 1.5rem); font-weight: 600; text-align: center; }

.child-feedback {
    font-size: clamp(1.1rem, 3vw, 1.8rem); font-weight: 700; text-align: center;
    padding: 10px 24px; border-radius: var(--md-sys-shape-corner-full);
}
.child-feedback.is-correct { color: var(--rec-green); }
.child-feedback.is-incorrect { color: var(--md-sys-color-on-surface-variant); }

.child-done { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; }
.child-done-emoji { font-size: clamp(4rem, 16vw, 8rem); }
.child-done-text { font-size: clamp(1.4rem, 4vw, 2.2rem); font-weight: 700; color: var(--md-sys-color-on-surface); }

.child-adult-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    padding: 10px 12px; margin-top: 16px;
    border-top: 1px solid var(--md-sys-color-outline-variant);
    color: var(--md-sys-color-on-surface-variant); font-size: 13px;
}
.child-progress { margin-right: auto; font-variant-numeric: tabular-nums; }
#childPromptBtn.is-armed { background: var(--rec-amber); color: #fff; border-color: transparent; }
.child-prompt-option { display: block; width: 100%; margin-bottom: 8px; text-align: left; }

/* ==========================================================================
   Sessão guiada (fluxo DTT Flow): stepper + shell de 2 painéis + prévia "tablet"
   Token-driven → tema com o app (t1–t6) em claro/escuro.
   ========================================================================== */
.flow-stepper {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
    gap: 8px; padding: 10px 8px; margin-bottom: 20px;
    background: var(--md-sys-color-background);
}
.flow-step {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 14px 6px 8px; border-radius: var(--md-sys-shape-corner-full);
    text-decoration: none; white-space: nowrap; border: 1px solid transparent;
    color: var(--md-sys-color-on-surface-variant); font-weight: 600; font-size: .875rem;
}
a.flow-step:hover { background: var(--md-sys-color-surface-variant); }
.flow-step-num {
    width: 22px; height: 22px; border-radius: 50%; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .75rem; font-weight: 700;
    background: var(--md-sys-color-surface-container-highest);
    color: var(--md-sys-color-on-surface-variant);
}
.flow-step.is-active {
    background: var(--md-sys-color-primary); color: var(--md-sys-color-on-primary);
}
.flow-step.is-active .flow-step-num {
    background: color-mix(in oklab, var(--md-sys-color-on-primary) 26%, transparent);
    color: var(--md-sys-color-on-primary);
}
.flow-step.is-done { color: var(--md-sys-color-on-surface); }
.flow-step.is-done .flow-step-num {
    background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
}
.flow-step.is-todo { opacity: .55; }
span.flow-step { cursor: default; }

/* Shell: config à esquerda, prévia à direita (empilha no estreito). */
.flow-shell { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr); gap: 20px; align-items: start; }
.flow-shell-single { grid-template-columns: minmax(0, 720px); justify-content: center; }
.flow-panel {
    background: var(--md-sys-color-surface); border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-large); box-shadow: var(--md-sys-elevation-1); padding: 28px;
}
.flow-eyebrow {
    font-size: .75rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    color: var(--md-sys-color-secondary); margin-bottom: 6px;
}
.flow-title { font-size: 1.6rem; font-weight: 800; color: var(--md-sys-color-on-surface); margin: 0 0 20px; line-height: 1.2; }
.flow-field { margin-bottom: 16px; }
.flow-field-label { font-size: .75rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--md-sys-color-on-surface-variant); margin-bottom: 4px; }
.flow-field-value { color: var(--md-sys-color-on-surface); font-weight: 600; }
.flow-field-help { font-size: .875rem; color: var(--md-sys-color-on-surface-variant); margin: 4px 0 0; }
.flow-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.flow-note { font-size: .875rem; color: var(--md-sys-color-on-surface-variant); display: inline-flex; align-items: center; gap: 6px; }
.flow-note .bi { color: var(--md-sys-color-secondary); }
.flow-targets { margin: 8px 0 20px; }
.flow-target-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.flow-target-tile {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    min-width: 76px; min-height: 76px; padding: 10px;
    border-radius: var(--md-sys-shape-corner-medium);
    background: var(--md-sys-color-surface-variant); border: 1px solid var(--md-sys-color-outline-variant);
}
.flow-target-emoji { font-size: 1.5rem; line-height: 1; }
.flow-target-text { font-size: .8125rem; font-weight: 600; color: var(--md-sys-color-on-surface); text-align: center; }
.flow-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.flow-primary { margin-left: auto; }
.flow-mastery-banner {
    display: flex; gap: 12px; align-items: flex-start; margin-bottom: 20px;
    padding: 14px 16px; border-radius: var(--md-sys-shape-corner-medium);
    background: var(--md-sys-color-primary-container); color: var(--md-sys-color-on-primary-container);
}
.flow-mastery-banner .bi { font-size: 1.25rem; flex: none; margin-top: 2px; }
.flow-mastery-banner .flow-field-help { display: block; margin-top: 2px; color: inherit; opacity: .85; }
.flow-chart-wrap { margin: 8px 0 20px; }

/* Prévia "tablet": moldura escura fixa (é um aparelho), tela = surface do tema. */
.flow-preview {
    background: #1c1f1b; border-radius: var(--md-sys-shape-corner-large);
    padding: 16px; display: flex; flex-direction: column; gap: 12px;
    position: sticky; top: 24px;
}
.flow-preview-bar {
    display: flex; align-items: center; gap: 8px;
    font-size: .7rem; font-weight: 700; letter-spacing: .06em; color: rgba(255, 255, 255, .65);
}
.flow-preview-dot { width: 8px; height: 8px; border-radius: 50%; background: #6fc294; box-shadow: 0 0 0 3px rgba(111, 194, 148, .25); }
.flow-preview-screen {
    background: var(--md-sys-color-surface); border-radius: var(--md-sys-shape-corner-medium);
    min-height: 300px; padding: 28px 20px; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 18px; text-align: center;
}
.flow-preview-meta { font-size: .7rem; font-weight: 700; letter-spacing: .05em; color: var(--md-sys-color-secondary); }
.flow-preview-empty { color: var(--md-sys-color-on-surface-variant); }
.flow-preview-empty .bi { font-size: 2rem; display: block; margin-bottom: 8px; color: var(--md-sys-color-outline); }
.flow-preview-foot { font-size: .75rem; color: rgba(255, 255, 255, .55); text-align: center; }
/* A prévia é estática: cards não são clicáveis. */
.flow-preview .child-card { cursor: default; pointer-events: none; }

@media (max-width: 900px) {
    .flow-shell { grid-template-columns: 1fr; }
    .flow-preview { position: static; }
    .flow-primary { margin-left: 0; }
}
@media (max-width: 560px) {
    .flow-stepper { top: 64px; }
    .flow-step-label { display: none; }
    .flow-step { padding: 6px; }
}
