:root {
    --navy-950: #10233c;
    --navy-900: #163252;
    --navy-700: #2d5278;
    --beige-50: #f7f2e8;
    --beige-100: #efe5d4;
    --beige-200: #dec8a8;
    --white: #ffffff;
    --text: #1f2a36;
    --muted: #6d7782;
    --success: #1f7a5b;
    --danger: #a64545;
    --border: rgba(16, 35, 60, 0.12);
    --shadow: 0 18px 40px rgba(16, 35, 60, 0.12);
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(222, 200, 168, 0.65), transparent 35%),
        linear-gradient(135deg, #f8f4ec 0%, #efe3cf 100%);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-layout {
    width: min(1100px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.55);
    border-radius: 32px;
    overflow: hidden;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
}

.login-highlight {
    padding: 56px;
    background:
        linear-gradient(180deg, rgba(16, 35, 60, 0.92) 0%, rgba(22, 50, 82, 0.88) 100%),
        linear-gradient(135deg, #183357, #244b76);
    color: var(--white);
}

.login-highlight h1 {
    font-size: clamp(2rem, 4vw, 3.5rem);
    line-height: 1.05;
    margin: 22px 0 18px;
}

.login-highlight p {
    color: rgba(255, 255, 255, 0.78);
    max-width: 520px;
}

.feature-list {
    margin: 32px 0 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 14px;
}

.feature-list li {
    padding: 16px 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-sm);
}

.login-card {
    padding: 48px;
    background: rgba(255, 252, 246, 0.88);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 24px;
}

.brand-badge,
.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.75rem;
    font-weight: 700;
}

.brand-badge {
    color: var(--navy-900);
    background: rgba(239, 229, 212, 0.95);
    padding: 10px 14px;
    border-radius: 999px;
}

.eyebrow {
    color: var(--navy-700);
    margin: 0 0 8px;
}

.muted {
    color: var(--muted);
    margin: 0;
}

.form-grid {
    display: grid;
    gap: 18px;
}

.form-grid label {
    display: grid;
    gap: 8px;
    font-weight: 600;
    color: var(--navy-950);
}

.form-grid input,
.form-grid select,
.form-grid textarea {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.9);
    transition: 0.2s border-color ease, 0.2s box-shadow ease;
}

.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus {
    outline: none;
    border-color: var(--navy-700);
    box-shadow: 0 0 0 4px rgba(45, 82, 120, 0.12);
}

.btn-primary,
.btn-secondary,
.btn-inline,
.logout-link {
    box-sizing: border-box;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease, background 0.2s ease;
}

.btn-primary,
.btn-secondary,
.btn-inline {
    max-width: 100%;
    min-width: 0;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    text-align: center;
    line-height: 1.35;
}

.btn-primary:hover,
.btn-secondary:hover,
.btn-inline:hover,
.logout-link:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

.btn-primary {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    color: var(--white);
    padding: 14px 20px;
    font-weight: 700;
}

.btn-secondary {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    background: rgba(16, 35, 60, 0.07);
    color: var(--navy-900);
    padding: 14px 20px;
    font-weight: 700;
    max-width: 100%;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
}

.btn-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 14px;
    background: rgba(16, 35, 60, 0.08);
    color: var(--navy-900);
    font-size: 0.95rem;
}

.btn-inline.danger {
    background: rgba(166, 69, 69, 0.1);
    color: var(--danger);
}

.login-hint {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--muted);
    font-size: 0.92rem;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 600;
}

.alert.success {
    background: rgba(31, 122, 91, 0.12);
    color: var(--success);
}

.alert.error {
    background: rgba(166, 69, 69, 0.12);
    color: var(--danger);
}

.app-shell {
    display: grid;
    grid-template-columns: 300px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: linear-gradient(180deg, rgba(16, 35, 60, 0.98), rgba(22, 50, 82, 0.95));
    color: var(--white);
    padding: 28px 22px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 24px;
}

.brand-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 18px;
}

.brand-logo {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
}

.brand-copy {
    display: grid;
    gap: 8px;
    min-width: 0;
    width: 100%;
}

.brand-card .brand-badge {
    background: rgba(239, 229, 212, 0.12);
    color: var(--beige-50);
}

.brand-card h1 {
    margin: 0;
    font-size: 1.32rem;
    line-height: 1.18;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.brand-card p,
.sidebar-footer span {
    color: rgba(255, 255, 255, 0.72);
}

.brand-card p {
    margin: 0;
    line-height: 1.55;
}

.nav-menu {
    display: grid;
    gap: 10px;
    margin-top: 24px;
}

.nav-menu a {
    padding: 14px 18px;
    border-radius: 14px;
    color: rgba(255, 255, 255, 0.82);
}

.nav-menu a.active,
.nav-menu a:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.nav-menu a.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-footer {
    padding: 18px 20px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.sidebar-footer strong,
.module-item strong {
    display: block;
}

.logout-link {
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.main-content {
    padding: 32px;
    display: grid;
    gap: 24px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 18px;
    background: rgba(255, 252, 246, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow);
}

.topbar-logo {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 16px;
    flex-shrink: 0;
}

.topbar-brand-copy {
    display: grid;
    gap: 2px;
}

.topbar-brand-copy strong {
    color: var(--navy-950);
    line-height: 1.1;
}

.topbar-brand-copy span {
    color: var(--muted);
    font-size: 0.88rem;
}

.topbar h2,
.panel h3 {
    margin: 0;
}

.stats-grid,
.content-grid {
    display: grid;
    gap: 22px;
}

.stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.content-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
}

.patients-layout {
    align-items: start;
}

.stat-card,
.panel {
    background: rgba(255, 252, 246, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.stat-card {
    padding: 24px;
}

.stat-card p,
.stat-card span,
.module-item span,
.page-footer p,
table td,
table th {
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin: 10px 0 8px;
    font-size: clamp(1.2rem, 1.75vw, 1.6rem);
    color: var(--navy-950);
    line-height: 1.15;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

.stat-card-datetime {
    display: grid;
    gap: 2px;
}

.stat-card-date {
    white-space: nowrap;
}

.stat-card-time {
    white-space: nowrap;
}

.panel {
    padding: 28px;
    min-width: 0;
}

.hero-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
    min-height: 250px;
    background:
        linear-gradient(135deg, rgba(16, 35, 60, 0.95), rgba(34, 74, 115, 0.92)),
        linear-gradient(135deg, #173154, #264e7b);
    color: var(--white);
}

.hero-panel .eyebrow,
.hero-panel p {
    color: rgba(255, 255, 255, 0.78);
}

.module-list {
    display: grid;
    gap: 16px;
    margin-top: 18px;
}

.module-item {
    padding: 18px;
    border-radius: var(--radius-md);
    background: rgba(16, 35, 60, 0.05);
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.search-form {
    display: flex;
    gap: 12px;
    width: min(100%, 380px);
}

.search-form input {
    flex: 1;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.form-actions,
.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
}

table th,
table td {
    text-align: left;
    padding: 16px 12px;
    border-bottom: 1px solid rgba(16, 35, 60, 0.08);
}

.empty-state {
    text-align: center;
    padding: 30px 12px;
}

.page-footer {
    padding-top: 8px;
}

.integrations-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.integration-card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.integration-card {
    border-radius: var(--radius-md);
    padding: 24px;
    background: rgba(16, 35, 60, 0.04);
    border: 1px solid rgba(16, 35, 60, 0.08);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.integration-card h4,
.section-heading h4 {
    margin: 0;
    color: var(--navy-950);
}

.integration-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.integration-card-top,
.integration-card-meta,
.integration-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.integration-category {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--navy-700);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
}

.status-pill.active {
    background: rgba(31, 122, 91, 0.14);
    color: var(--success);
}

.status-pill.draft {
    background: rgba(16, 35, 60, 0.1);
    color: var(--navy-900);
}

.status-pill.neutral {
    background: rgba(222, 200, 168, 0.45);
    color: var(--navy-900);
}

.integration-detail-layout {
    grid-template-columns: 1.25fr 0.75fr;
}

.integration-form-grid {
    display: grid;
    gap: 22px;
}

.integration-section {
    padding: 22px;
    border-radius: var(--radius-md);
    background: rgba(16, 35, 60, 0.04);
    border: 1px solid rgba(16, 35, 60, 0.08);
}

.section-heading {
    margin-bottom: 18px;
}

.section-heading h4 {
    font-size: 1.05rem;
}

.integration-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.integration-fields textarea,
.integration-fields select {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.9);
    font: inherit;
    resize: vertical;
    min-height: 52px;
}

.integration-fields textarea {
    min-height: 120px;
}

.toggle-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.75);
}

.toggle-field input {
    width: 22px;
    height: 22px;
}

@media (max-width: 1080px) {
    .login-layout,
    .app-shell,
    .stats-grid,
    .content-grid {
        grid-template-columns: 1fr;
    }

    .integrations-stats,
    .integration-card-grid,
    .integration-detail-layout,
    .integration-fields {
        grid-template-columns: 1fr;
    }

    .sidebar {
        padding-bottom: 20px;
    }
}

@media (max-width: 720px) {
    .login-highlight,
    .login-card,
    .main-content,
    .panel,
    .stat-card {
        padding: 22px;
    }

    .panel-heading,
    .stacked-mobile,
    .search-form,
    .sidebar-footer,
    .topbar,
    .sidebar-brand {
        flex-direction: column;
        align-items: stretch;
    }

    .brand-logo,
    .topbar-logo {
        align-self: center;
    }

    .topbar-brand {
        justify-content: center;
    }

    .table-actions {
        min-width: 150px;
    }

    .topbar h2 {
        font-size: 1.5rem;
    }
}

.full-width-panel {
    width: 100%;
}

.advanced-chart-layout {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.patient-directory-panel {
    position: sticky;
    top: 24px;
}

.patient-directory-list {
    display: grid;
    gap: 12px;
}

.patient-directory-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    border-radius: 18px;
    text-decoration: none;
    color: var(--navy-900);
    background: rgba(16, 35, 60, 0.04);
    border: 1px solid rgba(16, 35, 60, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    min-width: 0;
}

.patient-directory-item span {
    color: var(--muted);
    font-size: 0.92rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.patient-directory-item strong {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.patient-directory-item:hover,
.patient-directory-item.active {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(16, 35, 60, 0.1);
    border-color: rgba(16, 35, 60, 0.18);
}

.chart-main-column {
    display: grid;
    gap: 24px;
}

.quick-patient-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    color: var(--muted);
    font-weight: 600;
}

.quick-patient-meta span {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.chart-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.chart-tab {
    padding: 12px 18px;
    border-radius: 999px;
    font-weight: 700;
    background: rgba(16, 35, 60, 0.07);
    color: var(--navy-900);
    max-width: 100%;
    white-space: normal;
    text-align: center;
    line-height: 1.35;
}

.chart-tab.active {
    background: var(--navy-900);
    color: var(--beige-100);
}

.chart-tab.muted {
    opacity: 0.68;
}

.anamnesis-actions,
.history-item-actions,
.public-link-box {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.anamnesis-actions {
    margin: 24px 0;
}

.anamnesis-actions > * {
    max-width: 100%;
}

.public-link-box {
    padding: 18px;
    border-radius: 18px;
    background: rgba(16, 35, 60, 0.04);
    border: 1px solid rgba(16, 35, 60, 0.08);
}

.public-link-box input {
    flex: 1;
    min-width: 260px;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    font: inherit;
    background: rgba(255, 255, 255, 0.92);
}

.premium-clinical-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin: 24px 0;
}

.clinical-highlight-panel,
.section-answer-card,
.form-section-card {
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid rgba(16, 35, 60, 0.08);
    box-shadow: 0 20px 40px rgba(16, 35, 60, 0.06);
}

.highlight-block,
.muted-block {
    padding: 18px;
    border-radius: 16px;
    background: rgba(16, 35, 60, 0.04);
    line-height: 1.7;
}

.muted-block,
.muted-copy,
.public-form-intro {
    color: var(--muted);
}

.risk-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.risk-chip {
    display: inline-flex;
    align-items: center;
    padding: 10px 14px;
    border-radius: 999px;
    background: rgba(153, 60, 60, 0.12);
    color: #8c3232;
    font-weight: 700;
}

.answer-sections-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.section-answer-card,
.form-section-card {
    padding: 24px;
}

.section-answer-items {
    display: grid;
    gap: 12px;
}

.section-answer-item {
    display: grid;
    gap: 6px;
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(16, 35, 60, 0.04);
}

.section-answer-item strong {
    color: var(--navy-900);
}

.section-answer-item span {
    color: var(--muted);
    line-height: 1.65;
}

.section-answer-item.highlighted {
    background: rgba(222, 200, 168, 0.35);
    border: 1px solid rgba(16, 35, 60, 0.08);
}

.history-list,
.uploaded-file-list {
    display: grid;
    gap: 14px;
}

.history-item,
.uploaded-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border-radius: 16px;
    background: rgba(16, 35, 60, 0.04);
    border: 1px solid rgba(16, 35, 60, 0.08);
}

.history-item span,
.uploaded-file-item span {
    color: var(--muted);
}

.public-anamnesis-page {
    min-height: 100vh;
    margin: 0;
    background:
        radial-gradient(circle at top right, rgba(222, 200, 168, 0.35), transparent 24%),
        linear-gradient(180deg, #f8f2e9 0%, #f4eee4 100%);
    color: var(--navy-950);
}

.advanced-form-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 40px 0;
}

.advanced-form-panel {
    padding: 32px;
    border-radius: 28px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(16, 35, 60, 0.08);
    box-shadow: 0 28px 60px rgba(16, 35, 60, 0.08);
}

.advanced-anamnesis-form {
    display: grid;
    gap: 20px;
}

.advanced-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.advanced-field {
    display: grid;
    gap: 8px;
    color: var(--navy-900);
    font-weight: 600;
}

.advanced-field.full-span {
    grid-column: 1 / -1;
}

.advanced-field input,
.advanced-field select,
.advanced-field textarea {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
    font: inherit;
    color: var(--navy-950);
}

.advanced-field textarea {
    resize: vertical;
    min-height: 120px;
}

.field-error {
    color: #8c3232;
    font-size: 0.9rem;
}

.field-help {
    color: var(--muted);
    font-size: 0.9rem;
}

.agenda-layout {
    display: grid;
    grid-template-columns: 420px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.agenda-form-panel {
    position: sticky;
    top: 24px;
}

.agenda-content-column {
    display: grid;
    gap: 24px;
}

.agenda-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.agenda-form-grid label {
    display: grid;
    gap: 8px;
    color: var(--navy-900);
    font-weight: 600;
}

.agenda-form-grid label.full-span,
.form-actions.full-span {
    grid-column: 1 / -1;
}

.agenda-form-grid input,
.agenda-form-grid select,
.agenda-form-grid textarea {
    width: 100%;
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
    font: inherit;
    color: var(--navy-950);
}

.agenda-form-grid textarea {
    min-height: 126px;
    resize: vertical;
}

.panel-subtitle {
    margin: 8px 0 0;
    color: var(--muted);
    line-height: 1.6;
}

.appointment-list,
.patient-appointment-groups {
    display: grid;
    gap: 14px;
}

.appointment-card,
.patient-appointment-group {
    display: grid;
    gap: 14px;
    padding: 18px 20px;
    border-radius: 18px;
    background: rgba(16, 35, 60, 0.04);
    border: 1px solid rgba(16, 35, 60, 0.08);
}

.appointment-card strong,
.patient-appointment-group strong {
    color: var(--navy-900);
}

.appointment-card span,
.patient-appointment-group span {
    color: var(--muted);
    line-height: 1.6;
}

.appointment-card-meta,
.patient-appointment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.patient-appointment-items {
    display: grid;
    gap: 10px;
}

.patient-appointment-item {
    display: grid;
    gap: 4px;
    padding-top: 10px;
    border-top: 1px solid rgba(16, 35, 60, 0.08);
}

.appointment-notes {
    display: block;
    margin-top: 8px;
    color: var(--muted);
    line-height: 1.6;
}

.medical-agenda-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
        "form"
        "calendar"
        "details"
        "insights"
        "patients";
    gap: 24px;
    align-items: start;
}

.agenda-sidebar-panel,
.agenda-sidebar-panel.panel {
    grid-area: form;
    position: static;
    overflow: visible !important;
}

.agenda-sidebar-panel .panel-heading {
    margin-bottom: 18px;
}

.agenda-sidebar-panel .agenda-form-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
}

.agenda-sidebar-panel .patient-search-field.full-span,
.agenda-sidebar-panel .agenda-form-grid > label.full-span,
.agenda-sidebar-panel .teleconsultation-hint.full-span,
.agenda-sidebar-panel .form-actions.full-span {
    grid-column: span 2;
}

.agenda-sidebar-panel .agenda-form-grid textarea {
    min-height: 76px;
}

.agenda-sidebar-panel .form-actions {
    align-self: end;
}

.agenda-sidebar-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.agenda-mini-card {
    padding: 16px;
    border-radius: 16px;
    background: rgba(16, 35, 60, 0.04);
    border: 1px solid rgba(16, 35, 60, 0.08);
    display: grid;
    gap: 6px;
}

.agenda-mini-card span {
    color: var(--muted);
    font-size: 0.9rem;
}

.agenda-mini-card strong {
    color: var(--navy-900);
    font-size: 1.3rem;
}

.agenda-main-panel {
    display: contents;
}

.medical-calendar-panel {
    grid-area: calendar;
    padding: 28px;
}

.calendar-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 24px;
}

.calendar-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.calendar-jump-form {
    display: flex;
    align-items: end;
    gap: 10px;
    flex-wrap: wrap;
}

.calendar-jump-form label {
    display: grid;
    gap: 6px;
    color: var(--navy-900);
    font-weight: 600;
}

.calendar-jump-form input {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.96);
    font: inherit;
}

.calendar-view-hint {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 0.95rem;
}

.weekly-calendar,
.daily-calendar {
    display: grid;
    gap: 10px;
}

.weekly-calendar {
    overflow-x: auto;
    padding-bottom: 8px;
}

.calendar-grid-header,
.calendar-row {
    display: grid;
    grid-template-columns: 86px repeat(7, minmax(136px, 1fr));
    gap: 8px;
    min-width: 1120px;
}

.calendar-day-header,
.calendar-time-cell,
.calendar-slot,
.daily-calendar-slot {
    border-radius: 16px;
    border: 1px solid rgba(16, 35, 60, 0.08);
}

.calendar-time-cell {
    padding: 14px 12px;
    background: rgba(16, 35, 60, 0.04);
    color: var(--navy-900);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.calendar-day-header {
    padding: 14px 12px;
    background: rgba(222, 200, 168, 0.24);
    display: grid;
    gap: 4px;
    text-align: center;
}

.calendar-day-header span {
    color: var(--muted);
}

.calendar-slot {
    min-height: 78px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.82);
    display: grid;
    align-content: start;
    gap: 6px;
    cursor: pointer;
    transition: box-shadow 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}

.calendar-slot.today,
.calendar-day-header.today {
    box-shadow: inset 0 0 0 1px rgba(16, 35, 60, 0.14);
}

.daily-calendar-row {
    display: grid;
    grid-template-columns: 90px minmax(0, 1fr);
    gap: 10px;
}

.daily-calendar-slot {
    min-height: 86px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.82);
    display: grid;
    gap: 10px;
    align-content: start;
    cursor: pointer;
    transition: box-shadow 0.16s ease, transform 0.16s ease, border-color 0.16s ease;
}

.daily-slot-empty {
    color: var(--muted);
    font-size: 0.95rem;
}

.calendar-slot:hover,
.daily-calendar-slot:hover {
    border-color: rgba(16, 35, 60, 0.2);
    box-shadow: 0 10px 24px rgba(16, 35, 60, 0.06);
}

.selected-slot {
    border-color: rgba(16, 35, 60, 0.28);
    box-shadow: inset 0 0 0 2px rgba(16, 35, 60, 0.18), 0 12px 24px rgba(16, 35, 60, 0.08);
    background: rgba(222, 200, 168, 0.22);
}

.calendar-event-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 3px;
    padding: 9px 10px;
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: var(--navy-950);
    background: linear-gradient(180deg, rgba(16, 35, 60, 0.1), rgba(16, 35, 60, 0.06));
    border-left: 4px solid var(--navy-900);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.calendar-event-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(16, 35, 60, 0.08);
}

.calendar-event-card span,
.calendar-event-card small {
    color: var(--muted);
    line-height: 1.35;
}

.calendar-event-card .event-patient,
.calendar-event-card .event-card-meta,
.calendar-event-card .event-professional {
    display: block;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event-card .event-patient {
    font-size: 0.86rem;
    letter-spacing: -0.01em;
}

.calendar-event-card .event-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.76rem;
}

.calendar-event-card .event-card-meta span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.calendar-event-card .event-card-meta span + span::before {
    content: "•";
    margin-right: 6px;
    color: rgba(100, 113, 130, 0.7);
}

.weekly-calendar .calendar-event-card .event-professional {
    display: none;
}

.daily-calendar .calendar-event-card {
    gap: 5px;
}

.calendar-event-card.status-confirmado,
.calendar-event-card.status-realizado {
    border-left-color: var(--success);
}

.calendar-event-card.status-cancelado,
.calendar-event-card.status-remarcado {
    border-left-color: #8c3232;
}

.agenda-insights-grid {
    grid-area: insights;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.agenda-patient-summary-panel {
    grid-area: patients;
}

.appointment-list.compact .appointment-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
}

.patient-search-field {
    position: relative;
    z-index: 30;
}

.patient-search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.94);
}

.patient-search-box input {
    flex: 1;
    width: 100%;
    min-width: 0;
    border: 0;
    background: transparent;
    padding-left: 0;
}

.patient-search-box input:focus {
    outline: none;
}

.patient-search-icon {
    color: var(--muted);
    font-size: 1rem;
}

.patient-search-results,
.patient-search-empty {
    margin-top: 8px;
    position: relative;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(16, 35, 60, 0.1);
    box-shadow: 0 18px 40px rgba(16, 35, 60, 0.08);
    z-index: 40;
}

.patient-search-results {
    display: none;
    overflow: hidden;
    max-height: 280px;
    overflow-y: auto;
}

.patient-search-field.is-open .patient-search-results {
    display: grid;
}

.patient-search-empty {
    display: none;
    padding: 14px 16px;
    color: var(--muted);
}

.patient-search-field.is-open .patient-search-empty:not([hidden]) {
    display: block;
}

.patient-search-option {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
    padding: 14px 16px;
    display: grid;
    gap: 4px;
    cursor: pointer;
}

.patient-search-option:hover {
    background: rgba(16, 35, 60, 0.05);
}

.patient-search-option span {
    color: var(--muted);
}

.patient-inline-appointment-form {
    margin-bottom: 24px;
    padding: 18px;
    border-radius: 18px;
    background: rgba(16, 35, 60, 0.04);
    border: 1px solid rgba(16, 35, 60, 0.08);
}

.slot-selection-summary {
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(222, 200, 168, 0.24);
    border: 1px solid rgba(16, 35, 60, 0.08);
    color: var(--navy-900);
}

.teleconsultation-hint {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(16, 35, 60, 0.08);
    display: grid;
    gap: 4px;
    color: var(--navy-900);
}

.teleconsultation-hint.active {
    background: rgba(52, 168, 83, 0.12);
}

.teleconsultation-hint.warning {
    background: rgba(222, 200, 168, 0.24);
}

.teleconsultation-hint span {
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.5;
}

.appointment-detail-panel {
    grid-area: details;
    padding: 24px;
}

.appointment-detail-card {
    display: grid;
    gap: 18px;
}

.appointment-detail-head,
.appointment-detail-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.appointment-detail-head span {
    color: var(--muted);
}

.appointment-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
}

.appointment-detail-grid .module-item {
    min-width: 0;
}

.appointment-detail-grid .appointment-notes {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

body.page-agenda.agenda-expanded .app-shell {
    display: block;
}

body.page-agenda.agenda-expanded .sidebar {
    display: none;
}

body.page-agenda.agenda-expanded .main-content {
    padding: 28px;
}

body.page-agenda.agenda-expanded .topbar {
    padding-bottom: 12px;
}

body.page-agenda.agenda-expanded .medical-agenda-layout {
    grid-template-columns: minmax(0, 1fr);
}

body.page-agenda.agenda-expanded .medical-calendar-panel {
    padding: 20px;
}

@media (max-width: 1180px) {
    .advanced-chart-layout,
    .premium-clinical-grid,
    .answer-sections-grid,
    .agenda-layout,
    .medical-agenda-layout,
    .agenda-insights-grid,
    .appointment-detail-grid {
        grid-template-columns: 1fr;
    }

    .patient-directory-panel,
    .agenda-form-panel,
    .agenda-sidebar-panel {
        position: static;
    }

    .calendar-grid-header,
    .calendar-row {
        grid-template-columns: 80px repeat(7, minmax(180px, 1fr));
        min-width: 1380px;
    }

    .medical-agenda-layout {
        grid-template-areas:
            "calendar"
            "form"
            "details"
            "insights"
            "patients";
    }

    .medical-calendar-panel {
        overflow-x: auto;
    }
}

@media (max-width: 860px) {
    .advanced-form-grid,
    .agenda-form-grid {
        grid-template-columns: 1fr;
    }

    .agenda-sidebar-panel .agenda-form-grid {
        grid-template-columns: 1fr;
    }

    .agenda-sidebar-panel .patient-search-field.full-span,
    .agenda-sidebar-panel .agenda-form-grid > label.full-span,
    .agenda-sidebar-panel .teleconsultation-hint.full-span,
    .agenda-sidebar-panel .form-actions.full-span {
        grid-column: 1 / -1;
    }

    .history-item,
    .uploaded-file-item,
    .appointment-card-meta,
    .patient-appointment-header,
    .calendar-topbar,
    .appointment-detail-head,
    .appointment-detail-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-actions,
    .appointment-detail-actions {
        width: 100%;
    }

    .form-actions > .btn-primary,
    .form-actions > .btn-secondary,
    .appointment-detail-actions > .btn-primary,
    .appointment-detail-actions > .btn-secondary,
    .appointment-detail-actions > form,
    .appointment-detail-actions > form > .btn-inline {
        width: 100%;
    }

    .agenda-sidebar-cards {
        grid-template-columns: 1fr;
    }

    .daily-calendar-row {
        grid-template-columns: 1fr;
    }
}

.patient-chart-shell {
    padding: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 255, 255, 0.94)),
        radial-gradient(circle at top right, rgba(16, 35, 60, 0.08), transparent 34%);
    border: 1px solid rgba(16, 35, 60, 0.08);
    box-shadow: 0 24px 50px rgba(16, 35, 60, 0.08);
}

.patient-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding-bottom: 22px;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(16, 35, 60, 0.08);
}

.patient-chart-identity {
    display: grid;
    gap: 8px;
    max-width: 760px;
}

.patient-chart-identity h3 {
    font-size: clamp(2rem, 3vw, 2.6rem);
    letter-spacing: -0.03em;
    margin: 0;
}

.patient-chart-subtitle {
    margin: 0;
    color: var(--muted);
    max-width: 62ch;
    line-height: 1.7;
}

.patient-chart-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 12px;
}

.patient-meta-pill {
    min-width: 150px;
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    border-radius: 18px;
    background: rgba(16, 35, 60, 0.04);
    border: 1px solid rgba(16, 35, 60, 0.08);
}

.patient-meta-pill small {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.patient-meta-pill strong {
    font-size: 1rem;
    color: var(--navy-900);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

.patient-meta-pill.highlight {
    background: linear-gradient(135deg, rgba(16, 35, 60, 0.95), rgba(30, 58, 95, 0.92));
    border-color: transparent;
}

.patient-meta-pill.highlight small,
.patient-meta-pill.highlight strong {
    color: #fdfaf5;
}

.patient-focus-strip {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
    margin-top: 26px;
}

.patient-focus-card {
    display: grid;
    gap: 8px;
    padding: 20px 22px;
    border-radius: 20px;
    border: 1px solid rgba(16, 35, 60, 0.08);
    box-shadow: 0 16px 36px rgba(16, 35, 60, 0.06);
}

.patient-focus-card span {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    font-weight: 700;
}

.patient-focus-card strong {
    font-size: clamp(1.15rem, 1.4vw, 1.45rem);
    color: var(--navy-900);
    line-height: 1.35;
}

.patient-focus-card small {
    color: var(--muted);
    line-height: 1.6;
}

.patient-focus-card.soft-navy {
    background: linear-gradient(135deg, rgba(16, 35, 60, 0.92), rgba(32, 58, 94, 0.88));
}

.patient-focus-card.soft-navy span,
.patient-focus-card.soft-navy strong,
.patient-focus-card.soft-navy small {
    color: #fdfaf5;
}

.patient-focus-card.soft-beige {
    background: linear-gradient(135deg, rgba(223, 205, 176, 0.34), rgba(255, 250, 242, 0.96));
}

.patient-focus-card.soft-cream {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(244, 236, 222, 0.9));
}

.patient-chart-tabs {
    margin-bottom: 28px;
}

.patient-chart-tabs .chart-tab {
    padding: 13px 20px;
    border: 1px solid rgba(16, 35, 60, 0.07);
    box-shadow: 0 10px 24px rgba(16, 35, 60, 0.04);
}

.patient-chart-tabs .chart-tab.active {
    box-shadow: 0 16px 30px rgba(16, 35, 60, 0.14);
}

@media (max-width: 1100px) {
    .patient-chart-header {
        flex-direction: column;
    }

    .patient-chart-meta {
        justify-content: flex-start;
    }

    .patient-focus-strip {
        grid-template-columns: 1fr;
    }
}

.chart-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.chart-tab:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(16, 35, 60, 0.08);
}

.anamnesis-print-actions {
    justify-content: flex-end;
}

.print-trigger {
    min-width: 220px;
}

@media print {
    body.public-anamnesis-page {
        background: #ffffff !important;
    }

    .advanced-form-shell {
        width: 100%;
        max-width: none;
        padding: 0;
        margin: 0;
    }

    .advanced-form-panel,
    .section-answer-card,
    .form-section-card,
    .panel {
        background: #ffffff !important;
        border: 1px solid #d9dee7 !important;
        box-shadow: none !important;
    }

    .anamnesis-actions,
    .alert {
        display: none !important;
    }

    .answer-sections-grid {
        grid-template-columns: 1fr !important;
    }

    .uploaded-file-item,
    .section-answer-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    a {
        color: #10233c !important;
        text-decoration: none !important;
    }
}

.financial-page-layout {
    grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
    align-items: start;
}

.financial-dashboard-panel {
    grid-column: 1 / -1;
}

.financial-summary-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.financial-form-grid,
.patient-financial-form {
    gap: 16px;
}

.financial-record-list {
    display: grid;
    gap: 14px;
}

.financial-record-card {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 20px;
    border-radius: 18px;
    background: rgba(16, 35, 60, 0.03);
    border: 1px solid rgba(16, 35, 60, 0.08);
}

.financial-record-main {
    display: grid;
    gap: 6px;
}

.financial-record-main span,
.financial-record-main small {
    color: var(--muted);
    line-height: 1.6;
}

.financial-record-meta {
    display: grid;
    justify-items: end;
    align-content: start;
    gap: 10px;
    text-align: right;
}

.financial-record-meta strong {
    font-size: 1.05rem;
    color: var(--navy-900);
}

.financial-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.financial-filters select {
    min-width: 170px;
}

.patient-financial-summary-grid {
    margin-bottom: 20px;
    grid-template-columns: repeat(3, minmax(240px, 1fr));
}

.patient-financial-summary-grid .stat-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 14px;
    min-height: 210px;
}

.patient-financial-summary-grid .stat-card p {
    margin: 0;
}

.patient-financial-summary-grid .stat-card strong {
    margin-top: auto;
    margin-bottom: 0;
    text-align: left;
    white-space: nowrap;
}

.patient-financial-summary-grid .stat-card span {
    display: block;
    margin: 0;
}

.catalog-item-field small {
    color: var(--muted);
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.5;
    margin-top: 2px;
}

.catalog-item-picker {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(0, 1fr) auto;
}

.catalog-add-button {
    white-space: nowrap;
}

.catalog-selected-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.catalog-selected-list > span {
    background: rgba(16, 35, 60, 0.04);
    border: 1px dashed rgba(16, 35, 60, 0.16);
    border-radius: 14px;
    color: var(--muted);
    padding: 12px 14px;
}

.catalog-selected-item {
    align-items: center;
    background: rgba(245, 239, 228, 0.82);
    border: 1px solid var(--border);
    border-radius: 14px;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    padding: 10px 12px;
}

.catalog-selected-item strong {
    color: var(--navy-900);
    font-size: 0.94rem;
    line-height: 1.35;
}

.catalog-selected-item button {
    background: rgba(142, 44, 44, 0.08);
    border: 0;
    border-radius: 999px;
    color: #8e2c2c;
    cursor: pointer;
    font-weight: 700;
    padding: 8px 12px;
}

@media (max-width: 720px) {
    .catalog-item-picker {
        grid-template-columns: 1fr;
    }
}

.patient-financial-record-list {
    margin-top: 20px;
}

.chart-patient-search-panel {
    margin: 0 auto;
    max-width: 720px;
    width: 100%;
}

.chart-patient-search-form {
    margin-top: 18px;
}

.chart-patient-search-form .patient-search-field {
    z-index: 90;
}

@media (max-width: 1180px) {
    .financial-page-layout,
    .financial-summary-grid {
        grid-template-columns: 1fr;
    }

    
}

@media (max-width: 860px) {
    .financial-record-card {
        flex-direction: column;
    }

    .financial-record-meta {
        justify-items: start;
        text-align: left;
    }
}

.financial-record-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.financial-record-actions form {
    margin: 0;
}

.financial-record-actions .btn-inline {
    white-space: nowrap;
}

@media (max-width: 860px) {
    .financial-record-actions {
        justify-content: flex-start;
    }
}


.chart-upload-form {
    margin-top: 20px;
    display: grid;
    gap: 14px;
}

.upload-more-card {
    position: relative;
    display: grid;
    gap: 8px;
    padding: 20px;
    border: 1px dashed rgba(16, 35, 60, 0.22);
    border-radius: 18px;
    background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(246,239,226,0.9));
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.upload-more-card:hover {
    transform: translateY(-1px);
    border-color: rgba(16, 35, 60, 0.35);
    box-shadow: 0 16px 28px rgba(15, 35, 60, 0.10);
}

.upload-more-card {
    border: 0;
}


.upload-more-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: rgba(16, 35, 60, 0.1);
    color: var(--navy-900);
    font-size: 1.6rem;
    font-weight: 700;
}

.upload-more-card strong {
    color: var(--navy-950);
    font-size: 1rem;
}

.upload-more-card small {
    color: var(--muted);
    line-height: 1.5;
}

.patients-directory-page,
.patient-form-page {
    display: block;
    min-width: 0;
}

.patients-directory-panel {
    overflow: hidden;
}

.patients-directory-toolbar,
.patient-form-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.patients-directory-actions {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.patients-directory-search {
    width: min(100%, 520px);
}

.patients-directory-panel .panel-subtitle {
    max-width: 720px;
}

.patients-directory-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.patients-directory-wrap {
    overflow-x: auto;
    max-width: 100%;
    position: relative;
    border-radius: 18px;
}

.patients-directory-table {
    min-width: 1180px;
}

.patients-directory-table td,
.patients-directory-table th {
    white-space: nowrap;
}

.patients-directory-table td:first-child,
.patients-directory-table th:first-child {
    min-width: 240px;
}

.patients-directory-table td:nth-child(4),
.patients-directory-table th:nth-child(4) {
    min-width: 220px;
}

.patients-directory-table td:last-child,
.patients-directory-table th:last-child {
    width: 280px;
    min-width: 280px;
    position: sticky;
    right: 0;
    z-index: 1;
    background: rgba(255, 252, 246, 0.98);
    box-shadow: -16px 0 24px rgba(16, 35, 60, 0.06);
}

.patients-directory-table th:last-child {
    z-index: 2;
}

.patients-directory-table .table-actions {
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    min-width: 250px;
}

.patients-directory-table .table-actions form {
    display: flex;
    margin: 0;
}

.patients-directory-table .btn-inline {
    min-width: max-content;
    padding: 9px 12px;
    white-space: nowrap;
    overflow-wrap: normal;
}

.patient-name-cell strong {
    display: block;
    color: var(--navy-950);
}

.patient-form-shell {
    max-width: 960px;
    margin: 0 auto;
}

.patient-form-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.patient-form-grid-expanded {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 900px) {
    .patients-directory-toolbar,
    .patient-form-heading,
    .patients-directory-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .patients-directory-search {
        width: 100%;
    }

    .patient-form-grid-expanded {
        grid-template-columns: 1fr;
    }
}

.chart-focus-layout {
    grid-template-columns: minmax(0, 1fr);
}

.chart-main-column-expanded {
    max-width: 100%;
}

.patient-chart-topline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.selected-upload-files {
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(16, 35, 60, 0.05);
    border: 1px solid rgba(16, 35, 60, 0.08);
    line-height: 1.5;
    word-break: break-word;
}

.uploaded-file-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.uploaded-file-actions form {
    margin: 0;
}
.patient-imported-details {
    display: grid;
    gap: 14px;
    margin-top: 22px;
    padding: 18px;
    border: 1px solid rgba(18, 45, 73, 0.10);
    border-radius: 22px;
    background: rgba(246, 241, 232, 0.72);
    margin-bottom: 26px;
}

.patient-imported-details strong {
    display: block;
    margin-bottom: 6px;
    color: var(--navy);
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.patient-imported-details p {
    margin: 0;
    color: var(--muted);
    line-height: 1.65;
}
.patient-meta-wide {
    min-width: min(100%, 240px);
}

.patient-meta-wide strong {
    overflow-wrap: anywhere;
}

/* select-visual-align-fix */
.form-grid select,
.financial-form-grid select,
.patient-financial-form select,
.agenda-form-grid select {
  min-height: 50px;
  appearance: auto;
}

.form-grid textarea {
  min-height: 112px;
  resize: vertical;
}
.catalog-page {
    grid-template-columns: minmax(320px, 0.9fr) minmax(520px, 1.6fr);
    align-items: start;
}

.catalog-form-panel,
.catalog-list-panel {
    min-width: 0;
}

.catalog-toolbar {
    gap: 22px;
    align-items: flex-start;
}

.catalog-search {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.catalog-search input {
    min-width: 240px;
}

.catalog-search select {
    min-width: 170px;
}

.catalog-stats {
    margin: 18px 0 22px;
}

.catalog-table td:first-child strong {
    display: block;
    max-width: 420px;
}

.catalog-table td:first-child small {
    display: block;
    margin-top: 6px;
}

.checkbox-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid rgba(18, 45, 73, 0.12);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.55);
}

.checkbox-card input {
    width: auto;
}

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

    .catalog-search {
        justify-content: stretch;
    }

    .catalog-search input,
    .catalog-search select,
    .catalog-search button {
        width: 100%;
    }
}

.medical-page-layout {
    grid-template-columns: minmax(0, 920px);
    align-items: start;
    justify-content: center;
}

.medical-form-panel {
    min-width: 0;
    width: 100%;
}

.medical-document-form .patient-search-field {
    max-width: 100%;
    z-index: 80;
}

.medical-document-form .patient-search-box {
    width: 100%;
}

.medical-document-form .patient-search-results,
.medical-document-form .patient-search-empty {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    z-index: 120;
}

.medical-document-form .patient-search-field {
    margin-bottom: 6px;
}

.medical-document-form textarea {
    min-height: 280px;
    line-height: 1.65;
}

.medical-signature-preview {
    border: 1px dashed rgba(16, 35, 60, 0.24);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.62);
    padding: 18px;
    display: grid;
    gap: 4px;
}

.medical-signature-preview span,
.medical-patient-card span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.medical-signature-preview strong {
    color: var(--navy-950);
    font-size: 1.15rem;
}

.medical-signature-preview small {
    color: var(--muted);
}

.medical-patient-card {
    display: grid;
    gap: 7px;
    padding: 18px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid var(--border);
}

.medical-patient-card strong {
    margin-bottom: 8px;
    color: var(--navy-950);
}

.medical-history-list {
    margin-top: 22px;
    display: grid;
    gap: 12px;
}

.medical-history-list h4 {
    margin: 0;
    color: var(--navy-950);
}

.medical-history-item {
    display: grid;
    gap: 5px;
    padding: 14px;
    border-radius: var(--radius-sm);
    background: rgba(16, 35, 60, 0.06);
    color: var(--navy-950);
}

.medical-history-item span {
    color: var(--muted);
    font-size: 0.9rem;
}

.medical-document-list {
    display: grid;
    gap: 12px;
}

.medical-document-card {
    background: rgba(255, 255, 255, 0.68);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) auto;
    padding: 16px 18px;
}

.medical-document-info,
.medical-document-actions {
    display: grid;
    gap: 5px;
}

.medical-document-info > span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.medical-document-card strong {
    color: var(--navy-950);
}

.medical-document-card small {
    color: var(--muted);
}

.medical-document-actions {
    align-items: center;
    justify-items: end;
}

.medical-document-actions .status-pill {
    letter-spacing: 0;
    text-transform: none;
}

.medical-signature-upload-form {
    align-items: end;
    border-top: 1px dashed var(--border);
    display: grid;
    gap: 12px;
    grid-column: 1 / -1;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) auto;
    padding-top: 14px;
}

.medical-signature-upload-form label {
    color: var(--navy-900);
    display: grid;
    font-size: 0.88rem;
    font-weight: 700;
    gap: 8px;
}

.medical-signature-upload-form input {
    width: 100%;
}

@media (max-width: 720px) {
    .medical-document-card {
        align-items: flex-start;
        grid-template-columns: 1fr;
    }

    .medical-document-actions {
        justify-items: start;
    }

    .medical-signature-upload-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .medical-page-layout {
        grid-template-columns: 1fr;
    }
}

.catalog-list-page {
    grid-template-columns: 1fr;
}

.catalog-list-page .catalog-list-panel {
    width: 100%;
}

.catalog-toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.catalog-search-wide {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(180px, 240px) auto auto;
    gap: 12px;
    align-items: center;
    margin: 18px 0 4px;
}

.catalog-search-wide input,
.catalog-search-wide select {
    width: 100%;
}

.catalog-form-page {
    grid-template-columns: minmax(0, 880px);
    justify-content: center;
}

.standalone-form-panel {
    width: 100%;
}

.expanded-catalog-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.expanded-catalog-form .full-span {
    grid-column: 1 / -1;
}

@media (max-width: 980px) {
    .catalog-search-wide,
    .expanded-catalog-form {
        grid-template-columns: 1fr;
    }

    .catalog-toolbar-actions,
    .catalog-toolbar-actions .btn-primary {
        width: 100%;
    }
}

.medical-item-builder {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid rgba(16, 35, 60, 0.12);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.62);
}

.medical-item-builder-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.medical-item-builder-head strong {
    display: block;
    color: var(--navy-950);
    font-size: 1rem;
}

.medical-item-builder-head small {
    color: var(--muted);
    max-width: 240px;
    text-align: right;
}

.medical-item-picker {
    display: grid;
    grid-template-columns: minmax(170px, 0.7fr) minmax(260px, 1.3fr) auto;
    gap: 12px;
    align-items: end;
}

.medical-selected-list {
    display: grid;
    gap: 8px;
}

.medical-selected-list > span {
    background: rgba(16, 35, 60, 0.04);
    border: 1px dashed rgba(16, 35, 60, 0.16);
    border-radius: 14px;
    color: var(--muted);
    padding: 13px 14px;
}

.medical-selected-item strong {
    overflow-wrap: anywhere;
}

@media (max-width: 980px) {
    .medical-item-builder-head,
    .medical-item-picker {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .medical-item-builder-head small {
        max-width: none;
        text-align: left;
    }
}
.nutrition-combo-builder {
    display: grid;
    gap: 14px;
    padding: 18px;
    border: 1px solid rgba(16, 35, 60, 0.12);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.62);
}

.nutrition-combo-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.nutrition-combo-head strong {
    display: block;
    color: var(--navy-950);
    font-size: 1rem;
}

.nutrition-combo-head small {
    color: var(--muted);
    max-width: 320px;
    text-align: right;
}

.nutrition-combo-picker {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 12px;
    align-items: end;
}

.nutrition-combo-preview {
    display: grid;
    gap: 10px;
    padding: 16px;
    border-radius: var(--radius-sm);
    background: rgba(16, 35, 60, 0.04);
    border: 1px dashed rgba(16, 35, 60, 0.14);
}

.nutrition-combo-preview strong {
    color: var(--navy-950);
}

.nutrition-combo-preview p,
.nutrition-combo-preview li,
.nutrition-combo-chip small {
    color: var(--muted);
}

.nutrition-combo-preview ul,
.nutrition-combo-inserted-list {
    display: grid;
    gap: 8px;
    margin: 0;
    padding-left: 18px;
}

.nutrition-combo-inserted-list {
    padding-left: 0;
}

.nutrition-combo-inserted-list > span {
    background: rgba(16, 35, 60, 0.04);
    border: 1px dashed rgba(16, 35, 60, 0.16);
    border-radius: 14px;
    color: var(--muted);
    padding: 13px 14px;
}

.nutrition-combo-chip {
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid var(--border);
}

.nutrition-combo-chip strong {
    color: var(--navy-950);
}
@media (max-width: 720px) {
    .nutrition-combo-head,
    .nutrition-combo-picker {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .nutrition-combo-head small {
        max-width: none;
        text-align: left;
    }
}

/* Usuarios e acessos */
.sidebar-account-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.sidebar-account-actions > a:not(.logout-link) {
    color: rgba(255, 255, 255, 0.68);
    font-size: 0.86rem;
}

.access-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
    background:
        radial-gradient(circle at right top, rgba(222, 200, 168, 0.52), transparent 34%),
        rgba(255, 252, 246, 0.9);
}

.access-hero h3,
.temporary-access-card h3,
.access-user-title h4 {
    margin: 0;
    color: var(--navy-950);
}

.access-alert,
.temporary-access-card,
.access-stats {
    margin-bottom: 22px;
}

.temporary-access-card {
    padding: 24px 28px;
    border-radius: var(--radius-lg);
    color: var(--navy-950);
    background: linear-gradient(135deg, rgba(222, 200, 168, 0.88), rgba(247, 242, 232, 0.96));
    border: 1px solid rgba(16, 35, 60, 0.12);
    box-shadow: var(--shadow);
}

.temporary-access-card p {
    margin: 12px 0 8px;
}

.temporary-access-card code {
    display: inline-block;
    padding: 9px 13px;
    border-radius: 10px;
    background: var(--navy-950);
    color: var(--white);
    font-size: 1.05rem;
    letter-spacing: 0.06em;
    user-select: all;
}

.temporary-access-card span,
.panel-subtitle,
.access-user-main p,
.access-user-main span,
.access-card-footer small {
    color: var(--muted);
}

.panel-subtitle {
    margin: 8px 0 0;
    line-height: 1.55;
}

.access-management-grid {
    grid-template-columns: minmax(0, 1.08fr) minmax(380px, 0.92fr);
    align-items: start;
}

.access-form-panel,
.access-list-panel {
    min-width: 0;
}

.access-fields-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.access-fields-grid .field-wide {
    grid-column: 1 / -1;
}

.access-switches {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.access-switches label,
.permission-card {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    cursor: pointer;
}

.access-switches input,
.permission-card input {
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    flex: 0 0 auto;
    accent-color: var(--navy-700);
}

.access-switches span,
.permission-card span {
    display: grid;
    gap: 4px;
}

.access-switches small,
.permission-card small {
    color: var(--muted);
    font-weight: 400;
    line-height: 1.4;
}

.permission-fieldset {
    margin: 0;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.permission-fieldset legend {
    padding: 0 8px;
    color: var(--navy-950);
    font-weight: 700;
}

.permission-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.permission-heading p {
    margin: 0;
    color: var(--muted);
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 11px;
}

.access-user-list {
    display: grid;
    gap: 14px;
}

.access-user-card {
    display: grid;
    gap: 15px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.7);
}

.access-user-card.is-inactive {
    opacity: 0.68;
    background: rgba(16, 35, 60, 0.035);
}

.access-user-main {
    display: flex;
    align-items: center;
    gap: 13px;
}

.access-avatar {
    width: 46px;
    height: 46px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    color: var(--white);
    background: linear-gradient(135deg, var(--navy-900), var(--navy-700));
    font-weight: 800;
}

.access-user-main > div:last-child {
    min-width: 0;
    flex: 1;
}

.access-user-main p {
    margin: 5px 0 3px;
    overflow-wrap: anywhere;
}

.access-user-title,
.access-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.access-module-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.access-module-tags span {
    padding: 6px 9px;
    border-radius: 999px;
    background: rgba(45, 82, 120, 0.09);
    color: var(--navy-700);
    font-size: 0.76rem;
    font-weight: 700;
}

.access-card-footer {
    align-items: flex-end;
    padding-top: 13px;
    border-top: 1px solid rgba(16, 35, 60, 0.08);
}

.password-layout {
    max-width: 980px;
}

.protected-credential {
    display: block;
    margin-top: 6px;
    color: #287052;
    font-size: 0.78rem;
    font-weight: 700;
}

.google-connection-panel {
    display: grid;
    gap: 20px;
}

.google-connection-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.google-connection-grid code {
    display: block;
    margin-top: 7px;
    color: var(--navy-700);
    overflow-wrap: anywhere;
}

.google-connection-actions,
.google-connection-actions form {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0;
}

.btn-primary.is-disabled,
.btn-secondary.is-disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.section-heading > .form-actions {
    margin-top: 14px;
}

.memed-status-block.warning {
    background: rgba(222, 200, 168, 0.28);
}

.memed-prescription-container {
    min-height: 420px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px dashed rgba(16, 35, 60, 0.16);
}

.password-field {
    position: relative;
    display: block;
}

.password-field input {
    padding-right: 48px;
    width: 100%;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 999px;
    background: rgba(26, 70, 111, 0.08);
    color: var(--navy);
    cursor: pointer;
    transform: translateY(-50%);
}

.password-toggle:hover {
    background: rgba(26, 70, 111, 0.15);
}

.forgot-password-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--navy-700);
    font-size: 0.92rem;
    font-weight: 700;
    text-decoration: none;
}

.forgot-password-link:hover {
    text-decoration: underline;
}

.password-reset-requests-panel {
    margin-bottom: 22px;
}

.password-reset-request-list {
    display: grid;
    gap: 12px;
}

.password-reset-request-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px;
    border: 1px solid rgba(190, 158, 98, 0.34);
    border-radius: 18px;
    background: rgba(249, 239, 222, 0.78);
}

.password-reset-request-card div {
    display: grid;
    gap: 4px;
}

.password-reset-request-card strong {
    color: var(--navy);
}

.password-reset-request-card span,
.password-reset-request-card small {
    color: var(--muted);
}

.whatsapp-history-panel {
    scroll-margin-top: 24px;
}

.whatsapp-quick-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 18px 0;
}

.whatsapp-api-summary {
    margin-top: 14px;
}

.whatsapp-automation-panel {
    display: grid;
    gap: 18px;
}

.whatsapp-automation-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.whatsapp-cron-box {
    padding: 16px;
    border: 1px dashed rgba(37, 211, 102, 0.42);
    border-radius: 18px;
    background: rgba(37, 211, 102, 0.08);
}

.whatsapp-cron-box div {
    display: grid;
    gap: 7px;
}

.whatsapp-cron-box strong {
    color: var(--navy);
}

.whatsapp-cron-box span {
    color: var(--muted);
}

.whatsapp-cron-box code {
    display: block;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.74);
    color: var(--navy-700);
    overflow-wrap: anywhere;
}

.whatsapp-queue-list {
    display: grid;
    gap: 12px;
}

.whatsapp-queue-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.74);
}

.whatsapp-queue-card p {
    margin: 0;
    color: var(--text);
    line-height: 1.55;
}

.whatsapp-queue-error {
    display: block;
    margin-top: 8px;
    color: #a34848;
    font-weight: 700;
}

.whatsapp-care-note {
    margin-bottom: 18px;
    border-left: 4px solid #25d366;
}

.whatsapp-log-form {
    margin-bottom: 22px;
}

.whatsapp-message-list {
    display: grid;
    gap: 14px;
}

.whatsapp-message-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: start;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
}

.whatsapp-message-head {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.whatsapp-message-card p {
    margin: 0 0 8px;
    color: var(--text);
    line-height: 1.6;
}

.whatsapp-message-card small,
.whatsapp-message-meta {
    color: var(--muted);
}

.whatsapp-message-meta {
    display: grid;
    gap: 4px;
    justify-items: end;
    font-size: 0.86rem;
    white-space: nowrap;
}

.whatsapp-command-page {
    grid-template-columns: minmax(300px, 0.82fr) minmax(420px, 1.18fr);
}

.whatsapp-command-hero {
    margin-bottom: 4px;
}

.whatsapp-device-steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0;
}

.whatsapp-command-search,
.whatsapp-command-workspace {
    min-width: 0;
}

.whatsapp-patient-list {
    display: grid;
    gap: 12px;
    margin-top: 16px;
}

.whatsapp-patient-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px;
    border: 1px solid rgba(16, 35, 60, 0.1);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    color: inherit;
    text-decoration: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.whatsapp-patient-card:hover,
.whatsapp-patient-card.active {
    border-color: rgba(190, 158, 98, 0.52);
    box-shadow: 0 14px 28px rgba(16, 35, 60, 0.08);
    transform: translateY(-1px);
}

.whatsapp-patient-card div {
    display: grid;
    gap: 4px;
}

.whatsapp-patient-card strong {
    color: var(--navy);
}

.whatsapp-patient-card small {
    color: var(--muted);
}

.whatsapp-command-empty {
    min-height: 220px;
    display: grid;
    place-items: center;
    text-align: center;
}

.whatsapp-action-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.whatsapp-action-grid .btn-primary,
.whatsapp-action-grid .btn-secondary {
    justify-content: center;
}

.whatsapp-next-appointment {
    margin-bottom: 18px;
}

.whatsapp-register-form {
    margin-top: 18px;
}

.wesales-bridge-page {
    grid-template-columns: 1fr;
}

.wesales-bridge-heading {
    align-items: flex-start;
}

.wesales-bridge-search {
    margin: 20px 0;
}

.wesales-flow-grid {
    margin-top: 14px;
}

.wesales-bridge-card {
    display: grid;
    gap: 20px;
}

.wesales-bridge-grid {
    display: grid;
    grid-template-columns: minmax(260px, 0.9fr) minmax(320px, 1.4fr);
    gap: 18px;
}

.wesales-contact-facts,
.wesales-linked-patient {
    display: grid;
    gap: 8px;
    margin-top: 12px;
    color: var(--muted);
}

.wesales-linked-patient strong {
    color: var(--navy);
}

.wesales-link-list {
    display: grid;
    gap: 12px;
    margin-top: 14px;
}

.wesales-link-option {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid rgba(16, 35, 60, 0.1);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.72);
}

.wesales-link-option strong {
    display: block;
    color: var(--navy);
}

.wesales-link-option small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.4;
}

.attendance-page {
    grid-template-columns: 1fr;
}

.attendance-hero {
    margin-bottom: 6px;
}

.attendance-shell {
    display: grid;
    grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.35fr) minmax(300px, 0.95fr);
    gap: 18px;
    align-items: stretch;
    min-width: 0;
}

.attendance-inbox,
.attendance-chat-panel,
.attendance-patient-panel {
    min-width: 0;
}

.attendance-inbox-head,
.attendance-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.attendance-search {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-bottom: 16px;
}

.attendance-thread-list,
.attendance-message-list,
.attendance-suggestion-list,
.attendance-actions,
.attendance-contact-facts {
    display: grid;
    gap: 12px;
}

.attendance-thread {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 14px;
    border: 1px solid rgba(16, 35, 60, 0.09);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.76);
    color: inherit;
    text-decoration: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.attendance-thread:hover,
.attendance-thread.active {
    border-color: rgba(190, 158, 98, 0.52);
    box-shadow: 0 14px 28px rgba(16, 35, 60, 0.08);
    transform: translateY(-1px);
}

.attendance-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--navy), #2b5b88);
    color: #fff;
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.attendance-avatar.large {
    width: 56px;
    height: 56px;
    font-size: 1rem;
}

.attendance-thread-main {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.attendance-thread-main strong,
.attendance-linked-card strong,
.attendance-suggestion-card strong {
    color: var(--navy);
}

.attendance-thread-main small,
.attendance-thread-main em,
.attendance-thread-side small,
.attendance-contact-facts,
.attendance-linked-card small,
.attendance-suggestion-card small {
    color: var(--muted);
}

.attendance-thread-main em {
    font-style: normal;
    line-height: 1.35;
}

.attendance-thread-side {
    display: grid;
    justify-items: end;
    gap: 8px;
    min-width: 92px;
}

.attendance-contact-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 16px 0;
    padding: 14px;
    border-radius: 18px;
    background: rgba(249, 239, 222, 0.58);
    font-size: 0.92rem;
}

.attendance-conversation-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.attendance-conversation-tabs a {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--navy);
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
}

.attendance-conversation-tabs a.active {
    border-color: var(--gold);
    background: rgba(190, 158, 98, 0.18);
}

.attendance-message {
    max-width: 88%;
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(16, 35, 60, 0.08);
    background: rgba(255, 255, 255, 0.82);
}

.attendance-message.outbound {
    justify-self: end;
    background: rgba(26, 70, 111, 0.08);
}

.attendance-message.inbound {
    justify-self: start;
    background: rgba(249, 239, 222, 0.72);
}

.attendance-message-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 0.84rem;
}

.attendance-message p {
    margin: 0;
    color: var(--text);
    line-height: 1.55;
}

.attendance-attachment {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px dashed rgba(16, 35, 60, 0.16);
    font-size: 0.92rem;
}

.attendance-attachment a {
    color: var(--navy);
    font-weight: 700;
    text-decoration: none;
}

.attendance-send-form,
.attendance-manual-log {
    display: grid;
    gap: 14px;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(16, 35, 60, 0.08);
}

.attendance-send-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.75fr) minmax(0, 1fr);
    gap: 12px;
}

.attendance-send-form label,
.attendance-manual-log label,
.attendance-file-field {
    display: grid;
    gap: 8px;
    color: var(--navy);
    font-weight: 700;
}

.attendance-send-form textarea,
.attendance-send-form select,
.attendance-send-form input[type="file"],
.attendance-manual-log textarea {
    width: 100%;
}

.attendance-file-field {
    padding: 14px;
    border: 1px dashed rgba(16, 35, 60, 0.18);
    border-radius: 18px;
    background: rgba(249, 239, 222, 0.38);
}

.attendance-file-field small {
    color: var(--muted);
    font-weight: 500;
}

.attendance-linked-card,
.attendance-suggestion-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid rgba(16, 35, 60, 0.1);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.78);
}

.attendance-suggestion-card {
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
}

.attendance-actions {
    margin-top: 16px;
}

.attendance-actions .btn-primary,
.attendance-actions .btn-secondary {
    width: 100%;
    justify-content: center;
}

.attendance-empty {
    padding: 18px;
    border-radius: 18px;
}

@media (max-width: 1180px) {
    .access-management-grid {
        grid-template-columns: 1fr;
    }

    .attendance-shell {
        grid-template-columns: 1fr;
    }

    .attendance-contact-facts {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .access-hero,
    .access-user-title,
    .access-card-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .access-fields-grid,
    .permission-grid,
    .access-switches {
        grid-template-columns: 1fr;
    }

    .permission-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .google-connection-grid {
        grid-template-columns: 1fr;
    }

    .google-connection-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .access-management-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .password-reset-request-card {
        align-items: stretch;
        flex-direction: column;
    }

    .whatsapp-automation-grid,
    .whatsapp-command-page,
    .whatsapp-device-steps,
    .whatsapp-action-grid {
        grid-template-columns: 1fr;
    }

    .whatsapp-patient-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .whatsapp-message-card,
    .whatsapp-queue-card {
        grid-template-columns: 1fr;
    }

    .whatsapp-message-meta {
        justify-items: start;
        white-space: normal;
    }

    .wesales-bridge-grid,
    .wesales-link-option,
    .attendance-search,
    .attendance-thread,
    .attendance-send-grid,
    .attendance-suggestion-card {
        grid-template-columns: 1fr;
    }

    .attendance-thread-side {
        justify-items: start;
    }

    .attendance-message {
        max-width: 100%;
    }
}

/* Life&Cor stage28 - Agenda mais horizontal em telas estreitas */
@media (max-width: 1180px) {
    .medical-agenda-layout {
        grid-template-areas:
            "form"
            "calendar"
            "details"
            "insights"
            "patients";
    }
}

@media (max-width: 860px) {
    .agenda-sidebar-panel .agenda-form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .agenda-sidebar-panel .patient-search-field.full-span,
    .agenda-sidebar-panel .agenda-form-grid > label.full-span,
    .agenda-sidebar-panel .teleconsultation-hint.full-span,
    .agenda-sidebar-panel .form-actions.full-span {
        grid-column: 1 / -1;
    }
}

@media (max-width: 620px) {
    .agenda-sidebar-panel .agenda-form-grid {
        grid-template-columns: 1fr;
    }
}

/* Life&Cor stage29 - Tema visual por area do sistema */
body[class^="page-"] {
    --page-accent: #2d5278;
    --page-accent-rgb: 45, 82, 120;
    --page-accent-strong: #163252;
    --page-accent-soft: rgba(var(--page-accent-rgb), 0.12);
    --page-accent-faint: rgba(var(--page-accent-rgb), 0.06);
    --page-wash: #f5f8fb;
    --page-sidebar-top: #10233c;
    --page-sidebar-bottom: #163252;
}

body.page-dashboard {
    --page-accent: #2d5278;
    --page-accent-rgb: 45, 82, 120;
    --page-accent-strong: #10233c;
    --page-wash: #f4f8fc;
    --page-sidebar-top: #10233c;
    --page-sidebar-bottom: #214667;
}

body.page-patients {
    --page-accent: #0f766e;
    --page-accent-rgb: 15, 118, 110;
    --page-accent-strong: #0b4f4a;
    --page-wash: #f0faf8;
    --page-sidebar-top: #0f2f3a;
    --page-sidebar-bottom: #0f5f5a;
}

body.page-agenda {
    --page-accent: #b7791f;
    --page-accent-rgb: 183, 121, 31;
    --page-accent-strong: #7c4f12;
    --page-wash: #fff8ea;
    --page-sidebar-top: #14263d;
    --page-sidebar-bottom: #6d4b1c;
}

body.page-atendimento {
    --page-accent: #16834a;
    --page-accent-rgb: 22, 131, 74;
    --page-accent-strong: #0f5c35;
    --page-wash: #f0fbf5;
    --page-sidebar-top: #102d35;
    --page-sidebar-bottom: #11643f;
}

body.page-prontuario {
    --page-accent: #6657c8;
    --page-accent-rgb: 102, 87, 200;
    --page-accent-strong: #40368c;
    --page-wash: #f6f4ff;
    --page-sidebar-top: #14233f;
    --page-sidebar-bottom: #4c428f;
}

body.page-medico {
    --page-accent: #9b3f68;
    --page-accent-rgb: 155, 63, 104;
    --page-accent-strong: #6b2b48;
    --page-wash: #fff3f7;
    --page-sidebar-top: #18263d;
    --page-sidebar-bottom: #743451;
}

body.page-financeiro {
    --page-accent: #7a6a22;
    --page-accent-rgb: 122, 106, 34;
    --page-accent-strong: #534817;
    --page-wash: #fbf8ea;
    --page-sidebar-top: #15293d;
    --page-sidebar-bottom: #5c5121;
}

body.page-catalog {
    --page-accent: #276d85;
    --page-accent-rgb: 39, 109, 133;
    --page-accent-strong: #17475a;
    --page-wash: #eef8fb;
    --page-sidebar-top: #10233c;
    --page-sidebar-bottom: #19566b;
}

body.page-integrations {
    --page-accent: #6d5bd0;
    --page-accent-rgb: 109, 91, 208;
    --page-accent-strong: #43338f;
    --page-wash: #f6f4ff;
    --page-sidebar-top: #14233f;
    --page-sidebar-bottom: #50449f;
}

body.page-users {
    --page-accent: #b65f4d;
    --page-accent-rgb: 182, 95, 77;
    --page-accent-strong: #7b3b2f;
    --page-wash: #fff5f1;
    --page-sidebar-top: #14233f;
    --page-sidebar-bottom: #804235;
}

body[class^="page-"]:not(.login-body):not(.public-anamnesis-page) {
    background:
        radial-gradient(circle at 88% 4%, rgba(var(--page-accent-rgb), 0.2), transparent 28%),
        radial-gradient(circle at 5% 10%, rgba(222, 200, 168, 0.48), transparent 30%),
        linear-gradient(135deg, var(--page-wash) 0%, #fbf7ef 48%, #efe3cf 100%);
}

body[class^="page-"] .sidebar {
    background:
        radial-gradient(circle at 20% 0%, rgba(var(--page-accent-rgb), 0.38), transparent 28%),
        linear-gradient(180deg, var(--page-sidebar-top), var(--page-sidebar-bottom));
}

body[class^="page-"] .brand-card,
body[class^="page-"] .sidebar-footer {
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

body[class^="page-"] .nav-menu a {
    position: relative;
    transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

body[class^="page-"] .nav-menu a:hover {
    transform: translateX(3px);
}

body[class^="page-"] .nav-menu a.active {
    background:
        linear-gradient(135deg, rgba(var(--page-accent-rgb), 0.38), rgba(255, 255, 255, 0.12));
    box-shadow: inset 4px 0 0 rgba(255, 255, 255, 0.72);
}

body[class^="page-"] .topbar {
    padding: 18px 20px;
    border: 1px solid rgba(var(--page-accent-rgb), 0.14);
    border-radius: 28px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 252, 246, 0.88)),
        radial-gradient(circle at top right, rgba(var(--page-accent-rgb), 0.16), transparent 38%);
    box-shadow: 0 16px 36px rgba(var(--page-accent-rgb), 0.08);
}

body[class^="page-"] .topbar h2 {
    color: var(--navy-950);
}

body[class^="page-"] .topbar .eyebrow,
body[class^="page-"] .panel-heading .eyebrow,
body[class^="page-"] .eyebrow {
    color: var(--page-accent-strong);
}

body[class^="page-"] .topbar .eyebrow::before,
body[class^="page-"] .panel-heading .eyebrow::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 999px;
    background: var(--page-accent);
    box-shadow: 0 0 0 5px rgba(var(--page-accent-rgb), 0.12);
}

body[class^="page-"] .panel,
body[class^="page-"] .stat-card,
body[class^="page-"] .integration-card,
body[class^="page-"] .appointment-card,
body[class^="page-"] .patient-focus-card,
body[class^="page-"] .financial-record-card,
body[class^="page-"] .medical-document-card,
body[class^="page-"] .whatsapp-message-card,
body[class^="page-"] .section-answer-card,
body[class^="page-"] .form-section-card,
body[class^="page-"] .clinical-highlight-panel {
    border-color: rgba(var(--page-accent-rgb), 0.14);
    box-shadow:
        inset 0 4px 0 rgba(var(--page-accent-rgb), 0.2),
        0 18px 42px rgba(var(--page-accent-rgb), 0.07),
        0 10px 28px rgba(16, 35, 60, 0.08);
}

body[class^="page-"] .panel:nth-of-type(2n),
body[class^="page-"] .content-grid > .panel:nth-child(2n),
body[class^="page-"] .stats-grid > .stat-card:nth-child(2n) {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 252, 246, 0.9)),
        radial-gradient(circle at top right, rgba(var(--page-accent-rgb), 0.1), transparent 34%);
}

body[class^="page-"] .stats-grid > .stat-card:nth-child(1) {
    --card-accent-rgb: var(--page-accent-rgb);
}

body[class^="page-"] .stats-grid > .stat-card:nth-child(2) {
    --card-accent-rgb: 31, 122, 91;
}

body[class^="page-"] .stats-grid > .stat-card:nth-child(3) {
    --card-accent-rgb: 183, 121, 31;
}

body[class^="page-"] .stats-grid > .stat-card {
    box-shadow:
        inset 0 4px 0 rgba(var(--card-accent-rgb, var(--page-accent-rgb)), 0.24),
        0 18px 42px rgba(var(--card-accent-rgb, var(--page-accent-rgb)), 0.08);
}

body[class^="page-"] .btn-primary {
    background:
        linear-gradient(135deg, var(--page-accent-strong), var(--page-accent));
    box-shadow: 0 12px 22px rgba(var(--page-accent-rgb), 0.18);
}

body[class^="page-"] .btn-secondary,
body[class^="page-"] .status-pill.neutral,
body[class^="page-"] .patient-count-pill {
    background: rgba(var(--page-accent-rgb), 0.1);
    color: var(--page-accent-strong);
}

body[class^="page-"] input:focus,
body[class^="page-"] select:focus,
body[class^="page-"] textarea:focus {
    border-color: rgba(var(--page-accent-rgb), 0.55);
    box-shadow: 0 0 0 4px rgba(var(--page-accent-rgb), 0.12);
    outline: none;
}

body.page-agenda .calendar-day-header.today,
body.page-agenda .calendar-slot.selected,
body.page-agenda .appointment-detail-box {
    border-color: rgba(var(--page-accent-rgb), 0.22);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(var(--page-accent-rgb), 0.08));
}

body.page-agenda .calendar-event-card {
    background:
        linear-gradient(135deg, rgba(var(--page-accent-rgb), 0.16), rgba(255, 255, 255, 0.92));
    border-left-color: var(--page-accent);
}

body.page-patients .patient-directory-panel,
body.page-prontuario .patient-chart-shell,
body.page-atendimento .attendance-thread,
body.page-financeiro .financial-page-layout .panel,
body.page-medico .medical-page-layout .panel {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 252, 246, 0.9)),
        radial-gradient(circle at top right, rgba(var(--page-accent-rgb), 0.12), transparent 34%);
}

/* Life&Cor stage30 - Central WhatsApp estilo inbox clinico */
.attendance-command-strip {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.attendance-command-card {
    display: grid;
    gap: 5px;
    padding: 14px 16px;
    border: 1px solid rgba(var(--page-accent-rgb), 0.14);
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 252, 246, 0.78));
    color: var(--text);
}

.attendance-command-card span {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.attendance-command-card strong {
    color: var(--navy-950);
    line-height: 1.2;
}

.attendance-command-card.ready {
    border-color: rgba(31, 122, 91, 0.26);
    background:
        linear-gradient(180deg, rgba(240, 251, 245, 0.96), rgba(255, 255, 255, 0.82));
}

.attendance-command-card.pending {
    border-color: rgba(183, 121, 31, 0.26);
    background:
        linear-gradient(180deg, rgba(255, 248, 234, 0.98), rgba(255, 255, 255, 0.82));
}

.attendance-command-card.action {
    background:
        linear-gradient(135deg, var(--page-accent-strong), var(--page-accent));
    color: var(--white);
}

.attendance-command-card.action span,
.attendance-command-card.action strong {
    color: var(--white);
}

body.page-atendimento .attendance-shell {
    grid-template-columns: minmax(290px, 0.82fr) minmax(460px, 1.45fr) minmax(300px, 0.86fr);
}

body.page-atendimento .attendance-inbox,
body.page-atendimento .attendance-chat-panel,
body.page-atendimento .attendance-patient-panel {
    display: flex;
    flex-direction: column;
    min-height: 680px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 252, 246, 0.88)),
        radial-gradient(circle at top right, rgba(var(--page-accent-rgb), 0.1), transparent 36%);
}

body.page-atendimento .attendance-thread-list,
body.page-atendimento .attendance-message-list,
body.page-atendimento .attendance-suggestion-list {
    overflow: auto;
    padding-right: 4px;
}

body.page-atendimento .attendance-thread-list {
    max-height: 560px;
}

body.page-atendimento .attendance-message-list {
    flex: 1;
    min-height: 360px;
    max-height: 610px;
    padding: 18px;
    border: 1px solid rgba(var(--page-accent-rgb), 0.1);
    border-radius: 22px;
    background:
        radial-gradient(circle at top left, rgba(var(--page-accent-rgb), 0.08), transparent 36%),
        linear-gradient(180deg, rgba(247, 242, 232, 0.48), rgba(255, 255, 255, 0.78));
}

body.page-atendimento .attendance-thread {
    grid-template-columns: 46px minmax(0, 1fr);
    position: relative;
    padding-right: 14px;
}

body.page-atendimento .attendance-thread-side {
    grid-column: 2;
    grid-template-columns: auto auto;
    justify-content: space-between;
    justify-items: start;
    min-width: 0;
}

body.page-atendimento .attendance-thread.active {
    background:
        linear-gradient(135deg, rgba(var(--page-accent-rgb), 0.15), rgba(255, 255, 255, 0.92));
    border-color: rgba(var(--page-accent-rgb), 0.38);
}

body.page-atendimento .attendance-avatar {
    background:
        linear-gradient(135deg, var(--page-accent-strong), var(--page-accent));
}

body.page-atendimento .attendance-message {
    max-width: min(78%, 560px);
    box-shadow: 0 10px 24px rgba(16, 35, 60, 0.06);
}

body.page-atendimento .attendance-message.outbound {
    border-color: rgba(var(--page-accent-rgb), 0.14);
    background:
        linear-gradient(135deg, rgba(var(--page-accent-rgb), 0.12), rgba(255, 255, 255, 0.94));
}

body.page-atendimento .attendance-message.inbound {
    border-color: rgba(183, 121, 31, 0.18);
    background:
        linear-gradient(135deg, rgba(255, 248, 234, 0.98), rgba(255, 255, 255, 0.9));
}

.attendance-send-form {
    position: sticky;
    bottom: 0;
    margin-top: 16px;
    padding: 16px;
    border: 1px solid rgba(var(--page-accent-rgb), 0.12);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -10px 28px rgba(16, 35, 60, 0.06);
}

.attendance-lead-callout,
.attendance-lead-form {
    display: grid;
    gap: 12px;
    margin-top: 18px;
    padding: 18px;
    border: 1px solid rgba(var(--page-accent-rgb), 0.18);
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(var(--page-accent-rgb), 0.1), rgba(255, 255, 255, 0.94));
}

.attendance-lead-callout strong,
.attendance-lead-form strong {
    color: var(--navy-950);
}

.attendance-lead-callout span,
.attendance-lead-form small {
    color: var(--muted);
    line-height: 1.5;
}

.attendance-lead-form label {
    display: grid;
    gap: 8px;
    color: var(--navy-950);
    font-weight: 800;
}

.attendance-lead-form input {
    width: 100%;
}

.attendance-linked-card.lead {
    border-color: rgba(183, 121, 31, 0.28);
    background:
        linear-gradient(135deg, rgba(255, 248, 234, 0.98), rgba(255, 255, 255, 0.88));
}

body.page-atendimento .attendance-actions {
    grid-template-columns: 1fr 1fr;
}

body.page-atendimento .attendance-actions .btn-primary {
    grid-column: 1 / -1;
}

/* Life&Cor stage31 - Registro guiado do WhatsApp oficial */
.whatsapp-registration-panel {
    position: relative;
    overflow: hidden;
}

.whatsapp-registration-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto auto;
    width: 280px;
    height: 280px;
    background: radial-gradient(circle, rgba(22, 131, 74, 0.16), transparent 64%);
    pointer-events: none;
}

.whatsapp-registration-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    position: relative;
    z-index: 1;
}

.whatsapp-registration-grid .module-item {
    align-content: start;
    gap: 12px;
    min-height: 230px;
}

.whatsapp-registration-final-step {
    border-color: rgba(22, 131, 74, 0.24);
    background:
        linear-gradient(135deg, rgba(240, 251, 245, 0.98), rgba(255, 255, 255, 0.9));
}

.whatsapp-inline-form {
    display: grid;
    gap: 10px;
    margin-top: auto;
}

.whatsapp-inline-form input,
.whatsapp-inline-form select {
    width: 100%;
    min-width: 0;
}

.whatsapp-inline-form button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.whatsapp-registration-note {
    display: grid;
    gap: 5px;
    margin-top: 16px;
    padding: 16px 18px;
    border: 1px solid rgba(183, 121, 31, 0.2);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255, 248, 234, 0.95), rgba(255, 255, 255, 0.86));
    color: var(--navy-900);
}

.whatsapp-registration-note span,
.whatsapp-last-registration-message {
    color: var(--muted);
    line-height: 1.55;
}

.whatsapp-last-registration-message {
    margin-top: 12px;
}

@media (max-width: 1180px) {
    .whatsapp-registration-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 620px) {
    .whatsapp-registration-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1180px) {
    .attendance-command-strip {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body.page-atendimento .attendance-shell {
        grid-template-columns: 1fr;
    }

    body.page-atendimento .attendance-inbox,
    body.page-atendimento .attendance-chat-panel,
    body.page-atendimento .attendance-patient-panel {
        min-height: auto;
    }
}

@media (max-width: 620px) {
    .attendance-command-strip,
    body.page-atendimento .attendance-actions {
        grid-template-columns: 1fr;
    }

    body.page-atendimento .attendance-message {
        max-width: 100%;
    }
}

/* Life&Cor stage32 - WhatsApp mobile sem sobrepor conversa */
@media (max-width: 760px) {
    body.page-atendimento .main-content {
        padding-left: 14px;
        padding-right: 14px;
    }

    body.page-atendimento .attendance-page,
    body.page-atendimento .attendance-shell {
        gap: 14px;
    }

    body.page-atendimento .attendance-inbox,
    body.page-atendimento .attendance-chat-panel,
    body.page-atendimento .attendance-patient-panel {
        min-height: auto;
        padding: 18px;
        overflow: visible;
    }

    body.page-atendimento .attendance-inbox {
        order: 1;
    }

    body.page-atendimento .attendance-chat-panel {
        order: 2;
    }

    body.page-atendimento .attendance-patient-panel {
        order: 3;
    }

    body.page-atendimento .attendance-inbox-head,
    body.page-atendimento .attendance-chat-head {
        align-items: flex-start;
        margin-bottom: 12px;
    }

    body.page-atendimento .attendance-inbox-head h3,
    body.page-atendimento .attendance-chat-head h3 {
        font-size: clamp(1.3rem, 7vw, 1.75rem);
        line-height: 1.08;
        overflow-wrap: anywhere;
    }

    body.page-atendimento .attendance-search {
        grid-template-columns: 1fr;
    }

    body.page-atendimento .attendance-thread-list {
        display: flex;
        gap: 10px;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 2px 2px 12px;
        scroll-snap-type: x proximity;
    }

    body.page-atendimento .attendance-thread {
        min-width: min(78vw, 300px);
        scroll-snap-align: start;
    }

    body.page-atendimento .attendance-thread-main em {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    body.page-atendimento .attendance-contact-facts {
        grid-template-columns: repeat(3, minmax(118px, 1fr));
        gap: 8px;
        margin: 10px 0 14px;
        padding: 10px;
        overflow-x: auto;
        font-size: 0.86rem;
    }

    body.page-atendimento .attendance-contact-facts span {
        min-width: 118px;
        padding: 10px 12px;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.72);
        border: 1px solid rgba(var(--page-accent-rgb), 0.08);
        line-height: 1.35;
    }

    body.page-atendimento .attendance-contact-facts strong {
        font-size: 0.78rem;
        letter-spacing: 0.02em;
        text-transform: uppercase;
    }

    body.page-atendimento .attendance-message-list {
        flex: initial;
        min-height: auto;
        max-height: none;
        overflow: visible;
        padding: 12px;
        gap: 10px;
    }

    body.page-atendimento .attendance-message {
        max-width: 100%;
        padding: 12px;
        border-radius: 16px;
    }

    body.page-atendimento .attendance-message p,
    body.page-atendimento .attendance-message small {
        overflow-wrap: anywhere;
    }

    body.page-atendimento .attendance-send-form {
        position: static;
        bottom: auto;
        z-index: auto;
        margin-top: 14px;
        padding: 14px;
        border-top: 0;
        box-shadow: 0 12px 28px rgba(16, 35, 60, 0.08);
    }

    body.page-atendimento .attendance-send-grid {
        grid-template-columns: 1fr;
    }

    body.page-atendimento .attendance-send-form textarea {
        min-height: 110px;
    }

    body.page-atendimento .attendance-file-field {
        overflow: hidden;
    }

    body.page-atendimento .attendance-file-field input[type="file"] {
        max-width: 100%;
        font-size: 0.9rem;
    }

    body.page-atendimento .attendance-actions {
        grid-template-columns: 1fr;
    }
}

/* Life&Cor stage33 - Central estilo Clínica Expert */
body.page-atendimento .attendance-hero {
    padding: 20px;
}

body.page-atendimento .attendance-command-strip {
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
}

body.page-atendimento .attendance-workbench {
    grid-template-columns: 76px minmax(270px, 0.88fr) minmax(520px, 1.55fr) minmax(310px, 0.9fr);
    gap: 0;
    align-items: stretch;
    overflow: hidden;
    border: 1px solid rgba(var(--page-accent-rgb), 0.12);
    border-radius: 28px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 248, 246, 0.88)),
        radial-gradient(circle at 18% 12%, rgba(var(--page-accent-rgb), 0.12), transparent 28%);
    box-shadow: 0 24px 56px rgba(16, 35, 60, 0.08);
}

body.page-atendimento .attendance-channel-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 18px 10px;
    background:
        linear-gradient(180deg, rgba(15, 92, 53, 0.96), rgba(16, 35, 60, 0.94));
}

body.page-atendimento .attendance-channel-button {
    display: grid;
    justify-items: center;
    gap: 6px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
}

body.page-atendimento .attendance-channel-button span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 900;
    letter-spacing: 0.04em;
}

body.page-atendimento .attendance-channel-button small {
    max-width: 62px;
    font-size: 0.66rem;
    font-weight: 800;
    line-height: 1.1;
    text-align: center;
}

body.page-atendimento .attendance-channel-button.active span {
    background: #22c55e;
    box-shadow: 0 14px 28px rgba(34, 197, 94, 0.28);
}

body.page-atendimento .attendance-channel-button.disabled {
    opacity: 0.48;
    cursor: not-allowed;
}

body.page-atendimento .attendance-workbench > .panel {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

body.page-atendimento .attendance-workbench .attendance-inbox {
    border-right: 1px solid rgba(16, 35, 60, 0.08);
}

body.page-atendimento .attendance-workbench .attendance-chat-panel {
    border-right: 1px solid rgba(16, 35, 60, 0.08);
}

body.page-atendimento .attendance-thread-tabs {
    display: flex;
    gap: 8px;
    margin: 0 0 14px;
    padding: 5px;
    border-radius: 999px;
    background: rgba(16, 35, 60, 0.05);
}

body.page-atendimento .attendance-thread-tabs a {
    flex: 1;
    padding: 9px 10px;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.84rem;
    font-weight: 900;
    text-align: center;
    text-decoration: none;
}

body.page-atendimento .attendance-thread-tabs a.active {
    background: #fff;
    color: var(--page-accent-strong);
    box-shadow: 0 8px 18px rgba(16, 35, 60, 0.08);
}

body.page-atendimento .attendance-search input,
body.page-atendimento .attendance-search button {
    min-height: 42px;
}

body.page-atendimento .attendance-thread {
    border-radius: 0;
    border-width: 0 0 1px;
    box-shadow: none;
    transform: none;
    background: transparent;
}

body.page-atendimento .attendance-thread:hover,
body.page-atendimento .attendance-thread.active {
    transform: none;
    box-shadow: none;
    background:
        linear-gradient(135deg, rgba(var(--page-accent-rgb), 0.13), rgba(255, 255, 255, 0.84));
}

body.page-atendimento .attendance-chat-head {
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(16, 35, 60, 0.08);
}

body.page-atendimento .attendance-chat-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

body.page-atendimento .attendance-chat-panel .attendance-contact-facts {
    display: none;
}

body.page-atendimento .attendance-message-list {
    border-radius: 0;
    border: 0;
    background:
        linear-gradient(180deg, rgba(245, 248, 250, 0.74), rgba(255, 255, 255, 0.82));
}

body.page-atendimento .attendance-message {
    border-radius: 18px 18px 18px 6px;
}

body.page-atendimento .attendance-message.outbound {
    border-radius: 18px 18px 6px 18px;
}

body.page-atendimento .attendance-compose-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

body.page-atendimento .attendance-compose-title strong {
    color: var(--navy-950);
}

body.page-atendimento .attendance-compose-title small {
    color: var(--muted);
    text-align: right;
}

body.page-atendimento .attendance-compose-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.42fr);
    gap: 12px;
    align-items: stretch;
}

body.page-atendimento .attendance-compose-message {
    min-width: 0;
}

body.page-atendimento .attendance-send-form {
    border-top: 1px solid rgba(var(--page-accent-rgb), 0.08);
    border-radius: 0;
    margin: 0 -6px -6px;
    padding: 16px;
}

body.page-atendimento .attendance-send-form .form-actions {
    justify-content: flex-end;
}

body.page-atendimento .attendance-send-form .btn-primary {
    min-width: 220px;
}

body.page-atendimento .attendance-patient-panel {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(250, 247, 241, 0.9));
}

body.page-atendimento .attendance-linked-card {
    border-color: rgba(var(--page-accent-rgb), 0.12);
}

@media (max-width: 1240px) {
    body.page-atendimento .attendance-workbench {
        grid-template-columns: 72px minmax(240px, 0.9fr) minmax(430px, 1.35fr);
    }

    body.page-atendimento .attendance-patient-panel {
        grid-column: 2 / -1;
        border-top: 1px solid rgba(16, 35, 60, 0.08);
    }
}

@media (max-width: 760px) {
    body.page-atendimento .attendance-hero {
        padding: 16px;
    }

    body.page-atendimento .attendance-workbench {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
        border-radius: 22px;
        overflow: visible;
    }

    body.page-atendimento .attendance-channel-rail {
        order: 0;
        flex-direction: row;
        justify-content: center;
        padding: 12px;
        border-radius: 22px 22px 0 0;
        overflow-x: auto;
    }

    body.page-atendimento .attendance-channel-button {
        grid-template-columns: auto;
        min-width: 72px;
    }

    body.page-atendimento .attendance-channel-button span {
        width: 42px;
        height: 42px;
    }

    body.page-atendimento .attendance-thread-tabs {
        position: sticky;
        top: 0;
        z-index: 2;
    }

    body.page-atendimento .attendance-workbench .attendance-inbox,
    body.page-atendimento .attendance-workbench .attendance-chat-panel,
    body.page-atendimento .attendance-workbench .attendance-patient-panel {
        border-right: 0;
        border-top: 1px solid rgba(16, 35, 60, 0.08);
        border-radius: 0;
    }

    body.page-atendimento .attendance-workbench .attendance-patient-panel {
        grid-column: auto;
    }

    body.page-atendimento .attendance-chat-panel .attendance-contact-facts {
        display: grid;
    }

    body.page-atendimento .attendance-compose-title {
        align-items: flex-start;
        flex-direction: column;
    }

    body.page-atendimento .attendance-compose-title small {
        text-align: left;
    }

    body.page-atendimento .attendance-compose-row {
        grid-template-columns: 1fr;
    }

    body.page-atendimento .attendance-send-form {
        margin: 14px 0 0;
        border-radius: 18px;
    }

    body.page-atendimento .attendance-send-form .btn-primary {
        min-width: 0;
        width: 100%;
    }
}

/* Life&Cor stage34 - Atendimento com painel do paciente abaixo do chat e verde pastel */
body.page-atendimento {
    --page-accent: #42b883;
    --page-accent-rgb: 66, 184, 131;
    --page-accent-strong: #137051;
    --page-accent-soft: rgba(66, 184, 131, 0.16);
    --page-accent-faint: rgba(66, 184, 131, 0.08);
    --page-sidebar-top: #123b42;
    --page-sidebar-bottom: #2d8a67;
    --attendance-mint-50: #f3fbf6;
    --attendance-mint-100: #e3f8ec;
    --attendance-mint-200: #c9efd9;
    --attendance-mint-300: #a9e1c3;
    --attendance-mint-600: #22885f;
}

body.page-atendimento .attendance-workbench {
    grid-template-columns: 76px minmax(275px, 0.82fr) minmax(0, 1fr);
    grid-template-rows: auto auto;
    overflow: hidden;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 252, 248, 0.92)),
        radial-gradient(circle at 18% 12%, rgba(169, 225, 195, 0.38), transparent 30%),
        radial-gradient(circle at 88% 90%, rgba(190, 158, 98, 0.10), transparent 28%);
    border-color: rgba(66, 184, 131, 0.18);
}

body.page-atendimento .attendance-channel-rail {
    grid-column: 1;
    grid-row: 1 / span 2;
    background:
        linear-gradient(180deg, rgba(227, 248, 236, 0.98), rgba(243, 251, 246, 0.96));
    border-right: 1px solid rgba(66, 184, 131, 0.16);
}

body.page-atendimento .attendance-channel-button {
    color: #2f7c60;
}

body.page-atendimento .attendance-channel-button span {
    background: rgba(255, 255, 255, 0.78);
    border-color: rgba(66, 184, 131, 0.20);
    color: #2f7c60;
}

body.page-atendimento .attendance-channel-button.active span {
    background: linear-gradient(135deg, #a9e1c3, #57c995);
    color: #073f2d;
    box-shadow: 0 14px 28px rgba(66, 184, 131, 0.28);
}

body.page-atendimento .attendance-inbox {
    grid-column: 2;
    grid-row: 1 / span 2;
    background: rgba(255, 255, 255, 0.62);
    border-right: 1px solid rgba(16, 35, 60, 0.08);
}

body.page-atendimento .attendance-chat-panel {
    grid-column: 3;
    grid-row: 1;
    border-right: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(250, 253, 251, 0.90));
}

body.page-atendimento .attendance-message-list {
    background:
        linear-gradient(180deg, rgba(243, 251, 246, 0.78), rgba(255, 255, 255, 0.90));
}

body.page-atendimento .attendance-message.inbound {
    background: rgba(255, 248, 235, 0.84);
}

body.page-atendimento .attendance-message.outbound,
body.page-atendimento .attendance-message.manual {
    background: rgba(227, 248, 236, 0.86);
    border-color: rgba(66, 184, 131, 0.18);
}

body.page-atendimento .attendance-thread:hover,
body.page-atendimento .attendance-thread.active {
    background:
        linear-gradient(135deg, rgba(227, 248, 236, 0.95), rgba(255, 255, 255, 0.88));
}

body.page-atendimento .attendance-avatar {
    background: linear-gradient(135deg, #2f9f73, #7bd7a8);
    color: #073f2d;
}

body.page-atendimento .attendance-patient-panel {
    grid-column: 3;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-content: start;
    padding: 20px;
    border-top: 1px solid rgba(16, 35, 60, 0.08);
    border-right: 0;
    background:
        linear-gradient(180deg, rgba(250, 253, 251, 0.96), rgba(244, 251, 247, 0.92));
}

body.page-atendimento .attendance-patient-panel > .eyebrow,
body.page-atendimento .attendance-patient-panel > .attendance-empty,
body.page-atendimento .attendance-patient-panel > .attendance-suggestion-list {
    grid-column: 1 / -1;
}

body.page-atendimento .attendance-note-card {
    grid-column: 1 / -1;
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid rgba(66, 184, 131, 0.22);
    border-radius: 22px;
    background:
        linear-gradient(135deg, rgba(227, 248, 236, 0.96), rgba(255, 255, 255, 0.92));
    box-shadow: 0 14px 30px rgba(16, 35, 60, 0.06);
}

body.page-atendimento .attendance-note-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

body.page-atendimento .attendance-note-head strong {
    display: block;
    color: var(--navy-950);
    font-size: 1rem;
}

body.page-atendimento .attendance-note-head small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    line-height: 1.4;
}

body.page-atendimento .attendance-note-form {
    display: grid;
    gap: 10px;
}

body.page-atendimento .attendance-note-form textarea {
    width: 100%;
    min-height: 108px;
    resize: vertical;
    border-color: rgba(66, 184, 131, 0.22);
    background: rgba(255, 255, 255, 0.88);
}

body.page-atendimento .attendance-note-form textarea:focus {
    border-color: rgba(66, 184, 131, 0.58);
    box-shadow: 0 0 0 4px rgba(66, 184, 131, 0.12);
}

body.page-atendimento .attendance-note-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

body.page-atendimento .attendance-patient-panel .attendance-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 0;
}

body.page-atendimento .attendance-patient-panel .attendance-manual-log,
body.page-atendimento .attendance-patient-panel .attendance-lead-form {
    grid-column: 1 / -1;
    margin-top: 0;
    padding: 16px;
    border: 1px solid rgba(16, 35, 60, 0.08);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.74);
}

body.page-atendimento .attendance-linked-card {
    background: rgba(255, 255, 255, 0.82);
    border-color: rgba(66, 184, 131, 0.18);
}

body.page-atendimento .status-pill.active {
    background: rgba(197, 239, 213, 0.82);
    color: #126143;
}

body.page-atendimento .btn-primary {
    background: linear-gradient(135deg, #1f8f62, #58c993);
}

body.page-atendimento .btn-secondary {
    background: rgba(227, 248, 236, 0.76);
}

@media (max-width: 1240px) {
    body.page-atendimento .attendance-workbench {
        grid-template-columns: 72px minmax(250px, 0.9fr) minmax(0, 1fr);
    }

    body.page-atendimento .attendance-patient-panel {
        grid-column: 3;
        grid-row: 2;
    }
}

@media (max-width: 980px) {
    body.page-atendimento .attendance-workbench {
        grid-template-columns: 72px minmax(0, 1fr);
    }

    body.page-atendimento .attendance-channel-rail {
        grid-column: 1;
        grid-row: 1 / span 3;
    }

    body.page-atendimento .attendance-inbox {
        grid-column: 2;
        grid-row: 1;
        border-right: 0;
        border-bottom: 1px solid rgba(16, 35, 60, 0.08);
    }

    body.page-atendimento .attendance-chat-panel {
        grid-column: 2;
        grid-row: 2;
    }

    body.page-atendimento .attendance-patient-panel {
        grid-column: 2;
        grid-row: 3;
    }
}

@media (max-width: 760px) {
    body.page-atendimento .attendance-workbench {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    body.page-atendimento .attendance-channel-rail,
    body.page-atendimento .attendance-inbox,
    body.page-atendimento .attendance-chat-panel,
    body.page-atendimento .attendance-patient-panel {
        grid-column: auto;
        grid-row: auto;
    }

    body.page-atendimento .attendance-channel-rail {
        flex-direction: row;
        border-right: 0;
        border-bottom: 1px solid rgba(66, 184, 131, 0.16);
    }

    body.page-atendimento .attendance-patient-panel {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    body.page-atendimento .attendance-note-head,
    body.page-atendimento .attendance-note-actions {
        flex-direction: column;
        align-items: stretch;
    }

    body.page-atendimento .attendance-patient-panel .attendance-actions {
        grid-template-columns: 1fr;
    }
}
