/* Dial In Doctor — internal operations interface.
   Deliberately plain: this is a workspace staff use all day, so clarity and
   density matter more than decoration. Desktop-first, but every view collapses
   cleanly to a phone because reception is not always at a desk. */

:root {
    --brand: #2B8ECA;
    --brand-dark: #1F6E9E;
    --ink: #1A2330;
    --ink-soft: #5A6675;
    --line: #E3E8EF;
    --surface: #FFFFFF;
    --canvas: #F6F8FB;
    --ok: #12805C;
    --warn: #B45309;
    --danger: #C2413B;
    --radius: 8px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--canvas);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.skip-link {
    position: absolute; left: -9999px; top: 0; background: var(--brand);
    color: #fff; padding: 10px 16px; z-index: 100;
}
.skip-link:focus { left: 0; }

/* Focus is never removed, only restyled: operations staff work by keyboard. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
    outline: 3px solid var(--brand);
    outline-offset: 2px;
}

/* ---------- top bar ---------- */
.topbar {
    display: flex; align-items: center; gap: 16px;
    background: var(--surface); border-bottom: 1px solid var(--line);
    padding: 0 20px; height: 56px; position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { font-weight: 700; color: var(--brand); white-space: nowrap; }
.brand-sub { color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.topbar-context { color: var(--ink-soft); font-size: 13px; margin-left: 8px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { display: flex; align-items: center; gap: 8px; }
.who-name { font-weight: 600; }
.role-badge {
    background: #EAF4FB; color: var(--brand-dark); border: 1px solid #CBE4F5;
    border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600;
}
.logout-form { margin: 0; }

.nav-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
.nav-toggle span { display: block; width: 20px; height: 2px; background: var(--ink); margin: 4px 0; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: calc(100vh - 56px); align-items: flex-start; }
.sidebar {
    width: 210px; flex: 0 0 210px; background: var(--surface);
    border-right: 1px solid var(--line); padding: 14px 10px;
    position: sticky; top: 56px; align-self: flex-start;
}
.nav-item {
    display: block; padding: 9px 12px; border-radius: var(--radius);
    color: var(--ink); text-decoration: none; margin-bottom: 2px;
}
.nav-item:hover { background: #EFF5FA; color: var(--brand-dark); }
.content { flex: 1 1 auto; padding: 22px; min-width: 0; }

/* ---------- cards ---------- */
h1 { font-size: 20px; margin: 0 0 4px; }
.page-sub { color: var(--ink-soft); margin: 0 0 18px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 22px; }
.card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 14px; text-decoration: none; color: inherit; display: block;
}
.card:hover { border-color: var(--brand); }
.card-label { color: var(--ink-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.card-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.card.attention .card-value { color: var(--warn); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 20px; }
.panel-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-head h2 { font-size: 15px; margin: 0; }
.panel-body { padding: 14px; }

/* ---------- tables ----------
   Wide operational tables scroll inside their own container so the page body
   never scrolls sideways on a phone. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 720px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: #F9FBFD; color: var(--ink-soft); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: #F7FAFD; }
td.wrap, th.wrap { white-space: normal; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- chips ---------- */
.chip { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; border: 1px solid transparent; }
.chip-Booked { background: #EAF4FB; color: #1F6E9E; border-color: #CBE4F5; }
.chip-Assigned { background: #EEF2FF; color: #4338CA; border-color: #DDE3FF; }
.chip-Confirmed { background: #E7F6EF; color: var(--ok); border-color: #C6EBDA; }
.chip-Completed { background: #EFF1F4; color: #475569; border-color: #DFE3E9; }
.chip-Cancelled { background: #FDECEC; color: var(--danger); border-color: #F7D4D3; }
.chip-Pending { background: #FEF6E7; color: var(--warn); border-color: #F7E3BF; }
.chip-Paid { background: #E7F6EF; color: var(--ok); border-color: #C6EBDA; }
.chip-Refunded { background: #EFF1F4; color: #475569; border-color: #DFE3E9; }

/* ---------- controls ---------- */
.btn {
    display: inline-block; border: 1px solid var(--brand); background: var(--brand); color: #fff;
    padding: 8px 14px; border-radius: var(--radius); font-size: 13px; font-weight: 600;
    cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #EFF5FA; color: var(--brand-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filter { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); font-size: 13px; background: var(--surface); }
.filter.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--line);
    border-radius: var(--radius); font-size: 14px; background: #fff; color: var(--ink);
}
.field { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

.flash { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: #E7F6EF; border-color: #C6EBDA; color: var(--ok); }
.flash.warn { background: #FEF6E7; border-color: #F7E3BF; color: var(--warn); }
.flash.err { background: #FDECEC; border-color: #F7D4D3; color: var(--danger); }

.muted { color: var(--ink-soft); }
.empty { padding: 26px; text-align: center; color: var(--ink-soft); }
.dl { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; }
.dl dt { color: var(--ink-soft); }
.dl dd { margin: 0; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: var(--canvas); }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 28px; width: 100%; max-width: 380px; }
.login-brand { color: var(--brand); font-weight: 700; font-size: 18px; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
    .nav-toggle { display: block; }
    .topbar-context { display: none; }
    .shell { display: block; }
    .sidebar {
        position: fixed; inset: 56px auto 0 0; width: 220px; z-index: 30;
        transform: translateX(-100%); transition: transform .18s ease;
        height: calc(100vh - 56px); overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
    .content { padding: 16px; }
    .dl { grid-template-columns: 1fr; }
    .dl dt { margin-top: 8px; }
}

@media (max-width: 480px) {
    .brand-sub { display: none; }
    .who-name { display: none; }
    .cards { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* ============================================================================
   Unified platform additions: premium shell, clinical chart, consultation
   workspace. Kept in the same stylesheet so there is one design system rather
   than a second look bolted onto the first.
   ============================================================================ */

.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand);
    box-shadow: 0 0 0 3px rgba(43,142,202,.18); display: inline-block; }
.crumb { color: var(--ink-soft); font-size: 13px; padding-left: 14px; margin-left: 6px;
    border-left: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff; display: inline-flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; letter-spacing: .02em; }
.quick-search input { width: 190px; padding: 6px 10px; font-size: 13px; border-radius: 999px;
    border: 1px solid var(--line); background: var(--canvas); }
.quick-search input:focus { background: #fff; }

.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
    color: #93A1B1; font-weight: 700; padding: 14px 12px 6px; }
.nav-item { font-size: 13.5px; }
.nav-item.active { background: #EAF4FB; color: var(--brand-dark); font-weight: 600;
    box-shadow: inset 2px 0 0 var(--brand); }

/* ---------- premium cards ---------- */
.card { transition: box-shadow .15s ease, transform .15s ease; }
.card:hover { box-shadow: 0 6px 18px rgba(20,40,70,.07); }
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat-sub { font-size: 12px; color: var(--ink-soft); }

.section-head { display:flex; align-items:baseline; justify-content:space-between; margin: 22px 0 10px; }
.section-head h2 { font-size: 15px; margin: 0; }

/* ---------- patient chart ---------- */
.chart-head { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; margin-bottom: 16px; }
.chart-id { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.chart-avatar { width: 52px; height: 52px; border-radius: 50%;
    background: linear-gradient(135deg,#EAF4FB,#D3E9F7); color: var(--brand-dark);
    display:flex; align-items:center; justify-content:center; font-weight:700; font-size:18px; }
.chart-name { font-size: 20px; font-weight: 700; margin: 0; }
.chart-meta { display:flex; gap: 16px; flex-wrap: wrap; color: var(--ink-soft); font-size: 13px; margin-top: 4px; }
.chart-summary { display:grid; grid-template-columns: repeat(auto-fit,minmax(170px,1fr)); gap: 12px; margin-top: 16px; }
.summary-tile { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.summary-tile .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.summary-tile .v { font-weight: 600; margin-top: 3px; }

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

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 22px; position: relative; }
.timeline::before { content:''; position:absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 16px 4px; }
.timeline li::before { content:''; position:absolute; left: -21px; top: 5px; width: 10px; height: 10px;
    border-radius: 50%; background: #fff; border: 2px solid var(--brand); }
.timeline li.clinical::before { border-color: var(--ok); }
.timeline .t-title { font-weight: 600; }
.timeline .t-meta { color: var(--ink-soft); font-size: 12px; }

/* ---------- consultation workspace ---------- */
.workspace { display: grid; grid-template-columns: 260px minmax(0,1fr) 240px; gap: 16px; align-items: start; }
.workspace .col { min-width: 0; }
.ws-panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 14px; }
.ws-panel h3 { font-size: 13px; margin: 0; padding: 11px 13px; border-bottom: 1px solid var(--line);
    text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); }
.ws-panel .body { padding: 13px; }
.ws-sticky { position: sticky; top: 72px; }
.note-field { margin-bottom: 14px; }
.note-field label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); }
.note-field textarea { min-height: 84px; resize: vertical; font-family: inherit; line-height: 1.5; }
.note-field textarea.tall { min-height: 130px; }

/* ---------- prescription editor ---------- */
.rx-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto; gap: 8px; align-items: end;
    padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 8px; background: var(--canvas); }
.rx-row .full { grid-column: 1 / -1; }
.rx-doc { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fff; }

.chip-Draft { background:#EFF1F4; color:#475569; border-color:#DFE3E9; }
.chip-Issued { background:#E7F6EF; color:var(--ok); border-color:#C6EBDA; }
.chip-CheckedIn { background:#FEF6E7; color:var(--warn); border-color:#F7E3BF; }
.chip-InProgress { background:#EEF2FF; color:#4338CA; border-color:#DDE3FF; }
.chip-NoShow { background:#FDECEC; color:var(--danger); border-color:#F7D4D3; }
.chip-Superseded, .chip-Amended { background:#EFF1F4; color:#475569; border-color:#DFE3E9; }
.chip-Verified { background:#E7F6EF; color:var(--ok); border-color:#C6EBDA; }
.chip-Unverified, .chip-Pending2 { background:#FEF6E7; color:var(--warn); border-color:#F7E3BF; }

.notice { background:#F3F8FC; border:1px solid #D8E8F5; color:#215E85; padding:11px 13px;
    border-radius: var(--radius); font-size: 13px; }

@media (max-width: 1200px) {
    .workspace { grid-template-columns: 1fr; }
    .ws-sticky { position: static; }
}
@media (max-width: 900px) {
    .quick-search { display: none; }
    .crumb { display: none; }
    .rx-row { grid-template-columns: 1fr 1fr; }
}

/* ---------------------------------------------------------------- Reporting
   The business screens share one toolbar, one table shell and one set of
   chips, so a period chosen on OPD reads the same on Finance. Nothing here
   loads from a CDN: the trend is plain elements sized by inline height, which
   keeps a strict Content-Security-Policy possible later. */

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 10px 14px; margin: 0 0 16px;
}
.toolbar-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.toolbar-range { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.toolbar-range input[type=date] {
    padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px;
    font: inherit; color: var(--ink); background: var(--surface);
}
.toolbar-label { margin-left: auto; font-size: 12px; }

.filter-form, .form-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px; align-items: end;
}
.filter-form label, .form-grid label {
    display: flex; flex-direction: column; gap: 4px;
    font-size: 12px; color: var(--ink-soft);
}
.filter-form input, .filter-form select,
.form-grid input, .form-grid select {
    padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px;
    font: inherit; color: var(--ink); background: var(--surface); width: 100%;
}
.filter-form label.check, .form-grid label.check {
    flex-direction: row; align-items: center; gap: 8px;
}
.filter-form label.check input, .form-grid label.check input { width: auto; }
.form-actions {
    grid-column: 1 / -1; display: flex; align-items: center;
    gap: 10px; flex-wrap: wrap;
}

.pager {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 14px; border-top: 1px solid var(--line);
}

.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-actions form { display: flex; gap: 6px; align-items: center; }
.row-actions input {
    padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px;
    font: inherit; max-width: 140px;
}

.badge {
    display: inline-block; padding: 2px 8px; border-radius: 999px;
    font-size: 12px; font-weight: 600; border: 1px solid var(--line);
    background: var(--canvas); color: var(--ink-soft);
}
.badge-ok   { background: #E7F5F0; border-color: #B9E2D4; color: var(--ok); }
.badge-info { background: #E8F2FA; border-color: #BFDCF1; color: var(--brand-dark); }
.badge-warn { background: #FDF3E4; border-color: #F0D6A8; color: var(--warn); }

/* Trend bars. Height is the only inline style, so the shape is data and the
   styling stays in the stylesheet. */
.trend {
    display: flex; align-items: flex-end; gap: 6px;
    height: 180px; overflow-x: auto; padding-bottom: 4px;
}
.trend-col {
    display: flex; flex-direction: column; justify-content: flex-end;
    align-items: center; min-width: 34px; height: 100%; gap: 4px;
}
.trend-bar {
    width: 100%; min-height: 2px; background: var(--brand);
    border-radius: 3px 3px 0 0; position: relative;
    display: flex; flex-direction: column; justify-content: flex-end;
}
.trend-bar-share { width: 100%; background: var(--brand-dark); border-radius: 0 0 3px 3px; }
.trend-label { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.trend-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.swatch-gross { background: var(--brand); }
.swatch-share { background: var(--brand-dark); }

.snapshot {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 18px;
}
.snapshot-group h3 {
    margin: 0 0 8px; font-size: 12px; letter-spacing: .04em;
    text-transform: uppercase; color: var(--ink-soft);
}
.snapshot-group ul { list-style: none; margin: 0; padding: 0; }
.snapshot-group li {
    display: flex; justify-content: space-between; gap: 12px;
    padding: 4px 0; border-bottom: 1px solid var(--line);
}
.snapshot-group li:last-child { border-bottom: 0; }
.snapshot-group li span { color: var(--ink-soft); }
.snapshot-group li.warn strong { color: var(--warn); }
.snapshot-links { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

/* Reception is not always at a desk: below a phone width the toolbar stacks
   and the label drops under the controls rather than being pushed off. */
@media (max-width: 640px) {
    .toolbar { flex-direction: column; align-items: stretch; }
    .toolbar-label { margin-left: 0; }
    .toolbar-range { justify-content: space-between; }
    .pager { justify-content: space-between; }
}
