/* =====================================================================
   Digital OPD — shared shell for all three portals
   Design notes
   ------------
   Palette is anchored on the Digital OPD purple. Ink is a plum-black so
   the chrome never reads as "generic dark grey admin".
   No web fonts: clinic desktops sit on slow LANs and a blocked font CDN
   must never delay the first paint of a booking screen. The system stack
   is tuned with tracking and weight instead.
   Signature: each portal has a coloured spine — on the login card and
   down the left edge of the sidebar — so staff always know which of the
   three doors they walked through.
   ===================================================================== */

:root {
    --ink:          #1B1436;
    --ink-2:        #2A2150;
    --ink-soft:     #6B6480;
    --violet:       #6A3FD1;
    --violet-dark:  #563099;
    --violet-soft:  #EFEAFB;
    --teal:         #0E7C7B;
    --teal-soft:    #E2F1F0;
    --amber:        #B8710A;
    --amber-soft:   #FCF1DF;
    --rose:         #C02D4B;
    --rose-soft:    #FCE9EC;
    --paper:        #F7F6FB;
    --card:         #FFFFFF;
    --line:         #E3E0EC;
    --line-strong:  #CFC9DE;

    --radius:       8px;
    --radius-sm:    5px;
    --shadow:       0 1px 2px rgba(27,20,54,.06), 0 8px 24px rgba(27,20,54,.06);
    --sidebar-w:    248px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
            "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/* Portal accents */
.portal-platform { --accent: var(--ink);    --accent-soft: #E7E4F0; }
.portal-clinic   { --accent: var(--violet); --accent-soft: var(--violet-soft); }
.portal-desk     { --accent: var(--teal);   --accent-soft: var(--teal-soft); }

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--violet); text-decoration: none; }
a:hover { color: var(--violet-dark); text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.011em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

.muted     { color: var(--ink-soft); }
.small     { font-size: 12.5px; }
.mono      { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.num       { font-variant-numeric: tabular-nums; }
.eyebrow   { font-size: 11px; font-weight: 700; letter-spacing: .10em;
             text-transform: uppercase; color: var(--ink-soft); }

/* ---------------------------------------------------------- login screens */

.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(900px 420px at 12% -8%, rgba(106,63,209,.10), transparent 60%),
        radial-gradient(700px 380px at 105% 108%, rgba(14,124,123,.09), transparent 60%),
        var(--paper);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: grid;
    grid-template-columns: 46px 1fr;
}

/* The signature: a coloured spine naming the door you are at. */
.auth-spine {
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-spine span {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .22em;
    text-transform: uppercase;
    opacity: .92;
}

.auth-body  { padding: 32px 30px 28px; }
.auth-mark  { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.auth-mark b { color: var(--accent); }
.auth-title { margin: 20px 0 2px; font-size: 19px; }
.auth-sub   { margin: 0 0 22px; color: var(--ink-soft); font-size: 13px; }
.auth-foot  { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line);
              font-size: 12.5px; color: var(--ink-soft); display: flex;
              justify-content: space-between; gap: 12px; flex-wrap: wrap; }

@media (max-width: 420px) {
    .auth-card { grid-template-columns: 1fr; }
    .auth-spine { height: 34px; }
    .auth-spine span { writing-mode: horizontal-tb; transform: none; }
    .auth-body { padding: 24px 20px; }
}

/* ------------------------------------------------------------- form fields */

.field { margin-bottom: 14px; }
.field label {
    display: block; margin-bottom: 5px;
    font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.input, select.input, textarea.input {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    transition: border-color .12s, box-shadow .12s;
}
textarea.input { height: auto; padding: 10px 12px; resize: vertical; }
.input:focus {
    outline: none;
    border-color: var(--accent, var(--violet));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, var(--violet)) 18%, transparent);
}
.input:disabled { background: var(--paper); color: var(--ink-soft); }
.input.is-error { border-color: var(--rose); }
.field-error { margin-top: 5px; font-size: 12px; color: var(--rose); }
.field-hint  { margin-top: 5px; font-size: 12px; color: var(--ink-soft); }
.input-upper { text-transform: uppercase; letter-spacing: .05em; }

/* --------------------------------------------------------------- buttons */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 42px; padding: 0 18px;
    font-family: inherit; font-size: 14px; font-weight: 600;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent, var(--violet)); outline-offset: 2px; }
.btn-primary   { background: var(--accent, var(--violet)); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--accent, var(--violet)) 85%, #000); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink-2); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--paper); color: var(--ink); }
.btn-danger    { background: var(--rose); color: #fff; }
.btn-block     { width: 100%; }
.btn-sm        { height: 32px; padding: 0 12px; font-size: 13px; }

/* --------------------------------------------------------------- alerts */

.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 11px 14px; margin-bottom: 14px;
    border: 1px solid; border-radius: var(--radius-sm);
    font-size: 13.5px;
}
.alert-success { background: var(--teal-soft);  border-color: #B7DCDA; color: #0B5B5A; }
.alert-danger  { background: var(--rose-soft);  border-color: #F3C3CB; color: #8E1F37; }
.alert-warning { background: var(--amber-soft); border-color: #EFD6A8; color: #7C4C06; }
.alert-info    { background: var(--violet-soft);border-color: #D6CBF3; color: #40248A; }

/* ----------------------------------------------------------- app shell */

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

.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--ink);
    color: #C9C3DD;
    display: flex; flex-direction: column;
    border-left: 4px solid var(--accent);
    position: sticky; top: 0; height: 100vh;
}
.sidebar-head { padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,.09); }
.sidebar-mark { color: #fff; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.sidebar-tag  { margin-top: 3px; font-size: 10.5px; font-weight: 700;
                letter-spacing: .16em; text-transform: uppercase;
                color: var(--accent); filter: brightness(1.7); }
.sidebar-nav  { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group    { margin: 14px 0 5px; padding: 0 9px; font-size: 10px; font-weight: 700;
                letter-spacing: .14em; text-transform: uppercase; color: #6F678C; }
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; margin-bottom: 1px;
    color: #C9C3DD; font-size: 13.5px; border-radius: var(--radius-sm);
}
.nav-item:hover  { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--accent); color: #fff; font-weight: 600; }
.sidebar-foot { padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.09); font-size: 12px; }
.sidebar-foot a { color: #C9C3DD; }

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

.topbar {
    display: flex; align-items: center; gap: 14px;
    height: 58px; padding: 0 22px;
    background: #fff; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 20;
}
.topbar-title { font-size: 15px; font-weight: 650; }
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 9px; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center;
    font-size: 12px; font-weight: 700;
}
.content { padding: 22px; flex: 1; }
.content-narrow { max-width: 760px; }

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

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}
.card-head {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-body { padding: 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px 18px;
    border-top: 3px solid var(--accent);
}
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .1em;
              text-transform: uppercase; color: var(--ink-soft); }
.stat-value { margin-top: 6px; font-size: 27px; font-weight: 680;
              letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-note  { margin-top: 3px; font-size: 12px; color: var(--ink-soft); }

/* --------------------------------------------------------------- tables */

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    padding: 9px 12px; text-align: left;
    font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
    color: var(--ink-soft); background: var(--paper);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #FBFAFE; }
.table .right { text-align: right; font-variant-numeric: tabular-nums; }
.table-empty { padding: 40px 18px; text-align: center; color: var(--ink-soft); }
.table-empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

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

.pill {
    display: inline-block; padding: 2px 9px;
    font-size: 11.5px; font-weight: 600; border-radius: 20px;
    border: 1px solid;
}
.pill-ok   { background: var(--teal-soft);  border-color: #B7DCDA; color: #0B5B5A; }
.pill-wait { background: var(--amber-soft); border-color: #EFD6A8; color: #7C4C06; }
.pill-bad  { background: var(--rose-soft);  border-color: #F3C3CB; color: #8E1F37; }
.pill-off  { background: #EFEDF4; border-color: var(--line-strong); color: var(--ink-soft); }

/* ------------------------------------------------------------ utilities */

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.col { flex: 1 1 220px; min-width: 0; }
.stack > * + * { margin-top: 14px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 14px; }

/* --------------------------------------------------------------- mobile */

@media (max-width: 900px) {
    .sidebar {
        position: fixed; left: 0; top: 0; z-index: 40;
        transform: translateX(-100%); transition: transform .2s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .content { padding: 16px; }
    .menu-toggle { display: inline-flex !important; }
}
.menu-toggle {
    display: none;
    width: 34px; height: 34px; align-items: center; justify-content: center;
    background: #fff; border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); cursor: pointer;
}

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

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .content { padding: 0; }
    body { background: #fff; }
}

/* ------------------------------------------------- phase 3: lists & detail */

.filters {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
    padding: 14px 18px; border-bottom: 1px solid var(--line); background: #FCFBFE;
}
.filters .field { margin: 0; }
.filters .input { height: 38px; }
.filters .btn   { height: 38px; }
.filters-grow   { flex: 1 1 220px; min-width: 160px; }

.pager {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    padding: 12px 18px; border-top: 1px solid var(--line);
}
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.page-btn {
    display: inline-flex; align-items: center; height: 30px; padding: 0 10px;
    font-size: 13px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: #fff; color: var(--ink-2);
}
.page-btn:hover { background: var(--paper); text-decoration: none; }
.page-btn.is-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.page-btn.is-disabled { color: var(--ink-soft); background: var(--paper); pointer-events: none; }
.page-gap { padding: 0 4px; color: var(--ink-soft); }

.dl { display: grid; grid-template-columns: 168px 1fr; gap: 9px 16px; font-size: 13.5px; }
.dl dt { color: var(--ink-soft); }
.dl dd { margin: 0; }
@media (max-width: 560px) { .dl { grid-template-columns: 1fr; gap: 2px 0; } .dl dd { margin-bottom: 10px; } }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 820px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.credentials {
    padding: 14px 16px; border: 1px dashed var(--line-strong);
    border-radius: var(--radius-sm); background: #FCFBFE;
}
.credentials .cred-value {
    font-family: var(--mono); font-size: 16px; font-weight: 600;
    letter-spacing: .04em; user-select: all;
}

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.tab {
    padding: 9px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft);
    border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

.action-row { display: flex; gap: 8px; flex-wrap: wrap; }
.danger-zone { border-color: #F3C3CB; }
.danger-zone .card-head { border-bottom-color: #F3C3CB; }

/* ------------------------------------------------- phase 4: setup screens */

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.link-danger {
    background: none; border: 0; padding: 0; margin-top: 4px;
    font: inherit; font-size: 11.5px; color: var(--rose); cursor: pointer; text-decoration: underline;
}

.grid-master { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1080px) { .grid-master { grid-template-columns: 1fr; } }

/* weekly OPD grid */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 900px) { .week { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .week { grid-template-columns: 1fr; } }

.week-day { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.week-day-name {
    padding: 7px 9px; background: var(--paper); border-bottom: 1px solid var(--line);
    font-size: 10.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-soft);
}
.week-off { padding: 14px 9px; font-size: 12px; color: var(--ink-soft); text-align: center; }
.week-slot { padding: 9px; border-bottom: 1px solid var(--line); }
.week-slot:last-child { border-bottom: 0; }
.week-slot-time { font-family: var(--mono); font-size: 12.5px; font-weight: 600; color: var(--accent); }
.week-slot-name { font-size: 13px; font-weight: 600; margin-top: 1px; }
.week-slot-meta { font-size: 11px; color: var(--ink-soft); margin-top: 2px; }

.day-picker { display: flex; gap: 6px; flex-wrap: wrap; }
.day-picker.is-error { outline: 1px solid var(--rose); outline-offset: 4px; border-radius: 4px; }
.day-chip { position: relative; cursor: pointer; }
.day-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.day-chip span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 46px; height: 36px; padding: 0 10px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: #fff; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.day-chip input:checked + span { background: var(--accent); border-color: var(--accent); color: #fff; }
.day-chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.perm-grid td, .perm-grid th { padding: 7px 10px; }
.perm-grid input { width: 16px; height: 16px; accent-color: var(--accent); }

.setting-row {
    display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start;
    padding: 12px 0; border-bottom: 1px solid var(--line);
}
.setting-row:last-child { border-bottom: 0; padding-bottom: 0; }
.setting-label label { font-size: 13.5px; font-weight: 600; }
@media (max-width: 720px) { .setting-row { grid-template-columns: 1fr; gap: 6px; } }

.print-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 1000px) { .print-layout { grid-template-columns: 1fr; } }

/* ---------------------------------------------- prescription print layout */

.rx-frame {
    background: #fff; border: 1px solid var(--line-strong); border-radius: 4px;
    box-shadow: var(--shadow); overflow: hidden;
}
.rx-sheet {
    padding: 16mm 14mm;
    font-family: "Times New Roman", Georgia, serif;
    font-size: 12.5px; line-height: 1.45; color: #000; background: #fff;
}
.rx-head { display: flex; gap: 14px; align-items: flex-start; text-align: center; flex-direction: column; align-items: center; }
.rx-logo { max-height: 52px; margin-bottom: 6px; }
.rx-head-text { width: 100%; }
.rx-doctor { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.rx-qual { font-size: 12px; font-weight: 600; margin-left: 6px; letter-spacing: .02em; }
.rx-speciality { font-size: 14px; font-weight: 700; letter-spacing: .01em; margin-top: 1px; }
.rx-contact { font-size: 11.5px; margin-top: 2px; }
.rx-rule { border-bottom: 1.5px solid #000; margin: 8px 0 10px; }

.rx-meta { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 8px; }
.rx-meta .right { text-align: right; }

.rx-patient {
    display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    background: #EDEDED; border: 1px solid #C9C9C9; padding: 7px 10px;
}
.rx-patient-name { font-size: 15px; font-weight: 700; letter-spacing: .02em; }
.rx-patient-side { font-size: 12px; }
.rx-flag { border: 1px solid #999; padding: 1px 6px; margin-right: 8px; font-size: 10.5px; font-weight: 700; }

.rx-line { font-size: 12px; padding: 4px 10px; border: 1px solid #C9C9C9; border-top: 0; }
.rx-dx { font-weight: 600; }

.rx-symbol { font-size: 26px; font-weight: 700; margin: 12px 0 2px; font-family: Georgia, serif; }

.rx-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.rx-table th {
    background: #D9D9D9; border: 1px solid #B4B4B4; padding: 5px 8px;
    text-align: left; font-size: 12px; font-weight: 700;
}
.rx-table td { border: 1px solid #C9C9C9; padding: 5px 8px; height: 26px; }
.rx-col-med    { width: 42%; }
.rx-col-dose   { width: 14%; }
.rx-col-timing { width: 26%; }
.rx-col-dur    { width: 18%; text-align: right; }
.rx-table thead .rx-col-dur { text-align: right; }
.rx-blank td { color: transparent; }

.rx-advice, .rx-followup { font-size: 12px; margin-top: 8px; padding: 5px 8px; background: #EDEDED; border: 1px solid #C9C9C9; }

.rx-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 22px; gap: 20px; }
.rx-foot-left { font-size: 11px; }
.rx-foot-right { text-align: right; min-width: 190px; }
.rx-sign { max-height: 46px; display: block; margin-left: auto; }
.rx-sign-space { height: 46px; }
.rx-sign-rule { border-bottom: 1px solid #000; margin-bottom: 3px; }
.rx-sign-name { font-size: 13.5px; font-weight: 700; }
.rx-sign-qual { font-size: 11px; }
.rx-note { margin-top: 14px; font-size: 10.5px; text-align: center; color: #444; }

@media print {
    .rx-frame { border: 0; box-shadow: none; border-radius: 0; }
    .print-layout { display: block; }
    .print-layout > .stack, .tabs { display: none !important; }
    .rx-sheet { padding: 0; }
}

/* --------------------------------------------------- phase 5: front desk */

.row-dim td { opacity: .55; }

.book-layout { display: grid; grid-template-columns: 330px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 1000px) { .book-layout { grid-template-columns: 1fr; } }

/* seven-day availability strip */
.daystrip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.daystrip-item {
    flex: 0 0 auto; min-width: 62px; padding: 8px 6px; text-align: center;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: #fff; color: var(--ink-2); text-decoration: none;
}
.daystrip-item:hover { background: var(--paper); text-decoration: none; }
.daystrip-item.is-active { border-color: var(--accent); background: var(--accent-soft); }
.daystrip-item.is-full { opacity: .55; }
.daystrip-dow   { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.daystrip-date  { display: block; font-size: 13px; font-weight: 650; margin-top: 1px; }
.daystrip-count { display: block; font-size: 10.5px; color: var(--ink-soft); margin-top: 2px; }

/* slot picker */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 8px; }
.slot {
    display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
    padding: 9px 10px; text-align: left; cursor: pointer;
    font-family: inherit; border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); background: #fff;
    transition: border-color .1s, background .1s;
}
.slot-time  { font-family: var(--mono); font-size: 14px; font-weight: 650; }
.slot-label { font-size: 11px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.slot-token { font-size: 10.5px; font-weight: 700; color: var(--accent); }

.slot-free:hover { border-color: var(--accent); background: var(--accent-soft); }
.slot.is-chosen  { border-color: var(--accent); background: var(--accent); }
.slot.is-chosen .slot-time, .slot.is-chosen .slot-label, .slot.is-chosen .slot-token { color: #fff; }
.slot-booked { background: var(--violet-soft); border-color: #D6CBF3; cursor: not-allowed; }
.slot-held   { background: var(--amber-soft); border-color: #EFD6A8; cursor: not-allowed; }
.slot-past, .slot-closed { background: var(--paper); border-style: dashed; color: var(--ink-soft); cursor: not-allowed; }
.slot-past .slot-time, .slot-closed .slot-time { color: var(--ink-soft); font-weight: 500; }

.slot-legend { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 16px; font-size: 12px; color: var(--ink-soft); }
.slot-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; border: 1px solid var(--line-strong); }
.dot-free   { background: #fff; }
.dot-booked { background: var(--violet-soft); border-color: #D6CBF3; }
.dot-held   { background: var(--amber-soft); border-color: #EFD6A8; }
.dot-past   { background: var(--paper); border-style: dashed; }

/* token queue board */
.queue-now {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
    background: var(--line); border-bottom: 1px solid var(--line);
}
.queue-now-block { background: #fff; padding: 18px; }
.queue-token {
    font-size: 52px; font-weight: 700; line-height: 1.05;
    letter-spacing: -.03em; font-variant-numeric: tabular-nums; color: var(--accent);
    margin-top: 4px;
}
.queue-token-next { color: var(--ink); }
.queue-token-idle { color: var(--line-strong); }
.queue-name { font-size: 15px; font-weight: 650; margin-top: 2px; }
.queue-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 1px; }
@media (max-width: 640px) { .queue-now { grid-template-columns: 1fr; } .queue-token { font-size: 42px; } }

/* small inline action menu */
.inline-menu { position: relative; display: inline-block; }
.inline-menu > summary { list-style: none; cursor: pointer; }
.inline-menu > summary::-webkit-details-marker { display: none; }
.inline-menu-body {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
    min-width: 220px; padding: 12px; text-align: left;
    background: #fff; border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
}

/* ------------------------------------------------- phase 6: consultation */

.patient-banner {
    display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
    padding: 14px 18px; margin-bottom: 16px;
    background: #fff; border: 1px solid var(--line);
    border-left: 4px solid var(--accent); border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.patient-banner-name { font-size: 19px; font-weight: 680; letter-spacing: -.015em; }
.patient-banner-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.patient-banner-side { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.consult-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; align-items: start; }
@media (max-width: 1080px) { .consult-layout { grid-template-columns: 1fr; } }

.vitals-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.vitals-grid .field { margin: 0; }
.vitals-grid .input { height: 38px; }
@media (max-width: 700px) { .vitals-grid { grid-template-columns: repeat(2, 1fr); } }

.repeat-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.repeat-row:last-child { margin-bottom: 0; }

.row-remove {
    flex: 0 0 auto; width: 28px; height: 28px;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    background: #fff; color: var(--ink-soft);
    font-size: 17px; line-height: 1; cursor: pointer;
}
.row-remove:hover { border-color: var(--rose); color: var(--rose); }

.rx-editor td { padding: 6px 8px; vertical-align: top; }
.rx-editor .input { height: 38px; }
.rx-editor tr.rx-warn td:first-child { box-shadow: inset 3px 0 0 var(--amber); }

/* type-ahead */
.typeahead {
    position: absolute; z-index: 200; max-height: 300px; overflow-y: auto;
    background: #fff; border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.typeahead-item {
    display: block; width: 100%; padding: 8px 11px; text-align: left;
    background: none; border: 0; border-bottom: 1px solid var(--line);
    font: inherit; cursor: pointer;
}
.typeahead-item:last-child { border-bottom: 0; }
.typeahead-item:hover, .typeahead-item.is-active { background: var(--accent-soft); }
.ta-label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); }
.ta-sub   { display: block; font-size: 11.5px; color: var(--ink-soft); margin-top: 1px; }
.ta-warn  { display: inline-block; margin-top: 3px; padding: 1px 6px; border-radius: 10px;
            background: var(--amber-soft); color: #7C4C06; font-size: 10.5px; font-weight: 700; }

/* ----------------------------------------------------- phase 7: billing */

.due-amount { color: var(--rose); font-weight: 650; }

.bill-editor td { padding: 6px 8px; vertical-align: top; }
.bill-editor .input { height: 38px; }
.bill-editor .input.right { text-align: right; }

.totals { width: 100%; font-size: 13.5px; }
.totals td { padding: 5px 0; }
.totals td.right { text-align: right; font-variant-numeric: tabular-nums; }
.totals .totals-net td {
    padding-top: 9px; border-top: 1px solid var(--line-strong);
    font-size: 17px; font-weight: 700;
}
.totals .totals-due td { color: var(--rose); font-weight: 650; }

/* ------------------------------------------------------- printed bill */

.bill-frame { background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; box-shadow: var(--shadow); overflow: hidden; }
.bill-sheet {
    padding: 12mm 10mm; background: #fff; color: #000;
    font-family: "Times New Roman", Georgia, serif; font-size: 12px; line-height: 1.4;
}
.bill-sheet.bill-thermal {
    padding: 4mm 3mm; font-family: var(--mono); font-size: 11px;
}

.bill-head { text-align: center; }
.bill-logo { max-height: 46px; margin-bottom: 4px; }
.bill-clinic { font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.bill-sub { font-size: 11px; }
.bill-title {
    margin: 9px 0 8px; padding: 3px 0; text-align: center;
    font-size: 12.5px; font-weight: 700; letter-spacing: .14em;
    border-top: 1.2px solid #000; border-bottom: 1.2px solid #000;
}
.bill-void {
    margin-bottom: 8px; padding: 4px; text-align: center;
    border: 2px solid #C02D4B; color: #C02D4B;
    font-weight: 700; letter-spacing: .18em;
}

.bill-meta { width: 100%; font-size: 11.5px; margin-bottom: 8px; }
.bill-meta td { padding: 1.5px 0; }
.bill-meta .right { text-align: right; }
.bill-thermal .bill-meta .right { text-align: left; }

.bill-table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.bill-table th { background: #E4E4E4; border: 1px solid #B4B4B4; padding: 4px 6px; text-align: left; font-weight: 700; }
.bill-table td { border: 1px solid #C9C9C9; padding: 4px 6px; }
.bill-table .c-sr   { width: 26px; text-align: center; }
.bill-table .c-hsn  { width: 62px; }
.bill-table .c-qty, .bill-table .c-rate, .bill-table .c-disc,
.bill-table .c-gst, .bill-table .c-amt { text-align: right; white-space: nowrap; }
.bill-table .c-qty  { width: 44px; }
.bill-table .c-rate { width: 70px; }
.bill-table .c-disc { width: 66px; }
.bill-table .c-gst  { width: 52px; }
.bill-table .c-amt  { width: 84px; }

.bill-totals { width: 260px; margin: 8px 0 0 auto; font-size: 11.5px; }
.bill-thermal .bill-totals { width: 100%; }
.bill-totals td { padding: 2px 0; }
.bill-totals .right { text-align: right; font-variant-numeric: tabular-nums; }
.bill-totals .bill-net td { padding-top: 5px; border-top: 1px solid #000; font-size: 14px; font-weight: 700; }
.bill-totals .bill-due td { color: #C02D4B; font-weight: 700; }

.bill-pay { margin-top: 10px; padding: 4px 6px; border: 1px dashed #B4B4B4; font-size: 11px; }
.bill-foot { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 22px; gap: 20px; font-size: 11px; }
.bill-thermal .bill-foot { display: block; text-align: center; margin-top: 12px; }
.bill-sign { text-align: center; min-width: 150px; }
.bill-sign-rule { border-bottom: 1px solid #000; margin-bottom: 3px; height: 30px; }
.bill-note { margin-top: 10px; text-align: center; font-size: 10px; color: #444; }

@media print {
    .bill-frame { border: 0; box-shadow: none; border-radius: 0; }
    .bill-sheet { padding: 0; }
}

/* ------------------------------------------------------- phase 9: reports */

.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.report-tile {
    display: block; padding: 13px 15px;
    border: 1px solid var(--line-strong); border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm); background: #fff; color: inherit; text-decoration: none;
    transition: background .12s, border-color .12s;
}
.report-tile:hover { background: var(--accent-soft); text-decoration: none; }
.report-tile-title { display: block; font-size: 14px; font-weight: 650; }
.report-tile-desc  { display: block; margin-top: 3px; font-size: 12px; color: var(--ink-soft); line-height: 1.45; }

.quick-range { display: flex; gap: 6px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--line); }
.quick-range-item {
    padding: 4px 11px; font-size: 12.5px; border: 1px solid var(--line-strong);
    border-radius: 20px; background: #fff; color: var(--ink-2); text-decoration: none;
}
.quick-range-item:hover { background: var(--paper); text-decoration: none; }
.quick-range-item.is-active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.report-total td {
    border-top: 2px solid var(--line-strong); background: var(--paper);
    font-weight: 700; font-variant-numeric: tabular-nums;
}

.print-only { display: none; }
@media print {
    .print-only { display: block; }
    .report-print-head {
        margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px solid #000;
        font-size: 12px; font-weight: 600;
    }
    .card { border: 0; box-shadow: none; }
    .table { font-size: 11px; }
    .table th, .table td { padding: 4px 6px; }
}

/* ------------------------------------------- pickers, files, reschedule */

.picker {
    max-height: 320px; overflow-y: auto;
    border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff;
}
.picker-group {
    position: sticky; top: 0;
    padding: 6px 12px; background: var(--paper); border-bottom: 1px solid var(--line);
    font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-soft);
}
.picker-row {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13.5px;
}
.picker-row:last-child { border-bottom: 0; }
.picker-row:hover { background: var(--accent-soft); }
.picker-row input { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }
.picker-name { flex: 1; }
.picker-rate { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 12.5px; }

.file-row {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 0; border-bottom: 1px solid var(--line);
}
.file-row:last-child { border-bottom: 0; }
.file-icon {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: var(--radius-sm);
    background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center; font-size: 10px; font-weight: 700; letter-spacing: .04em;
}
.file-main { flex: 1; min-width: 0; }
.file-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 11.5px; color: var(--ink-soft); margin-top: 1px; }

.reschedule-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .reschedule-grid { grid-template-columns: 1fr; } }

/* -------------------------------------------- inline editing on masters */

.inline-bar {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; flex-wrap: wrap;
    padding: 11px 18px; background: #FCFBFE; border-bottom: 1px solid var(--line);
}
.inline-bar-foot { border-bottom: 0; border-top: 1px solid var(--line); }
#dirty-count.is-warning { color: var(--amber); }

.master-table td { padding: 5px 8px; vertical-align: middle; }
.master-table th .th-editable { margin-left: 4px; color: var(--accent); font-size: 10px; }

.cell-input {
    width: 100%; min-width: 74px; height: 32px; padding: 0 8px;
    font: inherit; font-size: 13px; color: var(--ink);
    background: #fff; border: 1px solid transparent; border-radius: 4px;
}
.cell-input:hover { border-color: var(--line-strong); }
.cell-input:focus {
    outline: none; border-color: var(--accent); background: #fff;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}
.cell-input.right { text-align: right; }
.cell-money { font-variant-numeric: tabular-nums; }
select.cell-input { min-width: 120px; }

/* an unsaved cell has to be obvious from across the desk */
.cell-input.is-dirty {
    border-color: var(--amber); background: var(--amber-soft); font-weight: 600;
}
.cell-check { width: 16px; height: 16px; accent-color: var(--accent); }
.cell-check.is-dirty { outline: 2px solid var(--amber); outline-offset: 2px; }

.rate-tool { padding: 16px 18px; background: var(--violet-soft); border-top: 1px solid #D6CBF3; border-bottom: 1px solid #D6CBF3; }
.rate-tool-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rate-tool-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.rate-tool-row .field { margin: 0; }
.rate-tool-row .input { height: 38px; background: #fff; }
.rate-tool-row .btn { height: 38px; }
