/* ==========================================================================
   Healthcare CRM portal — design system
   ========================================================================== */

:root {
    --brand: #0e7c86;
    --brand-600: #0b6a73;
    --brand-50: #e6f4f5;
    --brand-100: #c9e8ea;
    --ink: #0f1f2e;
    --ink-2: #44546a;
    --muted: #7a8799;
    --line: #e6eaf0;
    --surface: #ffffff;
    --canvas: #f4f6fa;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 16px rgba(16, 24, 40, .05);
    --sidebar-w: 256px;

    --bs-primary: var(--brand);
    --bs-primary-rgb: 14, 124, 134;
    --bs-link-color: var(--brand);
    --bs-link-color-rgb: 14, 124, 134;
    --bs-link-hover-color: var(--brand-600);
    --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-body-color: var(--ink);
    --bs-border-color: var(--line);
}

html, body {
    background: var(--canvas);
    color: var(--ink);
    font-family: var(--bs-body-font-family);
    font-size: 14.5px;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5 { color: var(--ink); letter-spacing: -.01em; }
h1:focus { outline: none; }
a { text-decoration: none; }

/* ---------- Buttons & forms ---------- */

.btn { border-radius: 10px; font-weight: 500; padding: .5rem .95rem; }
.btn-sm { border-radius: 8px; padding: .3rem .65rem; font-size: .82rem; }
/* Bootstrap 5 colours buttons through --bs-btn-* variables (including the checked state of .btn-check),
   so the theme sets those rather than the properties directly. */
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-600);
    --bs-btn-hover-border-color: var(--brand-600);
    --bs-btn-active-bg: var(--brand-600);
    --bs-btn-active-border-color: var(--brand-600);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    --bs-btn-focus-shadow-rgb: 14, 124, 134;
}
.btn-outline-primary {
    --bs-btn-color: var(--brand);
    --bs-btn-bg: var(--surface);
    --bs-btn-border-color: var(--brand-100);
    --bs-btn-hover-color: var(--brand-600);
    --bs-btn-hover-bg: var(--brand-50);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
    --bs-btn-disabled-color: var(--brand);
    --bs-btn-focus-shadow-rgb: 14, 124, 134;
}
.btn-link { --bs-btn-color: var(--brand); --bs-btn-hover-color: var(--brand-600); --bs-btn-active-color: var(--brand-600); }
.btn-light-soft { background: var(--surface); border: 1px solid var(--line); color: var(--ink-2); }
.btn-light-soft:hover { background: var(--canvas); color: var(--ink); }

.form-control, .form-select { border-radius: 10px; border-color: var(--line); padding: .55rem .8rem; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem rgba(14, 124, 134, .15);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 500; color: var(--ink-2); font-size: .85rem; margin-bottom: .35rem; }
.input-icon { position: relative; }
.input-icon > .bi { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon > .form-control { padding-left: 2.3rem; }

/* ---------- App shell ---------- */

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

.app-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.app-brand { display: flex; align-items: center; gap: .65rem; padding: 1.25rem 1.25rem 1rem; color: var(--ink); }
.app-brand:hover { color: var(--ink); }
.app-brand-mark {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), #14a3a0);
    color: #fff; display: grid; place-items: center; font-size: 1.1rem;
    box-shadow: 0 4px 10px rgba(14, 124, 134, .3);
}
.app-brand-name { font-weight: 700; line-height: 1.1; }
.app-brand-sub { font-size: .72rem; color: var(--muted); }

.app-nav { padding: .5rem .75rem; flex: 1; overflow-y: auto; }
.app-nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 1rem .75rem .4rem; font-weight: 600; }
.app-nav-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem .75rem; border-radius: 10px;
    color: var(--ink-2); font-weight: 500; margin-bottom: 2px;
}
.app-nav-link .bi { font-size: 1.05rem; color: var(--muted); }
.app-nav-link:hover { background: var(--canvas); color: var(--ink); }
.app-nav-link.active { background: var(--brand-50); color: var(--brand-600); }
.app-nav-link.active .bi { color: var(--brand); }

.app-sidebar-footer { padding: 1rem; border-top: 1px solid var(--line); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: 0 1.75rem; background: rgba(255, 255, 255, .85); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.app-topbar-title { color: var(--muted); font-size: .85rem; }
.app-user { display: flex; align-items: center; gap: .65rem; }
.app-user-name { font-weight: 600; line-height: 1.1; font-size: .88rem; }
.app-user-role { font-size: .74rem; color: var(--muted); }

.app-content { padding: 1.75rem; max-width: 1320px; width: 100%; }

.app-menu-toggle { display: none; }

@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
    #app-menu:checked ~ .app-shell .app-sidebar { transform: none; }
    .app-menu-toggle { display: inline-flex; }
    .app-content { padding: 1.25rem; }
    .app-topbar { padding: 0 1.25rem; }
}

/* ---------- Page header ---------- */

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-title { font-size: 1.6rem; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--muted); margin: .25rem 0 0; }
.breadcrumb-link { color: var(--muted); font-size: .85rem; display: inline-flex; align-items: center; gap: .3rem; margin-bottom: .5rem; }
.breadcrumb-link:hover { color: var(--brand); }

/* ---------- Cards ---------- */

.card-soft { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-soft > .card-body, .card-pad { padding: 1.25rem 1.35rem; }
.card-soft-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.35rem; border-bottom: 1px solid var(--line); }
.card-soft-title { font-weight: 600; margin: 0; font-size: 1rem; }
a.card-soft { color: inherit; display: block; transition: box-shadow .15s, transform .15s, border-color .15s; }
a.card-soft:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--brand-100); }

/* ---------- Stat cards ---------- */

.stat-card, a.card-soft.stat-card { display: flex; gap: 1rem; align-items: center; padding: 1.15rem 1.25rem; height: 100%; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.3rem; flex-shrink: 0; }
.stat-label { color: var(--muted); font-size: .8rem; font-weight: 500; }
.stat-value { font-size: 1.65rem; font-weight: 700; line-height: 1.15; color: var(--ink); }
.stat-hint { font-size: .75rem; color: var(--muted); }

.tone-teal { background: var(--brand-50); color: var(--brand); }
.tone-indigo { background: #eef0ff; color: #4f5bd5; }
.tone-amber { background: #fff5e6; color: #c77700; }
.tone-rose { background: #ffeef1; color: #d6336c; }
.tone-green { background: #e8f7ee; color: #1f8f4e; }
.tone-slate { background: #eef1f5; color: #4b5b70; }

/* ---------- Toolbar & chips ---------- */

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem; padding: 1rem 1.35rem; border-bottom: 1px solid var(--line); }
.toolbar .form-control, .toolbar .form-select { min-width: 190px; }
.chip-group { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .35rem .75rem; border-radius: 999px;
    border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: .8rem; font-weight: 500;
}
.chip:hover { border-color: var(--brand-100); color: var(--ink); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .count { opacity: .75; font-size: .72rem; }

/* ---------- Data grid ---------- */

.data-grid { width: 100%; margin: 0; border-collapse: separate; border-spacing: 0; }
.data-grid thead th {
    background: #fafbfc; color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    padding: .75rem 1rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.data-grid thead th a { color: inherit; display: inline-flex; align-items: center; gap: .25rem; }
.data-grid thead th a:hover { color: var(--ink); }
.data-grid thead th a.sorted { color: var(--brand); }
.data-grid tbody td { padding: .8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-grid tbody tr:last-child td { border-bottom: 0; }
.data-grid tbody tr:hover td { background: #fafcfd; }
.data-grid tr.row-link { cursor: pointer; }
.grid-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; padding: .85rem 1.35rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
.data-grid .cell-main, .data-grid .cell-sub, .data-grid .tag { white-space: nowrap; }
.data-grid .tag { max-width: 200px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.cell-main { font-weight: 600; color: var(--ink); }
a.cell-main:hover { color: var(--brand); }
.cell-sub { font-size: .78rem; color: var(--muted); }
.person { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.time-pill { display: inline-flex; align-items: center; gap: .35rem; background: var(--canvas); border-radius: 8px; padding: .2rem .55rem; font-weight: 600; font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.date-block { display: flex; align-items: center; gap: .7rem; }
.date-tile { width: 42px; text-align: center; border-radius: 10px; border: 1px solid var(--line); overflow: hidden; flex-shrink: 0; background: var(--surface); }
.date-tile .m { background: var(--brand); color: #fff; font-size: .62rem; font-weight: 700; text-transform: uppercase; padding: 1px 0; }
.date-tile .d { font-weight: 700; font-size: 1rem; line-height: 1.6; }

/* ---------- Status pills ---------- */

.pill { display: inline-flex; align-items: center; gap: .4rem; padding: .22rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-planned { background: #eef1f5; color: #52627a; }
.pill-confirmed { background: #e8f0ff; color: #2f6fd6; }
.pill-inprogress { background: #fff5e6; color: #c77700; }
.pill-completed, .pill-active, .pill-available { background: #e8f7ee; color: #1f8f4e; }
.pill-canceled, .pill-disable, .pill-deleted, .pill-unavailable { background: #ffeef1; color: #d6336c; }

.tag { display: inline-block; padding: .18rem .55rem; border-radius: 6px; background: var(--brand-50); color: var(--brand-600); font-size: .72rem; font-weight: 600; letter-spacing: .02em; text-transform: capitalize; }
.code-tag { display: inline-block; padding: .15rem .45rem; border-radius: 6px; background: #eef0ff; color: #4f5bd5; font-family: ui-monospace, Consolas, monospace; font-size: .78rem; font-weight: 600; }

/* ---------- Avatar ---------- */

.avatar { border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; color: #fff; flex-shrink: 0; letter-spacing: .02em; }

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

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--muted); }
.empty-state > .bi { font-size: 2.4rem; color: var(--brand-100); display: block; margin-bottom: .75rem; }
.empty-state h6 { color: var(--ink); font-weight: 600; }

/* ---------- Flash message ---------- */

.flash {
    display: flex; align-items: center; gap: .65rem; padding: .8rem 1rem; border-radius: 12px; margin-bottom: 1.25rem;
    background: #e8f7ee; color: #17663a; border: 1px solid #c8ecd6; font-weight: 500;
    animation: flash-in .25s ease-out;
}
.flash .bi { font-size: 1.15rem; }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- Slots ---------- */

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; }
.slot-btn {
    border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: .55rem .5rem;
    font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); text-align: center; font-size: .85rem;
}
.slot-btn small { display: block; color: var(--muted); font-weight: 500; font-size: .7rem; }
.slot-btn:hover { border-color: var(--brand); background: var(--brand-50); color: var(--brand-600); }

/* ---------- Steps ---------- */

.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; font-size: .8rem; font-weight: 700; margin-right: .5rem; }

/* ---------- Visit timeline ---------- */

.timeline { position: relative; padding-left: 1.75rem; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline-item { position: relative; margin-bottom: 1rem; }
.timeline-dot { position: absolute; left: -1.75rem; top: 1.1rem; width: 20px; height: 20px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); display: grid; place-items: center; font-size: .6rem; }
.timeline-dot.completed { border-color: #1f8f4e; color: #1f8f4e; }
.timeline-dot.canceled { border-color: #d6336c; color: #d6336c; }
.timeline-dot.upcoming { border-color: #2f6fd6; color: #2f6fd6; }
.visit-record { background: #fafcfd; border: 1px dashed var(--line); border-radius: 12px; padding: .9rem 1rem; margin-top: .85rem; }
.visit-record dl { display: grid; grid-template-columns: 140px 1fr; gap: .35rem .9rem; margin: 0; font-size: .86rem; }
.visit-record dt { color: var(--muted); font-weight: 500; }
.visit-record dd { margin: 0; }

/* ---------- Login ---------- */

.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; width: 100%; }
.login-hero {
    background: radial-gradient(900px 500px at -10% -10%, #19a7a2 0%, transparent 60%), linear-gradient(160deg, #0b5f69 0%, #0e7c86 55%, #12928f 100%);
    color: #fff; padding: 3.5rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden;
}
.login-hero::after { content: ""; position: absolute; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(255, 255, 255, .06); right: -140px; bottom: -140px; }
.login-hero h1 { color: #fff; font-size: 2.4rem; font-weight: 700; line-height: 1.15; }
.login-hero p { color: rgba(255, 255, 255, .82); font-size: 1.05rem; max-width: 30rem; }
.login-feature { display: flex; gap: .8rem; align-items: flex-start; margin-bottom: 1rem; color: rgba(255, 255, 255, .92); }
.login-feature .bi { background: rgba(255, 255, 255, .14); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.login-feature small { color: rgba(255, 255, 255, .7); }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 2.5rem; background: var(--surface); }
.login-box { width: 100%; max-width: 440px; }
.demo-account {
    display: flex; align-items: center; gap: .8rem; width: 100%; text-align: left; padding: .6rem .8rem;
    border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: .5rem; color: var(--ink);
}
.demo-account:hover { border-color: var(--brand); background: var(--brand-50); }
.demo-account .bi-arrow-right { margin-left: auto; color: var(--muted); }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .78rem; margin: 1.5rem 0 1rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

@media (max-width: 991.98px) {
    .login-wrap { grid-template-columns: 1fr; }
    .login-hero { padding: 2rem; }
    .login-hero .login-features { display: none; }
}

/* ---------- Search ---------- */

.topbar-search { flex: 1; max-width: 440px; }
.topbar-search .form-control { background: var(--canvas); border-color: transparent; }
.topbar-search .form-control:focus { background: var(--surface); }
.search-hit { display: flex; align-items: center; gap: .8rem; padding: .65rem .8rem; border-radius: 10px; color: var(--ink); }
.search-hit:hover { background: var(--brand-50); color: var(--ink); }

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

.min-w-0 { min-width: 0; }
.fw-600 { font-weight: 600; }

.profile-cover { height: 64px; border-radius: var(--radius) var(--radius) 0 0; background: linear-gradient(120deg, var(--brand-50), #eef0ff); }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: .5rem .75rem; font-size: .86rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; }

.blazor-error-boundary { background: #b32121; padding: 1rem 1rem 1rem 3.7rem; color: white; }
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ---- Form helpers (front desk, settings) ---- */
.form-section { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-top: 1px solid #edf0f4; padding-top: .9rem; }
.choice { display: flex; gap: .75rem; align-items: flex-start; border: 1px solid #e3e8ef; border-radius: var(--radius-sm); padding: .8rem .9rem; margin-bottom: .75rem; cursor: pointer; transition: border-color .15s, background .15s; }
.choice:hover { border-color: var(--brand-100); }
.choice:has(input:checked), .choice.active { border-color: var(--brand); background: var(--brand-50); }
.choice input { margin-top: .25rem; accent-color: var(--brand); }

/* ---- QR, check-in, printable slip & patient card ---- */
.qr { display: inline-block; flex: none; line-height: 0; }
.qr svg { width: 100%; height: 100%; }
.pill-checkedin { background: #e7f6ee; color: #1e7a4c; }
.scan-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.checkin-result { display: flex; gap: .8rem; align-items: center; margin: 0 1.25rem 1.25rem; padding: .9rem 1rem; border-radius: var(--radius-sm); }
.checkin-result i { font-size: 1.6rem; }
.checkin-result.ok { background: #e7f6ee; color: #1e5f3e; }
.checkin-result.fail { background: #fdecec; color: #8a2222; }
.scan-confirm { padding: 1rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.qr-scanner { position: fixed; inset: 0; z-index: 1200; display: flex; flex-direction: column; background: #0f172a; color: #fff; }
.qr-scanner[hidden] { display: none; }
.qr-scanner video { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.qr-scanner video.qr-mirror { transform: scaleX(-1); }
.qr-scanner-bar { display: flex; flex-direction: column; gap: .75rem; margin-top: auto; padding: 1rem; }

.print-sheet { background: #fff; border: 1px solid #e3e8ef; border-radius: var(--radius); max-width: 620px; }
.slip-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 1.25rem 1.5rem; border-bottom: 1px dashed #d5dce6; }
.slip-body { display: flex; gap: 1.5rem; align-items: center; padding: 1.25rem 1.5rem; }
.slip-qr { text-align: center; }
.slip-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 700; letter-spacing: .18em; margin-top: .35rem; }
.slip-foot { padding: .9rem 1.5rem; border-top: 1px dashed #d5dce6; }

.patient-card { width: 340px; border-radius: 16px; overflow: hidden; background: #fff; border: 1px solid #e3e8ef; box-shadow: 0 8px 24px rgba(15, 23, 42, .08); }
.patient-card-top { display: flex; align-items: center; gap: .6rem; padding: .8rem 1rem; color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-600)); }
.patient-card-top .app-brand-mark { width: 30px; height: 30px; font-size: .95rem; background: rgba(255, 255, 255, .2); box-shadow: none; }
.patient-card-body { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem; }
.patient-card-label { font-size: .65rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.patient-card-name { font-size: 1.1rem; font-weight: 700; }
.patient-card-foot { font-size: .72rem; color: var(--muted); padding: .55rem 1rem; border-top: 1px solid #edf0f4; }

@media print {
    .app-sidebar, .app-topbar, .no-print, .flash { display: none !important; }
    .app-main { margin: 0 !important; padding: 0 !important; }
    .app-content { padding: 0 !important; }
    body { background: #fff !important; }
    .print-sheet, .patient-card { box-shadow: none; break-inside: avoid; }
    .patient-card-top { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}


/* ---- CRM: leads board, stepper, activity ---- */
.tone-blue { background: #e8f0ff; color: #2f6fd6; }
.tag-soft { background: #eef1f5; color: #4b5b70; }
.tag-ok { background: #e8f7ee; color: #1f8f4e; }

.kanban { display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr)); gap: .9rem; overflow-x: auto; padding-bottom: .5rem; }
.kanban-col { background: #f3f5f9; border-radius: var(--radius); display: flex; flex-direction: column; min-height: 220px; }
.kanban-head { display: flex; justify-content: space-between; align-items: center; margin: .6rem .6rem 0; padding: .45rem .7rem; border-radius: var(--radius-sm); font-weight: 700; font-size: .82rem; }
.kanban-count { background: rgba(255, 255, 255, .7); border-radius: 999px; padding: 0 .5rem; font-size: .75rem; }
.kanban-body { display: flex; flex-direction: column; gap: .6rem; padding: .6rem; }
.kanban-empty { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem 0; }
.lead-card { background: #fff; border: 1px solid #e3e8ef; border-radius: var(--radius-sm); padding: .7rem .75rem; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); transition: box-shadow .15s, border-color .15s; }
.lead-card:hover { border-color: var(--brand-100); box-shadow: 0 4px 12px rgba(15, 23, 42, .07); }
.stretched-link-lite { display: block; color: inherit; text-decoration: none; }
.stretched-link-lite:hover .fw-600 { color: var(--brand); }

.stage-steps { display: flex; flex-wrap: wrap; gap: .35rem; }
.stage-step { flex: 1 1 110px; border: 0; padding: .55rem .8rem; background: #eef1f5; color: #52627a; font-weight: 600; font-size: .82rem;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); transition: background .15s; }
.stage-step:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); border-radius: 8px 0 0 8px; }
.stage-step:hover:not(:disabled) { background: var(--brand-100); color: var(--brand-600); }
.stage-step.done { background: var(--brand-50); color: var(--brand-600); }
.stage-step.current { background: var(--brand); color: #fff; opacity: 1; }

.lead-message { background: #f6f8fb; border-radius: var(--radius-sm); padding: .6rem .75rem; font-size: .85rem; }
.visit-mini { display: flex; align-items: center; gap: .8rem; padding: .6rem; border: 1px solid #e3e8ef; border-radius: var(--radius-sm); }

.activity-list { list-style: none; padding: 0; margin: 0; }
.activity-list li { display: flex; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid #f0f2f6; }
.activity-list li:last-child { border-bottom: 0; }
.activity-icon { flex: none; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); font-size: .8rem; }

.funnel-row { display: grid; grid-template-columns: 80px 1fr auto; align-items: center; gap: .6rem; margin-bottom: .45rem; }
.funnel-bar { height: 8px; background: #eef1f5; border-radius: 999px; overflow: hidden; }
.funnel-bar > span { display: block; height: 100%; border-radius: 999px; background: currentColor; }

/* ---- Lead channels ---- */
.key-reveal { background: #fff8e6; border: 1px solid #f5d48a; border-radius: var(--radius); padding: 1rem 1.25rem; }
.key-value { display: block; font-size: .95rem; background: #fff; border: 1px dashed #e0b84f; border-radius: 8px; padding: .55rem .75rem; word-break: break-all; user-select: all; }
pre.payload { background: #f6f8fb; border-radius: 8px; padding: .6rem .75rem; font-size: .75rem; white-space: pre-wrap; word-break: break-word; max-width: 420px; margin: .4rem 0 0; }

/* ---- Billing ---- */
.line-editor { width: 100%; border-collapse: separate; border-spacing: 0 .4rem; }
.line-editor th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 0 .3rem; }
.line-editor td { padding: 0 .3rem; }
.invoice-totals { padding: 1rem 1.25rem; margin-left: auto; max-width: 360px; }
.invoice-totals > div { display: flex; justify-content: space-between; gap: 1rem; padding: .2rem 0; }
.invoice-totals .grand { font-weight: 700; font-size: 1.05rem; border-top: 1px solid #e3e8ef; margin-top: .3rem; padding-top: .45rem; }
.invoice-totals .due { font-weight: 700; color: var(--brand-600); }
.payment-row { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .45rem 0; border-bottom: 1px solid #f0f2f6; }
.row-selected { background: var(--brand-50); }

.invoice-sheet { max-width: 820px; padding: 2rem 2.25rem; }
.inv-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--brand); padding-bottom: 1rem; }
.inv-title { font-size: 1.15rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-600); }
.inv-parties { display: flex; gap: 3rem; padding: 1rem 0; }
.inv-lines { width: 100%; border-collapse: collapse; font-size: .88rem; }
.inv-lines th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid #d5dce6; padding: .45rem .3rem; }
.inv-lines td { border-bottom: 1px solid #edf0f4; padding: .5rem .3rem; }
.inv-foot { display: flex; align-items: flex-start; gap: 1.5rem; margin-top: 1rem; }
.inv-qr { text-align: center; }
.receipt-sheet { max-width: 360px; padding: 1.5rem; }
.receipt-amount { font-size: 1.8rem; font-weight: 800; text-align: center; margin: 1rem 0 .25rem; color: var(--brand-600); }
@media print { .invoice-sheet, .receipt-sheet { border: 0; max-width: none; } }

/* ---- Accounts ---- */
.day-bars { display: flex; align-items: flex-end; gap: 4px; height: 170px; }
.day-bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.day-bar > span { width: 100%; max-width: 26px; background: var(--brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.day-bar:hover > span { background: var(--brand-600); }
.day-bar small { font-size: .62rem; color: var(--muted); margin-top: 3px; }
.rank-row { margin-bottom: .7rem; }
.rank-row .funnel-bar > span { background: var(--brand); }

/* ---- Attendance clock ---- */
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #1f8f4e; margin-right: .45rem; box-shadow: 0 0 0 3px rgba(31, 143, 78, .18); vertical-align: middle; }

/* ---- Checkbox chips (specialties, working days) ---- */
.check-chip { position: relative; cursor: pointer; margin: 0; }
.check-chip input { position: absolute; opacity: 0; pointer-events: none; }
.check-chip span { display: inline-block; padding: .35rem .8rem; border: 1px solid #d5dce6; border-radius: 999px; font-size: .85rem; font-weight: 600; color: #52627a; background: #fff; transition: all .15s; }
.check-chip:hover span { border-color: var(--brand-100); }
.check-chip input:checked + span { background: var(--brand-50); border-color: var(--brand); color: var(--brand-600); }
.check-chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- Specialties: doctor chips ---- */
.doctor-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .35rem .25rem .7rem; border-radius: 999px; background: var(--brand-50); color: var(--brand-600); font-size: .82rem; font-weight: 600; }
.doctor-chip.inactive { background: #eef1f5; color: #6b7a90; }
.chip-x { border: 0; background: transparent; color: inherit; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; padding: 0; line-height: 1; }
.chip-x:hover { background: rgba(214, 51, 108, .12); color: #d6336c; }
/* ---- Inventory reports ---- */
.report-list { display: flex; flex-direction: column; padding: .4rem; }
.report-link { display: flex; gap: .7rem; align-items: flex-start; padding: .6rem .7rem; border-radius: var(--radius-sm); color: inherit; text-decoration: none; }
.report-link i { font-size: 1.1rem; color: var(--brand); margin-top: .1rem; }
.report-link:hover { background: #f3f5f9; }
.report-link.active { background: var(--brand-50); box-shadow: inset 3px 0 0 var(--brand); }
.report-chart { border-bottom: 1px solid #edf0f4; }
.report-bar { display: grid; grid-template-columns: minmax(120px, 220px) 1fr auto; align-items: center; gap: .7rem; margin-bottom: .35rem; font-size: .82rem; }
.report-bar .funnel-bar > span { background: var(--brand); }
.report-bar-value { font-weight: 600; white-space: nowrap; }
.report-table tfoot td { font-weight: 700; background: #f6f8fb; border-top: 2px solid var(--brand-100); }
.report-print-brand { display: none; font-size: .8rem; font-weight: 700; color: var(--brand-600); margin-bottom: .2rem; }
@media print {
    .report-print-brand { display: block; }
    .report-sheet { border: 0; box-shadow: none; }
    .col-xl-9 { width: 100% !important; flex: 0 0 100% !important; max-width: 100% !important; }
}

/* ---- Arabic / right-to-left ---- */
[dir="rtl"] { --bs-body-font-family: 'Cairo', 'Inter', system-ui, 'Segoe UI', sans-serif; }
[dir="rtl"] body { font-family: var(--bs-body-font-family); }
[dir="rtl"] .input-icon > .bi { left: auto; right: .8rem; }
[dir="rtl"] .input-icon > .form-control { padding-left: .75rem; padding-right: 2.3rem; }
[dir="rtl"] .app-sidebar { border-right: 0; border-left: 1px solid var(--line); }
[dir="rtl"] .step-num { margin-right: 0; margin-left: .5rem; }
[dir="rtl"] .timeline { padding-left: 0; padding-right: 1.75rem; }
[dir="rtl"] .timeline::before { left: auto; right: 9px; }
[dir="rtl"] .timeline-dot { left: auto; right: -1.75rem; }
[dir="rtl"] .login-hero::after { right: auto; left: -140px; }
[dir="rtl"] .demo-account { text-align: right; }
[dir="rtl"] .demo-account .bi-arrow-right { margin-left: 0; margin-right: auto; }
[dir="rtl"] .invoice-totals { margin-left: 0; margin-right: auto; }
[dir="rtl"] .inv-lines th { text-align: right; }
[dir="rtl"] .live-dot { margin-right: 0; margin-left: .45rem; }
/* Arrows and chevrons point the reading direction. */
[dir="rtl"] .bi-chevron-left, [dir="rtl"] .bi-chevron-right, [dir="rtl"] .bi-arrow-left,
[dir="rtl"] .bi-arrow-right, [dir="rtl"] .bi-arrow-left-short, [dir="rtl"] .bi-arrow-right-short { display: inline-block; transform: scaleX(-1); }
/* Codes, numbers and emails stay left-to-right inside Arabic text. */
[dir="rtl"] .code-tag, [dir="rtl"] input[type="email"], [dir="rtl"] input[type="tel"], [dir="rtl"] .slip-code { direction: ltr; unicode-bidi: isolate; }
.lang-switch { white-space: nowrap; }
[lang="ar"].lang-switch, .lang-switch [lang="ar"] { font-family: 'Cairo', sans-serif; }
@media (max-width: 991.98px) {
    /* The off-canvas menu slides in from the right in Arabic. */
    [dir="rtl"] .app-sidebar { right: 0; left: auto; transform: translateX(100%); }
    [dir="rtl"] #app-menu:checked ~ .app-shell .app-sidebar { transform: none; }
}

/* ---- Patient attachments ---- */
.attach-list { display: flex; flex-direction: column; gap: .5rem; }
.attach-row { display: flex; align-items: flex-start; gap: .75rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: 10px; }
.attach-icon { font-size: 1.5rem; color: var(--brand); line-height: 1; margin-top: .1rem; }
.attach-form { border-top: 1px dashed var(--line); padding-top: .9rem; }
.min-w-0 { min-width: 0; }

/* ---- WhatsApp sharing ---- */
.btn-whatsapp { background: #25d366; border-color: #25d366; color: #fff; }
.btn-whatsapp:hover, .btn-whatsapp:focus { background: #1ebe5a; border-color: #1ebe5a; color: #fff; }
.wa-toast { position: fixed; bottom: 1.25rem; inset-inline-start: 50%; transform: translateX(-50%); z-index: 1100; max-width: min(92vw, 520px);
    background: #0f172a; color: #fff; padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow); font-size: .9rem; }
[dir="rtl"] .wa-toast { transform: translateX(50%); }

/* ---- Lead follow-up ---- */
.tone-violet { background: #f3edff; color: #7048c6; }
.followup-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding-top: .75rem; border-top: 1px dashed var(--line); }

/* ---- Follow-up bell ---- */
.notif { position: relative; }
.notif > summary { list-style: none; position: relative; }
.notif > summary::-webkit-details-marker { display: none; }
.notif-badge { position: absolute; top: -6px; inset-inline-end: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: #d6336c; color: #fff; font-size: .68rem; font-weight: 700; line-height: 18px; text-align: center; }
.notif-panel { position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 1050; width: min(360px, 92vw);
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.notif-item { display: flex; align-items: center; gap: .65rem; padding: .6rem .9rem; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.notif-item:hover { background: var(--brand-50); }
.notif-icon { font-size: 1.1rem; }
.notif-empty { padding: 1rem .9rem; color: var(--muted); font-size: .9rem; }
.notif-foot { display: block; text-align: center; padding: .55rem; font-size: .85rem; font-weight: 600; }

/* ---- Invoice filters ---- */
.invoice-filters { border-top: 1px dashed var(--line); padding-top: .75rem; align-items: flex-end; }
.invoice-totals-strip { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; align-items: center; margin: 0 0 1rem; padding: .7rem 1rem;
    border-radius: 10px; background: var(--brand-50); font-size: .88rem; }
.invoice-totals-strip strong { margin-inline-start: .35rem; }

/* ---- Expense categories ---- */
.expense-cat-row { display: flex; align-items: center; gap: .75rem; padding: .45rem .5rem; border-radius: 8px; color: inherit; text-decoration: none; }
.expense-cat-row:hover { background: var(--brand-50); }
.expense-cat-row.selected { background: var(--brand-50); outline: 1px solid var(--brand-100); }
.expense-cat-name { width: 130px; flex-shrink: 0; font-weight: 600; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-row { display: flex; align-items: center; gap: .4rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.cat-row.inactive { opacity: .6; }
.cat-edit, .cat-new { display: flex; flex-direction: column; gap: .4rem; }
.cat-edit { padding: .6rem; border: 1px solid var(--brand-100); border-radius: 8px; background: var(--brand-50); }

/* WhatsApp inbox */
.wa-simulate { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .6rem .8rem; border: 1px dashed var(--brand-100); border-radius: var(--radius-sm); background: var(--brand-50); }
.wa-simulate input { width: auto; min-width: 130px; }
.wa-layout { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 1rem; align-items: start; }
.wa-side { overflow: hidden; }
.wa-search { padding: .75rem .75rem .25rem; }
.wa-filters { display: flex; gap: .25rem; padding: .4rem .75rem .6rem; border-bottom: 1px solid var(--line); overflow-x: auto; }
.wa-filter { padding: .2rem .6rem; border-radius: 999px; font-size: .8rem; color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.wa-filter.active { background: var(--brand); color: #fff; }
.wa-row { display: flex; gap: .6rem; padding: .65rem .75rem; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.wa-row:hover { background: var(--canvas); }
.wa-row.active { background: var(--brand-50); }
.wa-count { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; line-height: 20px; }
.wa-main { display: flex; flex-direction: column; min-height: 520px; overflow: hidden; }
.wa-head { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .7rem .9rem; border-bottom: 1px solid var(--line); }
.wa-head .form-select { width: auto; max-width: 170px; }
.wa-thread { flex: 1; display: flex; flex-direction: column; gap: .5rem; height: 56vh; padding: 1rem; overflow-y: auto; background: var(--canvas); }
.wa-msg { align-self: flex-start; max-width: min(75%, 560px); padding: .5rem .7rem; border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); }
.wa-msg.outbound { align-self: flex-end; background: var(--brand-50); }
.wa-msg.note { align-self: center; max-width: 90%; background: #fff8e1; border: 1px dashed #e8c95a; }
.wa-msg.failed { border: 1px solid #e5a3a3; }
.wa-msg-label { margin-bottom: .2rem; font-size: .72rem; font-weight: 600; color: #8a6d00; }
.wa-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.wa-image { display: block; max-width: 100%; max-height: 280px; border-radius: 8px; }
.wa-file { display: inline-block; overflow-wrap: anywhere; font-weight: 600; }
.wa-msg audio { max-width: 100%; }
.wa-meta { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; margin-top: .2rem; font-size: .7rem; color: var(--muted); }
.wa-compose { display: flex; flex-direction: column; gap: .5rem; padding: .75rem .9rem; border-top: 1px solid var(--line); }
.wa-closed { padding: .75rem .9rem; border-top: 1px solid var(--line); font-size: .85rem; color: var(--ink-2); background: var(--canvas); }
.wa-note { display: flex; gap: .5rem; padding: .5rem .9rem .75rem; border-top: 1px solid var(--line); }
@media (max-width: 991.98px) {
    .wa-layout { grid-template-columns: minmax(0, 1fr); }
    .wa-layout.has-thread .wa-side { display: none; }
}
.wa-compose-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.wa-compose-row input[type=file] { flex: 1 1 200px; width: auto; min-width: 0; }
.wa-compose-row .btn { margin-inline-start: auto; }
.wa-toast-error { background: #b42318; color: #fff; }
.toast-auto { animation: toast-away .3s ease 8s forwards; }
@keyframes toast-away { to { opacity: 0; visibility: hidden; } }
