/* Design tokens now live in /css/tokens.css.
   This file contains component-specific styles that use those tokens. */

html,
body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    letter-spacing: -0.015em;
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
}

/* Global form styles using tokens */
.form-control, .form-select {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    background: var(--color-surface);
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-soft);
    color: var(--color-text);
}

.form-control::placeholder {
    color: var(--color-text-tertiary);
}

.form-label {
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    margin-bottom: var(--space-1);
}

/* Tables */
.table {
    color: var(--color-text);
    font-family: var(--font-sans);
}

.table thead th {
    background: var(--color-surface-2);
    color: var(--color-text-secondary);
    font-weight: var(--font-weight-medium);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--color-border);
    border-top: none;
}

.table tbody tr {
    border-bottom: 1px solid var(--color-divider);
}

.table tbody tr:hover {
    background: var(--color-accent-soft);
}

.table td {
    color: var(--color-text);
    border-color: var(--color-divider);
}

a,
.btn-link {
    color: var(--app-accent-deep);
}

.btn {
    font-weight: var(--font-weight-medium);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
}

.btn-primary {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-accent-contrast);
    box-shadow: var(--elev-1);
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--color-accent-deep);
    border-color: var(--color-accent-deep);
    color: var(--color-accent-contrast);
    box-shadow: var(--elev-2);
    transform: translateY(-1px);
}

.btn-outline-primary {
    color: var(--color-accent);
    border-color: var(--color-accent);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-accent-contrast);
}

.btn-outline-secondary {
    color: var(--color-text-secondary);
    border-color: var(--color-border-strong);
    background: transparent;
}

.btn-outline-secondary:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
}

.btn:focus,
.btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    box-shadow: 0 0 0 3px var(--color-accent-soft);
    border-color: var(--color-accent);
}

.eyebrow {
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.page-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--elev-1);
    transition: background var(--transition-base), border-color var(--transition-base);
}

.soft-card {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.stat-card {
    padding: var(--space-5);
    border-radius: var(--radius-lg);
    min-height: 100%;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    box-shadow: var(--elev-1);
    position: relative;
    overflow: hidden;
}

.stat-card h2,
.stat-card h3,
.stat-card h4 {
    color: var(--color-text);
    font-weight: var(--font-weight-bold);
    margin: 0;
}

.stat-card .eyebrow {
    color: var(--color-text-secondary);
}

.stat-card p {
    color: var(--color-text-secondary);
    font-size: var(--font-size-xs);
    margin: 0;
}

/* Left border accent in place of gradient backgrounds */
.stat-card.teal { border-left: 3px solid var(--color-accent); }
.stat-card.gold { border-left: 3px solid var(--color-warning); }
.stat-card.rose { border-left: 3px solid var(--color-danger); }

.section-title {
    margin-bottom: var(--space-1);
    font-weight: var(--font-weight-bold);
}

.section-copy {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-sm);
}

.form-slab {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
}

.week-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(140px, 1fr));
    gap: 0.85rem;
}

.week-day {
    padding: 1rem;
    border-radius: 1.1rem;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--app-line);
    min-height: 220px;
}

.week-day.today {
    border-color: rgba(47, 138, 132, 0.5);
    box-shadow: 0 0 0 3px rgba(47, 138, 132, 0.08);
}

.week-day-heading {
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.8rem;
}

.appt-chip {
    display: block;
    padding: 0.65rem 0.75rem;
    border-radius: 0.95rem;
    background: rgba(47, 138, 132, 0.08);
    border: 1px solid rgba(47, 138, 132, 0.12);
    margin-bottom: 0.6rem;
}

.appt-chip strong {
    display: block;
}

.meta {
    color: var(--app-ink-soft);
    font-size: 0.9rem;
}

.avatar-tile,
.avatar-image {
    width: 88px;
    height: 88px;
    border-radius: 1.35rem;
}

.avatar-image {
    object-fit: cover;
    border: 1px solid rgba(23, 55, 53, 0.1);
}

.avatar-tile {
    display: grid;
    place-items: center;
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    font-size: 1.4rem;
    font-weight: var(--font-weight-bold);
}

.patient-shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.25rem;
}

.patient-list {
    padding: 1rem;
}

.patient-list-item {
    display: block;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    text-decoration: none;
    color: var(--app-ink);
    border: 1px solid transparent;
}

.patient-list-item.active,
.patient-list-item:hover {
    background: rgba(47, 138, 132, 0.08);
    border-color: rgba(47, 138, 132, 0.14);
}

.details-grid {
    display: grid;
    gap: 1rem;
}

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

.data-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.data-pill {
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}

.timeline-list {
    display: grid;
    gap: var(--space-2);
}

.timeline-item {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    transition: all var(--transition-fast);
}

.timeline-item:hover {
    border-color: var(--color-border-strong);
    box-shadow: var(--elev-1);
}

.portal-shell {
    max-width: 1080px;
    margin: 0 auto;
}

.portal-hero {
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, var(--color-accent-deep) 0%, var(--color-accent) 100%);
    color: var(--color-accent-contrast);
}

.login-panel {
    max-width: 520px;
    margin: 0 auto;
}

.balance-due {
    font-size: 2rem;
    font-weight: 800;
    color: var(--app-danger);
}

.balance-good {
    font-size: 2rem;
    font-weight: 800;
    color: var(--app-success);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    background: var(--color-accent-soft);
    color: var(--color-accent);
}

.table > :not(caption) > * > * {
    background: transparent;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder,
.form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder,
.form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ── APP SHELL ────────────────────────────────────────────────── */
.shell {
    display: flex;
    min-height: 100vh;
    background: var(--color-bg);
}

.shell-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--color-chrome);
    border-right: 1px solid var(--color-chrome-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overscroll-behavior-y: contain;
}

.shell-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-bg);
}

.shell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    background: var(--color-chrome);
    border-bottom: 1px solid var(--color-chrome-border);
    color: var(--color-text);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
}

.shell-header .eyebrow {
    color: var(--color-text-secondary);
}

.shell-title {
    color: var(--color-text);
    font-size: var(--font-size-xl);
    margin: 0;
    letter-spacing: -0.015em;
    font-weight: var(--font-weight-bold);
}

.shell-actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.shell-content {
    flex: 1;
    padding: var(--space-6);
    overflow-y: auto;
}

/* Theme toggle button */
.theme-toggle {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    padding: 0;
}

.theme-toggle:hover {
    background: var(--color-surface-3);
    color: var(--color-text);
    transform: scale(1.05);
}

.global-search-form {
    display: flex;
}

.global-search-input {
    width: 220px;
    background: var(--color-surface-2) !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-text) !important;
    border-radius: var(--radius-full) !important;
    font-size: var(--font-size-sm) !important;
    padding-left: 1rem !important;
}

.global-search-input::placeholder {
    color: var(--color-text-tertiary) !important;
}

.global-search-input:focus {
    background: var(--color-surface) !important;
    border-color: var(--color-accent) !important;
    box-shadow: 0 0 0 3px var(--color-accent-soft) !important;
    width: 280px;
    transition: all var(--transition-fast);
}

.user-chip {
    background: var(--color-surface-2);
    color: var(--color-text);
    border-radius: var(--radius-full);
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    border: 1px solid var(--color-border);
}

/* ── SIDEBAR INNER ────────────────────────────────────────────── */
.nav-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: var(--space-5) 0 var(--space-4);
}

.nav-logo-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: 0 var(--space-5) var(--space-5);
    border-bottom: 1px solid var(--color-divider);
    margin-bottom: var(--space-4);
}

.nav-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.nav-brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    min-width: 0;
}

.nav-brand-text strong {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-bold);
    color: var(--color-text);
    letter-spacing: -0.01em;
}

.nav-brand-text span {
    font-size: 0.68rem;
    color: var(--color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

.nav-group-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--color-accent);
    opacity: 0.85;
}

.nav-group:not(.has-active) .nav-group-icon {
    color: var(--color-text-tertiary);
    opacity: 0.7;
}

.menu-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 var(--space-3);
    list-style: none;
    margin: 0;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    transition: all var(--transition-fast);
    min-height: 40px;
}

.menu-link:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
    text-decoration: none;
}

.menu-link.active {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    text-decoration: none;
    font-weight: var(--font-weight-medium);
}

.menu-link--muted {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
}

.menu-link--muted:hover {
    color: var(--color-text);
    background: var(--color-surface-2);
}

.menu-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    line-height: 1;
    opacity: 0.9;
    flex-shrink: 0;
}

.menu-link.active .menu-icon {
    opacity: 1;
}

.nav-divider {
    margin: var(--space-3);
    border-top: 1px solid var(--color-divider);
}

/* ── NAV GROUPS (collapsible sidebar sections) ──────────────── */
.nav-group {
    margin: 0.35rem 0.4rem 0;
}

.nav-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-2) var(--space-3);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.nav-group-header:hover {
    background: var(--color-surface-2);
    color: var(--color-text-secondary);
}

.nav-group-label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.05em;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.nav-group-chevron {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    transition: transform var(--transition-base);
    opacity: 0.6;
}

.nav-group.open .nav-group-chevron {
    transform: rotate(180deg);
}

.nav-group-items {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-1) 0 var(--space-2) var(--space-2);
    margin-left: var(--space-2);
    border-left: 1px solid var(--color-divider);
}

.nav-group-items .menu-link {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    min-height: 36px;
}

/* Pulsing dot when a group is closed but contains the active route */
.nav-group.has-active:not(.open) .nav-group-label::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent);
    margin-left: var(--space-2);
    box-shadow: 0 0 0 0 var(--color-accent-soft);
    animation: nav-pulse 1.8s infinite;
}

.nav-group.has-active .nav-group-label {
    color: var(--color-text-secondary);
}

@keyframes nav-pulse {
    0% { box-shadow: 0 0 0 0 rgba(47, 138, 132, 0.5); }
    70% { box-shadow: 0 0 0 5px rgba(47, 138, 132, 0); }
    100% { box-shadow: 0 0 0 0 rgba(47, 138, 132, 0); }
}

.nav-footer {
    margin-top: auto;
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--color-divider);
}

.nav-footer-title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-tertiary);
    margin-bottom: var(--space-1);
}

.nav-footer-copy {
    font-size: var(--font-size-xs);
    color: var(--color-text-tertiary);
    margin: 0;
    line-height: 1.5;
}

.nav-footer-copy strong {
    color: var(--color-text-secondary);
}

/* ── LOGIN PAGE ───────────────────────────────────────────────── */
.login-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 420px 1fr;
}

.login-brand {
    background: linear-gradient(160deg, var(--color-accent-deep) 0%, var(--color-accent) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-12) var(--space-8);
    text-align: center;
    color: var(--color-accent-contrast);
}

.login-brand-logo {
    width: 140px;
    height: 140px;
    object-fit: contain;
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-6);
    background: rgba(255,255,255,0.08);
    padding: var(--space-3);
}

.login-brand-name {
    font-size: var(--font-size-2xl);
    font-weight: var(--font-weight-bold);
    color: var(--color-accent-contrast);
    margin-bottom: var(--space-1);
    letter-spacing: -0.01em;
}

.login-brand-specialty {
    font-size: var(--font-size-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.login-form-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-12) var(--space-6);
    background: var(--color-bg);
}

.login-form-card {
    width: 100%;
    max-width: 400px;
}

/* ── INTAKE FORM ──────────────────────────────────────────────── */
.intake-shell {
    min-height: 100vh;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
}

.intake-header {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    padding: var(--space-5) var(--space-8);
    background: linear-gradient(135deg, var(--color-accent-deep) 0%, var(--color-accent) 100%);
    color: var(--color-accent-contrast);
}

.intake-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.1);
    padding: var(--space-1);
}

.intake-clinic-name {
    font-size: var(--font-size-xl);
    color: var(--color-accent-contrast);
    margin: 0;
    font-weight: var(--font-weight-bold);
}

.intake-clinic-sub {
    font-size: var(--font-size-xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

.intake-body {
    flex: 1;
    max-width: 820px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1rem;
}

.intake-footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--app-ink-soft);
    font-size: 0.85rem;
    border-top: 1px solid var(--app-line);
}

/* ── TOAST NOTIFICATIONS ─────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: var(--space-6);
    right: var(--space-6);
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: var(--space-2);
    max-width: 380px;
}

.toast-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    box-shadow: var(--elev-4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.toast-success {
    background: rgba(52, 199, 89, 0.95);
    color: white;
}

.toast-error {
    background: rgba(255, 59, 48, 0.95);
    color: white;
}

.toast-warning {
    background: rgba(255, 149, 0, 0.95);
    color: white;
}

.toast-info {
    background: rgba(0, 122, 255, 0.95);
    color: white;
}

.toast-icon {
    display: inline-flex;
    flex-shrink: 0;
}

.toast-fade-in {
    animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-fade-out {
    animation: toastOut 0.4s ease forwards;
}

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

@keyframes toastOut {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(-8px) scale(0.95); }
}

/* ── GLOBAL SEARCH MODAL (Cmd+K) ─────────────────────────────── */
.search-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: flex;
    justify-content: center;
    padding-top: 15vh;
    animation: fadeIn 0.15s ease;
}

.search-modal {
    width: 100%;
    max-width: 560px;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--elev-4);
    overflow: hidden;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    animation: fadeInUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--color-border);
}

.search-input-icon {
    color: var(--color-text-tertiary);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: var(--font-size-base);
    font-family: var(--font-sans);
    color: var(--color-text);
}

.search-input::placeholder {
    color: var(--color-text-tertiary);
}

.search-kbd {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    background: var(--color-surface-3);
    color: var(--color-text-tertiary);
    font-size: 0.7rem;
    font-family: var(--font-sans);
    font-weight: var(--font-weight-medium);
    border: 1px solid var(--color-border);
}

.search-results {
    overflow-y: auto;
    padding: var(--space-2);
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text);
    transition: background var(--transition-fast);
}

.search-result-item:hover {
    background: var(--color-accent-soft);
    text-decoration: none;
    color: var(--color-text);
}

.search-result-icon {
    color: var(--color-text-tertiary);
    flex-shrink: 0;
}

.search-empty {
    padding: var(--space-6);
    text-align: center;
    color: var(--color-text-tertiary);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── ENTRY ANIMATIONS ────────────────────────────────────────── */
.page-card, .stat-card, .timeline-item, .quick-action-btn {
    animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

/* Stagger animation for stat cards */
.row > .col-lg-4:nth-child(2) .stat-card,
.row > .col-md-6:nth-child(2) .stat-card { animation-delay: 60ms; }
.row > .col-lg-4:nth-child(3) .stat-card,
.row > .col-md-6:nth-child(3) .stat-card { animation-delay: 120ms; }
.row > .col-lg-4:nth-child(4) .stat-card,
.row > .col-md-6:nth-child(4) .stat-card { animation-delay: 180ms; }
.row > .col-lg-4:nth-child(5) .stat-card { animation-delay: 240ms; }
.row > .col-lg-4:nth-child(6) .stat-card { animation-delay: 300ms; }

/* ── COLORED AVATARS ─────────────────────────────────────────── */
.avatar-tile {
    display: grid;
    place-items: center;
    font-weight: var(--font-weight-bold);
}

/* ── HAMBURGER + OVERLAY ──────────────────────────────────────── */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    background: var(--color-accent-soft);
    border: 1px solid var(--color-accent);
    cursor: pointer;
    padding: 0;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.hamburger:hover,
.hamburger:active {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--color-accent);
    border-radius: 2px;
    transition: background var(--transition-fast);
}

.hamburger:hover span,
.hamburger:active span {
    background: var(--color-accent-contrast);
}

.shell-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
}

/* ── AVATAR WITH UPLOAD ───────────────────────────────────────── */
.avatar-wrap {
    position: relative;
    flex-shrink: 0;
}

.avatar-upload-btn {
    position: absolute;
    bottom: -6px;
    right: -6px;
    width: 26px;
    height: 26px;
    background: var(--app-accent);
    color: #fff;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 0.65rem;
    cursor: pointer;
    border: 2px solid var(--app-paper);
    line-height: 1;
}

/* ── ODONTOGRAM ───────────────────────────────────────────────── */
.odonto-wrap {
    overflow: hidden;
}

.odonto-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.75rem;
    background: rgba(243, 237, 226, 0.6);
    border-radius: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid var(--app-line);
}

.odonto-cond-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    border: 1.5px solid transparent;
    background: rgba(255,255,255,0.6);
    color: var(--app-ink);
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
    white-space: nowrap;
}

.odonto-cond-btn:hover {
    background: rgba(47, 138, 132, 0.08);
    border-color: rgba(47, 138, 132, 0.25);
}

.odonto-cond-btn.sel {
    background: rgba(47, 138, 132, 0.12);
    border-color: var(--app-accent);
    font-weight: 600;
}

.odonto-clear-btn {
    opacity: 0.7;
}

.odonto-dot {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    flex-shrink: 0;
}

.odonto-dot--sm {
    width: 11px;
    height: 11px;
    border-radius: 2px;
    flex-shrink: 0;
}

.odonto-scroller {
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.odonto-grid {
    min-width: 700px;
}

.odonto-arch-label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--app-ink-soft);
    text-align: center;
    margin-bottom: 0.25rem;
}

.odonto-arch-label--lower {
    margin-top: 0.5rem;
}

.odonto-row {
    display: flex;
    justify-content: center;
    gap: 2px;
}

.odonto-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.odonto-circle {
    display: block;
    flex-shrink: 0;
}

.odonto-num {
    font-size: 0.68rem;
    color: var(--app-ink-soft);
    font-weight: 600;
    text-align: center;
    line-height: 1;
}

/* Tooth shape drawings */
.odonto-tooth-shape {
    width: 28px;
    height: 28px;
    border: 1.5px solid var(--app-accent);
    background: #fff;
    margin: 0 auto;
}

.odonto-tooth-shape.tooth-incisor  { width: 16px; }
.odonto-tooth-shape.tooth-canine   { width: 18px; }
.odonto-tooth-shape.tooth-premolar { width: 22px; }
.odonto-tooth-shape.tooth-molar    { width: 30px; }

.odonto-tooth-shape.tooth-upper {
    border-radius: 40% 40% 60% 60% / 30% 30% 70% 70%;
}

.odonto-tooth-shape.tooth-lower {
    border-radius: 60% 60% 40% 40% / 70% 70% 30% 30%;
}

.odonto-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    padding: 0.75rem;
    background: rgba(243, 237, 226, 0.5);
    border-radius: 0.85rem;
    margin-top: 1rem;
    border: 1px solid var(--app-line);
}

.odonto-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--app-ink-soft);
}

/* ── DASHBOARD: BRIEFING CARD ────────────────────────────────── */
.briefing-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-8) var(--space-8);
    color: var(--color-text);
    box-shadow: var(--elev-1);
    position: relative;
    overflow: hidden;
}

.briefing-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--color-accent);
}

.briefing-card .eyebrow {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-2);
}

.briefing-greeting {
    color: var(--color-text);
    font-size: var(--font-size-3xl);
    font-weight: var(--font-weight-bold);
    margin: 0 0 var(--space-2) 0;
    letter-spacing: -0.02em;
}

.briefing-summary {
    color: var(--color-text-secondary);
    font-size: var(--font-size-base);
    line-height: 1.6;
    margin: 0;
    max-width: 760px;
}

/* ── DASHBOARD: QUICK ACTIONS ────────────────────────────────── */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-6) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--color-text);
    transition: all var(--transition-base);
    box-shadow: var(--elev-1);
    min-height: 120px;
}

.quick-action-btn:hover {
    transform: translateY(-2px);
    border-color: var(--color-accent);
    box-shadow: var(--elev-3);
    color: var(--color-accent);
    text-decoration: none;
}

.quick-action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-full);
    background: var(--color-accent-soft);
    color: var(--color-accent);
    transition: all var(--transition-base);
}

.quick-action-btn:hover .quick-action-icon {
    background: var(--color-accent);
    color: var(--color-accent-contrast);
    transform: scale(1.05);
}

.quick-action-label {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    letter-spacing: -0.005em;
}

/* ── DASHBOARD: INCOME CHART ─────────────────────────────────── */
.income-chart {
    display: flex;
    align-items: flex-end;
    gap: 0.4rem;
    height: 200px;
    padding: 0.5rem 0;
    overflow-x: auto;
}

.income-bar-wrap {
    flex: 1;
    min-width: 42px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    position: relative;
}

.income-bar-value {
    font-size: 0.68rem;
    color: var(--app-ink-soft);
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    min-height: 14px;
}

.income-bar {
    width: 100%;
    background: linear-gradient(180deg, var(--app-accent) 0%, var(--app-accent-deep) 100%);
    border-radius: 6px 6px 2px 2px;
    transition: transform 0.15s;
    cursor: pointer;
}

.income-bar:hover {
    transform: scaleY(1.03);
}

.income-bar-wrap.today .income-bar {
    background: linear-gradient(180deg, #f0c36f 0%, #b27a1f 100%);
    box-shadow: 0 0 0 2px rgba(240, 195, 111, 0.3);
}

.income-bar-label {
    font-size: 0.7rem;
    color: var(--app-ink-soft);
    margin-top: 6px;
    white-space: nowrap;
}

.income-bar-wrap.today .income-bar-label {
    font-weight: 700;
    color: var(--app-ink);
}

/* ── DASHBOARD: BIRTHDAY HIGHLIGHT ───────────────────────────── */
.birthday-item.highlight {
    background: linear-gradient(90deg, rgba(240, 195, 111, 0.12), rgba(255, 255, 255, 0.76));
    border-color: rgba(240, 195, 111, 0.35);
}

/* ── ALERT BAR ───────────────────────────────────────────────── */
.alert-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.alert-item {
    padding: 0.75rem 1rem;
    border-radius: 0.85rem;
    font-size: 0.9rem;
}

.alert-item a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.alert-danger-item {
    background: rgba(158, 63, 63, 0.1);
    border: 1px solid rgba(158, 63, 63, 0.2);
    color: var(--app-danger);
}

.alert-warning-item {
    background: rgba(169, 108, 23, 0.1);
    border: 1px solid rgba(169, 108, 23, 0.2);
    color: var(--app-warning);
}

.alert-info-item {
    background: rgba(47, 138, 132, 0.08);
    border: 1px solid rgba(47, 138, 132, 0.15);
    color: var(--app-accent-deep);
}

.border-danger {
    border-color: rgba(158, 63, 63, 0.35) !important;
}

/* ── NOTIFICATION BADGE ──────────────────────────────────────── */
.menu-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: #e74c3c;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: auto;
}

.menu-badge.warn {
    background: #d4a017;
}

.text-danger {
    color: var(--app-danger) !important;
}

/* ── COLLAPSIBLE SECTIONS ────────────────────────────────────── */
.collapsible-section {
    overflow: hidden;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    border-radius: 1.4rem;
}

.section-header:hover {
    background: rgba(47, 138, 132, 0.06);
}

.section-chevron {
    font-size: 1.1rem;
    color: var(--app-ink-soft);
    transition: transform 0.25s ease;
    line-height: 1;
}

.section-chevron.open {
    transform: rotate(180deg);
}

.section-body {
    padding: 0 1.25rem 1.25rem;
}

/* ── SECTION NAV (quick jump buttons) ────────────────────────── */
.section-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.section-nav-btn {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1.5px solid rgba(47, 138, 132, 0.25);
    background: rgba(47, 138, 132, 0.06);
    color: var(--app-accent-deep);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.section-nav-btn:hover {
    background: rgba(47, 138, 132, 0.14);
    border-color: var(--app-accent);
}

/* ── PHOTO GALLERY ───────────────────────────────────────────── */
.photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.75rem;
}

.photo-card {
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--app-line);
    border-radius: 1rem;
    overflow: hidden;
}

.photo-thumb {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.15s;
}

.photo-thumb:hover {
    opacity: 0.85;
}

.photo-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0.6rem;
}

/* ── PHOTO LIGHTBOX ──────────────────────────────────────────── */
.photo-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 2000;
    display: grid;
    place-items: center;
    cursor: pointer;
    padding: 2rem;
}

.photo-lightbox img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 0.75rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.photo-lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 1.5rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
}

.photo-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ── RESPONSIVE ───────────────────────────────────────────────── */
@media (max-width: 1199.98px) {
    .week-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .patient-shell,
    .info-grid {
        grid-template-columns: 1fr;
    }

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

    .login-brand {
        padding: 2.5rem 1.5rem;
    }

    .shell-content {
        padding: 1rem;
    }
}

@media (max-width: 767.98px) {
    /* Mobile: sidebar is fixed off-screen, slides in with glassy semi-transparent bg */
    .shell-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 1000;
        transition: left 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        background: rgba(244, 247, 248, 0.85);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-right: 1px solid rgba(47, 138, 132, 0.18);
    }

    .shell.nav-open .shell-sidebar {
        left: 0;
        box-shadow: 4px 0 32px rgba(0, 0, 0, 0.15);
    }

    .shell-overlay {
        background: rgba(0, 0, 0, 0.35);
        backdrop-filter: blur(2px);
    }

    .shell-overlay.visible {
        display: block;
    }

    .hamburger {
        display: flex;
    }

    .shell-header {
        padding: 0.85rem 1rem;
    }

    .shell-title {
        font-size: 1.1rem;
    }

    .shell-content {
        padding: 0.75rem;
    }

    .week-grid {
        grid-template-columns: 1fr;
    }

    .odonto-cond-label {
        display: none; /* toolbar icons only on mobile */
    }

    .odonto-cond-btn {
        padding: 0.3rem 0.5rem;
    }

    .page-card {
        border-radius: 1rem;
    }

    .section-copy {
        font-size: 0.9rem;
    }

    .photo-gallery {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .section-nav {
        gap: 0.3rem;
    }

    .section-nav-btn {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }

    .section-header {
        padding: 0.85rem 1rem;
    }

    .section-body {
        padding: 0 0.75rem 1rem;
    }

    /* Mobile stat cards */
    .stat-card {
        padding: 0.85rem;
    }

    .stat-card h2 {
        font-size: 1.4rem;
    }

    /* Mobile tables: horizontal scroll */
    .table-responsive {
        font-size: 0.85rem;
    }

    /* Mobile avatar smaller */
    .avatar-tile,
    .avatar-image {
        width: 60px;
        height: 60px;
        border-radius: 1rem;
    }

    .avatar-tile {
        font-size: 1.2rem;
    }

    /* Mobile global search */
    .global-search-form {
        display: none;
    }

    /* Mobile login */
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-brand {
        padding: 1.5rem;
    }

    .login-brand-logo {
        width: 80px;
        height: 80px;
    }

    /* Mobile eyebrow in header */
    .shell-header .eyebrow {
        display: none;
    }

    /* Balance display */
    .balance-due,
    .balance-good {
        font-size: 1.4rem;
    }

    /* Menu stack overflow */
    .menu-stack {
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }

    /* Signature canvas */
    .signature-canvas-wrap canvas {
        max-width: 100% !important;
    }

    /* Dashboard: quick actions stack to 2 columns */
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }

    .briefing-greeting {
        font-size: 1.4rem;
    }

    .briefing-summary {
        font-size: 0.95rem;
    }

    .briefing-card {
        padding: 1.4rem 1.25rem;
    }

    .income-chart {
        height: 160px;
    }
}

/* ── PERIODONTOGRAM ──────────────────────────────────────────── */
.perio-wrap {
    font-size: 0.75rem;
}

.perio-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 900px;
}

.perio-table th,
.perio-table td {
    border: 1px solid var(--app-line);
    padding: 2px;
    text-align: center;
    vertical-align: middle;
}

.perio-table th {
    background: rgba(47, 138, 132, 0.08);
    font-weight: 700;
    font-size: 0.72rem;
}

.perio-label {
    background: rgba(243, 237, 226, 0.6);
    font-weight: 600;
    white-space: nowrap;
    text-align: left !important;
    padding: 4px 8px !important;
    min-width: 110px;
}

.perio-triplet {
    display: flex;
    gap: 1px;
}

.perio-triplet {
    gap: 2px;
}

.perio-triplet input {
    width: 32px;
    height: 28px;
    padding: 2px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid var(--app-line);
    border-radius: 3px;
    -moz-appearance: textfield;
    appearance: textfield;
}

.perio-triplet input::-webkit-outer-spin-button,
.perio-triplet input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.mobility-input {
    width: 36px;
    padding: 2px;
    text-align: center;
    border: 1px solid var(--app-line);
    border-radius: 2px;
}

.perio-row-v {
    background: rgba(47, 138, 132, 0.04);
}

.perio-row-p {
    background: rgba(169, 108, 23, 0.04);
}

/* ── Tablet (768-991px) ─────────────────────────────────────── */
@media (min-width: 768px) and (max-width: 991.98px) {
    .info-grid {
        grid-template-columns: 1fr;
    }

    .patient-shell {
        grid-template-columns: 260px 1fr;
    }

    .stat-card h2 {
        font-size: 1.5rem;
    }
}
