:root {
    /* Premium Sky Blue Theme */
    --bs-primary: #0ea5e9;
    --bs-primary-rgb: 14, 165, 233;

    /* Background override (Almost white) */
    --bs-body-bg: #fcfcfd;
    --bs-body-bg-rgb: 252, 252, 253;

    /* Surface colors for cards */
    --surface-color: #ffffff;

    /* Text */
    --bs-body-color: #1e293b;
    /* slate-800 */
    --bs-heading-color: #0f172a;
    /* slate-900 */

    /* Typography */
    --bs-font-sans-serif: 'Inter', -apple-system, sans-serif;

    /* Premium Soft Shadows */
    --soft-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.04), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
    --hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
}

[data-bs-theme="dark"] {
    --bs-body-bg: #0f172a;
    --bs-body-bg-rgb: 15, 23, 42;
    --surface-color: #1e293b;
    --bs-body-color: #e2e8f0;
    --bs-heading-color: #f8fafc;
    --soft-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
    --hover-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

[data-bs-theme="dark"] .bg-white {
    background-color: var(--surface-color) !important;
}

[data-bs-theme="dark"] .text-dark {
    color: var(--bs-heading-color) !important;
}

[data-bs-theme="dark"] .border-bottom {
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #0f172a !important;
    color: var(--bs-body-color) !important;
    border-color: #334155 !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #0f172a !important;
    color: var(--bs-heading-color) !important;
    border-color: var(--bs-primary) !important;
}

/* Fix for Webkit Autofill in Dark Mode */
[data-bs-theme="dark"] input:-webkit-autofill,
[data-bs-theme="dark"] input:-webkit-autofill:hover,
[data-bs-theme="dark"] input:-webkit-autofill:focus,
[data-bs-theme="dark"] input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px #0f172a inset !important;
    -webkit-text-fill-color: #e2e8f0 !important;
    transition: background-color 5000s ease-in-out 0s;
}

[data-bs-theme="dark"] .text-secondary {
    color: #94a3b8 !important;
}

[data-bs-theme="dark"] .text-muted {
    color: #64748b !important;
}

html {
    font-size: 14px;
}

body {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-family: var(--bs-font-sans-serif);
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* Premium Card Design */
.card,
.glass-panel {
    background: var(--surface-color);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 16px;
    box-shadow: var(--soft-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* Buttons */
.btn-primary {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(14, 165, 233, 0.3);
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background-color: #0284c7;
    border-color: #0284c7;
    box-shadow: 0 4px 6px rgba(14, 165, 233, 0.4);
    transform: translateY(-1px);
}

/* Inputs */
.form-control {
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    padding: 0.6rem 1rem;
    background-color: #f8fafc;
}

.form-control:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.25rem rgba(14, 165, 233, 0.25);
    background-color: #ffffff;
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Manrope:wght@700;800&display=swap');

:root {
    --ink: #0E1526;
    --ink-soft: #64748B;
    --ink-faint: #9AA6B6;
    --surface: #FFFFFF;
    --surface-sunk: #F6F8FB;
    --surface-hover: #EFF3F8;
    --border: #E7EBF1;
    --accent: #7AAEE5;
    --accent-deep: #5E98DA;
    --accent-wash: #EAF1FF;
    --page: #F1F4F8;
    --radius-lg: 14px;
    --radius-md: 10px;
    --dur: 180ms;
}

[data-bs-theme="dark"] {
    --ink: #EEF2F8;
    --ink-soft: #93A0B4;
    --ink-faint: #5B6678;
    --surface: #101825;
    --surface-sunk: #0B121C;
    --surface-hover: #16202E;
    --border: #212C3C;
    --accent: #7AAEE5;
    --accent-deep: #5E98DA;
    --accent-wash: rgba(122, 174, 229, .14);
    --page: #0B111A;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: 0ms !important;
        animation-duration: 0ms !important;
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    background: var(--page);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
}

button {
    font-family: inherit;
}

.app {
    min-height: 100%;
}

.sticky-wrap {
    position: sticky;
    top: 0;
    z-index: 20;
}

.sticky-wrap.is-scrolled .topbar {
    box-shadow: 0 6px 20px -14px rgba(15, 23, 42, .35);
}

.topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    height: 64px;
    padding: 0 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    transition: box-shadow var(--dur) ease;
}

.tb-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
}

.tb-logo {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex: none;
    background: linear-gradient(155deg, var(--accent), var(--accent-deep));
    display: flex;
    align-items: center;
    justify-content: center;
}

.tb-logo svg {
    width: 19px;
    height: 19px;
    color: #fff;
}

.tb-word {
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    font-size: 17px;
    letter-spacing: -.01em;
    color: var(--ink);
}

.tb-utils {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: none;
    margin-left: auto;
}

.tb-divider {
    width: 1px;
    height: 26px;
    background: var(--border);
}

.clinic-wrap {
    position: relative;
}

.clinic-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-sunk);
    cursor: pointer;
    color: var(--ink);
    transition: background var(--dur) ease, border-color var(--dur) ease;
    max-width: 230px;
}

.clinic-btn:hover {
    background: var(--surface-hover);
    border-color: var(--ink-faint);
}

.clinic-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.clinic-btn svg.building {
    width: 15px;
    height: 15px;
    color: var(--ink-soft);
    flex: none;
}

.clinic-btn span.clinic-label {
    font-size: 13px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clinic-chevron {
    width: 13px;
    height: 13px;
    color: var(--ink-faint);
    flex: none;
    transition: transform var(--dur) ease;
}

.clinic-btn[aria-expanded="true"] .clinic-chevron {
    transform: rotate(180deg);
}

.clinic-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    width: 250px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 28px -12px rgba(15, 23, 42, .28);
    padding: 8px;
    opacity: 0;
    transform: translateY(-4px) scale(.98);
    pointer-events: none;
    transition: opacity var(--dur) ease, transform var(--dur) ease;
    z-index: 30;
}

.clinic-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.clinic-menu-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 6px 8px 8px;
}

.clinic-row-mini {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    padding: 8px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
}

.clinic-row-mini:hover {
    background: var(--surface-hover);
}

.clinic-row-mini-badge {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    flex: none;
    background: var(--accent-wash);
    color: var(--accent-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11.5px;
    font-weight: 700;
}

.clinic-row-mini-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.clinic-row-mini-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.clinic-row-mini-sub {
    font-size: 11.5px;
    color: var(--ink-soft);
}

.clinic-check {
    width: 16px;
    height: 16px;
    color: var(--accent);
    flex: none;
    opacity: 0;
}

.clinic-row-mini.is-active .clinic-check {
    opacity: 1;
}

.theme-btn {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ink-soft);
    transition: background var(--dur) ease, color var(--dur) ease;
}

.theme-btn:hover {
    background: var(--surface-hover);
    color: var(--ink);
}

.theme-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.theme-btn svg {
    position: absolute;
    width: 18px;
    height: 18px;
    transition: opacity var(--dur) ease, transform var(--dur) ease;
}

.icon-sun {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.icon-moon {
    opacity: 0;
    transform: rotate(-40deg) scale(.5);
}

[data-bs-theme="dark"] .icon-sun {
    opacity: 0;
    transform: rotate(40deg) scale(.5);
}

[data-bs-theme="dark"] .icon-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.user-wrap {
    position: relative;
}

.user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 8px 5px 12px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: background var(--dur) ease;
}

.user-btn:hover {
    background: var(--surface-hover);
}

.user-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.user-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.25;
}

.user-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
}

.user-role {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-soft);
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    flex: none;
    background: linear-gradient(155deg, var(--accent), var(--accent-deep));
    color: #fff;
    font-weight: 700;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-chevron {
    width: 14px;
    height: 14px;
    color: var(--ink-faint);
    transition: transform var(--dur) ease;
}

.user-btn[aria-expanded="true"] .user-chevron {
    transform: rotate(180deg);
}

.user-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 12px 28px -12px rgba(15, 23, 42, .28);
    padding: 6px;
    opacity: 0;
    transform: translateY(-4px) scale(.98);
    pointer-events: none;
    transition: opacity var(--dur) ease, transform var(--dur) ease;
    z-index: 30;
}

.user-menu.is-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.user-menu button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 9px;
    text-align: left;
    padding: 9px 10px;
    border: 0;
    background: transparent;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
}

.user-menu button:hover {
    background: var(--surface-hover);
}

.user-menu button svg {
    width: 16px;
    height: 16px;
    color: var(--ink-soft);
    flex: none;
}

.user-menu hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 5px 2px;
}

.crumbbar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 42px;
    padding: 0 24px;
    background: var(--surface-sunk);
    border-bottom: 1px solid var(--border);
}

.crumbbar svg {
    width: 15px;
    height: 15px;
    color: var(--ink-faint);
}

.crumbbar span {
    font-size: 13px;
    font-weight: 600;
    color: var(--ink-soft);
}

.shell {
    display: flex;
    align-items: flex-start;
}

.sidebar {
    width: 220px;
    flex: none;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    position: sticky;
    top: 106px;
    height: calc(100vh - 106px);
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-soft);
    margin-bottom: 2px;
}

.nav-item svg {
    width: 17px;
    height: 17px;
    flex: none;
}

.nav-item.active {
    background: var(--accent-wash);
    color: var(--accent-deep);
    font-weight: 600;
}

.nav-sep {
    height: 1px;
    background: var(--border);
    margin: 10px 4px;
}

.content {
    flex: 1;
    padding: 32px;
    display: flex;
    justify-content: center;
}

.content-inner {
    width: 100%;
    max-width: 100%;
}

/* ---------- home page ---------- */
.home-greeting h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0 0 4px;
}

.home-greeting p {
    font-size: 13.5px;
    color: var(--ink-soft);
    margin: 0 0 26px;
}

.cta-panel {
    background: var(--surface);
    border: 1.5px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.cta-panel.is-hidden {
    display: none;
}

.cta-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--accent-wash);
    color: var(--accent-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.cta-icon svg {
    width: 26px;
    height: 26px;
}

.cta-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 6px;
}

.cta-sub {
    font-size: 13px;
    color: var(--ink-soft);
    max-width: 340px;
    margin-bottom: 22px;
    line-height: 1.5;
}

.cta-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 46px;
    padding: 0 22px;
    border-radius: var(--radius-md);
    border: 0;
    background: var(--accent);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.cta-btn:hover {
    background: var(--accent-deep);
}

.cta-btn svg {
    width: 16px;
    height: 16px;
}

.intake-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: none;
}

.intake-panel.is-visible {
    display: block;
}

.intake-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.intake-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent-wash);
    color: var(--accent-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.intake-icon svg {
    width: 19px;
    height: 19px;
}

.intake-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink);
}

.intake-sub {
    font-size: 12.5px;
    color: var(--ink-soft);
    margin-top: 2px;
}

.intake-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.btn-ghost {
    height: 40px;
    padding: 0 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.btn-ghost:hover {
    background: var(--surface-hover);
}

.save-btn {
    height: 40px;
    padding: 0 18px;
    border-radius: var(--radius-md);
    border: 0;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.save-btn:hover {
    background: var(--accent-deep);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

.field label {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-soft);
}

.field input,
.field select {
    height: 40px;
    padding: 0 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    background: var(--surface-sunk);
    color: var(--ink);
    font-size: 13.5px;
    font-family: inherit;
}

.field select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px;
    padding-right: 36px;
}

[data-bs-theme="dark"] .field select {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='%2393A0B4' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    background-color: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

.field input:disabled {
    background: var(--surface-hover);
    color: var(--ink-faint);
    cursor: not-allowed;
}

@media (max-width:760px) {
    .sidebar {
        display: none;
    }

    .content {
        padding: 20px;
    }
}

@media (max-width:680px) {
    .clinic-btn span.clinic-label {
        display: none;
    }

    .clinic-btn {
        padding: 7px;
    }
}

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

@media (max-width:560px) {
    .user-text {
        display: none;
    }

    .tb-divider {
        display: none;
    }

    .topbar {
        padding: 0 16px;
        gap: 12px;
    }

    .crumbbar {
        padding: 0 16px;
    }
}