/* ===========================
   Gestao de Pacientes - Design System
   =========================== */

:root {
    /* Color Palette */
    --bg-primary: #0f1118;
    --bg-secondary: #161a25;
    --bg-card: rgba(25, 30, 42, 0.85);
    --bg-card-hover: rgba(30, 36, 52, 0.95);
    --bg-input: rgba(20, 24, 35, 0.9);
    --bg-modal-overlay: rgba(5, 6, 10, 0.75);
    
    --text-primary: #e8ecf4;
    --text-secondary: #8b93a7;
    --text-muted: #5a6178;
    
    --border-color: rgba(80, 90, 120, 0.25);
    --border-hover: rgba(100, 115, 155, 0.4);
    
    /* Accent Colors */
    --blue: #4e8cff;
    --blue-glow: rgba(78, 140, 255, 0.2);
    --green: #34d399;
    --green-glow: rgba(52, 211, 153, 0.15);
    --red: #f87171;
    --red-glow: rgba(248, 113, 113, 0.15);
    --orange: #fbbf24;
    --orange-glow: rgba(251, 191, 36, 0.15);
    --purple: #a78bfa;
    --purple-glow: rgba(167, 139, 250, 0.15);
    --teal: #2dd4bf;
    --teal-glow: rgba(45, 212, 191, 0.15);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #4e8cff 0%, #6366f1 100%);
    --gradient-danger: linear-gradient(135deg, #f87171 0%, #ef4444 100%);
    --gradient-success: linear-gradient(135deg, #34d399 0%, #10b981 100%);
    --gradient-card: linear-gradient(145deg, rgba(30, 36, 55, 0.7) 0%, rgba(20, 24, 38, 0.9) 100%);
    
    /* Spacing */
    --sidebar-width: 250px;
    --sidebar-collapsed: 68px;
    --top-bar-height: 64px;
    
    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    
    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(78, 140, 255, 0.1);
    
    /* Borders */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    /* Transitions */
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===========================
   Reset & Base
   =========================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(78, 140, 255, 0.06) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 20%, rgba(99, 102, 241, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 60% 80%, rgba(52, 211, 153, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

::selection {
    background: var(--blue);
    color: white;
}

/* ===========================
   Glass Card
   =========================== */
.glass-card {
    background: var(--gradient-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* ===========================
   Screens
   =========================== */
.screen {
    display: none;
    min-height: 100vh;
}
.screen.active {
    display: flex;
}

/* ===========================
   Login
   =========================== */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 48px 40px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: fadeInUp 0.6s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 4px 24px rgba(78, 140, 255, 0.3);
}

.login-icon .material-icons-round {
    font-size: 36px;
    color: white;
}

.login-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 0.9rem;
}

/* ===========================
   Inputs
   =========================== */
.input-group {
    position: relative;
    margin-bottom: 16px;
}

.input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 20px;
    transition: var(--transition);
}

.input-group input {
    width: 100%;
    padding: 14px 16px 14px 46px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
}

.input-group input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

.input-group input:focus + .input-icon,
.input-group input:focus ~ .input-icon {
    color: var(--blue);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

.textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===========================
   Buttons
   =========================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn .material-icons-round {
    font-size: 18px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 16px rgba(78, 140, 255, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(78, 140, 255, 0.35);
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
    box-shadow: 0 4px 16px rgba(248, 113, 113, 0.25);
}

.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 24px rgba(248, 113, 113, 0.35);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.btn-accent {
    background: rgba(78, 140, 255, 0.12);
    color: var(--blue);
    border: 1px solid rgba(78, 140, 255, 0.2);
}

.btn-accent:hover {
    background: rgba(78, 140, 255, 0.2);
}

.btn-sm {
    padding: 8px 14px;
    font-size: 0.82rem;
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 14px;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.btn-icon-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon-inline:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
}

.btn-icon-inline.danger:hover {
    background: var(--red-glow);
    color: var(--red);
}

.btn-icon-inline .material-icons-round {
    font-size: 18px;
}

/* ===========================
   Sidebar
   =========================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-overlay {
    display: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sidebar-logo .material-icons-round {
    font-size: 28px;
    color: var(--blue);
    flex: 0 0 auto;
}

.sidebar-title {
    font-size: 1.05rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.15;
    max-width: 132px;
    white-space: normal;
}

.sidebar-toggle-btn {
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--blue-glow);
    color: var(--blue);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    background: var(--blue);
    border-radius: 0 3px 3px 0;
}

.nav-item .material-icons-round {
    font-size: 22px;
}

.nav-badge {
    background: var(--red);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    margin-left: auto;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.user-info .material-icons-round {
    color: var(--blue);
}

body.prontuario-active .sidebar {
    width: var(--sidebar-collapsed);
}

body.prontuario-active .main-content {
    margin-left: var(--sidebar-collapsed);
}

body.prontuario-active .sidebar-header {
    justify-content: center;
    padding: 18px 10px;
}

body.prontuario-active .sidebar-logo {
    justify-content: center;
}

body.prontuario-active .sidebar-title,
body.prontuario-active .sidebar-toggle-btn,
body.prontuario-active .sidebar-quick,
body.prontuario-active .nav-label,
body.prontuario-active .user-name {
    display: none;
}

body.prontuario-active .sidebar-nav {
    padding: 12px 8px;
    align-items: center;
}

body.prontuario-active .nav-item {
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    gap: 0;
}

body.prontuario-active .nav-item.active::before {
    left: -8px;
}

body.prontuario-active .nav-badge {
    position: absolute;
    top: 3px;
    right: 2px;
    margin-left: 0;
    min-width: 17px;
    height: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-size: 0.62rem;
}

body.prontuario-active .sidebar-footer {
    justify-content: center;
    padding: 12px 8px;
}

body.prontuario-active .user-info {
    display: none;
}

body.prontuario-active .top-prontuario-quick {
    display: block;
}

/* ===========================
   Main Content
   =========================== */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: var(--transition);
    position: relative;
    z-index: 1;
}

/* ===========================
   Top Bar
   =========================== */
.top-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    height: var(--top-bar-height);
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 17, 24, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-title-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1 1 auto;
    min-width: 0;
}

.top-title-wrap .page-title {
    flex: 0 0 auto;
}

.top-prontuario-quick {
    display: none;
    position: relative;
    width: min(380px, 42vw);
}

.top-prontuario-quick .sidebar-quick-results {
    position: absolute;
    z-index: 80;
    left: 0;
    right: 0;
    top: calc(100% + 6px);
}

.mobile-menu-btn {
    display: none;
}

.page-title {
    font-size: 1.2rem;
    font-weight: 700;
    flex: 1;
}

.top-bar-actions {
    display: flex;
    gap: 8px;
}

/* ===========================
   Sections
   =========================== */
.section {
    display: none;
    padding: 24px 28px;
    animation: fadeIn 0.3s ease-out;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===========================
   Stats Grid
   =========================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card.clickable {
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--accent) 15%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon .material-icons-round {
    font-size: 24px;
    color: var(--accent);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===========================
   Cards
   =========================== */
.card {
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h3,
.card-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
}

.card-header .material-icons-round {
    color: var(--blue);
    font-size: 20px;
}

.card-body {
    padding: 20px;
}

.card-body.p-0 {
    padding: 0;
}

.card-inner {
    background: rgba(15, 18, 28, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

/* ===========================
   Tables
   =========================== */
.table-responsive {
    overflow-x: auto;
}

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

.data-table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(80, 90, 120, 0.1);
    font-size: 0.9rem;
    vertical-align: middle;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(78, 140, 255, 0.04);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.col-name {
    min-width: 180px;
}
.col-a1c { width: 100px; }
.col-date { width: 130px; }
.col-next { width: 130px; }
.col-appointment { width: 170px; }
.col-status { width: 120px; }
.col-actions { width: 130px; text-align: right !important; }

.patient-name-cell {
    font-weight: 600;
    cursor: pointer;
    color: var(--blue);
    transition: var(--transition);
}

.patient-name-cell:hover {
    color: #7aafff;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 16px !important;
    font-size: 0.95rem;
}

.empty-state .material-icons-round {
    font-size: 48px;
    opacity: 0.3;
    margin-bottom: 8px;
}

/* ===========================
   Status Badges
   =========================== */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-ok {
    background: var(--green-glow);
    color: var(--green);
}

.status-upcoming {
    background: var(--orange-glow);
    color: var(--orange);
}

.status-overdue {
    background: var(--red-glow);
    color: var(--red);
}

.status-pending {
    background: rgba(139, 147, 167, 0.15);
    color: var(--text-secondary);
}

/* A1C value color coding */
.a1c-good { color: var(--green); font-weight: 700; }
.a1c-warning { color: var(--orange); font-weight: 700; }
.a1c-danger { color: var(--red); font-weight: 700; }

.a1c-level-badge {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ===========================
   Search & Filter
   =========================== */
.section-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    min-width: 280px;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

.search-box .material-icons-round {
    color: var(--text-muted);
    font-size: 20px;
}

.search-box input {
    border: none !important;
    background: none !important;
    padding: 10px 0 !important;
    box-shadow: none !important;
    flex: 1;
}

.search-clear {
    width: 28px;
    height: 28px;
}

.filter-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.filter-btn:hover {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--blue-glow);
    border-color: rgba(78, 140, 255, 0.3);
    color: var(--blue);
}

/* ===========================
   Modals
   =========================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal-overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s ease-out;
}

.modal-lg {
    max-width: 720px;
}

.modal-sm {
    max-width: 400px;
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-body {
    padding: 24px;
}

.quick-patient-input {
    margin-bottom: 18px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.03);
}

.quick-patient-input-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.quick-patient-input-header label {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.quick-patient-input textarea {
    min-height: 92px;
    resize: vertical;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* ===========================
   Detail Status Bar
   =========================== */
.detail-status-bar {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.detail-stat {
    display: flex;
    flex-direction: column;
    padding: 12px 20px;
    background: rgba(15, 18, 28, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    min-width: 120px;
}

.detail-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.detail-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    margin-top: 4px;
}

/* ===========================
   Form Inline
   =========================== */
.form-inline {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.form-inline .form-group {
    margin-bottom: 0;
    flex: 1;
    min-width: 120px;
}

.form-inline .btn {
    flex-shrink: 0;
    height: 40px;
}

/* ===========================
   Bulk Add
   =========================== */
.bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
}

.bulk-count {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.help-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* ===========================
   Toast
   =========================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    font-size: 0.9rem;
    animation: toastIn 0.3s ease-out;
    min-width: 280px;
    max-width: 420px;
}

.toast.success {
    border-color: rgba(52, 211, 153, 0.3);
}

.toast.success .material-icons-round {
    color: var(--green);
}

.toast.error {
    border-color: rgba(248, 113, 113, 0.3);
}

.toast.error .material-icons-round {
    color: var(--red);
}

.toast.info {
    border-color: rgba(78, 140, 255, 0.3);
}

.toast.info .material-icons-round {
    color: var(--blue);
}

.toast-exit {
    animation: toastOut 0.3s ease-in forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

/* ===========================
   Error text
   =========================== */
.error-text {
    color: var(--red);
    font-size: 0.85rem;
    margin-top: 12px;
    text-align: center;
}

/* ===========================
   Utility Classes
   =========================== */
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.quick-add-form {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-inline {
    padding: 6px 8px !important;
    font-size: 0.8rem !important;
    border-radius: 4px !important;
    height: 30px !important;
    width: auto !important;
}

.w-60 { width: 60px !important; }
.w-date { width: 110px !important; }

.btn-icon-inline.success:hover {
    background: var(--green-glow);
    color: var(--green);
}

.date-sm {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* ===========================
   Scrollbar
   =========================== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(80, 90, 120, 0.3);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(80, 90, 120, 0.5);
}

/* ===========================
   Loading Spinner
   =========================== */
.spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===========================
   Responsive
   =========================== */
@media (max-width: 768px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 90;
        display: none;
        background: rgba(0, 0, 0, 0.48);
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .sidebar {
        width: min(var(--sidebar-width), 86vw);
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
        z-index: 100;
    }

    body.prontuario-active .sidebar {
        width: min(var(--sidebar-width), 86vw);
    }

    body.prontuario-active .main-content {
        margin-left: 0;
    }

    body.prontuario-active .sidebar-header {
        justify-content: space-between;
        padding: 20px 16px;
    }

    body.prontuario-active .sidebar-title,
    body.prontuario-active .nav-label,
    body.prontuario-active .user-name {
        display: inline;
    }

    body.prontuario-active .sidebar-quick {
        display: block;
    }

    body.prontuario-active .sidebar-nav {
        align-items: stretch;
    }

    body.prontuario-active .nav-item {
        justify-content: flex-start;
        width: auto;
        height: auto;
        padding: 12px 14px;
        gap: 12px;
    }

    body.prontuario-active .user-info {
        display: flex;
    }

    .top-title-wrap {
        gap: 10px;
    }

    .top-prontuario-quick {
        width: min(260px, 58vw);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-nav {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .main-content {
        margin-left: 0;
        min-width: 0;
    }
    
    .mobile-menu-btn {
        display: flex !important;
    }
    
    .section {
        padding: 16px;
    }
    
    .top-bar {
        padding: 0 16px;
        gap: 10px;
    }

    .top-bar-actions {
        flex-shrink: 0;
    }

    .page-title {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .search-box {
        min-width: 100%;
        order: 10;
    }
    
    .section-actions {
        gap: 8px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-card {
        padding: 14px;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }
    
    .form-inline {
        flex-direction: column;
        align-items: stretch;
    }
    
    .form-inline .form-group {
        min-width: 100%;
    }
    
    .detail-status-bar {
        gap: 8px;
    }
    
    .detail-stat {
        min-width: calc(50% - 8px);
        flex: 1;
    }
    
    .btn .btn-text {
        display: none;
    }
    
    .filter-group {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }
    
    .modal {
        margin: 10px;
    }
    
    .login-card {
        padding: 32px 24px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-stat {
        min-width: 100%;
    }
    
    .bulk-actions {
        flex-direction: column;
        gap: 12px;
    }
}

/* ===========================
   Exam Type Badge
   =========================== */
.badge-exam-type {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(78, 140, 255, 0.12);
    color: var(--blue);
    border: 1px solid rgba(78, 140, 255, 0.2);
    white-space: nowrap;
}

/* ===========================
   Settings – Exam Type Rows
   =========================== */
.exam-type-row { padding: 12px 16px; }
.exam-type-row-inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.exam-type-badge {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: rgba(78, 140, 255, 0.1);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.exam-type-badge .material-icons-round { color: var(--blue); font-size: 20px; }
.exam-name-input { flex: 1; min-width: 150px; }
.w-70 { width: 70px !important; }

/* Toggle Switch */
.toggle-switch {
    display: inline-flex; align-items: center; gap: 6px;
    cursor: pointer; user-select: none;
    font-size: 0.82rem; color: var(--text-secondary);
}
.toggle-switch input[type="checkbox"] { display: none; width: auto; padding: 0; }
.toggle-slider {
    position: relative; display: inline-block;
    width: 40px; height: 22px;
    background: rgba(80,90,120,0.4);
    border-radius: 11px; transition: var(--transition); flex-shrink: 0;
}
.toggle-slider::after {
    content: ''; position: absolute;
    top: 3px; left: 3px; width: 16px; height: 16px;
    border-radius: 50%; background: white; transition: var(--transition);
}
.toggle-switch input:checked + .toggle-slider { background: var(--blue); }
.toggle-switch input:checked + .toggle-slider::after { transform: translateX(18px); }

/* Patient Detail multi-exam status bar */
.exam-type-stat {
    flex-direction: column; align-items: flex-start; gap: 4px;
    min-width: 130px; padding: 12px 16px;
    background: rgba(15,18,28,0.5);
    border-radius: var(--radius-sm); border: 1px solid var(--border-color);
}
.detail-stat-sub { font-size: 0.78rem; color: var(--text-muted); }

/* Utilities */
.mb-16 { margin-bottom: 16px; }
.mt-20 { margin-top: 20px; }

/* ===========================
   Solicitação de Exames
   =========================== */

/* Badge: exame foi solicitado */
.request-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 180, 0, 0.12);
    border: 1px solid rgba(255, 180, 0, 0.35);
    color: #ffb400;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    animation: pulseRequest 2.5s ease-in-out infinite;
}

@keyframes pulseRequest {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 180, 0, 0); }
    50%       { box-shadow: 0 0 0 4px rgba(255, 180, 0, 0.15); }
}

.request-clear-btn {
    background: none;
    border: none;
    color: rgba(255, 180, 0, 0.6);
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    transition: color 0.2s;
    line-height: 1;
}

.request-clear-btn:hover {
    color: var(--red);
}

/* Botão para solicitar quando ainda não foi solicitado */
.btn-request {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    background: transparent;
    border: 1px dashed rgba(255, 130, 0, 0.4);
    color: rgba(255, 130, 0, 0.7);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-request:hover {
    background: rgba(255, 130, 0, 0.1);
    border-color: rgba(255, 130, 0, 0.7);
    color: #ff8200;
}

/* Coluna de solicitação e Status integrado */
.status-col-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    min-width: 120px;
}

.status-col-wrapper:hover .status-badge {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.inline-request-form {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(20, 25, 40, 0.95);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    margin-top: 4px;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.inline-request-form input {
    height: 28px !important;
    padding: 0 4px !important;
    font-size: 0.75rem !important;
    width: 105px !important;
}

.btn-save-inline {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    background: var(--green);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.request-tag-inline {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 180, 0, 0.1);
    border: 1px solid rgba(255, 180, 0, 0.2);
    color: #ffb400;
    font-size: 0.7rem;
    font-weight: 600;
}

.request-tag-inline button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0 0 0 4px;
    font-size: 14px;
    line-height: 1;
}

/* =========================================
   TABLE FILTERS
   ========================================= */
.table-filter-select {
    padding: 3px 8px;
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    outline: none;
    transition: var(--transition);
    text-transform: none;
    font-weight: 600;
    width: auto;
    min-width: 80px;
}

.table-filter-select:hover {
    border-color: var(--blue);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

.table-filter-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 8px;
}

/* =========================================
   REPORTS SECTION
   ========================================= */

.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

.report-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.report-card .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

@media (max-width: 768px) {
    .report-grid {
        grid-template-columns: 1fr;
    }
}

/* =========================================
   V2 - LINHAS DE CUIDADO
   ========================================= */

.section-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 24px;
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.4rem;
    margin: 0;
}

.section-header h2 .material-icons-round {
    color: var(--blue);
    font-size: 28px;
}

.section-description {
    margin: 0;
    opacity: 0.7;
    font-size: 0.9rem;
}

.mb-24 {
    margin-bottom: 24px;
}

/* Badge variants */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.72rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-primary {
    background: rgba(78, 140, 255, 0.12);
    color: var(--blue);
    border: 1px solid rgba(78, 140, 255, 0.2);
}

.badge-secondary {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.badge-info {
    background: rgba(6, 182, 212, 0.12);
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Outline button */
.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: var(--transition);
}

.btn-outline:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: rgba(78, 140, 255, 0.08);
}

.care-lines-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.care-lines-toolbar-note {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.care-lines-grid {
    display: grid;
    grid-template-columns: minmax(320px, 1.2fr) minmax(280px, 0.8fr);
    gap: 24px;
}

.care-line-form-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 12px;
}

.care-line-icon-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    gap: 6px;
    margin-top: 8px;
    max-height: 170px;
    overflow-y: auto;
    padding-right: 4px;
}
.care-line-icon-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 48px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease, transform .15s ease, background .15s ease;
}
.care-line-icon-choice:hover {
    border-color: var(--blue);
    color: var(--text-primary);
    transform: translateY(-1px);
}
.care-line-icon-choice.active {
    border-color: var(--blue);
    background: var(--blue-glow);
    color: var(--blue);
}
.care-line-icon-choice .material-icons-round { font-size: 18px; display: block; line-height: 1; }
.care-line-icon-choice small { font-size: 0.56rem; line-height: 1; }
.care-line-icon-badge { display: inline-flex; align-items: center; gap: 4px; }
.care-line-icon-badge .material-icons-round { font-size: 15px; }

.care-line-form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.care-lines-helper {
    display: grid;
    gap: 12px;
}

.care-lines-helper p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Care line cards (listagem) */
.care-line-card {
    transition: var(--transition);
}

.care-line-card:hover {
    background: rgba(255,255,255,0.08) !important;
}

.care-line-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.care-line-card-title {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.care-line-card-title .material-icons-round {
    font-size: 20px;
    vertical-align: middle;
}

.care-line-card-desc {
    margin: 4px 0 0 0;
    opacity: 0.7;
    font-size: 0.9rem;
}

.care-line-card-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

@keyframes careLineFocusPulse {
    0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--blue) 36%, transparent); }
    55% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--blue) 0%, transparent); }
    100% { box-shadow: none; }
}
.care-line-focus-pulse {
    animation: careLineFocusPulse 1.2s ease-out;
    border-color: color-mix(in srgb, var(--blue) 55%, var(--border-color)) !important;
}

.care-line-metrics {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.protocol-builder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    align-items: end;
}

.protocol-flags {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.protocol-builder-actions {
    display: flex;
    align-items: end;
    padding-bottom: 10px;
}

.protocol-manager-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 20px 0 12px;
}

/* Dashboard stat cards com borda colorida na esquerda */
.care-line-stat-card {
    border-left-width: 4px;
    border-left-style: solid;
}

.care-line-stat-card .stat-label {
    display: flex;
    align-items: center;
    gap: 4px;
}

.care-line-stat-card .stat-label .material-icons-round {
    font-size: 18px;
    vertical-align: middle;
}

.care-line-error,
.care-line-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
}

.care-line-empty .stat-value,
.care-line-error .stat-value {
    font-size: 1rem;
}

/* Indicador ativo/inativo (bolinha) */
.status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    vertical-align: middle;
}

.status-dot-active {
    background: var(--green);
    box-shadow: 0 0 6px rgba(52, 211, 153, 0.4);
}

.status-dot-inactive {
    background: rgba(80, 90, 120, 0.4);
}

/* Checkbox toggle para linhas de cuidado no modal do paciente */
.care-line-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    user-select: none;
    font-size: 0.82rem;
    color: var(--text-secondary);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.care-line-checkbox-label:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-hover);
}

.care-line-checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.care-line-checkbox-label input[type="checkbox"]:checked + .care-line-checkbox-pill {
    background: rgba(78, 140, 255, 0.14);
    border-color: rgba(78, 140, 255, 0.28);
    color: var(--blue);
}

.care-line-checkbox-label .material-icons-round {
    font-size: 16px;
}

.care-line-checkbox-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    border-radius: 10px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.detail-care-lines {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.detail-care-lines:empty {
    display: none;
}

.detail-care-lines-card {
    margin-bottom: 16px;
}

.detail-care-lines-editor {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.detail-care-lines-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

/* Modal adjustments for protocol modal */
#modal-protocol .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

#modal-protocol .modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

#modal-protocol .modal-header h3 .material-icons-round {
    font-size: 24px;
    vertical-align: middle;
}

#modal-protocol .modal-body h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
}

#modal-protocol .modal-body h4 .material-icons-round {
    color: var(--blue);
}

@media (max-width: 900px) {
    .care-lines-grid {
        grid-template-columns: 1fr;
    }

    .care-line-form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   PRONTUÁRIO V3 - Notebook de Consulta (3 colunas)
   Estilos adicionais; não alteram componentes existentes.
   ============================================================ */
.prontuario-section { display: none; }

.pront-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 12px;
    padding: 14px 18px; margin-bottom: 14px;
    border-radius: var(--radius-lg);
}
.pront-header-main { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 260px; }
.pront-header-id h2 { font-size: 1.25rem; margin: 0 0 4px; }
.pront-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.pront-tag { font-size: 0.72rem; padding: 2px 9px; border-radius: 20px; font-weight: 600; }
.pront-meta { font-size: 0.8rem; color: var(--text-muted); }
.pront-age { color: #fff; font-weight: 800; }
.pront-hint { font-size: 0.8rem; color: var(--text-muted); font-style: italic; }
.pront-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pront-care-wrap { position: relative; display: inline-flex; margin-bottom: 4px; }
.pront-care-trigger { appearance: none; -webkit-appearance: none; border: 1px solid transparent; background: transparent;
    color: inherit; padding: 2px 6px 2px 0; border-radius: 18px; display: flex; align-items: center; gap: 6px;
    cursor: pointer; font-family: inherit; text-align: left; }
.pront-care-trigger:hover { background: var(--bg-input); border-color: var(--border-color); }
.pront-care-trigger .material-icons-round { font-size: 15px; color: var(--text-muted); }
.pront-care-trigger:hover .material-icons-round { color: var(--blue); }
.pront-care-popover { display: none; position: absolute; z-index: 50; top: calc(100% + 8px); left: 0;
    width: min(320px, 86vw); background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 10px; }
.pront-care-popover.open { display: block; }
.pront-care-popover-head strong { display: block; color: var(--text-primary); font-size: 0.84rem; }
.pront-care-popover-head small, .pront-care-popover-loading { color: var(--text-muted); font-size: 0.74rem; }
.pront-care-popover-list { display: flex; flex-direction: column; gap: 7px; margin-top: 9px; }
.pront-care-option { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.82rem;
    color: var(--text-primary); padding: 7px 8px; border-radius: var(--radius-sm); background: var(--bg-input); }
.pront-care-option:hover { box-shadow: inset 0 0 0 1px var(--border-color); }
.pront-care-option input { width: auto; }
.pront-care-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }

.pront-grid {
    display: grid;
    grid-template-columns: 0.8fr 1.6fr 1fr;
    gap: 14px;
    align-items: start;
}
.pront-col { display: flex; flex-direction: column; gap: 14px; }

.pront-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
}
.pront-card-head {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 0.95rem; margin-bottom: 12px;
    color: var(--text-primary);
}
.pront-card-head .material-icons-round { font-size: 20px; color: var(--blue); }
.pront-card-subhead { font-size: 0.78rem; text-transform: uppercase; letter-spacing: .5px;
    color: var(--text-muted); margin: 14px 0 8px; font-weight: 600; }
.pront-patient-title { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.pront-patient-title:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 4px; }
.pront-patient-title::after {
    content: 'edit';
    font-family: 'Material Icons Round';
    font-size: 18px;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity .15s ease, color .15s ease;
}
.pront-patient-title:hover::after { opacity: 1; color: var(--blue); }

/* Sinais vitais */
.pront-vitals-head { justify-content: space-between; align-items: center; gap: 8px; }
.pront-vitals-head > span { display: flex; align-items: center; gap: 8px; }
.pront-vitals-actions { display: flex; align-items: center; gap: 6px; }
.pront-vitals-actions .btn { padding: 4px 9px; }
.pront-vitals-layout { display: flex; flex-direction: column; gap: 8px; }
.pront-vitals-row { display: grid; gap: 8px; }
.pront-vitals-row.row-3col { grid-template-columns: 1fr 1fr 1fr; }
.pront-vitals-row.row-2col { grid-template-columns: 1fr 1fr; }
.pront-vitals-layout label { display: flex; flex-direction: column; font-size: 0.72rem; color: #fff; font-weight: 700; gap: 3px; }
.pront-vitals-layout input {
    background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary); padding: 6px 8px; font-size: 0.85rem;
}
.pront-vitals-layout input:focus { border-color: var(--blue); outline: none; }
.pront-bmi { grid-column: 1 / -1; font-size: 0.85rem; color: var(--text-secondary); padding-top: 4px; }
.pront-vitals-history { margin-top: 12px; border-top: 1px solid var(--border-color); padding-top: 4px; }
.pront-vitals-history-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 7px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 0.78rem;
}
.pront-vitals-history-row strong { color: var(--text-primary); }
.pront-vitals-history-row span { color: var(--text-secondary); line-height: 1.35; }

/* Exames */
.pront-exam-list { display: flex; flex-direction: column; gap: 8px; }
.pront-exam-row {
    display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
    align-items: center; padding: 8px; border-radius: var(--radius-sm);
    background: var(--bg-input); cursor: pointer; transition: var(--transition);
    border: 1px solid transparent;
}
.pront-exam-row:hover { border-color: var(--blue); }

/* Formulário de registro de exame no prontuário */
.pront-exam-form { border-top: 1px dashed var(--border-color); margin-top: 8px; }
.pront-exam-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pront-exam-form-grid label { display: flex; flex-direction: column; font-size: 0.72rem; color: var(--text-muted); gap: 3px; }
.pront-exam-form-grid label.pront-exam-form-obs { grid-column: 1 / -1; }
.pront-exam-form-grid input, .pront-exam-form-grid select {
    background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary); padding: 6px 8px; font-size: 0.85rem;
}
.pront-exam-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.pront-exam-name { font-weight: 600; font-size: 0.85rem; }
.pront-exam-val { font-size: 0.85rem; text-align: right; }
.pront-exam-date { font-size: 0.72rem; color: var(--text-muted); }
.pront-trend { font-size: 0.72rem; color: var(--orange); margin-left: 4px; }
.pront-badge { font-size: 0.68rem; padding: 2px 8px; border-radius: 20px; font-weight: 700; justify-self: end; }
.pront-exam-recent { display: flex; flex-direction: column; gap: 4px; }
.pront-exam-mini { display: flex; justify-content: space-between; gap: 6px; font-size: 0.78rem;
    padding: 4px 6px; border-bottom: 1px dashed var(--border-color); }
.pront-exam-mini em { color: var(--text-muted); font-style: normal; }

/* SOAP */
.pront-col-center { display: flex; flex-direction: column; gap: 14px; }
.pront-soap-card { background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 16px; }
.pront-soap-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.pront-soap-title { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.pront-soap-title .material-icons-round { color: var(--blue); }
.pront-date-input { background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary); padding: 6px 8px; }
.pront-state-badge { font-size: 0.66rem; padding: 2px 8px; border-radius: 20px; font-weight: 700; text-transform: uppercase; }
.pront-state-badge.draft { background: var(--orange-glow); color: var(--orange); }
.pront-state-badge.done { background: var(--green-glow); color: var(--green); }
.pront-state-badge.cancel { background: var(--red-glow); color: var(--red); }
.pront-save-ind { font-size: 0.72rem; color: var(--text-muted); }
.pront-save-ind.saved { color: var(--green); }
.pront-save-ind.editing { color: var(--orange); }
.pront-save-ind.error { color: var(--red); }

.pront-templates { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.pront-tpl-label { font-size: 0.75rem; color: var(--text-muted); }
.pront-tpl-empty { font-size: 0.75rem; color: var(--text-muted); font-style: italic; }
.pront-tpl-btn { background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: 20px; color: var(--text-secondary); padding: 3px 12px; font-size: 0.75rem; cursor: pointer; }
.pront-tpl-btn:hover { border-color: var(--blue); color: var(--blue); }
.pront-tpl-editor { margin: -2px 0 14px; padding: 12px; background: var(--bg-input);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.pront-tpl-edit-row { padding: 10px; border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); background: rgba(255,255,255,0.025); }
.pront-tpl-edit-row + .pront-tpl-edit-row { margin-top: 10px; }
.pront-tpl-edit-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pront-tpl-edit-head input { flex: 1; min-width: 0; }
.pront-tpl-edit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.pront-tpl-edit-grid label { display: flex; flex-direction: column; gap: 4px;
    color: var(--text-secondary); font-size: 0.72rem; font-weight: 700; }
.pront-tpl-edit-grid textarea { min-height: 78px; resize: vertical; line-height: 1.45; }
.pront-tpl-editor-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.pront-soap-fields { display: flex; flex-direction: column; gap: 12px; }
.pront-soap-fields label { display: flex; flex-direction: column; font-size: 0.8rem; font-weight: 600; gap: 5px; color: var(--text-secondary); }
.pront-soap-fields input, .pront-soap-fields textarea {
    background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary); padding: 9px 10px;
    font-size: 0.9rem; font-family: inherit; resize: vertical; line-height: 1.5;
}
.pront-soap-fields input:focus, .pront-soap-fields textarea:focus { border-color: var(--blue); outline: none; }
.soap-tag { display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 6px; font-size: 0.72rem; font-weight: 800; margin-right: 6px; }
.soap-tag.s { background: var(--blue-glow); color: var(--blue); }
.soap-tag.o { background: var(--purple-glow); color: var(--purple); }
.soap-tag.a { background: var(--orange-glow); color: var(--orange); }
.soap-tag.p { background: var(--green-glow); color: var(--green); }
.soap-tag.n { background: rgba(120,130,160,0.2); color: var(--text-secondary); }

.ai-insights-card { margin-top: 12px; }
.ai-insights-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.ai-insights-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.ai-insights-title > .material-icons-round { color: var(--purple); }
.ai-insights-title strong { display: block; font-size: 0.95rem; }
.ai-insights-title small { display: block; color: var(--text-muted); font-size: 0.72rem; margin-top: 1px; }
.ai-insights-badge { font-size: 0.66rem; padding: 2px 7px; border-radius: 20px; color: var(--text-secondary);
    background: var(--bg-input); border: 1px solid var(--border-color); }
.ai-insights-badge.stale { color: var(--orange); background: var(--orange-glow); border-color: transparent; }
.ai-insights-actions { display: flex; gap: 6px; align-items: center; }
.ai-insights-summary { color: var(--text-primary); font-size: 0.88rem; line-height: 1.5; padding: 9px 10px;
    background: var(--bg-input); border-radius: var(--radius-sm); margin-bottom: 10px; white-space: pre-wrap; }
.ai-insights-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ai-insights-grid h4 { margin: 0 0 5px; font-size: 0.74rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }
.ai-insights-grid ul, .ai-insights-details ul { margin: 0; padding-left: 18px; color: var(--text-secondary); font-size: 0.82rem; line-height: 1.45; }
.ai-insights-grid li + li, .ai-insights-details li + li { margin-top: 3px; }
.ai-insights-empty, .ai-insights-empty-block, .ai-insights-warning, .ai-insights-loading { color: var(--text-muted); font-size: 0.84rem; }
.ai-insights-empty-block, .ai-insights-warning, .ai-insights-loading { padding: 10px; background: var(--bg-input); border-radius: var(--radius-sm); }
.ai-insights-warning p { margin: 0; }
.ai-insights-warning p + p { margin-top: 4px; }
.ai-insights-loading { display: flex; align-items: center; gap: 8px; }
.ai-insights-details { margin-top: 10px; color: var(--text-secondary); font-size: 0.82rem; }
.ai-insights-details summary { cursor: pointer; margin-bottom: 6px; }
.ai-insights-foot { margin: 10px 0 0; color: var(--text-muted); font-size: 0.72rem; }

/* Condições e Medicamentos */
.pront-item-list { display: flex; flex-direction: column; gap: 8px; }
.pront-item { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
    padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-input); }
.pront-item.is-off { opacity: 0.5; }
.pront-item-main { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.pront-item-main strong { font-size: 0.88rem; }
.pront-sub { font-size: 0.74rem; color: var(--text-muted); }
.pront-med-notes { white-space: pre-wrap; line-height: 1.45; color: var(--text-secondary); }
.pront-item-actions { display: flex; align-items: center; gap: 2px; }
.pront-item-actions select { background: var(--bg-secondary); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 0.72rem; padding: 2px 4px; }
.pront-add-row, .pront-add-med { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pront-add-row input, .pront-add-med input, .pront-add-med textarea {
    flex: 1; min-width: 80px; background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary); padding: 7px 9px; font-size: 0.82rem;
    font-family: inherit; line-height: 1.45; }
.pront-add-med input { min-width: 100%; }
.pront-add-med input#med-name { min-width: 100%; }
.pront-add-med textarea { min-width: 100%; resize: vertical; }
.pront-med-edit {
    grid-template-columns: 1fr;
    gap: 6px;
    margin-top: 8px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--bg-card) 72%, transparent);
}
.pront-med-edit input, .pront-med-edit select, .pront-med-edit textarea {
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 7px 9px;
    font-family: inherit;
    font-size: 0.82rem;
}
.pront-med-edit textarea { min-height: 74px; resize: vertical; line-height: 1.45; }
.pront-med-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

/* Feed de consultas anteriores (rolagem infinita, abaixo da consulta nova) */
.pront-feed-section { margin-top: 14px; }
.pront-feed { max-height: 620px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding-right: 4px; }
.pront-feed::-webkit-scrollbar { width: 8px; }
.pront-feed::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 8px; }
.pront-feed-item { background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); padding: 12px 14px; }
.pront-feed-item.is-cancel { opacity: 0.55; }
.pront-feed-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color); padding-bottom: 8px; }
.pront-feed-date { font-weight: 700; font-size: 0.85rem; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pront-feed-cc { font-weight: 500; font-size: 0.78rem; color: var(--text-muted); }
.pront-feed-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.pront-feed-actions .btn { padding: 3px 9px; font-size: 0.7rem; }

/* Layout interno em 3 colunas: sinais/exames | SOAP | medicamentos/condições */
.pront-feed-body { display: grid; grid-template-columns: 0.9fr 1.5fr 0.9fr; gap: 16px; align-items: start; }
.pront-feed-side { display: flex; flex-direction: column; gap: 10px; }
.pront-feed-side.left { border-right: 1px solid var(--border-color); padding-right: 14px; }
.pront-feed-side.right { border-left: 1px solid var(--border-color); padding-left: 14px; }
.pront-feed-center { display: flex; flex-direction: column; gap: 7px; }

.fs-row { font-size: 0.82rem; line-height: 1.45; }
.fs-row p { margin: 2px 0 0; white-space: pre-wrap; color: var(--text-secondary); }
.fs-tag { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
    border-radius: 5px; font-size: 0.68rem; font-weight: 800; margin-right: 6px; }
.fs-tag.s { background: var(--blue-glow); color: var(--blue); }
.fs-tag.o { background: var(--purple-glow); color: var(--purple); }
.fs-tag.a { background: var(--orange-glow); color: var(--orange); }
.fs-tag.p { background: var(--green-glow); color: var(--green); }
.fs-tag.d { width: auto; padding: 0 5px; background: var(--blue-glow); color: var(--blue); }
.pfb-doc-list { margin: 4px 0 0 24px; padding: 0; color: var(--text-secondary); }
.pfb-doc-list em { color: var(--text-muted); font-style: normal; font-size: 0.74rem; }

.pront-feed-block { font-size: 0.78rem; }
.pront-feed-block .pfb-title { font-weight: 700; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.pront-feed-block .pfb-title .material-icons-round { color: var(--blue); }
.pront-feed-block ul { margin: 0; padding-left: 18px; color: var(--text-secondary); }
.pront-feed-block li { margin-bottom: 2px; }
.pront-feed-block li em { font-style: normal; color: var(--text-muted); font-size: 0.72rem; }
.pfb-vitals { color: var(--text-secondary); line-height: 1.5; }
.pront-feed-empty { font-size: 0.8rem; color: var(--text-muted); font-style: italic; }
.pront-feed-loading { text-align: center; font-size: 0.75rem; color: var(--text-muted); padding: 8px; }
.pront-feed-sentinel { height: 1px; }

@media (max-width: 900px) {
    .pront-feed-body { grid-template-columns: 1fr; gap: 10px; }
    .pront-feed-side.left, .pront-feed-side.right { border: 0; padding: 0; }
    .pront-feed-side.left { border-bottom: 1px dashed var(--border-color); padding-bottom: 10px; }
    .pront-feed-side.right { border-top: 1px dashed var(--border-color); padding-top: 10px; }
}

/* Botão prontuário na tabela */
.btn-icon-inline.prontuario { color: var(--blue); }

/* Modais V3 */
.cp-options { display: flex; flex-direction: column; gap: 10px; }
.cp-options label { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; cursor: pointer; }
.pront-export-text { width: 100%; background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary); padding: 12px; font-family: monospace;
    font-size: 0.82rem; line-height: 1.5; resize: vertical; }
.pp-row { margin-bottom: 10px; }
.pp-row span { font-size: 0.72rem; font-weight: 700; color: var(--blue); text-transform: uppercase; }
.pp-row p { margin: 2px 0 0; font-size: 0.86rem; white-space: pre-wrap; }
.pp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.pp-vitals { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 12px; padding: 6px 8px;
    background: var(--bg-input); border-radius: var(--radius-sm); }
.pp-actions { margin-top: 14px; border-top: 1px solid var(--border-color); padding-top: 12px; }

@media (max-width: 1100px) {
    .pront-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    body.prontuario-active .top-prontuario-quick {
        display: none;
    }

    #section-prontuario {
        padding: 10px;
        padding-bottom: calc(22px + env(safe-area-inset-bottom));
    }

    .pront-header {
        align-items: stretch;
        gap: 10px;
        padding: 10px;
        margin-bottom: 10px;
        border-radius: var(--radius-md);
    }

    .pront-header-main {
        width: 100%;
        min-width: 0;
        align-items: flex-start;
        gap: 8px;
    }

    .pront-header-main > .btn {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 8px 10px;
    }

    .pront-header-id {
        min-width: 0;
        flex: 1;
    }

    .pront-header-id h2 {
        font-size: 1rem;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .pront-patient-title {
        display: inline;
    }

    .pront-patient-title::after {
        display: none;
    }

    .pront-care-wrap,
    .pront-care-trigger {
        width: 100%;
        max-width: 100%;
    }

    .pront-care-trigger {
        flex-wrap: wrap;
        padding: 4px 6px 4px 0;
    }

    .pront-care-popover {
        left: auto;
        right: 0;
        width: min(320px, calc(100vw - 28px));
    }

    .pront-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 8px;
        font-size: 0.74rem;
        line-height: 1.35;
    }

    .pront-header-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }

    .pront-header-actions .btn {
        width: 100%;
        min-height: 34px;
        justify-content: center;
        padding: 5px 7px;
        font-size: 0.72rem;
        line-height: 1.15;
        white-space: normal;
        gap: 4px;
        border-radius: 8px;
    }

    .pront-header-actions .btn .material-icons-round {
        font-size: 16px;
    }

    .pront-grid {
        gap: 10px;
    }

    .pront-col {
        gap: 10px;
        min-width: 0;
    }

    .pront-col-center {
        order: -1;
    }

    .pront-card,
    .pront-soap-card {
        padding: 11px;
        border-radius: var(--radius-sm);
    }

    .pront-card-head {
        margin-bottom: 9px;
        font-size: 0.9rem;
    }

    .pront-soap-head {
        align-items: stretch;
        gap: 8px;
    }

    .pront-soap-title {
        width: 100%;
        min-width: 0;
        flex-wrap: wrap;
    }

    .pront-soap-head > div:last-child {
        width: 100%;
        display: grid !important;
        grid-template-columns: 1fr;
        gap: 8px !important;
        align-items: stretch !important;
    }

    .pront-soap-head > div:last-child > .btn,
    .pront-soap-head > div:last-child > .pront-date-input,
    .pront-mode-toggle {
        width: 100%;
    }

    .pront-mode-toggle {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .pront-mode-toggle button {
        padding: 8px 6px;
        white-space: normal;
    }

    .pront-date-input {
        min-height: 40px;
    }

    .pront-templates {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
        margin-bottom: 10px;
    }

    .pront-tpl-label,
    .pront-tpl-empty {
        flex: 0 0 auto;
    }

    .pront-tpl-btn {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .pront-soap-fields {
        gap: 10px;
    }

    .pront-soap-fields input,
    .pront-soap-fields textarea,
    .pront-free-text {
        font-size: 16px;
        padding: 10px;
    }

    .pront-soap-fields textarea,
    .pront-free-text {
        background: color-mix(in srgb, var(--bg-input) 72%, var(--blue) 8%);
        border: 1px solid color-mix(in srgb, var(--blue) 42%, var(--border-color));
        box-shadow: inset 0 0 0 1px rgba(78, 140, 255, 0.08), 0 0 0 3px rgba(78, 140, 255, 0.07);
    }

    .pront-soap-fields textarea:focus,
    .pront-free-text:focus {
        border-color: var(--blue);
        box-shadow: 0 0 0 3px var(--blue-glow);
    }

    .pront-soap-box {
        position: relative;
    }

    .pront-soap-box::after,
    .pront-free-wrap::before {
        content: 'toque para digitar';
        position: absolute;
        right: 10px;
        top: 7px;
        color: var(--blue);
        font-size: 0.62rem;
        font-weight: 700;
        letter-spacing: .2px;
        pointer-events: none;
        opacity: .78;
    }

    .pront-free-wrap::before {
        top: 10px;
        right: 12px;
        z-index: 1;
    }

    .pront-soap-fields textarea {
        min-height: 116px;
    }

    .pront-soap-fields #soap-notes {
        min-height: 84px;
    }

    .pront-free-text {
        min-height: min(46vh, 360px);
        padding-bottom: 104px;
    }

    .pront-magic-bar {
        align-items: stretch;
    }

    .pront-magic-bar .btn {
        width: 100%;
        min-height: 42px;
        justify-content: center;
    }

    .pront-magic-bar .pront-hint {
        line-height: 1.35;
    }

    .homecare-draft-head {
        flex-direction: column;
        align-items: stretch;
    }

    .homecare-draft-actions {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .homecare-draft-head .btn {
        width: 100%;
        justify-content: center;
        min-height: 40px;
    }

    .homecare-clarifications {
        font-size: 16px;
        min-height: 130px;
    }

    body.prontuario-homecare .pront-header {
        padding: 8px 10px;
        margin-bottom: 8px;
    }

    body.prontuario-homecare .pront-header-main {
        align-items: center;
    }

    body.prontuario-homecare .pront-header-main > .btn {
        width: auto;
        min-height: 34px;
        padding: 6px 9px;
    }

    body.prontuario-homecare .pront-header-id h2 {
        font-size: 0.95rem;
        margin-bottom: 2px;
    }

    body.prontuario-homecare .pront-meta,
    body.prontuario-homecare .pront-care-trigger .material-icons-round {
        display: none;
    }

    body.prontuario-homecare .pront-care-trigger {
        padding: 0;
    }

    body.prontuario-homecare .pront-tag {
        font-size: 0.64rem;
        padding: 1px 7px;
    }

    body.prontuario-homecare .pront-header-actions {
        display: flex;
        justify-content: flex-end;
    }

    body.prontuario-homecare .pront-header-actions .btn {
        display: none;
    }

    body.prontuario-homecare .pront-header-actions .btn:last-child {
        display: inline-flex;
        width: auto;
        min-height: 34px;
        padding: 6px 12px;
    }

    body.prontuario-homecare .pront-soap-card {
        padding: 9px;
        border-radius: 10px;
    }

    body.prontuario-homecare .pront-soap-head {
        margin-bottom: 7px;
    }

    body.prontuario-homecare .pront-soap-title {
        font-size: 0.86rem;
    }

    body.prontuario-homecare .pront-soap-title .material-icons-round,
    body.prontuario-homecare .pront-soap-head .btn,
    body.prontuario-homecare .pront-mode-toggle,
    body.prontuario-homecare .pront-templates,
    body.prontuario-homecare .ai-insights-card {
        display: none;
    }

    body.prontuario-homecare .pront-soap-head > div:last-child {
        display: flex !important;
        justify-content: flex-end;
    }

    body.prontuario-homecare .pront-date-input {
        width: auto;
        min-height: 34px;
        padding: 5px 8px;
        font-size: 0.8rem;
    }

    body.prontuario-homecare .homecare-quick-free {
        gap: 8px;
    }

    body.prontuario-homecare .homecare-quick-card .pront-free-text {
        min-height: min(58vh, 470px);
        font-size: 16px;
        line-height: 1.55;
        padding: 12px 54px 92px 12px;
    }

    body.prontuario-homecare .homecare-quick-actions {
        display: grid;
        grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr);
        gap: 6px;
    }

    body.prontuario-homecare .homecare-quick-actions .btn {
        width: 100%;
        min-width: 0;
        min-height: 40px;
        justify-content: center;
        gap: 4px;
        padding: 7px 6px;
        font-size: 0.72rem;
        overflow: hidden;
    }

    body.prontuario-homecare .homecare-quick-actions .btn .material-icons-round {
        font-size: 17px;
    }

    body.prontuario-homecare .homecare-quick-actions #btn-magic-soap,
    body.prontuario-homecare .homecare-quick-actions #btn-tts-evolution,
    body.prontuario-homecare .homecare-quick-actions .btn-tts-stop,
    body.prontuario-homecare .homecare-quick-actions .pront-hint {
        display: none;
    }

    body.prontuario-homecare .pront-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    body.prontuario-homecare .pront-col {
        display: contents;
    }

    body.prontuario-homecare #pront-center { order: 1; }
    body.prontuario-homecare #pront-medications { order: 2; }
    body.prontuario-homecare #pront-documents { order: 3; }
    body.prontuario-homecare #pront-vitals { order: 4; }
    body.prontuario-homecare #pront-exams { order: 5; }
    body.prontuario-homecare #pront-conditions { order: 6; }
    body.prontuario-homecare #pront-labs { order: 7; }
    body.prontuario-homecare #pront-attachments { order: 8; }

    body.prontuario-homecare .homecare-collapsible.is-collapsed .homecare-collapse-body,
    body.prontuario-homecare .homecare-doc-emitted-collapsed,
    body.prontuario-homecare .ambient-transcript-panel:not(.open) .ambient-transcript-closed {
        display: none;
    }

    body.prontuario-homecare .homecare-collapsible.is-collapsed .pront-card-head {
        margin-bottom: 0;
    }

    body.prontuario-homecare .homecare-collapsible.is-collapsed .pront-card-head .btn {
        display: none;
    }

    body.prontuario-homecare .homecare-collapse-toggle {
        width: 32px;
        height: 32px;
        flex: 0 0 auto;
    }

    body.prontuario-homecare .homecare-doc-emitted-head {
        display: flex;
        align-items: center;
        gap: 6px;
        cursor: pointer;
        margin-bottom: 0;
    }

    body.prontuario-homecare .homecare-doc-emitted-head .material-icons-round {
        font-size: 18px;
        color: var(--blue);
    }

    body.prontuario-homecare .ambient-transcript-panel:not(.open) {
        padding: 8px 10px;
    }

    .pront-vitals-row.row-3col,
    .pront-vitals-row.row-2col,
    .pront-exam-form-grid,
    .doc-tpl-grid,
    .ai-insights-grid {
        grid-template-columns: 1fr;
    }

    .pront-vitals-layout input,
    .pront-exam-form-grid input,
    .pront-exam-form-grid select,
    .pront-add-row input,
    .pront-add-med input,
    .pront-item-actions select {
        min-height: 40px;
        font-size: 16px;
    }

    .pront-item {
        flex-direction: column;
        gap: 8px;
    }

    .pront-item-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .pront-item-actions select {
        flex: 1;
        min-width: 150px;
    }

    .pront-add-row,
    .pront-add-med,
    .pront-med-edit-actions,
    .pront-exam-form-actions {
        align-items: stretch;
    }

    .pront-add-row .btn,
    .pront-add-med .btn,
    .pront-med-edit-actions .btn,
    .pront-exam-form-actions .btn {
        min-height: 40px;
        justify-content: center;
    }

    .lab-table-wrap {
        max-height: none;
        margin-left: -4px;
        margin-right: -4px;
    }

    .lab-table th,
    .lab-table td {
        padding: 6px 7px;
    }

    .pront-feed-section {
        margin-top: 10px;
    }

    .pront-feed {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .pront-feed-item {
        padding: 11px;
        border-radius: var(--radius-sm);
    }

    .pront-feed-actions {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .pront-feed-actions .btn {
        width: 100%;
        justify-content: center;
        min-height: 36px;
    }

    .ai-insights-head,
    .ai-insights-actions {
        width: 100%;
    }

    .ai-insights-actions {
        justify-content: stretch;
    }

    .ai-insights-actions .btn {
        flex: 1;
        justify-content: center;
        min-height: 38px;
    }

    .pront-export-text {
        font-size: 16px;
    }
}

@media (max-width: 420px) {
    .pront-header-actions,
    .pront-feed-actions {
        grid-template-columns: 1fr;
    }

    .pront-header-main {
        flex-wrap: wrap;
    }

    .pront-header-main > .btn {
        width: 100%;
        justify-content: center;
    }

    .pront-soap-title .material-icons-round {
        display: none;
    }
}

/* ============================================================
   Acesso rápido ao Prontuário (sidebar)
   ============================================================ */
.sidebar-quick { padding: 10px 12px 4px; position: relative; }
.sidebar-quick-box {
    display: flex; align-items: center; gap: 6px;
    background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); padding: 7px 10px;
}
.sidebar-quick-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-glow); }
.sidebar-quick-box .material-icons-round { font-size: 18px; color: var(--blue); }
.sidebar-quick-box input {
    flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
    color: var(--text-primary); font-size: 0.82rem; font-family: inherit;
}
.sidebar-quick-box input::placeholder { color: var(--text-muted); }

.sidebar-quick-results { display: none; margin-top: 6px; background: var(--bg-card);
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    overflow: hidden; box-shadow: var(--shadow-md); max-height: 320px; overflow-y: auto; }
.sidebar-quick-results.open { display: block; }
.sq-item { display: flex; align-items: center; gap: 8px; padding: 9px 11px; cursor: pointer; font-size: 0.82rem; }
.sq-item .material-icons-round { font-size: 17px; color: var(--text-muted); }
.sq-item:hover, .sq-item.active { background: var(--blue-glow); }
.sq-item.active .material-icons-round { color: var(--blue); }
.sq-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sq-empty { padding: 10px 12px; font-size: 0.8rem; color: var(--text-muted); font-style: italic; }

/* ============================================================
   Magic SOAP / modo de registro
   ============================================================ */
.pront-mode-toggle { display: inline-flex; background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; }
.pront-mode-toggle button { appearance: none; -webkit-appearance: none; background: transparent; border: 0;
    color: var(--text-secondary); padding: 6px 14px; font-size: 0.75rem; font-weight: 600; cursor: pointer;
    font-family: inherit; line-height: 1.4; white-space: nowrap; transition: var(--transition); }
.pront-mode-toggle button + button { border-left: 1px solid var(--border-color); }
.pront-mode-toggle button:hover { color: var(--text-primary); }
.pront-mode-toggle button.active { background: var(--blue); color: #fff; }
.pront-soap-head .pront-soap-title { flex: 1 1 auto; min-width: 0; }

.pront-soap-free { display: flex; flex-direction: column; gap: 10px; }
.pront-magic-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn-magic { background: linear-gradient(135deg, #a78bfa 0%, #6366f1 100%); color: #fff;
    box-shadow: 0 4px 16px rgba(124, 99, 240, 0.3); }
.btn-magic:hover { transform: translateY(-1px); }
.btn-magic:disabled { opacity: 0.7; cursor: default; transform: none; }
.btn-homecare { background: linear-gradient(135deg, #10b981 0%, #0ea5e9 100%); color: #fff;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.24); }
.btn-homecare:hover { transform: translateY(-1px); }
.btn-homecare:disabled { opacity: 0.7; cursor: default; transform: none; }
.btn-tts { background: rgba(14, 165, 233, 0.12); color: var(--blue); border: 1px solid rgba(14, 165, 233, 0.28); }
.btn-tts:hover { background: rgba(14, 165, 233, 0.18); }
.btn-tts.tts-playing { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-tts-stop { background: rgba(248, 113, 113, 0.1); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.26); }
.btn-no-publish { color: #f59e0b; border-color: rgba(245, 158, 11, 0.32); background: rgba(245, 158, 11, 0.08); }
.btn-publish-on { color: var(--green); border-color: rgba(16, 185, 129, 0.32); background: rgba(16, 185, 129, 0.08); }
.pront-pub-badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 7px;
    background: rgba(245, 158, 11, 0.14); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.34);
    font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .02em; }
.btn-homecare-final { background: var(--green); color: #fff; white-space: nowrap; }
.btn-homecare-final:disabled { opacity: 0.7; cursor: default; }
.homecare-draft-panel { border: 1px solid rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.08);
    border-radius: var(--radius-sm); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.homecare-draft-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.homecare-draft-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.homecare-draft-head strong { display: block; color: var(--text-primary); font-size: 0.9rem; }
.homecare-draft-head span { display: block; color: var(--text-secondary); font-size: 0.78rem; margin-top: 2px; }
.homecare-question-list { margin: 0; padding-left: 18px; color: var(--text-primary); font-size: 0.84rem; line-height: 1.45; }
.homecare-question-list li + li { margin-top: 4px; }
.homecare-question-empty { color: var(--text-secondary); font-size: 0.84rem; }
.homecare-clarify-wrap { position: relative; }
.homecare-clarifications { width: 100%; background: var(--bg-input); border: 1px solid rgba(14, 165, 233, 0.35);
    border-radius: var(--radius-sm); color: var(--text-primary); padding: 10px 54px 10px 12px; font-size: 0.9rem;
    font-family: inherit; line-height: 1.55; resize: vertical; }
.homecare-clarifications:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.12); }
.pront-free-text { width: 100%; background: var(--bg-input); border: 1px solid var(--border-color);
    border-radius: var(--radius-sm); color: var(--text-primary); padding: 12px; font-size: 0.92rem;
    font-family: inherit; line-height: 1.6; resize: vertical; }
.pront-free-text:focus { border-color: var(--blue); outline: none; }
.pront-ambient-btn { position: absolute; right: 10px; bottom: 58px; width: 38px; height: 38px;
    border-radius: 50%; border: 1px solid rgba(16, 185, 129, 0.35); background: var(--bg-card);
    color: var(--green); cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm); transition: var(--transition); }
.pront-ambient-btn:hover { border-color: var(--green); }
.pront-ambient-btn .material-icons-round { font-size: 20px; }
.pront-ambient-btn.recording { background: var(--green); color: #fff; border-color: var(--green); animation: ambient-pulse 1.2s infinite; }
@keyframes ambient-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.46); } 50% { box-shadow: 0 0 0 8px rgba(16,185,129,0); } }
.ambient-transcript-panel { border: 1px solid rgba(16,185,129,0.26); background: rgba(16,185,129,0.07);
    border-radius: var(--radius-sm); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.ambient-transcript-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.ambient-transcript-head strong { display: block; color: var(--text-primary); font-size: 0.84rem; }
.ambient-transcript-head span { display: block; color: var(--text-muted); font-size: 0.72rem; margin-top: 2px; }
.ambient-transcript-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.ambient-transcript-text { width: 100%; min-height: 110px; background: var(--bg-input); border: 1px solid rgba(16,185,129,0.35);
    border-radius: var(--radius-sm); color: var(--text-primary); padding: 9px 10px; font-size: 0.86rem;
    font-family: inherit; line-height: 1.5; resize: vertical; }
.ambient-transcript-text:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,0.1); }
.ambient-transcript-closed { color: var(--text-secondary); font-size: 0.78rem; line-height: 1.45;
    background: var(--bg-input); border: 1px dashed rgba(16,185,129,0.28); border-radius: var(--radius-sm); padding: 8px 10px; }
.spin { animation: pront-spin 0.9s linear infinite; }
@keyframes pront-spin { to { transform: rotate(360deg); } }

/* Radios de modo no painel de configurações */
.soap-mode-radio { display: flex; align-items: center; gap: 8px; padding: 10px 14px;
    background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    cursor: pointer; font-size: 0.88rem; }
.soap-mode-radio input { width: auto; }

/* ============================================================
   Locais de Atendimento
   ============================================================ */
.location-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 0.65rem; padding: 1px 7px; border-radius: 20px; font-weight: 600; vertical-align: middle; }
.location-badge .material-icons-round { font-size: 12px; }

.location-row { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 8px;
    background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); }
.location-row input[type="color"] { width: 38px; height: 34px; padding: 2px; border-radius: var(--radius-sm); flex-shrink: 0; cursor: pointer; }
.location-row .input-inline { flex: 1; min-width: 120px; }
.location-count { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

/* Opção de criar paciente na busca rápida do sidebar */
.sq-create { display: flex; align-items: center; gap: 8px; padding: 10px 11px; cursor: pointer;
    font-size: 0.8rem; color: var(--green); border-top: 1px solid var(--border-color); background: rgba(16,185,129,0.06); }
.sq-create:hover { background: rgba(16,185,129,0.14); }
.sq-create .material-icons-round { font-size: 17px; }

/* Autocomplete de local na criação rápida de paciente */
.qc-loc-wrap { position: relative; }
.qc-loc-results { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30;
    background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-md);
    box-shadow: var(--shadow-md); max-height: 240px; overflow-y: auto; }
.qc-loc-results.open { display: block; }
.qc-loc-item, .qc-loc-create { display: flex; align-items: center; gap: 8px; padding: 9px 11px; cursor: pointer; font-size: 0.85rem; }
.qc-loc-item .material-icons-round, .qc-loc-create .material-icons-round { font-size: 17px; }
.qc-loc-item:hover { background: var(--blue-glow); }
.qc-loc-create { color: var(--green); border-top: 1px solid var(--border-color); background: rgba(16,185,129,0.06); }
.qc-loc-create:hover { background: rgba(16,185,129,0.14); }

/* ============================================================
   Entrada rápida de exames (Fast Labs)
   ============================================================ */
.btn-fast { background: linear-gradient(135deg, #f59e0b 0%, #f97316 100%); color: #fff; box-shadow: 0 4px 14px rgba(245,158,11,0.28); }
.btn-fast:hover { transform: translateY(-1px); }

.fast-labs-preview { max-height: 320px; overflow-y: auto; }
.fast-labs-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.fast-labs-table th { text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); padding: 6px 8px; border-bottom: 1px solid var(--border-color); }
.fast-labs-table td { padding: 7px 8px; border-bottom: 1px solid var(--border-color); }
.fast-labs-table input[type="checkbox"] { width: auto; }
.lab-tag-ok { font-size: 0.66rem; padding: 1px 7px; border-radius: 20px; background: var(--green-glow); color: var(--green); font-weight: 700; }
.lab-tag-new { font-size: 0.66rem; padding: 1px 7px; border-radius: 20px; background: var(--orange-glow); color: var(--orange); font-weight: 700; margin-left: 4px; }

/* Lista de exames lançados na coluna esquerda */
.lab-groups { display: flex; flex-direction: column; gap: 10px; }
.lab-group-date { font-size: 0.72rem; font-weight: 700; color: var(--blue); margin-bottom: 4px; }
.lab-line { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
    padding: 5px 8px; border-radius: var(--radius-sm); background: var(--bg-input); margin-bottom: 4px; }
.lab-name { font-size: 0.82rem; font-weight: 600; }
.lab-val { font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap; }
.lab-del { opacity: 0.5; }
.lab-line:hover .lab-del { opacity: 1; }

/* Cores de status de exame (normal/alterado/incerto) */
.lab-normal { color: var(--green) !important; }
.lab-alterado { color: var(--red) !important; }
.lab-incerto { color: var(--orange) !important; }
.lab-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.lab-dot.lab-normal { background: var(--green); }
.lab-dot.lab-alterado { background: var(--red); }
.lab-dot.lab-incerto { background: var(--orange); }
.fast-labs-table td.lab-normal, .fast-labs-table td.lab-alterado, .fast-labs-table td.lab-incerto { font-weight: 700; }

/* ============================================================
   Documentos
   ============================================================ */
.doc-tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.doc-tpl-btn { display: flex; align-items: center; gap: 8px; padding: 9px 10px; cursor: pointer;
    background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    color: var(--text-secondary); font-size: 0.82rem; font-family: inherit; text-align: left; }
.doc-tpl-btn:hover { border-color: var(--blue); color: var(--blue); }
.doc-tpl-btn .material-icons-round { font-size: 18px; color: var(--blue); }
.doc-list { display: flex; flex-direction: column; gap: 6px; }
.doc-line { display: flex; align-items: center; justify-content: space-between; gap: 6px;
    background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 6px 8px; }
.doc-line-main { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.82rem; flex: 1; overflow: hidden; }
.doc-line-main .material-icons-round { font-size: 16px; color: var(--blue); }
.doc-line-main em { color: var(--text-muted); font-style: normal; font-size: 0.72rem; margin-left: auto; }
.doc-line-main:hover { color: var(--blue); }

/* Modal documento: editor + preview lado a lado */
.doc-editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.doc-preview-wrap { display: flex; flex-direction: column; }
.doc-preview-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 6px; }
.doc-preview { background: #fff; color: #111; border-radius: var(--radius-sm); padding: 22px; overflow-y: auto;
    max-height: 460px; box-shadow: var(--shadow-sm); }
.doc-vaccine-panel { margin-top: 12px; border: 1px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--bg-input); padding: 12px; }
.doc-vaccine-head { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; color: var(--text-primary); }
.doc-vaccine-head .material-icons-round { color: var(--blue); font-size: 22px; }
.doc-vaccine-head strong { display: block; font-size: 0.86rem; }
.doc-vaccine-head small { display: block; color: var(--text-muted); font-size: 0.72rem; margin-top: 2px; }
.doc-vaccine-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.doc-vaccine-check, .doc-vaccine-reason { display: flex; gap: 8px; align-items: flex-start; cursor: pointer;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-card); padding: 9px; }
.doc-vaccine-check input, .doc-vaccine-reason input { width: auto; margin-top: 2px; }
.doc-vaccine-check strong { display: block; font-size: 0.78rem; color: var(--text-primary); }
.doc-vaccine-check small { display: block; font-size: 0.68rem; line-height: 1.35; color: var(--text-muted); margin-top: 2px; }
.doc-vaccine-reason { margin-top: 9px; font-size: 0.78rem; color: var(--text-secondary); }
.med-controlled-badge { background: rgba(14,165,233,0.14) !important; color: var(--blue) !important; border: 1px solid rgba(14,165,233,0.28); }
.med-no-print-badge { background: rgba(148,163,184,0.14) !important; color: var(--text-muted) !important; border: 1px solid rgba(148,163,184,0.28); }
.btn-icon-inline.is-controlled { color: var(--blue); border-color: rgba(14,165,233,0.4); background: rgba(14,165,233,0.12); }
.btn-icon-inline.med-rx-single { color: var(--green); border-color: rgba(16,185,129,0.34); background: rgba(16,185,129,0.1); }
.btn-icon-inline.med-print-toggle.is-print-enabled { color: var(--blue); border-color: rgba(14,165,233,0.34); background: rgba(14,165,233,0.1); }
.btn-icon-inline.med-print-toggle.is-print-disabled { color: var(--text-muted); border-color: rgba(148,163,184,0.24); background: rgba(148,163,184,0.08); opacity: 0.78; }
.med-control-check { display: flex; align-items: center; gap: 7px; min-height: 36px; padding: 0 10px;
    border: 1px solid var(--border-color); border-radius: var(--radius-sm); background: var(--bg-card);
    color: var(--text-secondary); font-size: 0.78rem; }
.med-control-check input { width: auto; }
.doc-controlled-alert { border: 1px solid rgba(245,158,11,0.35); background: rgba(245,158,11,0.1);
    color: var(--text-secondary); border-radius: var(--radius-sm); padding: 9px 10px; font-size: 0.76rem;
    line-height: 1.45; margin-bottom: 10px; }
.doc-controlled-alert.is-danger { border-color: rgba(248,113,113,0.5); background: rgba(248,113,113,0.12); color: var(--red); font-weight: 700; }
.doc-controlled-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.doc-controlled-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 0.72rem;
    color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .35px; }
.doc-controlled-grid input { min-height: 36px; }
.doc-controlled-med-list { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.doc-controlled-med-list > strong { color: var(--text-primary); font-size: 0.82rem; }
.doc-controlled-med { display: grid; grid-template-columns: minmax(180px, 1.3fr) minmax(140px, .8fr) minmax(140px, .8fr);
    gap: 8px; align-items: stretch; }
.doc-controlled-med .doc-vaccine-check { margin: 0; }
.doc-controlled-med textarea { grid-column: 1 / -1; min-height: 52px; resize: vertical; }
@media (max-width: 820px) { .doc-editor-grid { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
    .doc-vaccine-grid, .doc-controlled-grid, .doc-controlled-med { grid-template-columns: 1fr; }
}

/* Botão "corrigir" na entrada rápida + referência do dicionário base */
.fast-fix-btn { appearance:none; -webkit-appearance:none; background:transparent; border:1px solid var(--border-color);
    border-radius:20px; color:var(--blue); font-size:0.66rem; padding:2px 9px; cursor:pointer; font-family:inherit; }
.fast-fix-btn:hover { background:var(--blue-glow); }
.med-builtin-ref { margin-top:10px; max-height:240px; overflow-y:auto; background:var(--bg-input);
    border:1px solid var(--border-color); border-radius:var(--radius-sm); padding:10px; font-size:0.78rem; }
.med-ref-row { padding:3px 0; border-bottom:1px dashed var(--border-color); color:var(--text-secondary); }
.med-ref-row strong { color:var(--text-primary); }

/* ============================================================
   Foco DM: seleção múltipla + badge
   ============================================================ */
.dm-select-bar { display: none; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-top: 12px; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); }
.dm-select-count { font-size: 0.85rem; font-weight: 600; color: var(--text-secondary); }
.dm-badge { display: inline-flex; align-items: center; gap: 2px; font-size: 0.62rem; font-weight: 800;
    padding: 1px 7px; border-radius: 20px; background: rgba(239,68,68,0.15); color: #f87171;
    border: 1px solid rgba(239,68,68,0.4); vertical-align: middle; }
.dm-badge .material-icons-round { font-size: 12px; }
.pt-select { display: inline-flex; align-items: center; margin-right: 6px; vertical-align: middle; }
.pt-select input { width: 16px; height: 16px; cursor: pointer; }
.pt-name-text { cursor: pointer; }
.pt-name-text:hover { color: var(--blue); }

/* Ditado (speech-to-text) no campo livre do Magic SOAP */
.pront-free-wrap { position: relative; }
.pront-free-wrap .pront-free-text { padding-right: 58px; padding-bottom: 104px; }
.pront-dictate-btn { position: absolute; right: 10px; bottom: 10px; width: 38px; height: 38px;
    border-radius: 50%; border: 1px solid var(--border-color); background: var(--bg-card);
    color: var(--blue); cursor: pointer; display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-sm); transition: var(--transition); }
.pront-dictate-btn:hover { border-color: var(--blue); }
.pront-dictate-btn .material-icons-round { font-size: 20px; }
.pront-dictate-btn.recording { background: var(--red); color: #fff; border-color: var(--red); animation: dictate-pulse 1.2s infinite; }
@keyframes dictate-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(248,113,113,0.5); } 50% { box-shadow: 0 0 0 8px rgba(248,113,113,0); } }

/* Texto bruto (auditoria) */
.raw-text-pre { white-space: pre-wrap; word-break: break-word; background: var(--bg-input);
    border: 1px solid var(--border-color); border-radius: var(--radius-sm); padding: 14px;
    font-family: inherit; font-size: 0.9rem; line-height: 1.6; color: var(--text-primary);
    max-height: 400px; overflow-y: auto; margin: 0; }

/* Mesclagem de pacientes */
.merge-primary { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; font-size: 0.88rem; }
.merge-primary label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.merge-id { color: var(--text-muted); font-size: 0.78rem; }
.merge-rows { display: flex; flex-direction: column; gap: 8px; }
.merge-row { display: grid; grid-template-columns: 160px 1fr; gap: 12px; align-items: start;
    padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg-input); border: 1px solid var(--border-color); }
.merge-row.conflict { border-color: var(--orange); }
.merge-label { font-weight: 600; font-size: 0.85rem; }
.merge-conflict-tag { font-size: 0.62rem; background: var(--orange-glow); color: var(--orange); padding: 1px 6px; border-radius: 20px; font-weight: 700; }
.merge-final { font-size: 0.88rem; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.merge-final .material-icons-round { font-size: 16px; color: var(--green); }
.merge-opts { display: flex; flex-direction: column; gap: 6px; }
.merge-opt { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; cursor: pointer; }
.merge-custom { background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    color: var(--text-primary); padding: 6px 8px; font-size: 0.85rem; margin-top: 4px; }

/* Exames lançados — tabela comparativa (datas em colunas, nomes fixos) */
.lab-table-wrap { overflow-x: auto; margin-top: 6px; max-height: 360px; overflow-y: auto; }
.lab-table { border-collapse: separate; border-spacing: 0; font-size: 0.76rem; width: auto; }
.lab-table th, .lab-table td { border: 1px solid var(--border-color); padding: 4px 8px; white-space: nowrap; text-align: center; }
.lab-table thead th { position: sticky; top: 0; background: var(--bg-secondary); z-index: 2; font-weight: 700; color: var(--text-secondary); }
.lab-th-name { position: sticky; left: 0; background: var(--bg-card); text-align: left !important; z-index: 3; font-weight: 600; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
.lab-table thead th.lab-th-name { z-index: 4; }
.lab-group-row th {
    position: sticky;
    left: 0;
    z-index: 3;
    text-align: left !important;
    background: color-mix(in srgb, var(--blue) 12%, var(--bg-secondary));
    color: var(--text-primary);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    padding: 6px 8px;
}
.lab-cell { cursor: pointer; font-weight: 600; }
.lab-cell-key { cursor: default; }
.lab-cell:hover { outline: 2px solid var(--blue); outline-offset: -2px; }
.lab-cell-empty { color: var(--text-muted); }
.lab-toggle:hover { color: var(--blue); }

/* Edição inline na tabela de exames + pedido pendente */
.lab-cell-input { width: 72px; max-width: 90px; background: var(--bg-secondary); border: 1px solid var(--blue);
    border-radius: 4px; color: var(--text-primary); font-size: 0.76rem; padding: 2px 4px; text-align: center; }
.pront-exam-requests { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--orange);
    background: var(--orange-glow); border-radius: var(--radius-sm); padding: 6px 10px; margin-bottom: 10px; }
.pront-exam-requests .material-icons-round { font-size: 16px; }

/* Dicionário de exames editável (Configurações) */
.dict-list { display: flex; flex-direction: column; gap: 6px; }
.dict-row { display: grid; grid-template-columns: 1.4fr 1.6fr 70px 70px 70px 32px; gap: 8px; align-items: center; }
.dict-row.dict-head { font-size: 0.7rem; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); font-weight: 700; }
.dict-row.dict-head span { padding: 0 2px; }
.dict-row input { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    color: var(--text-primary); padding: 6px 8px; font-size: 0.82rem; }
@media (max-width: 760px) { .dict-row { grid-template-columns: 1fr 1fr; } .dict-row.dict-head { display: none; } }

/* Terapias seriadas (extras no checklist) */
.doc-therapy-extra { display: flex; gap: 14px; flex-wrap: wrap; margin: 10px 0; }
.doc-therapy-extra label { display: flex; flex-direction: column; font-size: 0.78rem; color: var(--text-secondary); gap: 3px; }
.doc-therapy-extra input { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); padding: 5px 8px; width: 120px; }
.doc-therapy-just { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.doc-therapy-just > strong { font-size: 0.82rem; }
.doc-therapy-just input[type="text"] { background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); padding: 6px 8px; font-size: 0.82rem; }

/* Dicionário de medicamentos (nome + sinônimos) */
.dict-row-med { grid-template-columns: 1.2fr 2fr 32px; }
@media (max-width: 760px) { .dict-row-med { grid-template-columns: 1fr 1fr 32px; } }
@media (max-width: 760px) { .pront-tpl-edit-grid { grid-template-columns: 1fr; } }
@media (max-width: 760px) { .ai-insights-grid { grid-template-columns: 1fr; } .ai-insights-actions { width: 100%; justify-content: flex-end; } }

/* Cards de configuração recolhíveis (details/summary) */
.cfg-details > summary.cfg-summary { cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cfg-details > summary.cfg-summary::-webkit-details-marker { display: none; }
.cfg-details > summary.cfg-summary h3 { margin: 0; }
.cfg-chevron { color: var(--text-muted); transition: transform 0.2s; }
.cfg-details[open] > summary .cfg-chevron { transform: rotate(180deg); }
.cfg-details > summary.cfg-summary:hover h3 { color: var(--blue); }

/* Integrações / API externa */
.api-scope-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 8px;
}

.api-doc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.api-doc-block {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    padding: 14px;
}

.api-doc-block h4 {
    margin: 0 0 8px;
}

#section-integration pre {
    margin: 0 0 10px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    overflow-x: auto;
    white-space: pre;
}

#section-integration code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.82rem;
}

.api-created-token {
    margin-top: 14px;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(245, 158, 11, 0.35);
    background: var(--orange-glow);
}

.api-created-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    color: var(--orange);
}

.api-token-copy-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.api-token-copy-row code {
    display: inline-block;
    max-width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    overflow-wrap: anywhere;
}

.api-note {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--blue-glow);
    color: var(--text-secondary);
}

.api-key-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 8px 0 12px;
}

.api-key-list p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.bg-green { background: var(--green-glow); color: var(--green); }
.bg-red { background: var(--red-glow); color: var(--red); }
.bg-orange { background: var(--orange-glow); color: var(--orange); }

/* Agenda */
.schedule-layout {
    display: grid;
    grid-template-columns: minmax(320px, 0.8fr) minmax(620px, 1.4fr);
    gap: 18px;
    align-items: start;
}
.schedule-import-text { min-height: 260px; }
.schedule-import-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.schedule-mark-missing {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.82rem;
}
.schedule-mark-missing input { width: auto; }
.schedule-import-preview { margin-top: 14px; }
.schedule-preview-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.schedule-preview-summary span,
.schedule-stat {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    padding: 9px 10px;
    color: var(--text-secondary);
    font-size: 0.8rem;
}
.schedule-preview-summary strong,
.schedule-stat strong {
    display: block;
    color: var(--text-primary);
    font-size: 1.05rem;
}
.schedule-preview-group {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    margin-top: 8px;
}
.schedule-preview-group summary {
    cursor: pointer;
    padding: 9px 10px;
    color: var(--text-primary);
    font-weight: 700;
}
.schedule-preview-list { padding: 0 10px 10px; display: flex; flex-direction: column; gap: 6px; }
.schedule-preview-item {
    display: grid;
    grid-template-columns: 132px 1fr;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.schedule-preview-item strong { color: var(--text-primary); }
.schedule-preview-item small { grid-column: 2; color: var(--orange); }
.schedule-month-head { justify-content: space-between; }
.schedule-month-actions { display: flex; align-items: center; gap: 6px; }
.schedule-stats {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}
.schedule-stat span { font-size: 0.74rem; color: var(--text-muted); }
.schedule-weekdays {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.schedule-weekdays span { padding: 0 4px; }
.schedule-calendar {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
}
.schedule-day {
    min-height: 160px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.025);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}
.schedule-day.muted { opacity: 0.35; background: transparent; }
.schedule-day.today { box-shadow: inset 0 0 0 1px var(--blue); }
.schedule-day-number { font-weight: 800; color: var(--text-primary); font-size: 0.86rem; }
.schedule-day-events { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.schedule-empty-day { color: var(--text-muted); font-size: 0.74rem; }
.schedule-event {
    border-left: 3px solid var(--blue);
    border-radius: 6px;
    background: var(--bg-input);
    padding: 6px 7px;
    min-width: 0;
}
.schedule-event.status-attended { border-left-color: var(--green); }
.schedule-event.status-no_show { border-left-color: var(--red); }
.schedule-event.status-cancelled,
.schedule-event.status-removed { border-left-color: var(--text-muted); opacity: 0.72; }
.schedule-event-time { color: var(--blue); font-size: 0.72rem; font-weight: 800; }
.schedule-patient-link,
.schedule-patient-name {
    display: block;
    width: 100%;
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.schedule-patient-link {
    border: 0;
    background: transparent;
    text-align: left;
    padding: 0;
    cursor: pointer;
}
.schedule-patient-link:hover { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.schedule-event-meta { display: flex; flex-direction: column; gap: 5px; margin-top: 5px; }
.schedule-badge {
    display: inline-flex;
    width: fit-content;
    border-radius: 20px;
    padding: 1px 7px;
    font-size: 0.64rem;
    font-weight: 700;
}
.schedule-badge.ok { color: var(--green); background: var(--green-glow); }
.schedule-badge.pending { color: var(--orange); background: var(--orange-glow); }
.schedule-event select {
    width: 100%;
    height: 28px;
    padding: 3px 6px;
    font-size: 0.72rem;
}
@media (max-width: 1180px) {
    .schedule-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .schedule-calendar, .schedule-weekdays { grid-template-columns: 1fr; }
    .schedule-weekdays { display: none; }
    .schedule-day.muted { display: none; }
    .schedule-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Publicações */
.public-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}
.public-actions {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* ============================================================
   Scanner de Documentos (fullscreen)
   ============================================================ */
.scanner-root { position: fixed; inset: 0; z-index: 10000; background: #0b0d12;
    display: flex; flex-direction: column; }
.scanner-top { display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; color: #fff; }
.scanner-title { font-weight: 700; font-size: 0.95rem; }
.scn-btn { appearance: none; background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.15);
    color: #fff; border-radius: 10px; width: 42px; height: 42px; display: flex; align-items: center;
    justify-content: center; cursor: pointer; }
.scn-btn.danger { color: #f87171; }
.scanner-stage { flex: 1; position: relative; overflow: hidden; display: flex;
    align-items: center; justify-content: center; background: #000; }
.scanner-stage.flash::after { content: ''; position: absolute; inset: 0; background: #fff; opacity: 0.55; }
.scanner-video { width: 100%; height: 100%; object-fit: contain; }
.scanner-msg { position: absolute; inset: auto 16px; top: 45%; text-align: center; color: #cbd5e1;
    font-size: 0.95rem; line-height: 1.6; }
.scanner-review { position: absolute; inset: 0; background: #111; display: flex;
    align-items: center; justify-content: center; padding: 10px; }
.scanner-review-canvas { max-width: 100%; max-height: 100%; box-shadow: 0 4px 30px rgba(0,0,0,0.6); }
.scanner-pagebar { padding: 6px 10px; }
.scanner-thumbs { display: flex; gap: 8px; overflow-x: auto; min-height: 8px; }
.scanner-thumb { position: relative; flex-shrink: 0; border: 2px solid rgba(255,255,255,0.25);
    border-radius: 6px; overflow: hidden; cursor: pointer; background: #222; }
.scanner-thumb.active { border-color: var(--blue); }
.scanner-thumb canvas { display: block; }
.scanner-thumb-n { position: absolute; bottom: 2px; right: 4px; color: #fff; font-size: 0.65rem;
    background: rgba(0,0,0,0.6); border-radius: 8px; padding: 0 5px; }
.scanner-controls { padding: 8px 14px calc(14px + env(safe-area-inset-bottom)); display: flex;
    flex-direction: column; gap: 10px; }
.scanner-edit { display: flex; align-items: center; gap: 8px; justify-content: center; }
.scanner-edit .scn-filter { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.2);
    color: #fff; border-radius: 8px; padding: 8px 10px; font-size: 0.85rem; width: auto; }
.scanner-main-controls { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.scn-upload { width: 46px; height: 46px; border-radius: 12px; background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15); color: #fff; display: flex; align-items: center;
    justify-content: center; cursor: pointer; }
.scanner-shutter { appearance: none; width: 68px; height: 68px; border-radius: 50%; cursor: pointer;
    background: #fff; border: 5px solid rgba(255,255,255,0.35); box-shadow: 0 0 0 3px rgba(0,0,0,0.4); }
.scanner-shutter:active { transform: scale(0.93); }
.scn-done { appearance: none; background: var(--gradient-primary); color: #fff; border: 0;
    border-radius: 12px; padding: 12px 16px; font-weight: 700; font-size: 0.9rem; cursor: pointer;
    display: flex; align-items: center; gap: 8px; }
.scn-count { background: rgba(255,255,255,0.25); border-radius: 12px; padding: 0 8px; font-size: 0.8rem; }

/* Card Documentos Anexados */
.attach-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.attach-upload-btn { cursor: pointer; }
.attach-list { display: flex; flex-direction: column; gap: 6px; }
.attach-line { display: flex; align-items: center; justify-content: space-between; gap: 6px;
    background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 6px 8px; }
.attach-main { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; cursor: pointer; }
.attach-main:hover strong { color: var(--blue); }
.attach-thumb { width: 38px; height: 48px; object-fit: cover; border-radius: 4px; background: #fff; flex-shrink: 0; }
.attach-icon { font-size: 30px; color: var(--text-muted); flex-shrink: 0; }
.attach-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.attach-info strong { font-size: 0.84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-info small { font-size: 0.7rem; color: var(--text-muted); }
.attach-linked { color: var(--blue); }
.attach-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* Preview de anexo */
.attach-prev-body { display: flex; align-items: center; justify-content: center;
    background: var(--bg-input); border-radius: var(--radius-sm); min-height: 320px; }
.attach-prev-img { max-width: 100%; max-height: 64vh; border-radius: 4px; }
.attach-prev-frame { width: 100%; height: 64vh; border: 0; border-radius: 4px; background: #fff; }

/* Standalone */
.sa-thumbs { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.sa-thumb { position: relative; flex-shrink: 0; }
.sa-thumb img { height: 110px; border-radius: 6px; border: 1px solid var(--border-color); background: #fff; }
.sa-thumb span { position: absolute; bottom: 4px; right: 4px; background: rgba(0,0,0,0.65); color: #fff;
    font-size: 0.65rem; border-radius: 8px; padding: 0 6px; }

/* Biblioteca do Scanner (standalone) */
.sa-doc-list { display: flex; flex-direction: column; gap: 8px; }
.sa-doc { display: flex; align-items: center; justify-content: space-between; gap: 8px;
    background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm);
    padding: 8px 10px; }
.sa-doc-main { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; cursor: pointer; }
.sa-doc-main:hover strong { color: var(--blue); }
.sa-doc-thumb { width: 44px; height: 56px; object-fit: cover; border-radius: 4px; background: #fff; flex-shrink: 0; }
.sa-link-panel { background: var(--bg-card); border: 1px dashed var(--blue); border-radius: var(--radius-sm);
    padding: 10px 12px; margin: -2px 0 4px; }
.sa-patient-wrap { width: 100%; max-width: 420px; margin-top: 6px; }
#scanner-standalone .sa-patient-wrap .qc-loc-results {
    position: static; left: auto; right: auto; top: auto; z-index: auto;
    margin-top: 6px; max-height: min(46vh, 320px); box-shadow: none;
}
#scanner-standalone .sa-patient-wrap .qc-loc-item { align-items: flex-start; }
#scanner-standalone .sa-patient-wrap .qc-loc-item span:last-child {
    min-width: 0; line-height: 1.25; overflow-wrap: anywhere;
}

@media (max-width: 768px) {
    .sa-doc { align-items: flex-start; }
    .sa-doc .attach-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 96px; }
    .sa-patient-wrap { max-width: 100%; }
}

/* Visualização de documento escaneado (grade estilo CamScanner) */
.att-grid-toolbar, .att-page-toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    margin-bottom: 10px; width: 100%; }
.att-page-counter { font-size: 0.85rem; color: var(--text-secondary); font-weight: 600; white-space: nowrap; }
.att-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; width: 100%;
    max-height: 64vh; overflow-y: auto; padding: 4px; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; }
.att-grid-item { position: relative; cursor: pointer; border-radius: 8px; overflow: hidden;
    background: #fff; border: 1px solid var(--border-color); aspect-ratio: 3/4; }
.att-grid-item img { width: 100%; height: 100%; object-fit: contain; background: #fff; display: block; }
.att-grid-item:hover { outline: 2px solid var(--blue); outline-offset: -2px; }
.att-grid-n { position: absolute; bottom: 6px; right: 8px; background: rgba(0,0,0,0.65); color: #fff;
    font-size: 0.7rem; font-weight: 700; border-radius: 10px; padding: 1px 8px; }
.att-page-stage { display: flex; align-items: center; justify-content: center; width: 100%; }
/* corpo do preview deixa de centralizar verticalmente no modo scan */
#attach-prev-body { flex-direction: column; align-items: stretch; }

/* Seleção múltipla de páginas (pressionar e segurar) */
.att-grid { -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
.att-grid-item img { pointer-events: none; }
.att-grid-check { display: none; position: absolute; top: 6px; left: 6px; color: var(--blue);
    background: #fff; border-radius: 50%; font-size: 22px; box-shadow: 0 1px 6px rgba(0,0,0,0.35); }
.att-grid-item.selected { outline: 3px solid var(--blue); outline-offset: -3px; }
.att-grid-item.selected .att-grid-check { display: block; }
.att-grid-item.selected img { opacity: 0.82; }
.att-sel-bar { display: flex; align-items: center; justify-content: center; gap: 10px;
    margin-top: 10px; padding: 10px; background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius-md); position: sticky; bottom: 0; box-shadow: var(--shadow-md); }

/* Visualizador de documento escaneado em TELA CHEIA */
.attviewer-root { position: fixed; inset: 0; z-index: 9500; background: var(--bg-primary);
    display: flex; flex-direction: column; }
.attviewer-top { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-bottom: 1px solid var(--border-color); }
.attviewer-title { flex: 1; font-weight: 700; font-size: 0.95rem; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap; }
.attviewer-toolbar { padding: 8px 12px 0; margin-bottom: 8px; }
.attviewer-stage { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 0 12px; }
.attviewer-root .att-grid { flex: 1; max-height: none; padding: 4px 2px calc(12px + env(safe-area-inset-bottom)); }
.attviewer-root .att-page-stage { flex: 1; overflow: auto; }
.attviewer-root .attach-prev-img { max-height: none; width: 100%; object-fit: contain; }
.attviewer-root .att-sel-bar { margin: 0 12px calc(10px + env(safe-area-inset-bottom)); }

/* Arrastar para reordenar */
.att-grid-item.lifted { transform: scale(1.04); box-shadow: 0 6px 24px rgba(0,0,0,0.5); z-index: 2; }
.att-grid-item.drag-src { opacity: 0.35; }
.att-drag-ghost { position: fixed; z-index: 9600; pointer-events: none; opacity: 0.9;
    box-shadow: 0 10px 34px rgba(0,0,0,0.6); transform: scale(0.92); border: 2px solid var(--blue); }
.att-grid-item.drop-target { outline: 3px dashed var(--green); outline-offset: -3px; }

/* Busca na biblioteca do Scanner */
.sa-search { display: flex; align-items: center; gap: 8px; background: var(--bg-input);
    border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 8px 12px;
    margin-bottom: 12px; }
.sa-search:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-glow); }
.sa-search .material-icons-round { font-size: 19px; color: var(--text-muted); }
.sa-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: none;
    color: var(--text-primary); font-size: 0.88rem; font-family: inherit; padding: 0; box-shadow: none; }

/* ============ Gerenciar Usuários ============ */
.tag-chip { display:inline-block; background:var(--bg-card); border:1px solid var(--border-color);
    border-radius:12px; padding:2px 8px; font-size:0.78rem; color:var(--text-primary);
    margin:2px 3px 2px 0; white-space:nowrap; }
.badge { display:inline-block; padding:2px 8px; border-radius:10px; font-size:0.75rem; font-weight:600; }
.badge-green { background:rgba(16,185,129,0.15); color:var(--green); }
.badge-gray  { background:rgba(100,116,139,0.15); color:var(--text-muted); }
.perm-check-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(200px,1fr)); gap:6px; }
.perm-check-label { display:flex; align-items:center; gap:8px; padding:6px 10px;
    background:var(--bg-input); border:1px solid var(--border-color); border-radius:var(--radius-sm);
    cursor:pointer; font-size:0.87rem; transition:border-color 0.15s; }
.perm-check-label:hover { border-color:var(--blue); }
.perm-check-label input[type=checkbox] { width:16px; height:16px; cursor:pointer; flex-shrink:0; }
.color-dot { width:10px; height:10px; border-radius:50%; flex-shrink:0; }
.btn-xs { padding:3px 8px !important; font-size:0.78rem !important; }
.user-card .btn-danger { background:rgba(239,68,68,0.12); color:#ef4444; border:1px solid rgba(239,68,68,0.25); }
.user-card .btn-danger:hover { background:rgba(239,68,68,0.22); }
