/* Optics Platform - UI refresh */

:root {
    --font-sans: "Manrope", "Segoe UI", sans-serif;
    --font-support: "IBM Plex Sans", "Segoe UI", sans-serif;
    --bg: #f3f7f9;
    --bg-strong: #d9e7e8;
    --surface: rgba(255, 255, 255, 0.82);
    --surface-strong: #ffffff;
    --surface-muted: rgba(243, 247, 249, 0.9);
    --text: #13212f;
    --muted: #617183;
    --muted-strong: #39485a;
    --border: rgba(19, 33, 47, 0.1);
    --border-strong: rgba(19, 33, 47, 0.16);
    --accent: #0e8f9a;
    --accent-strong: #0a6b74;
    --accent-soft: rgba(14, 143, 154, 0.12);
    --ink: #102131;
    --warning-soft: rgba(240, 169, 58, 0.15);
    --danger-soft: rgba(199, 71, 78, 0.14);
    --success-soft: rgba(56, 142, 109, 0.14);
    --shadow-lg: 0 32px 70px rgba(14, 23, 34, 0.12);
    --shadow-md: 0 18px 44px rgba(14, 23, 34, 0.08);
    --shadow-sm: 0 10px 26px rgba(14, 23, 34, 0.06);
    --radius-xl: 28px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --sidebar-w: 292px;
    --page-w: min(1180px, calc(100vw - 2.5rem));
    --transition: 180ms ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--text);
    font-family: var(--font-sans);
    font-feature-settings: "ss01" 1, "ss02" 1;
    background:
        radial-gradient(circle at top left, rgba(14, 143, 154, 0.14), transparent 28rem),
        radial-gradient(circle at bottom right, rgba(16, 33, 49, 0.08), transparent 28rem),
        linear-gradient(180deg, #f9fbfc 0%, #edf4f6 100%);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.5) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.5) 1px, transparent 1px);
    background-size: 36px 36px;
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.4), transparent 82%);
    opacity: 0.35;
}

img {
    max-width: 100%;
    display: block;
}

a {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
}

.shell-scrim {
    position: fixed;
    inset: 0;
    background: rgba(8, 16, 25, 0.46);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    z-index: 110;
}

.shell-sidebar {
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    bottom: 1.25rem;
    width: var(--sidebar-w);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.32);
    border-radius: 30px;
    background:
        linear-gradient(180deg, rgba(16, 33, 49, 0.97), rgba(19, 39, 58, 0.88)),
        radial-gradient(circle at top, rgba(14, 143, 154, 0.2), transparent 60%);
    color: #d3dde6;
    box-shadow: 0 28px 60px rgba(6, 14, 22, 0.28);
    backdrop-filter: blur(18px);
    z-index: 120;
}

.shell-sidebar::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

.shell-brand {
    display: flex;
    align-items: center;
    gap: 0.95rem;
    padding: 0.45rem 0.35rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
    width: 3rem;
    height: 3rem;
    border-radius: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(14, 143, 154, 0.28), rgba(255, 255, 255, 0.12));
    color: #f4fbfd;
    font-size: 1.35rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.brand-copy strong {
    display: block;
    color: #ffffff;
    font-size: 1rem;
    letter-spacing: -0.02em;
}

.brand-copy span {
    display: block;
    color: #89a0b6;
    font-size: 0.78rem;
    font-family: var(--font-support);
}

.shell-nav {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    flex: 1;
    overflow: auto;
    padding-right: 0.15rem;
}

.nav-group-label {
    margin: 0 0 0.45rem;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #6f879d;
    font-family: var(--font-support);
}

.shell-link {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.82rem 0.95rem;
    border-radius: 18px;
    color: #afc0cf;
    text-decoration: none;
    transition:
        transform var(--transition),
        color var(--transition),
        background var(--transition),
        box-shadow var(--transition);
}

.shell-link i {
    width: 1.1rem;
    text-align: center;
    font-size: 1rem;
}

.shell-link:hover,
.shell-link:focus-visible {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.shell-link.active {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(14, 143, 154, 0.26), rgba(255, 255, 255, 0.1));
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.06),
        0 12px 26px rgba(4, 10, 16, 0.24);
}

.shell-profile {
    padding: 1rem;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.shell-profile-head {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.9rem;
}

.profile-avatar {
    width: 2.8rem;
    height: 2.8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #0e8f9a, #63d0d7);
    color: #ffffff;
    font-weight: 800;
}

.profile-copy strong {
    display: block;
    color: #ffffff;
    font-size: 0.92rem;
}

.profile-copy span {
    display: block;
    color: #8ea4ba;
    font-size: 0.75rem;
}

.shell-profile .btn {
    --bs-btn-padding-y: 0.75rem;
    --bs-btn-border-color: transparent;
    --bs-btn-bg: rgba(255, 255, 255, 0.08);
    --bs-btn-hover-bg: rgba(255, 255, 255, 0.14);
    --bs-btn-color: #d7e3ec;
    --bs-btn-hover-color: #ffffff;
    border-radius: 16px;
    font-weight: 700;
}

.shell-main {
    min-height: 100vh;
    margin-left: calc(var(--sidebar-w) + 2.5rem);
}

.shell-topbar {
    position: sticky;
    top: 0;
    z-index: 90;
    padding: 1.25rem 0 0;
    backdrop-filter: blur(14px);
}

.shell-toolbar {
    width: var(--page-w);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.65);
    box-shadow: var(--shadow-sm);
}

.shell-toolbar-start,
.shell-toolbar-end {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.shell-toolbar-title {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.shell-toolbar-kicker {
    margin: 0;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-family: var(--font-support);
}

.shell-toolbar-title h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.shell-toolbar-title p {
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.shell-toggle {
    width: 2.85rem;
    height: 2.85rem;
    display: none;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.74);
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.topbar-quick-lead,
.topbar-quick-patient {
    flex-shrink: 0;
    font-weight: 700;
    border-radius: 999px;
    padding-inline: 1rem;
}

.topbar-quick-patient {
    box-shadow: 0 8px 20px rgba(14, 143, 154, 0.22);
}

.topbar-quick-lead {
    box-shadow: none;
}

.topbar-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    background: rgba(16, 33, 49, 0.06);
    border: 1px solid rgba(16, 33, 49, 0.08);
    color: var(--muted-strong);
    font-size: 0.84rem;
    font-weight: 700;
}

.page-shell {
    width: var(--page-w);
    margin: 0 auto;
    padding: 1.15rem 0 2rem;
}

.flash-stack {
    display: grid;
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.alert {
    border: 1px solid transparent;
    border-radius: 18px;
    padding: 0.95rem 1.1rem;
    box-shadow: var(--shadow-sm);
}

.alert-success {
    background: rgba(56, 142, 109, 0.12);
    color: #0f5f3d;
    border-color: rgba(56, 142, 109, 0.18);
}

.alert-danger {
    background: rgba(199, 71, 78, 0.12);
    color: #7a2026;
    border-color: rgba(199, 71, 78, 0.18);
}

.alert-warning {
    background: rgba(240, 169, 58, 0.15);
    color: #855316;
    border-color: rgba(240, 169, 58, 0.2);
}

.alert-info {
    background: rgba(14, 143, 154, 0.12);
    color: #0a6770;
    border-color: rgba(14, 143, 154, 0.2);
}

.page-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1.35rem;
    align-items: end;
    padding: 1.6rem 1.7rem;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-xl);
    background:
        linear-gradient(140deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.62)),
        linear-gradient(135deg, rgba(14, 143, 154, 0.1), transparent 45%);
    border: 1px solid rgba(255, 255, 255, 0.76);
    box-shadow: var(--shadow-md);
    animation: rise-in 420ms ease both;
}

.page-header-copy {
    max-width: 46rem;
}

.page-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.42rem 0.7rem;
    margin-bottom: 0.9rem;
    border-radius: 999px;
    background: rgba(16, 33, 49, 0.06);
    color: var(--muted-strong);
    font-size: 0.74rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-family: var(--font-support);
}

.page-header h2,
.page-header h1 {
    margin: 0;
    font-size: clamp(1.9rem, 3vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.05;
}

.page-header p {
    margin: 0.75rem 0 0;
    max-width: 44rem;
    color: var(--muted);
    font-size: 0.98rem;
    line-height: 1.65;
}

.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.page-actions .btn,
.action-cluster .btn {
    --bs-btn-padding-x: 1.1rem;
    --bs-btn-padding-y: 0.82rem;
    --bs-btn-font-weight: 700;
    border-radius: 16px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

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

.metric-card {
    position: relative;
    overflow: hidden;
    padding: 1.2rem 1.2rem 1.15rem;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid rgba(255, 255, 255, 0.82);
    box-shadow: var(--shadow-sm);
    animation: rise-in 480ms ease both;
}

.metric-card::after {
    content: "";
    position: absolute;
    inset: auto -12% -35% auto;
    width: 7.5rem;
    height: 7.5rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14, 143, 154, 0.18), transparent 72%);
}

.metric-card:nth-child(2)::after {
    background: radial-gradient(circle, rgba(240, 169, 58, 0.18), transparent 72%);
}

.metric-card:nth-child(3)::after {
    background: radial-gradient(circle, rgba(56, 142, 109, 0.18), transparent 72%);
}

.metric-card:nth-child(4)::after {
    background: radial-gradient(circle, rgba(16, 33, 49, 0.16), transparent 72%);
}

.metric-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.metric-icon {
    width: 3rem;
    height: 3rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    font-size: 1.1rem;
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.metric-card.warning .metric-icon {
    background: var(--warning-soft);
    color: #9a5e0d;
}

.metric-card.success .metric-icon {
    background: var(--success-soft);
    color: #166548;
}

.metric-card.ink .metric-icon {
    background: rgba(16, 33, 49, 0.09);
    color: var(--ink);
}

.metric-label {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.metric-value {
    display: block;
    margin-top: 0.55rem;
    font-size: clamp(1.8rem, 3vw, 2.4rem);
    font-weight: 800;
    letter-spacing: -0.05em;
}

.metric-note {
    display: block;
    margin-top: 0.65rem;
    color: var(--muted);
    font-size: 0.85rem;
}

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

.content-grid.split {
    grid-template-columns: 1.2fr 0.8fr;
}

.panel,
.card {
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(14px);
}

.panel {
    animation: rise-in 520ms ease both;
}

.panel-header,
.card-header {
    padding: 1.15rem 1.3rem;
    background: transparent;
    border-bottom: 1px solid rgba(19, 33, 47, 0.08);
    border-radius: inherit inherit 0 0;
}

.panel-header-title,
.panel-header h3,
.card-header {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.panel-header p {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.panel-body,
.card-body {
    padding: 1.25rem 1.3rem;
}

.card-footer {
    padding: 1rem 1.3rem;
    background: transparent;
    border-top: 1px solid rgba(19, 33, 47, 0.08);
}

.stack-list {
    display: grid;
    gap: 0.9rem;
}

.stack-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.05rem;
    border-radius: 18px;
    background: rgba(243, 247, 249, 0.88);
    border: 1px solid rgba(19, 33, 47, 0.08);
}

.stack-item-main {
    min-width: 0;
}

.stack-item-title {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.stack-item-meta {
    margin: 0.2rem 0 0;
    color: var(--muted);
    font-size: 0.84rem;
}

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

.summary-tile {
    padding: 1rem;
    border-radius: 18px;
    background: rgba(243, 247, 249, 0.8);
    border: 1px solid rgba(19, 33, 47, 0.08);
}

.summary-tile-label {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.summary-tile-value {
    display: block;
    margin-top: 0.45rem;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.status-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.status-filter-bar .btn {
    --bs-btn-padding-y: 0.72rem;
    --bs-btn-padding-x: 1rem;
    border-radius: 999px;
    font-weight: 700;
}

.filter-panel .row {
    --bs-gutter-y: 0.85rem;
}

.table-responsive {
    border-radius: inherit;
}

.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: rgba(16, 33, 49, 0.03);
    margin-bottom: 0;
}

.table> :not(caption)>*>* {
    padding: 1rem 1.1rem;
    border-color: rgba(19, 33, 47, 0.08);
    vertical-align: middle;
}

.table thead th {
    background: rgba(16, 33, 49, 0.03);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.entity-link {
    text-decoration: none;
    color: var(--text);
    font-weight: 700;
}

.entity-link:hover {
    color: var(--accent-strong);
}

.entity-meta {
    margin-top: 0.22rem;
    color: var(--muted);
    font-size: 0.8rem;
}

.badge {
    border-radius: 999px;
    padding: 0.5rem 0.78rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.badge-new {
    background: rgba(36, 106, 222, 0.12);
    color: #184fbc;
}

.badge-contacted {
    background: rgba(240, 169, 58, 0.16);
    color: #9d620d;
}

.badge-follow_up {
    background: rgba(115, 90, 196, 0.14);
    color: #5a3fa5;
}

.badge-qualified {
    background: rgba(14, 143, 154, 0.12);
    color: #0a6871;
}

.badge-converted {
    background: rgba(56, 142, 109, 0.14);
    color: #17654a;
}

.badge-lost {
    background: rgba(199, 71, 78, 0.12);
    color: #8a2830;
}

/* Appointment status badges */
.badge-appt-scheduled {
    background: rgba(36, 106, 222, 0.12);
    color: #184fbc;
}

.badge-appt-confirmed {
    background: rgba(14, 143, 154, 0.14);
    color: #0a6871;
}

.badge-appt-checked-in {
    background: rgba(115, 90, 196, 0.14);
    color: #5a3fa5;
}

.badge-appt-completed {
    background: rgba(56, 142, 109, 0.14);
    color: #17654a;
}

.badge-appt-cancelled {
    background: rgba(199, 71, 78, 0.12);
    color: #8a2830;
}

.badge-appt-no-show {
    background: rgba(16, 33, 49, 0.1);
    color: var(--muted-strong);
}

.appt-show-grid .appt-show-main {
    min-width: 0;
}

.appt-detail-summary .summary-tile--wide {
    grid-column: 1 / -1;
}

.appt-summary-value {
    font-size: 1.15rem !important;
}

.appt-summary-value--sm {
    font-size: 1.02rem !important;
    line-height: 1.25;
    word-break: break-word;
}

.appt-summary-sub {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--muted-strong);
}

.appt-notes-block {
    padding: 1rem 1.1rem;
    border-radius: 18px;
    background: rgba(243, 247, 249, 0.72);
    border: 1px solid rgba(19, 33, 47, 0.08);
}

.appt-notes-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.appt-notes-text {
    color: var(--text);
    font-size: 0.92rem;
    line-height: 1.55;
}

.appt-cancelled-banner {
    border-radius: 16px !important;
}

.appt-workflow-panel .btn {
    --bs-btn-padding-x: 1.1rem;
    --bs-btn-padding-y: 0.82rem;
    --bs-btn-font-weight: 700;
    border-radius: 16px;
}

.appt-workflow-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.appt-inline-form {
    margin: 0;
}

.appt-cancel-zone {
    padding: 1.1rem 1.15rem;
    border-radius: 20px;
    background: rgba(199, 71, 78, 0.05);
    border: 1px solid rgba(199, 71, 78, 0.18);
}

.appt-cancel-zone-head {
    margin-bottom: 0.85rem;
}

.appt-cancel-zone-title {
    display: flex;
    align-items: center;
    font-weight: 800;
    font-size: 0.92rem;
    color: var(--text);
}

.appt-cancel-zone-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8rem;
    color: var(--muted);
    line-height: 1.45;
}

.appt-cancel-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
}

@media (max-width: 576px) {
    .appt-cancel-form {
        grid-template-columns: 1fr;
    }

    .appt-cancel-form .btn {
        width: 100%;
    }
}

.appt-patient-panel .info-list {
    gap: 0.5rem;
}

.form-label {
    margin-bottom: 0.5rem;
    color: var(--muted-strong);
    font-weight: 700;
    font-size: 0.88rem;
}

.form-control,
.form-select,
.input-group-text {
    min-height: 3rem;
    border-radius: 16px;
    border-color: rgba(19, 33, 47, 0.12);
    background: rgba(255, 255, 255, 0.86);
    color: var(--text);
    box-shadow: none;
}

.form-control-sm,
.form-select-sm {
    min-height: 2.55rem;
    border-radius: 14px;
}

.form-control:focus,
.form-select:focus {
    border-color: rgba(14, 143, 154, 0.36);
    box-shadow: 0 0 0 0.28rem rgba(14, 143, 154, 0.12);
}

.input-group-text {
    color: var(--muted);
}

textarea.form-control {
    min-height: unset;
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.btn {
    --bs-btn-focus-box-shadow: 0 0 0 0.28rem rgba(14, 143, 154, 0.12);
    border-radius: 16px;
    font-weight: 700;
    transition:
        transform var(--transition),
        box-shadow var(--transition),
        background var(--transition),
        border-color var(--transition);
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    --bs-btn-bg: #0e8f9a;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-bg: #0f97a3;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: #0b7e88;
    --bs-btn-active-border-color: transparent;
    --bs-btn-color: #ffffff;
    background-color: #0e8f9a;
    background-image: linear-gradient(135deg, #0e8f9a, #0b6c75);
    box-shadow: 0 16px 28px rgba(14, 143, 154, 0.2);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background-color: #0f97a3;
    background-image: linear-gradient(135deg, #0f97a3, #0a626a);
}

.btn-primary:active {
    background-color: #0b7e88;
    background-image: linear-gradient(135deg, #0b7e88, #085962);
}

.btn-success {
    --bs-btn-bg: #177a52;
    --bs-btn-border-color: #177a52;
    --bs-btn-hover-bg: #136745;
    --bs-btn-hover-border-color: #136745;
}

.btn-dark {
    --bs-btn-bg: #102131;
    --bs-btn-border-color: #102131;
    --bs-btn-hover-bg: #1a3348;
    --bs-btn-hover-border-color: #1a3348;
}

.btn-outline-secondary,
.btn-outline-primary,
.btn-outline-danger {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
}

.btn-outline-primary {
    --bs-btn-color: var(--accent-strong);
    --bs-btn-border-color: rgba(14, 143, 154, 0.22);
    --bs-btn-hover-bg: rgba(14, 143, 154, 0.08);
    --bs-btn-hover-border-color: rgba(14, 143, 154, 0.28);
    --bs-btn-hover-color: var(--accent-strong);
}

.btn-outline-secondary {
    --bs-btn-color: var(--muted-strong);
    --bs-btn-border-color: rgba(19, 33, 47, 0.12);
    --bs-btn-hover-bg: rgba(16, 33, 49, 0.05);
    --bs-btn-hover-border-color: rgba(19, 33, 47, 0.16);
    --bs-btn-hover-color: var(--text);
}

.btn-outline-danger {
    --bs-btn-color: #8a2830;
    --bs-btn-border-color: rgba(199, 71, 78, 0.2);
    --bs-btn-hover-bg: rgba(199, 71, 78, 0.08);
    --bs-btn-hover-border-color: rgba(199, 71, 78, 0.24);
    --bs-btn-hover-color: #8a2830;
}

.btn-xs {
    --bs-btn-padding-y: 0.35rem;
    --bs-btn-padding-x: 0.62rem;
    font-size: 0.76rem;
}

.pagination {
    gap: 0.35rem;
}

.page-link {
    border: 1px solid rgba(19, 33, 47, 0.1);
    border-radius: 12px;
    color: var(--muted-strong);
    min-width: 2.45rem;
    text-align: center;
}

.page-item.active .page-link {
    background: var(--ink);
    border-color: var(--ink);
}

.list-group-item {
    border-color: rgba(19, 33, 47, 0.08);
    background: transparent;
}

.timeline-list {
    display: grid;
    gap: 0;
}

.timeline-item {
    position: relative;
    padding: 1.15rem 1.3rem 1.15rem 4.2rem;
    border-top: 1px solid rgba(19, 33, 47, 0.08);
}

.timeline-item:first-child {
    border-top: 0;
}

.timeline-marker {
    position: absolute;
    top: 1.15rem;
    left: 1.35rem;
    width: 2rem;
    height: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-strong);
}

.timeline-item::after {
    content: "";
    position: absolute;
    top: 3.1rem;
    bottom: -1.1rem;
    left: 2.3rem;
    width: 1px;
    background: rgba(19, 33, 47, 0.08);
}

.timeline-item:last-child::after {
    display: none;
}

.timeline-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.timeline-top strong {
    display: block;
    font-size: 0.94rem;
}

.timeline-top span {
    color: var(--muted);
    font-size: 0.78rem;
}

.timeline-note {
    margin: 0.5rem 0 0;
    color: var(--muted-strong);
    font-size: 0.9rem;
    line-height: 1.6;
}

.info-list {
    display: grid;
    gap: 0.9rem;
}

.info-item {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.info-item i {
    width: 2.35rem;
    height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: rgba(16, 33, 49, 0.05);
    color: var(--accent-strong);
}

.info-item strong {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.info-item span {
    display: block;
    margin-top: 0.18rem;
    color: var(--text);
    line-height: 1.45;
}

.notes-block {
    padding: 1rem 1.05rem;
    border-radius: 18px;
    background: rgba(243, 247, 249, 0.86);
    border: 1px solid rgba(19, 33, 47, 0.08);
    color: var(--muted-strong);
    line-height: 1.7;
}

.auth-wrapper {
    min-height: 100vh;
    padding: 1.5rem;
    display: grid;
    place-items: center;
    background-color: #08121c;
    background-image:
        url("/template/img/auth-optics-pattern.svg"),
        radial-gradient(ellipse 80% 55% at 18% 22%, rgba(99, 208, 215, 0.14), transparent 50%),
        radial-gradient(ellipse 70% 50% at 88% 78%, rgba(14, 143, 154, 0.12), transparent 45%),
        radial-gradient(circle at top left, rgba(14, 143, 154, 0.22), transparent 26rem),
        radial-gradient(circle at bottom right, rgba(16, 33, 49, 0.24), transparent 24rem),
        linear-gradient(145deg, #061018 0%, #0c2233 38%, #143952 72%, #0a1622 100%);
    background-size:
        56px 56px,
        auto,
        auto,
        auto,
        auto,
        auto;
    background-repeat: repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat;
}

.auth-shell {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    overflow: hidden;
    border-radius: 34px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 36px 80px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(22px);
}

.auth-showcase {
    position: relative;
    overflow: hidden;
    padding: 3rem;
    color: #f4f8fb;
    background:
        radial-gradient(circle at top right, rgba(99, 208, 215, 0.24), transparent 22rem),
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}

.auth-showcase-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image: url("/template/img/auth-lens-hero.svg");
    background-repeat: no-repeat;
    background-position: right -12% center;
    background-size: min(115%, 520px);
    opacity: 0.42;
    pointer-events: none;
}

.auth-showcase> :not(.auth-showcase-bg) {
    position: relative;
    z-index: 1;
}

.auth-showcase::after {
    content: "";
    position: absolute;
    z-index: 0;
    right: -6rem;
    bottom: -6rem;
    width: 18rem;
    height: 18rem;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(14, 143, 154, 0.36), transparent 72%);
    pointer-events: none;
}

.auth-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 2rem;
}

.auth-brand .brand-mark {
    width: 3.25rem;
    height: 3.25rem;
}

.auth-showcase h1 {
    margin: 0;
    max-width: 30rem;
    font-size: clamp(2.2rem, 4vw, 3.9rem);
    font-weight: 800;
    letter-spacing: -0.05em;
    line-height: 0.98;
}

.auth-showcase p {
    margin: 1.05rem 0 0;
    max-width: 28rem;
    color: rgba(235, 243, 248, 0.82);
    font-size: 1rem;
    line-height: 1.8;
}

.auth-feature-list {
    display: grid;
    gap: 0.9rem;
    margin-top: 2rem;
}

.auth-feature {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1rem 1.05rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.09);
}

.auth-feature i {
    width: 2.35rem;
    height: 2.35rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
}

.auth-feature strong {
    display: block;
    font-size: 0.95rem;
}

.auth-feature span {
    display: block;
    margin-top: 0.18rem;
    color: rgba(235, 243, 248, 0.72);
    font-size: 0.88rem;
    line-height: 1.55;
}

.auth-card {
    width: 100%;
    min-height: 100%;
    padding: 3rem 2.6rem;
    border: 0;
    border-radius: 0;
    background:
        radial-gradient(ellipse 100% 70% at 100% 0%, rgba(14, 143, 154, 0.07), transparent 52%),
        radial-gradient(ellipse 60% 50% at 0% 100%, rgba(16, 33, 49, 0.04), transparent 45%),
        rgba(249, 252, 252, 0.94);
    box-shadow: none;
}

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

.auth-kicker {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    background: rgba(14, 143, 154, 0.1);
    color: var(--accent-strong);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.auth-card h2 {
    margin: 0;
    font-size: 1.95rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.auth-card p {
    margin: 0.75rem 0 1.6rem;
    color: var(--muted);
    line-height: 1.65;
}

.auth-card .btn-primary {
    min-height: 3.1rem;
}

.section-label {
    margin-bottom: 0.8rem;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-family: var(--font-support);
}

.empty-state {
    padding: 2.4rem 1.2rem;
    text-align: center;
    color: var(--muted);
}

.text-due {
    color: #8a2830;
    font-weight: 700;
}

.sticky-panel {
    position: sticky;
    top: 6.7rem;
}

@keyframes rise-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    .content-grid.split {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 991px) {
    .shell-toggle {
        display: inline-flex;
    }

    .shell-sidebar {
        top: 1rem;
        left: 1rem;
        bottom: 1rem;
        width: min(320px, calc(100vw - 2rem));
        transform: translateX(calc(-100% - 1rem));
        transition: transform var(--transition);
    }

    .sidebar-open .shell-sidebar {
        transform: translateX(0);
    }

    .sidebar-open .shell-scrim {
        opacity: 1;
        pointer-events: auto;
    }

    .shell-main {
        margin-left: 0;
    }

    .shell-toolbar,
    .page-shell {
        width: min(100vw - 2rem, 1180px);
    }

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

    .page-actions {
        justify-content: flex-start;
    }

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

    .auth-showcase-bg {
        background-position: right -25% bottom -15%;
        background-size: min(100%, 380px);
        opacity: 0.26;
    }

    .auth-showcase {
        padding: 2.2rem;
    }

    .auth-card {
        padding: 2.2rem;
    }
}

@media (max-width: 767px) {
    body::before {
        opacity: 0.2;
    }

    .shell-topbar {
        padding-top: 1rem;
    }

    .shell-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .shell-toolbar-start,
    .shell-toolbar-end {
        width: 100%;
        justify-content: space-between;
    }

    .metric-grid,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .page-shell {
        padding-bottom: 1.5rem;
    }

    .panel-header,
    .panel-body,
    .card-header,
    .card-body,
    .card-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .timeline-item {
        padding-left: 3.5rem;
    }

    .timeline-marker {
        left: 1rem;
    }

    .timeline-item::after {
        left: 2rem;
    }

    .auth-wrapper {
        padding: 1rem;
    }

    .auth-showcase,
    .auth-card {
        padding: 1.6rem;
    }
}

/* Lead profile — log activity form */
.lead-log-activity-form .activity-form-stack {
    display: flex;
    flex-direction: column;
    gap: 1.35rem;
}

.lead-log-activity-form .activity-form-meta {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem 1.25rem;
    align-items: start;
}

.lead-log-activity-form .activity-form-field .form-select,
.lead-log-activity-form .activity-form-field .form-control {
    width: 100%;
}

.lead-log-activity-form .form-hint {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--muted);
    font-weight: 500;
}

.lead-log-activity-form textarea.form-control {
    min-height: 9rem;
    resize: vertical;
}

.lead-log-activity-form .activity-form-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 1rem 1.25rem;
    align-items: end;
    padding-top: 1.35rem;
    margin-top: 0.15rem;
    border-top: 1px solid var(--border);
}

.lead-log-activity-form .activity-form-footer .activity-form-submit {
    box-shadow: var(--shadow-sm);
}

@media (max-width: 991.98px) {
    .lead-log-activity-form .activity-form-meta {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 575.98px) {
    .lead-log-activity-form .activity-form-footer {
        grid-template-columns: 1fr;
    }

    .lead-log-activity-form .activity-form-footer .activity-form-submit {
        width: 100%;
    }
}

/* Encounter — record / edit form */
.encounter-form .encounter-section-label {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.35rem;
}

.encounter-form .encounter-meta-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 1.25rem;
    align-items: end;
}

.encounter-form .refraction-shell {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--surface-strong);
    box-shadow: var(--shadow-sm);
}

.encounter-form .refraction-table {
    width: 100%;
    min-width: 640px;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.encounter-form .refraction-table th,
.encounter-form .refraction-table td {
    border: 1px solid var(--border);
    padding: 0.4rem 0.35rem;
    text-align: center;
    vertical-align: middle;
}

.encounter-form .refraction-table .refraction-corner {
    width: 7.5rem;
    min-width: 6.5rem;
}

.encounter-form .refraction-table .refraction-row-label {
    background: linear-gradient(180deg, rgba(14, 143, 154, 0.08), rgba(14, 143, 154, 0.02));
    font-weight: 700;
    color: var(--muted-strong);
    text-align: left;
    padding-left: 0.75rem;
    font-size: 0.8rem;
}

.encounter-form .refraction-table .refraction-eye-head {
    font-weight: 800;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 0.55rem 0.35rem;
}

.encounter-form .refraction-table .refraction-eye-od {
    background: rgba(14, 143, 154, 0.14);
    color: var(--accent-strong);
}

.encounter-form .refraction-table .refraction-eye-os {
    background: rgba(19, 33, 47, 0.06);
    color: var(--muted-strong);
}

.encounter-form .refraction-table thead tr:last-child th {
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: var(--surface-muted);
}

.encounter-form .refraction-table .form-control-sm {
    min-height: 2.45rem;
    font-size: 0.8125rem;
    text-align: center;
    padding: 0.35rem 0.25rem;
    border-radius: 12px;
}

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

.encounter-form .rx-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 0.5rem 1rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
}

.encounter-form .rx-options-grid .form-check {
    margin: 0;
    min-height: 1.5rem;
}

.encounter-form .encounter-form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem 1.25rem;
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.encounter-form .encounter-outcome-field {
    flex: 1 1 220px;
    min-width: 0;
    max-width: 320px;
}

.encounter-form .encounter-save-btn {
    box-shadow: var(--shadow-sm);
}

.refraction-table-readonly td,
.refraction-table-readonly th {
    padding: 0.55rem 0.45rem;
}

.encounter-show-eye .refraction-table-readonly .refraction-row-label {
    background: var(--surface-muted);
}

@media (max-width: 767.98px) {
    .encounter-form .encounter-meta-bar {
        grid-template-columns: 1fr;
    }

    .encounter-form .iop-grid {
        grid-template-columns: 1fr;
    }

    .encounter-form .encounter-form-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .encounter-form .encounter-outcome-field {
        max-width: none;
    }

    .encounter-form .encounter-save-btn {
        width: 100%;
    }
}