/* RoundLog — design system (self-contained, no external CDN dependency) */

@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Light.woff2') format('woff2');
    font-weight: 300;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Medium.woff2') format('woff2');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Poppins';
    src: url('../fonts/Poppins-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

/* -------------------------------------------------------------------- */
/* Color system — tech navy/indigo + electric blue + emerald, on a clean */
/* white-and-slate neutral base. Everything derives from these variables */
/* so the palette stays centralized.                                     */
/* -------------------------------------------------------------------- */

:root {
    --bg: #faf9f9;                 /* Bright Snow */
    --bg-secondary: #f3f5f8;
    --surface: #ffffff;
    --surface-hover: #eef2f8;
    --border: #e3e7ee;
    --border-strong: #ced5e0;
    --text-primary: #0f1b2e;
    --text-secondary: #55657a;
    --text-tertiary: #8d99ac;

    /* Brand palette — client-provided reference swatch (Digital Blue /
       Emerald / Prussian Blue / Deep Twilight / Bright Snow). Accent is
       the primary interactive color; emerald pairs with it as gradient
       stops on hero surfaces (brand mark, primary buttons, FAB, chat
       bubbles). No other hue enters a gradient — that ribbon is strictly
       blue and emerald. */
    --accent: #0b6eef;            /* Digital Blue */
    --accent-hover: #0958bf;
    --accent-fg: #ffffff;
    --accent-subtle: #e9f1fe;
    --accent-subtle-strong: #cfe2fd;
    --emerald: #06d6a0;           /* Emerald */

    --gradient-brand: linear-gradient(135deg, var(--emerald) 0%, var(--accent) 50%, var(--emerald) 100%);
    --gradient-accent: linear-gradient(135deg, var(--emerald), var(--accent));

    /* Client's exact UX/UI color-code spec — two named gradients, used
       verbatim on the dashboard hero cards and the onboarding screen.
       Deliberately separate from --gradient-brand/--emerald above (close
       but not identical hues) since the spec sheet pins these exact stops. */
    --gradient-blue-green: linear-gradient(135deg, #0b6eef 0%, #03e8b4 100%);
    --gradient-blue-white: linear-gradient(135deg, #d0e1f7 0%, #faf9f9 100%);

    /* Extended brand swatch — deep navy through sky-cyan to the accent/
       emerald pair, used for icon badges and accent bars app-wide. */
    --brand-navy: #03045e;        /* Deep Twilight */
    --brand-ink: #001233;         /* Prussian Blue */
    --brand-cyan: #4c9ffb;
    --gradient-brand-blue: linear-gradient(135deg, var(--brand-navy) 0%, var(--accent) 55%, var(--brand-cyan) 100%);

    --gold: #d5a64a;              /* Soft Amber */
    --gold-subtle: #fbf6ed;

    --success: #009973;           /* Emerald, deepened for text/button contrast */
    --success-subtle: #e5f8f1;
    --danger: #c76565;            /* Muted Red */
    --danger-subtle: #f8eded;
    --warning: #d5a64a;           /* Soft Amber */
    --warning-subtle: #fbf6ed;
    --info: #2b6fd1;              /* Electric Blue, deepened */
    --info-subtle: #eaf2ff;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(15, 40, 35, .05);
    --shadow: 0 1px 3px rgba(15, 40, 35, .06), 0 6px 16px rgba(15, 40, 35, .05);
    --shadow-lg: 0 12px 34px rgba(15, 40, 35, .14);

    --topbar-h: 60px;
    --bottomnav-h: 64px;
    --ease: cubic-bezier(.4, 0, .2, 1);
    /* Spring-like settle curves (no JS spring lib in this stack — approximated in CSS). */
    --ease-spring: cubic-bezier(.22, 1, .36, 1);       /* critically damped: fast, no overshoot */
    --ease-spring-bounce: cubic-bezier(.34, 1.56, .64, 1); /* slight overshoot: reserve for momentum-driven moments */
    color-scheme: light;

    /* Spacing scale — 4px base. Use these instead of one-off margin/padding
       values so rhythm stays consistent as screens get redesigned. */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;
    --space-9: 48px;
    --space-10: 64px;

    /* Type scale. Weights are pinned to the four Poppins cuts actually
       loaded above (400/500/600/700) — nothing in between. */
    --fs-page-title: 30px;   --fw-page-title: 300;
    --fs-section-title: 19px; --fw-section-title: 400;
    --fs-card-title: 16px;    --fw-card-title: 400;
    --fs-body: 14.5px;        --fw-body: 400;
    --fs-secondary: 12.5px;

    --control-h: 46px;      /* desktop input/button height, 44–48px band */
    --control-h-mobile: 50px; /* mobile input/button height, 48–52px band */
}

/* Tablet/mobile get their own, smaller type scale rather than inheriting */
/* the desktop sizes verbatim — scaled down a step, never down to "tiny". */
@media (min-width: 768px) and (max-width: 979px) {
    :root {
        --fs-page-title: 26px;
        --fs-section-title: 18px;
        --fs-card-title: 15.5px;
    }
}
@media (max-width: 767px) {
    :root {
        --fs-page-title: 22px;
        --fs-section-title: 16.5px;
        --fs-card-title: 15px;
        --fs-body: 14px;
    }
}

/* -------------------------------------------------------------------- */
/* Base                                                                  */
/* -------------------------------------------------------------------- */

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text-primary);
}

body {
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0; font-weight: 400; color: var(--text-primary); }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }

::selection { background: var(--accent-subtle-strong); }

/* -------------------------------------------------------------------- */
/* Layout shells                                                        */
/* -------------------------------------------------------------------- */

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg) 55%);
    padding: 24px;
    position: relative;
    overflow: hidden;
}
/* Soft brand-color glow behind the login card — the logo's own blue/
   emerald combo, kept low-opacity and blurred so it reads as ambience. */
.auth-shell::before, .auth-shell::after {
    content: '';
    position: absolute;
    width: 420px; height: 420px;
    border-radius: 50%;
    filter: blur(90px);
    opacity: .16;
    z-index: 0;
}
.auth-shell::before {
    top: -120px; left: -100px;
    background: radial-gradient(circle, var(--accent), transparent 70%);
}
.auth-shell::after {
    bottom: -140px; right: -100px;
    background: radial-gradient(circle, var(--emerald), transparent 70%);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 32px 28px;
    position: relative;
    z-index: 1;
}

.auth-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 26px;
}
.auth-wordmark { height: 44px; width: auto; }
.auth-card h1, .auth-card > p.page-sub { text-align: center; }

/* Mobile app shell — doctor role, phone-width column even on desktop */
.app-shell-mobile {
    max-width: 560px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    padding-bottom: calc(var(--bottomnav-h) + 20px);
    position: relative;
}

/* -------------------------------------------------------------------- */
/* Topbar (both roles)                                                  */
/* -------------------------------------------------------------------- */

.topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(255, 255, 255, .5);
    box-shadow: 0 1px 0 var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}
@media (prefers-reduced-transparency: reduce) {
    .topbar { background: var(--surface); backdrop-filter: none; border-bottom-color: var(--border); box-shadow: none; }
}

.topbar-brand { display: flex; align-items: center; gap: 10px; }
.topbar-brand .sidebar-wordmark { height: 38px; width: auto; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }

.icon-btn {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; color: var(--text-secondary);
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease), transform .1s var(--ease-spring);
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.icon-btn:active { background: var(--surface-hover); transform: scale(.9); transition-duration: .05s; }

.avatar-pill {
    display: flex; align-items: center; gap: 8px;
    padding: 5px 10px 5px 5px;
    border-radius: 999px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}
.pill-info { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.pill-role { font-size: 11px; font-weight: 400; color: var(--text-secondary); }
.avatar-circle {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent-subtle); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 11px;
    overflow: hidden; flex-shrink: 0;
}
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.photo-upload-row { display: flex; align-items: center; gap: 16px; }
.photo-upload-preview { position: relative; display: inline-flex; cursor: pointer; flex-shrink: 0; }
.photo-upload-preview-edit {
    position: absolute; bottom: -2px; right: -2px;
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--surface);
}
.photo-upload-controls { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.photo-upload-controls input[type="file"] {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.photo-upload-filename { font-size: 12px; color: var(--text-tertiary); }
.photo-upload-actions { margin-top: 14px; }

/* -------------------------------------------------------------------- */
/* Bottom nav (doctor, mobile)                                          */
/* -------------------------------------------------------------------- */

.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: var(--bottomnav-h);
    max-width: 560px;
    margin: 0 auto;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(255, 255, 255, .5);
    display: flex;
    align-items: stretch;
    z-index: 50;
    box-shadow: 0 -1px 0 var(--border), 0 -4px 20px rgba(15, 40, 35, .06);
}
@media (prefers-reduced-transparency: reduce) {
    .bottom-nav { background: var(--surface); backdrop-filter: none; border-top-color: var(--border); }
}

.bottom-nav a, .bottom-nav button.bottom-nav-item {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    color: var(--text-tertiary);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    background: none; border: none; padding: 0; cursor: pointer; font-family: inherit;
    transition: transform .1s var(--ease-spring), color .15s var(--ease);
}
.bottom-nav a.active, .bottom-nav button.bottom-nav-item.active { color: var(--accent); }
.bottom-nav a:active, .bottom-nav button.bottom-nav-item:active { transform: scale(.88); transition-duration: .05s; }
.bottom-nav a svg, .bottom-nav button.bottom-nav-item svg { width: 21px; height: 21px; }

.bottom-nav .fab-slot {
    flex: 1.1;
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.bottom-nav a.fab, .bottom-nav button.fab {
    position: absolute;
    top: -22px;
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--gradient-brand);
    color: #ffffff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 10px 22px rgba(13, 110, 253, .35);
    border: 4px solid var(--bg);
    cursor: pointer;
    transition: transform .1s var(--ease-spring);
}
.bottom-nav a.fab:active, .bottom-nav button.fab:active { transform: scale(.9); transition-duration: .05s; }
.fab svg { width: 24px; height: 24px; }

/* -------------------------------------------------------------------- */
/* Content containers                                                   */
/* -------------------------------------------------------------------- */

.page-pad { padding: 18px 18px 6px; }
.page-title { font-size: var(--fs-page-title); font-weight: var(--fw-page-title); line-height: 1.2; letter-spacing: -0.02em; }
.page-sub { font-size: 13px; color: var(--text-secondary); margin-top: var(--space-1); }
.section-title { font-size: var(--fs-section-title); font-weight: var(--fw-section-title); margin-bottom: var(--space-3); }
.card-title { font-size: var(--fs-card-title); font-weight: var(--fw-card-title); margin-bottom: var(--space-1); }

.container-wide { padding: 22px 32px 50px; }

/* -------------------------------------------------------------------- */
/* Cards — three reusable shapes. Everything in the app should be one of */
/* these rather than a one-off style="" block.                          */
/*   .card           base surface (kept for existing call sites)        */
/*   .card-standard  a titled content panel — forms, settings, detail    */
/*   .card-data      a figure/metric panel — stat tiles, counts          */
/*   .card-action    a panel whose point is a single primary action      */
/* -------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.card-standard {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
}

.card-data {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.card-action {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}
.card-action > .btn { align-self: flex-start; }

.card-data[href] {
    text-decoration: none; color: inherit;
    transition: background .2s var(--ease-spring), border-color .2s var(--ease-spring), transform .15s var(--ease-spring);
}
.card-data[href]:hover { background: var(--surface-hover); border-color: var(--border-strong); text-decoration: none; }
.card-data[href]:active { transform: scale(.98); transition-duration: .1s; }

/* -------------------------------------------------------------------- */
/* Admin Dashboard — bento layout (trial, admin-home.php only)          */
/* -------------------------------------------------------------------- */

.bento-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr 1fr;
    grid-template-areas:
        "hero billing billing"
        "hero practices categories";
    gap: var(--space-5);
    align-items: stretch;
}
@media (max-width: 980px) {
    .bento-grid {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "hero hero"
            "billing billing"
            "practices categories";
    }
}
@media (max-width: 620px) {
    .bento-grid {
        grid-template-columns: 1fr;
        grid-template-areas:
            "hero"
            "billing"
            "practices"
            "categories";
    }
}
.bento-hero { grid-area: hero; }
.bento-billing { grid-area: billing; }
.bento-practices { grid-area: practices; }
.bento-categories { grid-area: categories; }

.bento-card {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-sm);
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    transition: box-shadow .3s var(--ease-spring), border-color .3s var(--ease-spring), transform .3s var(--ease-spring);
    opacity: 0; transform: translateY(10px) scale(.98); filter: blur(4px);
    animation: bentoIn .5s var(--ease-spring) forwards;
}
.bento-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: var(--gradient-brand-blue);
}
.bento-card:hover {
    box-shadow: var(--shadow), 0 0 0 1px rgba(19, 95, 235, .04), 0 14px 32px -14px rgba(19, 95, 235, .22);
    border-color: var(--border-strong);
}
.bento-grid .bento-hero { animation-delay: .02s; }
.bento-grid .bento-billing { animation-delay: .08s; }
.bento-grid .bento-practices { animation-delay: .14s; }
.bento-grid .bento-categories { animation-delay: .2s; }
@keyframes bentoIn { to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); } }

/* Popover/dropdown entrance — scales in from the trigger it's anchored to */
/* (transform-origin set per-panel) rather than just snapping into view.   */
@keyframes dropdownIn { from { opacity: 0; transform: scale(.94) translateY(-4px); } }

@media (prefers-reduced-motion: reduce) {
    .bento-card { animation: none; opacity: 1; transform: none; filter: none; }
    .filter-dropdown-panel, .row-menu-panel { animation: none; }
}

.bento-eyebrow {
    display: flex; width: fit-content; align-items: center;
    font-size: 13px; font-weight: 400; letter-spacing: .02em; white-space: nowrap;
    margin-bottom: var(--space-3);
    padding: 6px 14px;
    border-radius: 100px;
    background: var(--brand-navy);
    color: #fff;
}
.bento-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-2); flex-wrap: wrap; }
.bento-card-head a {
    font-size: 12.5px; font-weight: 500; white-space: nowrap; display: inline-flex; align-items: center; gap: 1px; margin-top: 2px;
    transition: transform .15s var(--ease-spring), opacity .15s var(--ease);
}
.bento-card-head a:active { transform: scale(.94); transition-duration: .1s; }

.hero-kpi-num { font-size: clamp(40px, 4.5vw, 60px); font-weight: 400; line-height: .95; color: var(--text-primary); letter-spacing: -0.03em; margin-top: var(--space-3); }
.hero-kpi-label { font-size: 14px; color: var(--text-secondary); margin-top: var(--space-2); line-height: 1.4; }

.hero-chip-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); margin-top: var(--space-6); }
.hero-chip {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px;
    background: var(--bg-secondary); text-decoration: none; color: inherit;
    transition: background .2s var(--ease-spring), transform .2s var(--ease-spring);
}
.hero-chip:hover { background: var(--surface-hover); transform: translateY(-1px); text-decoration: none; }
.hero-chip:active { transform: scale(.96); transition-duration: .1s; }
.hero-chip-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.hero-chip-num { font-size: 19px; font-weight: 500; line-height: 1; letter-spacing: -0.01em; }
.hero-chip-label { font-size: 11.5px; color: var(--text-secondary); margin-top: 1px; letter-spacing: .01em; }
.hero-chip-urgent { background: var(--danger-subtle); }

.bento-hero-number {
    background: var(--accent-subtle); border-radius: 16px; padding: var(--space-4);
    margin-top: var(--space-4);
}

.bento-card-head a:focus-visible, .hero-chip:focus-visible, .card-data:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
}

.practice-avatar {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    background: var(--gradient-brand-blue); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 500; letter-spacing: .01em;
}

/* Practice/category overview rows — avatar+name (or name alone) on the  */
/* left, meta counts on the right, single line.                         */
.kpi-row { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px var(--space-3); }
.kpi-row > *:first-child { flex: 1; min-width: 200px; }
.kpi-row .card-title { overflow-wrap: break-word; line-height: 1.3; }
.kpi-row-meta { display: flex; align-items: center; gap: var(--space-3); font-size: 12.5px; font-weight: 400; color: var(--text-secondary); white-space: nowrap; flex-shrink: 0; margin-left: auto; }
.kpi-row-meta span { display: inline-flex; align-items: center; gap: 5px; }
.kpi-row-meta svg { color: var(--text-tertiary); }

.bento-card .card-title { font-weight: 400; }
.dash-asof {
    font-size: 12.5px; color: var(--text-tertiary); white-space: nowrap; display: flex; align-items: center; gap: 6px;
    padding: 7px 12px; border-radius: 100px;
    background: rgba(255, 255, 255, .6);
    backdrop-filter: blur(12px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, .5);
    box-shadow: var(--shadow-sm);
}
@media (prefers-reduced-transparency: reduce) {
    .dash-asof { background: var(--bg-secondary); backdrop-filter: none; border-color: var(--border); }
}

/* -------------------------------------------------------------------- */
/* Search + filter bar                                                  */
/* -------------------------------------------------------------------- */

/* Outer pill is the gradient itself (not a clipped border) — a plain
   nested fill div on top avoids the "ghost ring" rendering bug that the
   border-image / two-background-clip tricks both have at this border-radius
   (100px, far past the box's own half-height). */
.search-bar {
    position: relative;
    display: flex;
    padding: 3px;
    border-radius: 100px;
    background: linear-gradient(135deg, var(--brand-cyan) 0%, var(--accent) 55%, var(--brand-navy) 100%);
    transition: box-shadow .15s var(--ease);
}
.search-bar:focus-within {
    box-shadow: 0 3px 14px rgba(19, 95, 235, .3);
}
.search-bar-fill {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    border-radius: 100px;
    background: var(--surface);
    overflow: hidden;
}
.search-bar svg {
    order: 2;
    position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
    width: 18px !important; height: 18px !important;
    padding: 11px;
    box-sizing: content-box;
    border-radius: 50%;
    background: var(--brand-ink);
    color: #fff;
}
.search-bar input {
    order: 1;
    flex: 1; min-width: 0;
    border: none; background: transparent; outline: none;
    font-size: 14px; color: var(--text-primary);
    padding: 11px 56px 11px 18px;
}

/* -------------------------------------------------------------------- */
/* Patient log list (doctor) + card grid (operator)                     */
/* -------------------------------------------------------------------- */

.log-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }

.log-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.log-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); text-decoration: none; }

.log-thumb {
    width: 48px; height: 48px; border-radius: 10px;
    background: var(--accent-subtle); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; overflow: hidden;
    font-weight: 700; font-size: 15px;
}
.log-thumb img { width: 100%; height: 100%; object-fit: cover; }

.log-row-main { flex: 1; min-width: 0; }
.log-row-name { font-weight: 400; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.log-row-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.chip-sm { padding: 1px 7px; font-size: 10px; margin-top: 2px; }
.code-pill {
    background: var(--accent-subtle); color: var(--accent-hover);
    border-color: var(--accent-subtle-strong);
}

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .2px; text-transform: uppercase; }
.badge-new { background: var(--warning-subtle); color: var(--warning); }
.badge-claimed { background: var(--accent-subtle); color: var(--accent); }
.badge-processed { background: var(--success-subtle); color: var(--success); }
.badge-closed { background: var(--bg-secondary); color: var(--text-tertiary); }
.badge-active { background: var(--success-subtle); color: var(--success); }
.badge-suspended { background: var(--danger-subtle); color: var(--danger); }
.badge-cancelled { background: var(--bg-secondary); color: var(--text-tertiary); }
.badge-overdue { background: var(--warning-subtle); color: var(--warning); }

/* -------------------------------------------------------------------- */
/* Admin: doctor list + profile                                         */
/* -------------------------------------------------------------------- */

.doctor-list-row {
    display: flex; align-items: center; gap: 14px;
    padding: 15px 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none; color: inherit;
    box-shadow: var(--shadow-sm);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease);
}
.doctor-list-row:hover {
    border-color: var(--accent-subtle-strong);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
    text-decoration: none;
}
.doctor-list-row .avatar-circle { flex-shrink: 0; box-shadow: var(--shadow-sm); }
.doctor-list-chevron { display: flex; color: var(--text-tertiary); flex-shrink: 0; transition: transform .15s var(--ease), color .15s var(--ease); }
.doctor-list-row:hover .doctor-list-chevron { color: var(--accent); transform: translateX(2px); }
.doctor-list-main { flex: 1; min-width: 0; }
.doctor-list-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.doctor-list-name { font-weight: 500; font-size: 14.5px; }
.doctor-list-name[href] { display: block; color: inherit; text-decoration: none; }
.doctor-list-name[href]:hover { color: var(--accent); text-decoration: none; }
.doctor-list-meta { font-size: 12px; color: var(--text-secondary); margin-top: 5px; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.doctor-list-meta-item { display: inline-flex; align-items: center; gap: 5px; }
.doctor-list-meta-item svg { color: var(--text-tertiary); flex-shrink: 0; }

.stat-tile {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 15px 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s var(--ease), transform .15s var(--ease), border-color .15s var(--ease);
}
.stat-tile::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--gradient-brand-blue);
}
.stat-tile:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
/* Icon variant (admin-dashboard.php) — plain stat-tiles elsewhere (patient
   log counts, billing/report KPIs) keep the original stacked layout. */
.stat-tile:has(.stat-tile-icon) { display: flex; align-items: center; gap: 12px; }
.stat-tile .stat-num { font-size: 23px; font-weight: 400; line-height: 1.1; }
.stat-tile .stat-label {
    display: inline-flex; align-items: center;
    font-size: 11px; font-weight: 400; color: #fff;
    background: var(--brand-navy);
    padding: 3px 10px; border-radius: 100px;
    margin-top: 6px; white-space: nowrap;
}
.stat-tile-icon {
    width: 38px; height: 38px; border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-tile-icon-neutral { background: var(--accent-subtle); color: var(--accent); }
.stat-tile-icon-success { background: var(--success-subtle); color: var(--success); }
.stat-tile-icon-warning { background: var(--warning-subtle); color: var(--warning); }
.stat-tile-icon-danger { background: var(--danger-subtle); color: var(--danger); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 16px 0 22px; }
/* Stat cards doubling as filter toggles (admin-dashboard.php) */
.stat-row-filterable .stat-tile { text-decoration: none; color: inherit; }
.stat-row-filterable .stat-tile:hover { text-decoration: none; }
.stat-tile-active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-subtle); }

/* Trend variant — icon+delta row, then number, then label. Overrides the
   plain icon variant's horizontal layout. The delta pill ("Action needed")
   needs more room than a bare number, so this variant gets a taller min
   column width than the base .stat-row — otherwise 3-per-row widths (as
   seen on an ~768px tablet) clip it. */
.stat-row-trend { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat-row-trend .stat-tile { display: flex; flex-direction: column; align-items: flex-start; }
.stat-tile-top { display: flex; align-items: center; justify-content: space-between; width: 100%; margin-bottom: 10px; }
.stat-tile-delta { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.stat-tile-delta-neutral { background: var(--accent-subtle); color: var(--accent); }
.stat-tile-delta-success { background: var(--success-subtle); color: var(--success); }
.stat-tile-delta-warning { background: var(--warning-subtle); color: var(--warning); }
.stat-tile-delta-danger { background: var(--danger-subtle); color: var(--danger); }

/* Page header icon badge (admin-dashboard.php and similar list pages) */
.page-icon-badge {
    width: 44px; height: 44px; border-radius: 13px; flex-shrink: 0;
    background: var(--gradient-brand-blue); color: #fff;
    display: flex; align-items: center; justify-content: center;
}

/* Doctor dashboard (dashboard.php) — greeting header, hero stat card,
   quick-action grid, recent-patients list. */
.dash-greet-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.dash-greet-label { font-size: 13.5px; color: rgba(0, 18, 51, .5); }
.dash-greet-name { font-size: 20px; font-weight: 600; color: rgba(0, 18, 51, .5); margin-top: 1px; }
.dash-avatar { flex-shrink: 0; transition: transform .15s var(--ease-spring); }
.dash-avatar:hover { transform: scale(1.05); }
.dash-avatar .avatar-circle { background: var(--accent); color: #fff; }

.dash-hero {
    display: block;
    margin-top: var(--space-5);
    padding: 20px 22px;
    border-radius: var(--radius-lg);
    background: var(--gradient-blue-green);
    color: #fff;
    box-shadow: var(--shadow-lg);
}
.dash-hero-label { font-size: 13px; font-weight: 500; opacity: .85; }
.dash-hero-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.dash-hero-num { font-size: 40px; font-weight: 600; line-height: 1; }
.dash-hero-arrow {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.dash-hero-sub { font-size: 12.5px; opacity: .85; margin-top: 8px; }

.dash-quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: var(--space-5); }
.dash-quick-item {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 14px 6px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 11.5px; font-weight: 500; text-align: center;
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.dash-quick-item:hover { border-color: var(--border-strong); background: var(--surface-hover); text-decoration: none; }
.dash-quick-icon {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(11, 110, 239, .2); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
}

.dash-section-head { display: flex; align-items: center; justify-content: space-between; margin-top: var(--space-7); margin-bottom: var(--space-3); }
.dash-section-head h2 { font-size: var(--fs-section-title); font-weight: var(--fw-section-title); }
.dash-section-head a { font-size: 13px; font-weight: 500; color: var(--accent); }

.dash-recent-list { display: flex; flex-direction: column; gap: 8px; }
.dash-recent-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    color: inherit;
}
.dash-recent-row:hover { border-color: var(--border-strong); text-decoration: none; }
.dash-recent-icon {
    flex-shrink: 0; display: flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 50%;
}
.dash-recent-info { flex: 1; min-width: 0; }
.dash-recent-name { font-size: 14.5px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-recent-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.dash-recent-chevron { flex-shrink: 0; color: var(--text-tertiary); display: flex; }

/* Doctors list toolbar — search + filter/sort dropdowns */
.doctor-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doctor-toolbar-search { flex: 1; min-width: 200px; }
.doctor-toolbar-search .search-bar { height: 44px; }
/* Filter/sort dropdowns — native <details>, fully styled (a native <select>
   can't have its open list styled consistently across browsers). */
.filter-dropdown { position: relative; flex-shrink: 0; }
.filter-dropdown > summary {
    display: flex; align-items: center; gap: 7px;
    height: 44px; padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 13px; font-weight: 600;
    white-space: nowrap; cursor: pointer;
    list-style: none;
    transition: border-color .15s var(--ease), background .15s var(--ease);
}
.filter-dropdown > summary::-webkit-details-marker { display: none; }
.filter-dropdown > summary svg:first-child { color: var(--text-tertiary); flex-shrink: 0; }
.filter-dropdown > summary svg:last-child { margin-left: 4px; color: var(--text-tertiary); flex-shrink: 0; transition: transform .15s var(--ease); }
.filter-dropdown[open] > summary { border-color: var(--accent-subtle-strong); background: var(--surface); }
.filter-dropdown[open] > summary svg:last-child { transform: rotate(180deg); }
.filter-dropdown-panel {
    position: absolute; top: calc(100% + 6px); left: 0;
    min-width: 190px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); z-index: 60; overflow: hidden; padding: 4px;
    transform-origin: top left;
    animation: dropdownIn .18s var(--ease-spring);
}
.filter-dropdown-panel a {
    display: block; padding: 9px 12px; border-radius: 8px;
    font-size: 13px; font-weight: 500; color: var(--text-primary);
}
.filter-dropdown-panel a:hover { background: var(--surface-hover); text-decoration: none; }
.filter-dropdown-panel a.active { background: var(--accent-subtle); color: var(--accent); font-weight: 700; }
/* Doctor contact/date fragments, reused inside .doctor-grid-card */
.doctor-table-contact { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: var(--text-secondary); }
.doctor-table-contact span { display: inline-flex; align-items: center; gap: 6px; }
.doctor-table-contact svg { color: var(--text-tertiary); flex-shrink: 0; }
.doctor-table-date { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.doctor-table-date svg { color: var(--text-tertiary); flex-shrink: 0; }

/* Grid layout (admin-dashboard.php, admin-practices.php, admin-packages.php, admin-categories.php) */
.doctor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 14px; }

/* Practice detail's Doctors/Operators columns (admin-practice-detail.php) —
   side by side once there's room, stacked on a phone instead of squeezing
   into two unreadably-narrow columns. */
.practice-members-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; margin-top: 22px; }
@media (max-width: 640px) {
    .practice-members-grid { grid-template-columns: 1fr; }
}
.doctor-grid-card {
    position: relative; overflow: hidden;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
    padding: 16px; box-shadow: var(--shadow-sm);
    transition: box-shadow .15s var(--ease), transform .15s var(--ease);
}
.doctor-grid-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--gradient-brand-blue);
}
.doctor-grid-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.doctor-grid-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.doctor-grid-card-dates { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.doctor-grid-card-actions { display: flex; align-items: center; gap: 6px; margin-top: 14px; }

/* Per-row "more" menu — native <details>, styled as a small dropdown */
.row-menu { position: relative; display: inline-block; }
.row-menu > summary { list-style: none; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { background: var(--surface-hover); }
.row-menu-panel {
    position: absolute; right: 0; top: calc(100% + 4px);
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg); min-width: 170px; z-index: 60; overflow: hidden;
    transform-origin: top right;
    animation: dropdownIn .18s var(--ease-spring);
}
.row-menu-panel a, .row-menu-panel button {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 9px 12px; font-size: 13px; font-weight: 500; text-align: left;
    color: var(--text-primary); background: none; border: none;
}
.row-menu-panel a:hover, .row-menu-panel button:hover { background: var(--surface-hover); text-decoration: none; }

/* Inline "+ create" disclosure — native <details>, styled with a rotating
   chevron so it reads as expandable rather than as plain link text. */
.inline-disclosure { margin-top: var(--space-3); }
.inline-disclosure > summary {
    cursor: pointer; list-style: none;
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; font-weight: 600; color: var(--accent);
    padding: 6px 8px; margin-left: -8px; border-radius: var(--radius-sm);
}
.inline-disclosure > summary::-webkit-details-marker { display: none; }
.inline-disclosure > summary:hover { background: var(--accent-subtle); }
.inline-disclosure > summary .chev { display: inline-flex; transition: transform .15s var(--ease); }
.inline-disclosure[open] > summary .chev { transform: rotate(90deg); }

/* Pagination footer */
.table-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.table-pagination-summary { font-size: 12.5px; color: var(--text-tertiary); }
.table-pagination-controls { display: flex; align-items: center; gap: 4px; }
.table-pagination-page {
    display: flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; padding: 0 4px;
    border-radius: 8px; font-size: 12.5px; font-weight: 600;
    color: var(--text-secondary);
}
.table-pagination-page:hover { background: var(--surface-hover); text-decoration: none; }
.table-pagination-page.active { background: var(--accent); color: var(--accent-fg); }
.table-pagination-controls .icon-btn.is-disabled { opacity: .4; pointer-events: none; }

/* -------------------------------------------------------------------- */
/* Manual patient-card details (operator view, no photo)                */
/* -------------------------------------------------------------------- */

.card-details-panel {
    padding: 12px 14px;
    background: var(--bg-secondary);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px 14px;
    height: 100%;
    align-content: start;
}
.card-details-item .cd-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px; color: var(--text-tertiary); font-weight: 700; }
.card-details-item .cd-value { font-size: 12.5px; color: var(--text-primary); font-weight: 600; word-break: break-word; }

/* -------------------------------------------------------------------- */
/* Forms                                                                */
/* -------------------------------------------------------------------- */

.field { margin-bottom: 16px; position: relative; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }

.autocomplete-list {
    position: absolute;
    top: 100%; left: 0; right: 0;
    margin-top: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 220px;
    overflow-y: auto;
    z-index: 30;
}
.autocomplete-item {
    padding: 10px 14px;
    font-size: 13.5px;
    color: var(--text-primary);
    cursor: pointer;
}
.autocomplete-item:hover, .autocomplete-item.active { background: var(--surface-hover); }
.autocomplete-item mark { background: var(--accent-subtle); color: var(--accent-hover); border-radius: 3px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="tel"], input[type="search"], textarea, select, .wheel-display {
    width: 100%;
    min-width: 0;
    min-height: var(--control-h);
    padding: 11px 13px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    outline: none;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input:focus, textarea:focus, select:focus {
    border-color: var(--border-strong);
}
textarea { resize: vertical; min-height: 70px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%235c7069' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }

.wheel-display {
    font: inherit;
    text-align: left;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235c7069' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}
.wheel-display:disabled { cursor: default; opacity: .6; }
.wheel-display-placeholder { color: var(--text-tertiary); }

.field-row { display: flex; gap: 10px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 150px; }

.add-code-section {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    padding: 14px;
    margin-bottom: 14px;
}
.add-code-row { display: flex; flex-direction: column; gap: 10px; }
.add-code-row .field { margin-bottom: 0; }
@media (min-width: 640px) {
    .add-code-row { flex-direction: row; align-items: flex-end; }
    .add-code-row > .field { flex: 1; }
    .add-code-row > .btn { flex-shrink: 0; width: auto; }
}

/* -------------------------------------------------------------------- */
/* Buttons                                                              */
/* -------------------------------------------------------------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    min-height: var(--control-h);
    padding: 11px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease);
    user-select: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn svg { width: 17px; height: 17px; }
.btn:focus, .btn:focus-visible { outline: none; box-shadow: none; }

/* Resting state: a plain, simple two-stop gradient — no oversized canvas,
   so there's nothing to clip or seam at the rounded corners. The wider
   repeating gradient (below) only applies while hovered, for the wave. */
.btn-primary {
    background: linear-gradient(100deg, var(--emerald), var(--accent));
    color: var(--accent-fg);
    transition: filter .15s var(--ease), transform .1s var(--ease);
}
@keyframes btnGradientWave {
    0% { background-position: 0% 50%; }
    100% { background-position: 200% 50%; }
}
.btn-primary:hover {
    filter: brightness(1.08);
    background: linear-gradient(100deg, var(--emerald), var(--accent), var(--emerald), var(--accent));
    background-size: 300% 100%;
    animation: btnGradientWave 2.4s linear infinite;
}

.btn-outline { background: var(--surface); color: var(--text-primary); border-color: var(--border-strong); }
.btn-outline:hover { background: var(--surface-hover); }

.btn-navy { background: var(--brand-navy); color: #fff; border-color: var(--brand-navy); }
.btn-navy:hover { background: var(--brand-navy); filter: brightness(1.15); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-primary); }

.btn-danger { background: var(--danger-subtle); color: var(--danger); }
.btn-danger:hover { background: #eed1d1; }

.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: #b95555; }

.btn-sm { min-height: 0; padding: 7px 12px; font-size: 12.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

@media (max-width: 767px) {
    input[type="text"], input[type="email"], input[type="password"], input[type="number"],
    input[type="tel"], input[type="search"], select, .wheel-display,
    .btn:not(.btn-sm) {
        min-height: var(--control-h-mobile);
    }
}

.btn-icon-only { padding: 9px; }

/* -------------------------------------------------------------------- */
/* Alerts / flash                                                       */
/* -------------------------------------------------------------------- */

.alert { display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-radius: 10px; font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: var(--danger-subtle); color: var(--danger); }
.alert-success { background: var(--success-subtle); color: var(--success); }
.alert-info { background: var(--info-subtle); color: var(--info); }

/* -------------------------------------------------------------------- */
/* Quick code chips + code entry (doctor log page)                      */
/* -------------------------------------------------------------------- */

.quick-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 9px 16px;
    border-radius: 999px;
    background: var(--accent-subtle);
    color: var(--accent-hover);
    border: 1px solid var(--accent-subtle-strong);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s var(--ease);
}
.quick-chip:active { background: var(--accent-subtle-strong); }
.quick-chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

.code-entry-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.code-entry-row {
    display: flex; flex-direction: column; gap: 8px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 11px;
}
.code-entry-top { display: flex; align-items: center; gap: 10px; }
.code-entry-code { font-weight: 700; color: var(--accent-hover); font-size: 14.5px; min-width: 40px; }
.code-entry-body { flex: 1; min-width: 0; }
.code-entry-label { font-size: 12.5px; color: var(--text-secondary); }
.code-entry-date { font-size: 11.5px; color: var(--text-tertiary); margin-top: 1px; }
.code-entry-note { font-size: 11.5px; color: var(--text-secondary); font-style: italic; margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.code-entry-actions { display: flex; gap: 4px; }
.code-entry-code-form { display: flex; flex-direction: column; gap: 6px; }
.code-entry-code-form select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    background: var(--surface);
    color: var(--text-primary);
}
.code-entry-form-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* -------------------------------------------------------------------- */
/* Card image capture (doctor log page)                                 */
/* -------------------------------------------------------------------- */

.card-photo-frame {
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    min-height: 170px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px;
    padding: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}
.card-photo-frame.has-image { border-style: solid; border-color: var(--border); padding: 0; min-height: 0; }
.card-photo-frame img { width: 100%; max-height: 320px; object-fit: contain; background: #0000; }
.card-photo-frame .photo-empty-icon { color: var(--text-tertiary); }
.card-photo-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; }
.card-photo-actions .icon-btn { background: rgba(255,255,255,.92); box-shadow: var(--shadow-sm); }
.card-photo-confirm-row { display: flex; gap: 8px; width: 100%; padding: 10px; order: -1; }
.card-photo-confirm-row .btn { flex: 1; }
.capture-btn-row { display: flex; gap: 10px; }
.capture-btn-row .btn { flex: 1; }

.card-scan-overlay {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 2;
    background: linear-gradient(90deg, rgba(37,99,235,.10), rgba(37,99,235,.02) 40%, rgba(37,99,235,.10));
}
.card-scan-line {
    position: absolute;
    top: 0; bottom: 0;
    left: 0;
    width: 3px;
    background: linear-gradient(180deg, transparent, #3b82f6 15%, #93c5fd 50%, #3b82f6 85%, transparent);
    box-shadow: 0 0 14px 3px rgba(59,130,246,.85), 0 0 28px 8px rgba(59,130,246,.35);
    animation: cardScanSweep 5s ease-in-out infinite;
}
@keyframes cardScanSweep {
    0%   { left: 0%;   opacity: 0; }
    5%   { opacity: 1; }
    95%  { opacity: 1; }
    100% { left: 100%; opacity: 0; }
}
.card-scan-label {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    display: flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 10px;
    text-align: center;
    font-size: 12.5px;
    font-weight: 600;
    color: #fff;
    letter-spacing: .2px;
    background: linear-gradient(0deg, rgba(15,23,42,.75), rgba(15,23,42,0));
}
.card-scan-label .spinner { border-color: rgba(255,255,255,.4); border-top-color: #fff; width: 13px; height: 13px; }

/* -------------------------------------------------------------------- */
/* Operator: card grid                                                  */
/* -------------------------------------------------------------------- */

.filters-bar {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 20px;
}
.filters-bar .search-bar { max-width: 280px; }
#opHomeSearchBar { max-width: none; width: 100%; }
.date-nav { display: flex; align-items: center; gap: 6px; }
.date-nav .date-label { font-weight: 600; font-size: 14px; min-width: 150px; text-align: center; }

.status-tabs { display: flex; gap: 4px; background: var(--bg-secondary); border-radius: 10px; padding: 4px; }
.status-tabs a { padding: 7px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); text-decoration: none; }
.status-tabs a.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

.patient-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 30px;
}

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 28px; }
.pagination-info { font-size: 12.5px; color: var(--text-secondary); }
.btn-disabled { opacity: .4; pointer-events: none; }
@media (min-width: 1320px) {
    .patient-grid { grid-template-columns: repeat(4, 1fr); }
}

.patient-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex; flex-direction: column;
    text-decoration: none; color: inherit;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
a.patient-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); text-decoration: none; }
.patient-card-photo {
    height: 150px;
    background: var(--bg-secondary);
    display: flex; align-items: center; justify-content: center;
    cursor: zoom-in;
    overflow: hidden;
}
.patient-card-photo.has-details { height: auto; min-height: 150px; cursor: default; align-items: stretch; }
.patient-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.no-card-name {
    width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    text-align: center;
    padding: 12px;
    background: var(--gradient-accent);
    color: #ffffff;
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
}
.patient-card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.patient-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.patient-card-name { font-weight: 500; font-size: 15px; }
.patient-card-codes { display: flex; flex-wrap: wrap; gap: 6px; }
.patient-card-note { font-size: 12.5px; color: var(--text-secondary); background: var(--bg-secondary); border-radius: 8px; padding: 8px 10px; }
.patient-card-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin-top: auto; padding-top: 4px; }
.patient-card-foot .muted { font-size: 11.5px; color: var(--text-tertiary); }
.patient-card-stats { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11px; color: var(--text-secondary); }
.patient-card-stats strong { color: var(--text-primary); font-weight: 500; }

.op-entry-list { display: flex; flex-direction: column; gap: 6px; }
.op-entry-list-more { display: flex; flex-direction: column; gap: 6px; }
.op-entry-toggle {
    display: flex; align-items: center; justify-content: center; gap: 5px;
    background: none; border: none; cursor: pointer;
    padding: 5px 4px;
    font-size: 12px; font-weight: 600; color: var(--accent);
}
.op-entry-toggle:hover { color: var(--accent-hover); }
.op-entry-toggle-chevron { display: flex; transition: transform .15s var(--ease); }
.op-entry-toggle.expanded .op-entry-toggle-chevron { transform: rotate(180deg); }
.op-entry {
    display: flex; flex-direction: column; gap: 7px;
    padding: 7px 9px;
    border-radius: 9px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}
.op-entry.is-processed { background: var(--success-subtle); border-color: transparent; }
.op-entry-top { display: flex; align-items: center; gap: 9px; }
.op-entry-code { font-weight: 700; color: var(--accent-hover); font-size: 12.5px; min-width: 30px; flex-shrink: 0; }
.op-entry-info { flex: 1; min-width: 0; }
.op-entry-label { font-size: 11.5px; color: var(--text-secondary); }
.op-entry-date { font-size: 11px; color: var(--text-tertiary); }
.op-entry .btn-icon-only { padding: 6px; flex-shrink: 0; }

/* Operator's note on one code entry — e.g. explaining a replaced code */
.op-entry-note {
    display: flex; align-items: flex-start; gap: 6px;
    font-size: 11.5px; color: var(--text-secondary);
    background: var(--surface); border: 1px solid var(--border); border-radius: 7px;
    padding: 6px 8px;
}
.op-entry-note span { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; }
.op-note-edit-btn, .op-note-add-btn { background: none; border: none; cursor: pointer; padding: 0; }
.op-note-edit-btn { color: var(--text-tertiary); display: flex; flex-shrink: 0; }
.op-note-edit-btn:hover { color: var(--accent); }
.op-note-add-btn {
    display: flex; align-items: center; gap: 5px; align-self: flex-start;
    color: var(--accent); font-size: 11.5px; font-weight: 600; padding: 2px 0;
}
.op-note-add-btn:hover { color: var(--accent-hover); }
.op-note-form { display: flex; flex-direction: column; gap: 6px; }
.op-note-form textarea {
    width: 100%; min-height: 56px; resize: vertical;
    font: inherit; font-size: 12.5px; padding: 7px 9px;
    border-radius: 7px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text-primary);
}
.op-note-actions { display: flex; gap: 6px; justify-content: flex-end; }
.op-mark-new { background: var(--warning); color: #fff; border-color: transparent; }
.op-mark-new:hover { background: var(--warning); opacity: .88; }
.op-mark-processed { background: var(--success); color: #fff; border-color: transparent; }
.op-mark-processed:hover { background: var(--success); opacity: .88; }

/* Three-way pending/claimed/paid status control, per code entry — only an */
/* operator can change any of the three (operator-dashboard.php).          */
.op-status-group { display: flex; gap: 3px; flex-shrink: 0; }
.op-status-btn {
    display: flex; align-items: center; justify-content: center;
    padding: 6px; border-radius: 8px; border: 1px solid transparent;
    background: var(--bg-secondary); color: var(--text-tertiary); cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.op-status-btn:hover { opacity: .85; }
.op-status-btn.active[data-target-action="mark_pending"] { background: var(--warning); color: #fff; }
.op-status-btn.active[data-target-action="mark_claimed"] { background: var(--accent); color: #fff; }
.op-status-btn.active[data-target-action="mark_paid"] { background: var(--success); color: #fff; }

.history-toggle { font-size: 12px; color: var(--accent); cursor: pointer; font-weight: 600; }
.history-block { display: none; margin-top: 4px; }
.history-block.open { display: flex; }
.history-row { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }

/* -------------------------------------------------------------------- */
/* Lightbox                                                             */
/* -------------------------------------------------------------------- */

.lightbox {
    position: fixed; inset: 0; background: rgba(10, 25, 22, .82);
    display: none; align-items: center; justify-content: center;
    z-index: 200; padding: 30px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 8px; box-shadow: var(--shadow-lg); }
.lightbox-close { position: absolute; top: 20px; right: 24px; color: #fff; background: rgba(255,255,255,.15); }
.lightbox-close:hover { background: rgba(255,255,255,.28); color: #fff; }

/* -------------------------------------------------------------------- */
/* Wheel picker — app-style date/time picker (replaces the native one)  */
/* -------------------------------------------------------------------- */

.wheel-overlay {
    position: fixed; inset: 0; background: rgba(10, 25, 22, .45);
    z-index: 500;
    display: flex; align-items: flex-end; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity .2s var(--ease);
}
.wheel-overlay.open { opacity: 1; pointer-events: auto; }

.wheel-sheet {
    width: 100%; max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    transform: translateY(100%);
    transition: transform .3s var(--ease-spring);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.wheel-overlay.open .wheel-sheet { transform: translateY(0); }

@media (min-width: 560px) {
    .wheel-overlay { align-items: center; }
    .wheel-sheet { border-radius: var(--radius-lg); }
}

.wheel-sheet-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 8px;
    border-bottom: 1px solid var(--border);
}
.wheel-sheet-btn {
    background: transparent; border: none;
    font-size: 14px; font-weight: 600;
    padding: 8px 14px; border-radius: 8px;
    color: var(--text-secondary); cursor: pointer;
}
.wheel-sheet-btn:hover { background: var(--surface-hover); }
.wheel-sheet-set { color: var(--accent); }
.wheel-sheet-title { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.wheel-columns {
    position: relative;
    display: flex;
    padding: 12px 10px 20px;
}
.wheel-highlight {
    position: absolute; left: 10px; right: 10px; top: 50%;
    height: 40px; transform: translateY(-50%);
    background: var(--accent-subtle);
    border-radius: 10px;
    pointer-events: none;
}
.wheel-col {
    flex: 1;
    height: 200px;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: relative;
}
.wheel-col::-webkit-scrollbar { display: none; }
.wheel-col-pad { scroll-snap-align: none; }
.wheel-col-item {
    display: flex; align-items: center; justify-content: center;
    scroll-snap-align: center;
    font-size: 16px;
    color: var(--text-tertiary);
    cursor: pointer;
}
.wheel-col-item.selected { color: var(--text-primary); font-weight: 700; font-size: 18px; }

.wheel-calendar { display: none; padding: 6px 16px 20px; }
.wheel-cal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 2px 14px;
}
.wheel-cal-title { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.wheel-cal-nav {
    width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: transparent; border: none; border-radius: 50%;
    font-size: 20px; line-height: 1; color: var(--text-secondary); cursor: pointer;
}
.wheel-cal-nav:hover { background: var(--surface-hover); }
.wheel-cal-nav:disabled { opacity: .3; cursor: default; }
.wheel-cal-dow {
    display: grid; grid-template-columns: repeat(7, 1fr);
    margin-bottom: 4px;
}
.wheel-cal-dow span {
    display: flex; align-items: center; justify-content: center;
    height: 28px; font-size: 11px; font-weight: 700; letter-spacing: .02em;
    color: var(--text-tertiary); text-transform: uppercase;
}
.wheel-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.wheel-cal-cell {
    display: flex; align-items: center; justify-content: center;
    width: 100%; aspect-ratio: 1; margin: 0 auto;
    max-width: 42px; max-height: 42px;
    background: transparent; border: none; border-radius: 50%;
    font-size: 14px; color: var(--text-primary); cursor: pointer;
}
.wheel-cal-cell:hover { background: var(--surface-hover); }
.wheel-cal-cell.is-outside { color: var(--text-tertiary); opacity: .4; cursor: default; pointer-events: none; }
.wheel-cal-cell.is-today { color: var(--accent); font-weight: 700; box-shadow: inset 0 0 0 1.5px var(--accent); }
.wheel-cal-cell.is-selected { background: var(--accent); color: #fff; font-weight: 700; }
.wheel-cal-cell.is-selected:hover { background: var(--accent); }

/* -------------------------------------------------------------------- */
/* Confirm dialog — in-app replacement for window.confirm()             */
/* -------------------------------------------------------------------- */

.confirm-overlay {
    position: fixed; inset: 0; background: rgba(10, 25, 22, .45);
    z-index: 600;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    opacity: 0; pointer-events: none;
    transition: opacity .2s var(--ease);
}
.confirm-overlay.open { opacity: 1; pointer-events: auto; }

.confirm-card {
    width: 100%; max-width: 360px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 22px 20px;
    transform: scale(.94);
    transition: transform .2s var(--ease-spring);
}
.confirm-overlay.open .confirm-card { transform: scale(1); }

.confirm-title { font-size: 16px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.confirm-message { font-size: 13.5px; color: var(--text-secondary); line-height: 1.55; }
.confirm-actions { display: flex; gap: 10px; margin-top: 20px; }
.confirm-actions .btn { flex: 1; }

/* -------------------------------------------------------------------- */
/* Side panel — patient details (operator dashboard)                    */
/* -------------------------------------------------------------------- */

.side-panel-backdrop {
    position: fixed; inset: 0;
    background: rgba(10, 25, 22, .45);
    z-index: 210;
    opacity: 0; pointer-events: none;
    transition: opacity .2s var(--ease);
}
.side-panel-backdrop.open { opacity: 1; pointer-events: auto; }

.side-panel {
    position: fixed; right: 0; top: 0; bottom: 0;
    width: 380px; max-width: 92vw;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    z-index: 220;
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform .3s var(--ease-spring);
}
/* Nav menu opens from the left instead — the conventional side for a
   hamburger-triggered menu, unlike a detail drawer (e.g. patient details). */
.side-panel-left { right: auto; left: 0; transform: translateX(-100%); }
.side-panel-left.open { transform: translateX(0); }
.side-panel.open { transform: translateX(0); }

.side-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.side-panel-header h2 { font-size: 15px; }
.side-panel-body { padding: 20px; overflow-y: auto; flex: 1; }

/* The hamburger "all pages" nav menu (one per role, same #id, see
   includes/header.php) gets its own solid-blue treatment, distinct from
   every other slide-out panel (directory pickers, filters, detail views)
   which stay on the plain white .side-panel look above. */
#navMenuPanel {
    background: var(--accent);
    color: #fff;
}
#navMenuPanel .side-panel-header { border-bottom-color: rgba(255, 255, 255, .15); }
#navMenuPanel .side-panel-header h2 { color: #fff; }
#navMenuPanel .side-panel-header .icon-btn { color: #fff; }
#navMenuPanel .side-panel-header .icon-btn:hover { background: rgba(255, 255, 255, .15); }
#navMenuPanel .sidebar-nav a { color: rgba(255, 255, 255, .82); }
#navMenuPanel .sidebar-nav a:hover { background: rgba(3, 4, 94, .15); color: #fff; }
#navMenuPanel .sidebar-nav a.active { background: rgba(3, 4, 94, .25); color: #fff; font-weight: 600; }

.detail-panel-name { font-size: 18px; font-weight: 500; }
.detail-panel-ref { font-size: 13px; color: var(--text-secondary); margin-top: 3px; }
.detail-panel-photo {
    width: 100%; margin-top: 16px; border-radius: var(--radius);
    border: 1px solid var(--border); cursor: zoom-in;
}
.detail-panel-fields { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.detail-row .dr-label { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--text-tertiary); font-weight: 700; }
.detail-row .dr-value { font-size: 14.5px; color: var(--text-primary); font-weight: 600; margin-top: 2px; }

/* -------------------------------------------------------------------- */
/* FAB action sheet — mobile bottom-nav "+" opens a choice of what to    */
/* create, instead of jumping straight to one fixed destination.        */
/* -------------------------------------------------------------------- */

.fab-sheet {
    position: fixed; left: 0; right: 0; bottom: 0;
    max-width: 560px; margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    z-index: 220;
    padding: 10px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    transform: translateY(100%);
    transition: transform .3s var(--ease-spring);
}
.fab-sheet.open { transform: translateY(0); }
.fab-sheet-handle { width: 36px; height: 4px; border-radius: 99px; background: var(--border-strong); margin: 4px auto 10px; }
.fab-sheet-title { font-size: 13px; font-weight: 500; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .04em; padding: 0 6px 8px; }
.fab-sheet-option {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 13px 10px; border-radius: var(--radius-sm);
    background: none; border: none; text-align: left;
    font-size: 15px; font-weight: 400; color: var(--text-primary);
    cursor: pointer;
}
.fab-sheet-option:hover { background: var(--surface-hover); }
.fab-sheet-option .fab-sheet-icon {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    background: var(--accent-subtle); color: var(--accent);
}
.fab-sheet-cancel { margin-top: 10px; }

/* -------------------------------------------------------------------- */
/* Empty state                                                          */
/* -------------------------------------------------------------------- */

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-secondary); }
.empty-state svg { color: var(--text-tertiary); margin-bottom: 10px; }
.empty-state .empty-title { font-weight: 500; color: var(--text-primary); margin-bottom: 4px; }
.empty-state .empty-text { font-size: 13px; }

/* -------------------------------------------------------------------- */
/* Table (settings pages)                                               */
/* -------------------------------------------------------------------- */

table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .3px;
    color: var(--text-tertiary); font-weight: 700; padding: 10px 14px; border-bottom: 1px solid var(--border);
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--bg-secondary); }
.table-scroll { overflow-x: auto; }

.code-cell { display: flex; flex-direction: column; gap: 2px; }
.code-cell-code { font-weight: 700; color: var(--accent-hover); font-size: 13.5px; }
.code-cell-label { color: var(--text-secondary); font-size: 12.5px; }

.toggle-switch { position: relative; width: 38px; height: 22px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; cursor: pointer; transition: background .15s var(--ease); }
.toggle-slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s var(--ease); }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* -------------------------------------------------------------------- */
/* Settings tabs / section headers                                     */
/* -------------------------------------------------------------------- */

.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.section-head h2 { font-size: 16px; }

.tab-row {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 11px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 20px;
}
.tab-row a {
    flex: 1;
    display: flex; align-items: center; justify-content: center;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13.5px; font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    text-align: center;
}
.tab-row a.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

/* Operator dashboard — one tab per linked doctor, with avatar + unread-new
   count badge (plain .tab-row text links weren't enough once there could be
   several doctors, each with their own pending-work count to scan for). */
.doctor-tab-row {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.doctor-tab-row::-webkit-scrollbar { display: none; }
.doctor-tab {
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0;
    padding: 7px 14px 7px 8px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 13.5px; font-weight: 600;
    text-decoration: none;
    transition: border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease);
}
.doctor-tab:hover { text-decoration: none; border-color: var(--border-strong); }
.doctor-tab .avatar-circle { width: 26px; height: 26px; font-size: 11px; flex-shrink: 0; }
.doctor-tab-name { white-space: nowrap; }
.doctor-tab.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent-subtle-strong); box-shadow: var(--shadow-sm); }
/* The unread count sits as a small badge on the avatar's corner (standard
   notification-badge placement) rather than its own separate pill — one
   rounded shape per tab, not two, keeps the tab row from looking busy. */
.doctor-tab-avatar-wrap { position: relative; display: flex; flex-shrink: 0; }
.doctor-tab-badge {
    position: absolute; top: -3px; right: -4px;
    background: var(--danger); color: #fff;
    font-size: 9px; font-weight: 700;
    min-width: 15px; height: 15px; padding: 0 3px;
    border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    border: 1.5px solid var(--surface);
}
.doctor-tab.active .doctor-tab-badge { border-color: var(--accent-subtle); }

#cardManualPanel .field label, #sidePanelBody .field label { text-transform: uppercase; letter-spacing: .3px; }

/* New Log page — mobile-only jump tabs, so getting to the codes section
   doesn't need a long scroll past every patient-detail field. Desktop
   shows both sides at once (the 50/50 grid) and hides these entirely. */
.mobile-section-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 11px;
    padding: 4px;
    gap: 4px;
    margin-bottom: 16px;
}
.mobile-section-tabs a {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
}
.mobile-section-tabs a.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.log-form-right.mobile-section-inactive, .log-form-left.mobile-section-inactive { display: none; }

/* -------------------------------------------------------------------- */
/* Misc                                                                 */
/* -------------------------------------------------------------------- */

.spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
    animation: spin .7s linear infinite;
}
.spinner-dark { border: 2px solid var(--border-strong); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

.toast-wrap { position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--text-primary); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: opacity .2s var(--ease), transform .25s var(--ease-spring); }
.toast.show { opacity: 1; transform: translateY(0); }

.password-reveal-box { background: var(--gold-subtle); border: 1px solid #e6cf9c; border-radius: 10px; padding: 14px; margin-top: 10px; }
.password-reveal-box code { font-size: 15px; font-weight: 700; letter-spacing: .5px; color: var(--text-primary); }

/* -------------------------------------------------------------------- */
/* Notification bell + badge                                            */
/* -------------------------------------------------------------------- */

.bell-btn { position: relative; }
.bell-badge {
    position: absolute; top: 3px; right: 3px;
    min-width: 15px; height: 15px; padding: 0 3px;
    border-radius: 999px;
    background: var(--danger);
    color: #fff;
    font-size: 9.5px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    border: 1.5px solid var(--surface);
}
.sidebar-nav .bell-badge { position: static; margin-left: auto; border: none; }
.sidebar-nav a { position: relative; }

.notif-tabs {
    display: flex;
    gap: 6px;
    margin: 14px 0 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.notif-tabs::-webkit-scrollbar { display: none; }
.notif-tabs a {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    white-space: nowrap;
}
.notif-tabs a:hover { color: var(--text-primary); text-decoration: none; }
.notif-tabs a.active { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent-subtle-strong); }

.notif-day-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--text-tertiary); margin: 18px 0 8px; }
.notif-day-label:first-of-type { margin-top: 6px; }
.notif-list { display: flex; flex-direction: column; gap: 6px; }
.notif-row {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    text-decoration: none;
}
.notif-row:hover { border-color: var(--border-strong); text-decoration: none; }
.notif-row.unread { background: var(--accent-subtle); border-color: var(--accent-subtle-strong); }
.notif-icon {
    width: 30px; height: 30px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-secondary); color: var(--text-secondary);
}
.notif-icon-entry_processed { background: var(--success-subtle); color: var(--success); }
.notif-icon-entry_marked_new { background: var(--warning-subtle); color: var(--warning); }
.notif-icon-log_created, .notif-icon-log_created_returning, .notif-icon-entry_added { background: var(--accent-subtle); color: var(--accent-hover); }
.notif-text { flex: 1; font-size: 13.5px; }
.notif-time { font-size: 11px; color: var(--text-tertiary); flex-shrink: 0; }

/* -------------------------------------------------------------------- */
/* Report page                                                          */
/* -------------------------------------------------------------------- */

.report-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-radius: 11px;
    padding: 4px;
    gap: 4px;
    margin-top: 18px;
}
.report-tabs a {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
}
.report-tabs a.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.report-tab-panel { margin-top: 16px; }

.discharged-list { display: flex; flex-direction: column; gap: 8px; }
.discharged-row {
    display: flex; align-items: center; gap: 16px;
    padding: 13px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.discharged-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); text-decoration: none; }
.discharged-row-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex-shrink: 0; }
.discharged-name { font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.discharged-date { font-size: 12px; color: var(--text-tertiary); }
.discharged-row-stats { display: flex; flex: 1; flex-wrap: wrap; justify-content: center; gap: 8px; }
.discharged-stat { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.discharged-stat-pending { background: var(--warning-subtle); color: var(--warning); }
.discharged-stat-claimed { background: var(--accent-subtle); color: var(--accent); }
.discharged-stat-paid { background: var(--success-subtle); color: var(--success); }
.discharged-row-open {
    flex-shrink: 0; margin-left: auto;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    color: var(--text-tertiary);
    transition: background .15s var(--ease), color .15s var(--ease);
}
.discharged-row:hover .discharged-row-open { background: var(--accent-subtle); color: var(--accent); }
@media (max-width: 560px) {
    .discharged-row { flex-wrap: wrap; }
    .discharged-row-stats { order: 3; flex-basis: 100%; justify-content: flex-start; }
}

/* Read-only patient card details — discharged-log.php */
.view-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 20px;
    padding: 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}
.view-item .view-label { font-size: 11px; text-transform: uppercase; letter-spacing: .3px; color: var(--text-tertiary); font-weight: 700; margin-bottom: 3px; }
.view-item .view-value { font-size: 13.5px; color: var(--text-primary); font-weight: 600; word-break: break-word; }
@media (max-width: 640px) { .view-grid { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------------- */
/* Responsive                                                           */
/* -------------------------------------------------------------------- */

/* Phone only — tablets (>= 768px) get the sidebar shell below instead, and
   .patient-grid's own auto-fit already sizes columns to whatever width a
   tablet's content area actually has, so it doesn't need forcing to 1
   column the way a phone's does. */
@media (max-width: 767px) {
    .container-wide { padding: 16px 14px 40px; }
    .patient-grid { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filters-bar .search-bar { max-width: none; }
    .date-nav { width: 100%; }
    .date-nav form { flex: 1; }
    .date-nav input[type="date"] { width: 100%; }
    /* Side-by-side field pairs (new doctor/operator forms, code entry,
       payment logging, etc.) — full width, one below another, instead of
       squeezing two fields into half-width columns on a phone screen. */
    .field-row { flex-direction: column; gap: 0; }
}

/* Operator topbar — used at every width (operator has no sidebar/bottom
   nav), so trim it down on small phones instead of letting it wrap. */
@media (max-width: 480px) {
    .avatar-pill .pill-name { display: none; }
    .avatar-pill { padding: 5px; }

    /* Three tabs ("Processed"/"Pending"/"Discharged" + count chips) don't
       fit their generous desktop padding/gap on a narrow phone — the last
       tab was overflowing past the viewport edge. */
    .report-tabs { gap: 2px; padding: 3px; }
    .report-tabs a { gap: 3px; padding: 8px 4px; font-size: 11.5px; }
    .report-tabs a .chip { padding: 2px 6px; font-size: 10.5px; }
}

/* Doctor sidebar — hidden (mobile bottom-nav is used instead) until the
   viewport is wide enough for a real laptop-style layout. Tablets (>=768px)
   get this too, not just laptops/desktops (>=960px) — a 768-959px viewport
   has plenty of room for a persistent sidebar, it just isn't wide enough
   yet for the New Log page's two-column form (that split waits for the
   960px breakpoint below). */
.doctor-sidebar { display: none; }

/* Shared by the desktop sidebar and the mobile "all pages" menu panel —
   not gated behind the desktop media query since both need it. */
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 13.5px; font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
}
.sidebar-nav a:hover { background: var(--surface-hover); text-decoration: none; }
.sidebar-nav a.active { background: var(--accent-subtle); color: var(--accent-hover); font-weight: 600; }

@media (min-width: 768px) {
    .app-shell-mobile {
        max-width: none;
        padding-left: 240px;
        box-shadow: none;
        min-height: 100vh;
    }
    .app-shell-mobile > .topbar,
    .app-shell-mobile > .bottom-nav {
        display: none;
    }
    .doctor-sidebar {
        display: flex;
        flex-direction: column;
        gap: 4px;
        position: fixed;
        left: 0; top: 0; bottom: 0;
        width: 240px;
        padding: 18px 14px;
        background: var(--surface);
        border-right: 1px solid var(--border);
        overflow-y: auto;
    }
    .sidebar-brand { display: flex; align-items: center; padding: 6px 8px 18px; }
    .sidebar-wordmark { height: 42px; width: auto; }
    .sidebar-new-btn { margin-bottom: 16px; }
    .sidebar-footer {
        margin-top: auto;
        display: flex; align-items: center; gap: 6px;
        padding-top: 14px;
        border-top: 1px solid var(--border);
    }
    .sidebar-footer .avatar-pill { flex: 1; min-width: 0; background: transparent; border: none; padding: 6px; }
    .sidebar-footer .pill-name,
    .sidebar-footer .pill-role { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .page-pad {
        padding: 34px 40px 60px;
    }

    /* The mobile jump-tabs only make sense when the two New Log sections
       are forced to one at a time — once there's a sidebar there's room to
       just show both, stacked, with a normal scroll between them (the true
       side-by-side grid still waits for 960px, below). */
    .mobile-section-tabs { display: none; }
    #homeSearchBar { max-width: 50%; }
    .log-form-right.mobile-section-inactive, .log-form-left.mobile-section-inactive { display: block; }
}

@media (min-width: 960px) {
    .log-form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
}

/* -------------------------------------------------------------------- */
/* Chat (messages.php)                                                   */
/* -------------------------------------------------------------------- */

.chat-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-h) - 120px);
    min-height: 420px;
    margin-top: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
}
.chat-sidebar {
    width: 100%;
    padding: 14px;
    overflow-y: auto;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.chat-conv-list { display: flex; flex-direction: column; gap: 2px; }
.chat-conv-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 8px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    text-decoration: none;
}
.chat-conv-row:hover, .chat-conv-row.active { background: var(--accent-subtle); text-decoration: none; }
.chat-conv-info { flex: 1; min-width: 0; }
.chat-conv-name { font-size: 13.5px; font-weight: 400; }
.chat-conv-preview { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-unread-dot {
    background: var(--accent); color: var(--accent-fg);
    font-size: 11px; font-weight: 700;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.chat-thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-thread-empty {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; color: var(--text-tertiary); text-align: center; padding: 30px;
}
.chat-thread-active { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-thread-header {
    display: flex; align-items: center; gap: 4px;
    padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-back-btn { display: none; }

/* Typing indicator — a subtitle under the thread name, same spot WhatsApp
   puts it, so it doesn't disturb the message list's scroll position. */
.chat-typing-indicator { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--accent); font-weight: 600; margin-top: 1px; }
.chat-typing-dots { display: inline-flex; gap: 2px; }
.chat-typing-dots span {
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--accent);
    animation: chatTypingBounce 1.2s ease-in-out infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: .15s; }
.chat-typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes chatTypingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-3px); opacity: 1; } }

.chat-messages { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.chat-bubble-row { display: flex; flex-direction: column; }
.chat-bubble-row.mine { align-items: flex-end; }
.chat-bubble-row.theirs { align-items: flex-start; }
.chat-bubble {
    max-width: 78%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.4;
    background: var(--bg-secondary);
    color: var(--text-primary);
    position: relative;
}
.chat-bubble-row.mine .chat-bubble { background: var(--accent); color: var(--accent-fg); }
.chat-bubble-patient {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px;
    opacity: .8;
    margin-bottom: 3px;
}
.chat-bubble-footer { display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.chat-bubble-time {
    font-size: 10.5px;
    opacity: .65;
}
/* Always rendered for my own messages, shown only once the row gets its
   .seen class — toggled live by applySeenThreshold() in chat.js as poll
   responses come in, since read status can change long after the bubble
   was first drawn. */
.chat-bubble-seen { display: none; font-size: 10.5px; opacity: .8; font-weight: 600; }
.chat-bubble-row.mine.seen .chat-bubble-seen { display: inline; }
/* Reply/Edit/Forward — always visible, one direct click each, rendered
   below the bubble (not on top of its color) so the icons stay legible
   whatever the bubble's background is. */
.chat-bubble-actions-outside { display: flex; align-items: center; gap: 4px; margin-top: 3px; }
.chat-bubble-action-btn {
    display: flex; align-items: center; justify-content: center;
    width: 25px; height: 25px;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.chat-bubble-action-btn:hover { background: var(--accent-subtle); color: var(--accent); border-color: var(--accent-subtle-strong); }

.chat-bubble-forwarded {
    display: flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 600; font-style: italic;
    opacity: .75;
    margin-bottom: 4px;
}
.chat-bubble-quote {
    border-left: 3px solid currentColor;
    opacity: .85;
    padding: 4px 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    background: rgba(0,0,0,.06);
    cursor: pointer;
    font-size: 12px;
}
.chat-bubble-row.mine .chat-bubble-quote { background: rgba(255,255,255,.15); }
.chat-bubble-quote-sender { font-weight: 700; font-size: 11px; }
.chat-bubble-quote-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* The mentioned patient's own note, snapshotted at send time — a fixed
   amber tint regardless of mine/theirs, so it reads as an attached record
   rather than part of either bubble's own color. */
.chat-bubble-attached-note {
    background: var(--warning-subtle);
    color: var(--text-primary);
    border-radius: 8px;
    padding: 6px 9px;
    margin-bottom: 5px;
    font-size: 12px;
}
.chat-bubble-attached-note-label {
    display: flex; align-items: center; gap: 4px;
    font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .3px;
    color: var(--warning);
    margin-bottom: 2px;
}
/* Separates one mentioned patient's note+message section from the next,
   inside the same bubble (see bodyWithNotesHtml in chat.js). */
.chat-bubble-note-divider { border-top: 1px dashed currentColor; opacity: .3; margin: 8px 0; }
.chat-bubble-attached-note-body { white-space: pre-wrap; }

.chat-msg-highlight { animation: chatHighlight 2s ease; }
@keyframes chatHighlight {
    0% { background: var(--accent-subtle); border-radius: 14px; }
    100% { background: transparent; }
}

.chat-date-divider {
    display: flex; justify-content: center;
    position: sticky; top: 0; z-index: 1;
    margin: 6px 0;
}
.chat-date-divider span {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font-size: 11px; font-weight: 700;
    padding: 4px 12px;
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
}

.chat-compose-context {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}
.chat-compose-context-icon { color: var(--accent); flex-shrink: 0; display: flex; }
.chat-compose-context-body { flex: 1; min-width: 0; }
.chat-compose-context-title { font-size: 12px; font-weight: 700; color: var(--accent); }
.chat-compose-context-snippet { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* "Attach this patient's note?" offer, and the confirmed attachments —
   amber-toned (distinct from the blue reply/edit bar above) since both
   represent the same attached-record feature, not a reply/edit action. */
.chat-note-prompt .chat-compose-context-icon,
.chat-note-prompt .chat-compose-context-title { color: var(--warning); }
.chat-note-prompt-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Confirmed attachments — one row per mentioned patient (a handover can
   cover more than one), each independently removable. */
.chat-note-attached { border-top: 1px solid var(--border); background: var(--bg-secondary); flex-shrink: 0; }
.chat-note-attached-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 14px;
}
.chat-note-attached-item + .chat-note-attached-item { border-top: 1px solid var(--border); }
.chat-note-attached-item .chat-compose-context-icon,
.chat-note-attached-item .chat-compose-context-title { color: var(--warning); }

.chat-input-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border); flex-shrink: 0; position: relative; }
.chat-input-row input {
    flex: 1;
    padding: 10px 13px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    background: var(--surface);
}
.chat-input-patient { font-weight: 600; }
.chat-input-note-row { display: flex; gap: 6px; align-items: flex-end; }
/* Anchored to .chat-input-row (not .chat-input-note-row) so it opens above
   the whole compose area — patient name field included — instead of
   overlapping it in the narrow gap between the two rows. */
.chat-mention-list { top: auto; bottom: 100%; left: 14px; right: 14px; width: auto; margin-top: 0; margin-bottom: 6px; }

/* WhatsApp-style pill: attach + note + mic all live inside one field
   instead of competing with it for width as separate siblings. */
.chat-input-pill {
    flex: 1; min-width: 0;
    display: flex; align-items: flex-end; gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 22px;
    padding: 3px 3px 3px 4px;
    position: relative;
}
.chat-input-pill textarea {
    flex: 1; min-width: 0;
    resize: none;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font: inherit;
    line-height: 1.35;
    max-height: 96px;
    overflow-y: auto;
    outline: none;
}
.chat-input-pill .icon-btn { width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0; }

/* Plain icon, no bubble/gradient — a colored circle button next to a pill
   field reads as one-button-too-many; a bare icon keeps send visually
   subordinate to the message itself. */
.chat-send-btn {
    display: flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; flex-shrink: 0;
    background: transparent; border: none;
    color: var(--brand-navy);
    border-radius: 50%;
    cursor: pointer;
    transition: background .15s var(--ease), transform .1s var(--ease-spring);
}
.chat-send-btn:hover { background: var(--surface-hover); }
.chat-send-btn:active { background: var(--surface-hover); transform: scale(.9); transition-duration: .05s; }

/* Recording row — swaps in for .chat-input-note-row while a voice note is
   being captured (see assets/js/chat.js startRecording/stopRecording). */
.chat-recording-row {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 4px;
}
.chat-recording-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--danger);
    flex-shrink: 0;
    animation: chatRecordingPulse 1.1s ease-in-out infinite;
}
@keyframes chatRecordingPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.chat-recording-time { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.chat-recording-label { font-size: 12.5px; color: var(--text-secondary); flex: 1; }
.chat-recording-row .btn-icon-only { border-radius: 999px; width: 36px; height: 36px; flex-shrink: 0; }

/* Attachments inside a bubble ------------------------------------------- */
.chat-attachment { margin-bottom: 6px; }
.chat-bubble .chat-attachment:last-child { margin-bottom: 4px; }

.chat-attachment-image img {
    display: block;
    max-width: 100%; max-height: 260px;
    border-radius: 10px;
    cursor: zoom-in;
}

.chat-attachment-file {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(0,0,0,.06);
    color: inherit;
    text-decoration: none;
}
.chat-bubble-row.mine .chat-attachment-file { background: rgba(255,255,255,.15); }
.chat-attachment-file:hover { text-decoration: none; opacity: .88; }
.chat-attachment-file-info { display: flex; flex-direction: column; min-width: 0; }
.chat-attachment-file-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.chat-attachment-file-size { font-size: 10.5px; opacity: .75; }

.chat-attachment-voice {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px 6px 6px;
    border-radius: 999px;
    background: rgba(0,0,0,.06);
    min-width: 190px;
}
.chat-bubble-row.mine .chat-attachment-voice { background: rgba(255,255,255,.15); }
.chat-voice-play-btn {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: currentColor;
    color: inherit;
}
.chat-voice-play-btn svg { color: var(--bg-secondary); }
.chat-bubble-row.mine .chat-voice-play-btn svg { color: var(--accent); }
.chat-voice-track { flex: 1; height: 3px; border-radius: 999px; background: rgba(0,0,0,.15); overflow: hidden; }
.chat-bubble-row.mine .chat-voice-track { background: rgba(255,255,255,.3); }
.chat-voice-progress { height: 100%; width: 0; background: currentColor; }
.chat-voice-duration { font-size: 10.5px; font-variant-numeric: tabular-nums; opacity: .8; flex-shrink: 0; }

.chat-search-wrap { position: relative; margin-bottom: 12px; }
.chat-search-wrap .search-bar input { padding: 8px 56px 8px 18px; font-size: 13px; }
.chat-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    max-height: 340px;
    overflow-y: auto;
    z-index: 20;
}
.chat-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}
.chat-search-row:last-child { border-bottom: none; }
.chat-search-row:hover { background: var(--accent-subtle); text-decoration: none; }
.chat-search-row-body { flex: 1; min-width: 0; }
.chat-search-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-search-row-name { font-size: 12.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-search-row-date { font-size: 10.5px; color: var(--text-tertiary); flex-shrink: 0; }
.chat-search-row-patient { font-size: 11px; font-weight: 600; color: var(--accent); text-transform: uppercase; letter-spacing: .2px; }
.chat-search-row-snippet { font-size: 12px; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.chat-search-empty { padding: 14px; font-size: 12.5px; color: var(--text-tertiary); text-align: center; }

.chat-directory-row {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 6px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13.5px; font-weight: 500;
}
.chat-directory-row:hover { background: var(--accent-subtle); text-decoration: none; }

/* Operator picker rows on team.php / admin-practice-detail.php */
.practice-operator-row {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--border);
}
.practice-operator-row:last-child { border-bottom: none; }

/* Mobile: sidebar and thread stack, one visible at a time */
@media (max-width: 767px) {
    .chat-layout { height: calc(100vh - var(--topbar-h) - var(--bottomnav-h) - 90px); }
    .chat-thread { display: none; }
    .chat-layout.chat-mobile-show-thread .chat-sidebar { display: none; }
    .chat-layout.chat-mobile-show-thread .chat-thread { display: flex; }
    .chat-back-btn { display: inline-flex; }

    /* Full-screen immersive thread — the same pattern WhatsApp/Telegram/
       Messenger use: opening a conversation takes over the entire screen
       (topbar, page title, bottom-nav all hidden) instead of being
       squeezed into whatever's left under the app's normal chrome.
       Toggled by chat.js adding/removing .chat-fullscreen on <body> at the
       same moments it adds/removes .chat-mobile-show-thread above, so this
       only ever applies while a thread is actually open on a phone.
       100dvh (with a 100vh fallback for browsers that don't support it)
       so the box correctly shrinks when the on-screen keyboard appears
       instead of trapping the composer behind it. */
    body.chat-fullscreen .topbar,
    body.chat-fullscreen .bottom-nav,
    body.chat-fullscreen .chat-page-header {
        display: none !important;
    }
    body.chat-fullscreen .page-pad {
        padding: 0 !important;
    }
    body.chat-fullscreen .chat-layout {
        position: fixed;
        inset: 0;
        height: 100vh;
        height: 100dvh;
        margin: 0;
        border: none;
        border-radius: 0;
        z-index: 40;
    }

    /* The reply/edit/note-prompt subline truncates to one line on desktop,
       where the sidebar leaves the thread panel wide — too narrow on a
       phone, where it just clips mid-word. Let it wrap instead. */
    .chat-compose-context-snippet,
    .chat-note-attached-item .chat-compose-context-snippet {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
}

@media (min-width: 768px) {
    .chat-layout { flex-direction: row; }
    .chat-sidebar { width: 300px; border-bottom: none; border-right: 1px solid var(--border); }
    .chat-back-btn { display: none; }
}
