* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --navy: #1b365d;
    --navy-dark: #132742;
    --navy-mid: #2a4a73;
    --accent: #2b6cb0;
    --accent-hover: #1a4f8a;
    --record: #1f7a46;
    --record-hover: #176338;
    --record-active: #c0392b;
    --record-active-hover: #a93226;
    --danger: #b42318;
    --danger-hover: #912018;
    --surface: #f4f6f8;
    --panel: #ffffff;
    --border: #d5dde5;
    --text: #1a2332;
    --muted: #5b6b7c;
    --menubar-height: 64px;
    --actionbar-height: 56px;
    --tabbar-height: 44px;
}

body {
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
    color: var(--text);
    background: linear-gradient(160deg, #1b365d 0%, #2a4a73 55%, #3d5a80 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

html {
    height: 100%;
}

/* A `display` rule otherwise beats the hidden attribute, which several
   flex containers here rely on for show/hide. */
[hidden] {
    display: none !important;
}

.login-page {
    overflow-y: auto;
}

/* Login uses the default body background; the clinical workspace is full-viewport. */
.app-page {
    background: var(--surface);
    height: 100%;
    max-height: 100%;
    max-width: 100%;
    overflow: hidden;
    position: relative;
}

html.is-docked,
html.is-fullscreen,
html.is-docked body.app-page,
html.is-fullscreen body.app-page {
    height: var(--app-height, 100%);
    max-height: var(--app-height, 100%);
    overflow: hidden;
}

.app-shell {
    position: absolute;
    inset: 0;
    width: auto;
    max-width: none;
    min-width: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow: hidden;
}

/* ---------- Menu / title row ---------- */
.app-menubar {
    flex-shrink: 0;
    min-width: 0;
    height: var(--menubar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 20px;
    background: var(--navy);
    color: #fff;
    box-shadow: 0 2px 8px rgba(19, 39, 66, 0.35);
    border-bottom: 1px solid var(--navy-dark);
    z-index: 20;
}

.menubar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 0 1 auto;
}

.brand-mark {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #7eb6ff;
    box-shadow: 0 0 0 3px rgba(126, 182, 255, 0.25);
    flex-shrink: 0;
}

.app-menubar h1 {
    margin: 0;
    font-size: 1.15em;
    font-weight: 650;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.menubar-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    flex: 1 1 auto;
    min-width: 0;
    padding: 4px 0;
}

.menubar-user {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex: 0 1 auto;
    min-width: 0;
}

.user-name {
    color: #d7e3f0;
    font-size: 0.92em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
}

.logout-btn {
    padding: 11px 24px;
    background: transparent;
    color: #fff;
    text-decoration: none;
    border-radius: 999px;
    font-size: 0.88em;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.35);
    transition: background 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.logout-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.78; }
}

/* Menubar keeps only the telemetry icons and the button description text. */
.recording-status {
    color: #c5d4e4;
    font-size: 0.85em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    min-width: 0;
}

.recording-status:empty,
.recording-status[hidden] {
    display: none;
}

.recording-status.active {
    color: #ffb4ab;
    font-weight: 650;
}

/* ---------- Telemetry (network / audio signal) ---------- */
.telemetry-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    padding: 0 4px;
}

.telemetry {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 9px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.14);
    color: #9fb3c8;
    cursor: default;
    white-space: nowrap;
    transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.telemetry:focus-visible {
    outline: 2px solid #7eb6ff;
    outline-offset: 1px;
}

.telemetry-label {
    font-size: 0.76em;
    font-weight: 650;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #c5d4e4;
}

.signal-icon {
    width: 20px;
    height: 16px;
    flex-shrink: 0;
    overflow: visible;
}

.signal-icon .bar {
    fill: currentColor;
    opacity: 0.2;
    transition: opacity 0.2s ease;
}

.signal-icon .signal-slash {
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    display: none;
}

/* Lit bars follow the measured strength */
.telemetry[data-bars="1"] .bar-1,
.telemetry[data-bars="2"] .bar-1,
.telemetry[data-bars="2"] .bar-2,
.telemetry[data-bars="3"] .bar-1,
.telemetry[data-bars="3"] .bar-2,
.telemetry[data-bars="3"] .bar-3,
.telemetry[data-bars="4"] .bar-1,
.telemetry[data-bars="4"] .bar-2,
.telemetry[data-bars="4"] .bar-3,
.telemetry[data-bars="4"] .bar-4 {
    opacity: 1;
}

/* Strong / good signal */
.telemetry[data-state="strong"],
.telemetry[data-state="good"] {
    color: #3ddc84;
    border-color: rgba(61, 220, 132, 0.45);
    background: rgba(61, 220, 132, 0.12);
}

/* Weak signal */
.telemetry[data-state="weak"] {
    color: #f5c451;
    border-color: rgba(245, 196, 81, 0.45);
    background: rgba(245, 196, 81, 0.12);
}

/* Poor signal */
.telemetry[data-state="poor"] {
    color: #ff6b5e;
    border-color: rgba(255, 107, 94, 0.5);
    background: rgba(255, 107, 94, 0.14);
}

/* Hard failure: disconnected network or unavailable audio */
.telemetry[data-state="error"] {
    color: #ff5449;
    border-color: rgba(255, 84, 73, 0.7);
    background: rgba(255, 84, 73, 0.2);
    animation: telemetryAlert 1.8s ease-in-out infinite;
}

.telemetry[data-state="error"] .signal-slash {
    display: block;
}

.telemetry[data-state="error"] .telemetry-label {
    color: #ffd5d1;
}

@keyframes telemetryAlert {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.62; }
}

/* ---------- Hamburger menu ---------- */
.app-menu {
    position: relative;
    flex-shrink: 0;
}

.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.menu-toggle:hover,
.menu-toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, 0.14);
    border-color: #fff;
}

.menu-toggle:focus-visible {
    outline: 2px solid #7eb6ff;
    outline-offset: 2px;
}

/* Three bars drawn from one element plus its two pseudo-elements. */
.menu-toggle-bars,
.menu-toggle-bars::before,
.menu-toggle-bars::after {
    display: block;
    width: 17px;
    height: 2px;
    background: #fff;
    border-radius: 2px;
}

.menu-toggle-bars {
    position: relative;
}

.menu-toggle-bars::before,
.menu-toggle-bars::after {
    content: '';
    position: absolute;
    left: 0;
}

.menu-toggle-bars::before {
    top: -5px;
}

.menu-toggle-bars::after {
    top: 5px;
}

.app-menu-list {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 60;
    min-width: 220px;
    margin: 0;
    padding: 6px;
    list-style: none;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(19, 39, 66, 0.28);
}

.app-menu-item {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-size: 0.92em;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease;
}

.app-menu-item:hover {
    background: #eef2f6;
}

.app-menu-item.is-active {
    background: var(--navy);
    color: #fff;
    font-weight: 650;
}

.app-menu-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

a.app-menu-item {
    text-decoration: none;
}

/* ---------- Top-level views ---------- */
.app-view {
    display: none;
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    flex-direction: column;
}

.app-view.is-active {
    display: flex;
}

/* ---------- Saved-record banner ---------- */
.record-banner {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 20px;
    background: #fff5d6;
    border-bottom: 1px solid #e3c766;
    font-size: 0.88em;
    color: #5b4708;
}

.record-banner-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
}

.record-banner-text strong {
    margin-left: 6px;
}

.record-banner-time {
    margin-left: 0;
    color: #7d6417;
    white-space: nowrap;
    flex-shrink: 0;
}

.record-banner-back {
    margin-left: auto;
    flex-shrink: 0;
    padding: 6px 14px;
    background: var(--accent);
    color: var(--btn-ink);
    border: none;
    border-radius: 6px;
    font: inherit;
    font-size: 0.95em;
    font-weight: 650;
    cursor: pointer;
}

.record-banner-back:hover {
    background: var(--accent-hover);
}

/* ---------- Report view ---------- */
.report-filter {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: #eef2f6;
    border-bottom: 1px solid var(--border);
}

.report-filter-fields {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.report-filter .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.report-filter label {
    font-size: 0.78em;
    font-weight: 650;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #52657a;
}

.date-picker {
    position: relative;
}

.date-picker-btn {
    min-width: 168px;
    padding: 8px 12px;
    font: inherit;
    font-size: 0.92em;
    font-weight: 600;
    text-align: left;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}

.date-picker-btn:hover,
.date-picker-btn[aria-expanded="true"] {
    border-color: var(--accent);
}

.date-picker-btn:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.18);
}

.date-cal {
    position: absolute;
    z-index: 40;
    top: calc(100% + 6px);
    left: 0;
    width: 280px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(27, 54, 93, 0.16);
}

.date-cal-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.date-cal-nav select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 6px 8px;
    font: inherit;
    font-size: 0.88em;
    font-weight: 650;
    color: var(--text);
    background: #f4f7fa;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.date-cal-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}

.date-cal-dow,
.date-cal-day {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    font-size: 0.78em;
}

.date-cal-dow {
    font-weight: 650;
    color: #6a7b8c;
}

.date-cal-day {
    border: none;
    background: transparent;
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    font-size: 0.86em;
    cursor: pointer;
}

.date-cal-day:hover:not(:disabled) {
    background: #e4eef8;
}

.date-cal-day.is-today {
    box-shadow: inset 0 0 0 1px var(--accent);
}

.date-cal-day.is-selected {
    background: var(--accent);
    color: #fff;
    font-weight: 650;
}

.date-cal-day.is-outside,
.date-cal-day:disabled {
    color: #b0bbc6;
    cursor: default;
}

.report-ok-btn {
    padding: 6px 14px;
    background: var(--accent);
    color: var(--btn-ink);
    border: none;
    border-radius: 6px;
    font: inherit;
    font-size: 0.9em;
    font-weight: 650;
    cursor: pointer;
    transition: background 0.2s ease;
}

.report-ok-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.report-ok-btn:disabled {
    background: #e8eaed;
    color: #c5c9d1;
    font-weight: 400;
    opacity: 1;
    cursor: not-allowed;
}

.report-exports {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.report-exports-label {
    font-size: 0.78em;
    font-weight: 650;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #52657a;
}

.export-btn {
    padding: 6px 14px;
    background: var(--accent);
    color: var(--btn-ink);
    border: none;
    border-radius: 6px;
    font: inherit;
    font-size: 0.84em;
    font-weight: 650;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.export-btn:hover:not(:disabled) {
    background: var(--accent-hover);
    color: var(--btn-ink);
}

.export-btn:disabled {
    background: #e8eaed;
    color: #c5c9d1;
    font-weight: 400;
    opacity: 1;
    cursor: not-allowed;
}

.report-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 20px 24px;
    background: var(--panel);
}

#billingView .report-body {
    overflow: hidden;
}

#billingView .report-empty {
    flex-shrink: 0;
    margin-top: 0;
}

#billingView .report-table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

#billingView .report-table {
    border-collapse: separate;
    border-spacing: 0;
}

#billingView .report-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    border: 1px solid #0f2744;
}

#billingView .report-table tbody td {
    border: 1px solid #c3d0dd;
}

.report-empty {
    margin: 24px 0;
    color: #5b6b7c;
    font-size: 0.95em;
}

.report-table-wrap {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.report-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 14px;
    background: var(--navy);
    color: #fff;
    text-align: left;
    font-weight: 650;
    white-space: nowrap;
}

.report-table .col-time { width: 170px; }
.report-table .col-title { width: 18%; }
.report-table .col-encounter { width: 140px; }
.report-table .col-icd-code { width: 120px; }
.report-table .col-icd-desc { width: 28%; }
.report-table .col-notes { width: 110px; }
.report-table .col-completed { width: 200px; }

.report-select {
    min-width: 168px;
    padding: 8px 12px;
    font: inherit;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--navy);
}

.report-table tbody tr {
    cursor: pointer;
    border-top: 1px solid var(--border);
    transition: background 0.15s ease;
}

.report-table tbody tr.is-static {
    cursor: default;
}

.report-table tbody tr:nth-child(even) {
    background: #f7fafc;
}

.report-table tbody tr:hover,
.report-table tbody tr:focus-visible {
    background: #e3edf7;
    outline: none;
}

.report-table td {
    padding: 10px 14px;
    vertical-align: top;
}

.report-table td.cell-time {
    white-space: nowrap;
    color: #445a70;
    font-variant-numeric: tabular-nums;
}

.report-table td.cell-title {
    font-weight: 600;
}

.report-table td.cell-icd {
    white-space: pre-wrap;
    color: #3d4f61;
}

.report-table td.cell-icd-code,
.report-table td.cell-icd-desc,
.report-table td.cell-icd-pair {
    color: #3d4f61;
}

.report-table td.cell-icd-pair {
    padding: 0;
}

.icd-pair {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: stretch;
}

.icd-pair .icd-code,
.icd-pair .icd-desc {
    padding: 6px 10px;
    border-bottom: 1px solid #d5dde6;
    line-height: 1.45;
    min-height: 1.45em;
}

.icd-pair .icd-code {
    border-right: 1px solid #d5dde6;
}

.icd-pair > :nth-last-child(-n+2) {
    border-bottom: none;
}

.report-table td.cell-notes {
    vertical-align: middle;
}

.report-table td.cell-encounter {
    vertical-align: middle;
}

.encounter-id-input {
    width: 100%;
    min-width: 110px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.encounter-id-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.report-table td.cell-completed {
    white-space: nowrap;
    vertical-align: middle;
}

.completed-mark {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
}

.completed-mark input {
    width: 16px;
    height: 16px;
    accent-color: var(--navy);
    cursor: pointer;
}

.completed-at {
    color: #445a70;
    font-variant-numeric: tabular-nums;
    font-size: 0.92em;
}

.record-title-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font: inherit;
    font-weight: 650;
    text-align: left;
    cursor: pointer;
    text-decoration: underline;
}

.record-title-link:hover,
.record-title-link:focus-visible {
    color: var(--accent-hover);
}

.icd-line,
.icd-code,
.icd-desc {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.92em;
    padding: 2px 0;
    line-height: 1.45;
    box-sizing: border-box;
}

.icd-line,
.icd-code {
    white-space: pre;
    user-select: text;
    cursor: text;
}

.icd-desc {
    white-space: normal;
    user-select: text;
}

.icd-code.is-procedure,
.icd-desc.is-procedure {
    padding-left: 14px;
    color: #52657a;
}

.billing-notes-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--accent);
    font: inherit;
    font-weight: 650;
    cursor: pointer;
    text-decoration: underline;
}

.billing-notes-link:hover,
.billing-notes-link:focus-visible {
    color: var(--accent-hover);
}

.audit-thread-wrap {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.audit-thread {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.audit-thread-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #eef2f6;
    font-weight: 650;
}

.audit-thread .report-table {
    border-radius: 0;
}

.audit-query {
    min-width: 220px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.reason-overlay {
    position: fixed;
    inset: 0;
    background: rgba(19, 39, 66, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.reason-overlay[hidden] {
    display: none;
}

.reason-dialog {
    width: min(480px, calc(100vw - 32px));
    background: #fff;
    border-radius: 10px;
    padding: 20px 22px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.bill-note-dialog {
    width: min(760px, calc(100vw - 32px));
    min-height: min(640px, calc(100vh - 48px));
    height: min(720px, calc(100vh - 48px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 10px;
    padding: 22px 24px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.bill-note-dialog h2 {
    margin: 0 0 6px;
}

.bill-note-dialog .setup-lead {
    margin: 0 0 14px;
}

.bill-note-label {
    font-size: 0.78em;
    font-weight: 650;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #52657a;
}

.bill-note-text {
    flex: 0 0 28%;
    min-height: 140px;
    width: 100%;
    margin: 6px 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    resize: vertical;
}

.bill-note-text:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

.bill-note-history-block {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.bill-note-history-title {
    margin: 0 0 8px;
    font-size: 0.95em;
}

.bill-note-history {
    flex: 1 1 auto;
    min-height: 180px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #f7fafc;
}

.bill-note-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.bill-note-history-table th,
.bill-note-history-table td {
    padding: 8px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}

.bill-note-history-table th {
    position: sticky;
    top: 0;
    background: var(--navy);
    color: #fff;
    font-weight: 650;
}

.bill-note-history-table td:nth-child(1) {
    white-space: nowrap;
    width: 170px;
    font-variant-numeric: tabular-nums;
}

.bill-note-history-table td:nth-child(2) {
    white-space: nowrap;
    width: 90px;
}

.bill-note-empty {
    margin: 16px 12px;
    color: #5b6b7c;
}

.reason-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
}

.lang-dialog #sessionLangList {
    display: block;
    width: 100%;
    margin: 8px 0 4px;
    min-height: 12em;
    padding: 6px;
    border: 2px solid var(--field-border, var(--border));
    border-radius: 8px;
    background: var(--field-bg, #fff);
    color: var(--text);
    font: inherit;
}

.report-count {
    margin: 0 0 10px;
    font-size: 0.85em;
    color: #5b6b7c;
}

/* ---------- Admin setup ---------- */
.setup-panel {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 20px 24px;
    overflow: auto;
}

.setup-header h2 {
    margin: 0 0 6px;
    font-size: 1.15em;
}

.setup-lead {
    margin: 0 0 18px;
    color: #4a5b6d;
    font-size: 0.92em;
}

.setup-add {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 8px;
}

.setup-add .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
}

.setup-add label {
    font-size: 0.76em;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #52657a;
}

.setup-add input,
.setup-add select,
.setup-role-select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.setup-role-help {
    margin: 0 0 14px;
    font-size: 0.82em;
    color: #5b6b7c;
}

.setup-status-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: var(--btn-ink);
    cursor: pointer;
    font: inherit;
    font-size: 0.85em;
    font-weight: 650;
}

.setup-status-btn:hover {
    background: #eef3f8;
}

.setup-status-btn:disabled,
.setup-password.is-disabled input,
.setup-password.is-disabled button {
    opacity: 1;
    cursor: not-allowed;
    background: #e8eaed;
    color: #c5c9d1;
    font-weight: 400;
}

.setup-account {
    margin-bottom: 28px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--border);
}

.setup-password {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 8px;
}

.setup-password .field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 180px;
}

.setup-password label {
    font-size: 0.76em;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #52657a;
}

.setup-password input {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
}

.setup-temp {
    margin: 0 0 14px;
    padding: 12px 14px;
    background: #fff8e6;
    border: 1px solid #e6d39a;
    border-radius: 8px;
}

.setup-temp-label {
    margin: 0 0 6px;
    font-size: 0.85em;
    color: #6b5720;
}

.setup-temp-email {
    margin: 0 0 8px;
    font-size: 0.9em;
}

.setup-temp-value {
    display: inline-block;
    margin-right: 10px;
    padding: 4px 8px;
    background: #fff;
    border-radius: 4px;
    font-size: 1.05em;
    letter-spacing: 0.04em;
}

.setup-auth-label {
    font-size: 0.85em;
}

.setup-must-change {
    display: inline-block;
    margin-left: 6px;
    font-size: 0.75em;
    color: #8a5a00;
}

/* ---------- Tabbed workspace ---------- */
.workspace {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.tab-widget {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--panel);
}

.tab-bar {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    height: auto;
    min-height: var(--tabbar-height);
    background: transparent;
    border-bottom: 2px solid var(--field-border, var(--border));
    overflow: visible;
    min-width: 0;
    gap: 4px 6px;
    padding: 6px 8px 0;
    position: relative;
    z-index: 1;
}

.tab-btn {
    appearance: none;
    border: 2px solid transparent;
    border-bottom-width: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 0.92em;
    font-weight: 600;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 10px 10px 0 0;
    white-space: nowrap;
    flex: 0 0 auto;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.tab-btn:hover {
    color: var(--text);
    background: transparent;
}

.tab-btn.is-active {
    color: var(--text);
    background: var(--panel);
    border: 2px solid var(--field-border, var(--border));
    border-bottom-color: var(--panel);
    margin-bottom: -2px;
}

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

.tab-panels {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    position: relative;
    background: var(--panel);
    border: 2px solid var(--field-border, var(--border));
    border-top: none;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
}

.tab-panel {
    display: none;
    height: 100%;
    min-height: 0;
    min-width: 0;
    padding: 16px 20px 12px;
    overflow: hidden;
}

.tab-panel.is-active {
    display: flex;
    flex-direction: column;
}

.tab-panel .text-box {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    height: 100%;
    max-height: none;
    resize: none;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1em;
    line-height: 1.55;
    font-family: inherit;
    color: var(--text);
    background: #fff;
}

.tab-panel .text-box::-webkit-scrollbar {
    width: 10px;
}

.tab-panel .text-box::-webkit-scrollbar-track {
    background: #eef2f6;
    border-radius: 6px;
}

.tab-panel .text-box::-webkit-scrollbar-thumb {
    background: #9aa8b8;
    border-radius: 6px;
}

.tab-panel .text-box:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(43, 108, 176, 0.15);
}

/* ---------- Combined office visit panel ---------- */
.visit-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 6px;
}

.visit-box-label {
    font-size: 0.76em;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #52657a;
}

.visit-box-label.spaced {
    display: block;
    flex-shrink: 0;
    margin: 12px 0 6px;
}

.visit-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.visit-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: var(--accent);
    color: var(--btn-ink);
    font: inherit;
    font-size: 0.85em;
    font-weight: 650;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.visit-btn.approve,
.visit-btn.delete {
    background: var(--accent);
}

.visit-btn.approve:hover:not(:disabled),
.visit-btn.delete:hover:not(:disabled) {
    background: var(--accent-hover);
}

.visit-btn:disabled {
    background: #e8eaed;
    color: #c5c9d1;
    font-weight: 400;
    opacity: 1;
    cursor: not-allowed;
}

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

/* ICD box is a few extra lines; sectioned notes leave room for the buttons. */
.tab-panel .text-box.icd-box {
    flex: 0 0 auto;
    box-sizing: border-box;
    height: calc(6 * 1.4em + 24px);
    padding: 10px 12px;
    font-size: 0.88em;
    line-height: 1.4;
}

.tab-panel .text-box.note-box {
    flex: 1 1 auto;
    min-height: 0;
    font-size: 0.88em;
    line-height: 1.4;
    padding: 10px 12px;
}

#noteViewSections .text-box.note-box {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
}

.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;
}

/* ---------- Bottom action row ---------- */
.app-actionbar {
    flex-shrink: 0;
    min-width: 0;
    width: 100%;
    min-height: 0;
    height: auto;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    padding: 8px 16px;
    background: #eef2f6;
    border-top: 1px solid var(--border);
    box-sizing: border-box;
}

.actionbar-buttons {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    margin-right: auto;
    width: 100%;
    min-width: 0;
    overflow: visible;
}

.actionbar-row {
    display: contents;
}

#currentBtn {
    order: 3;
}

.action-btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font: inherit;
    font-size: 0.9em;
    font-weight: 650;
    color: var(--btn-ink);
    white-space: nowrap;
    transition: background 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

.action-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.action-btn:disabled {
    background: #e8eaed;
    color: #c5c9d1;
    font-weight: 400;
    opacity: 1;
    cursor: not-allowed;
}

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

/* Every action button shares one blue; state is carried by label, pulse,
   and the disabled treatment rather than by hue. */
.action-btn {
    background: var(--accent);
}

.action-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.record-btn {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.record-btn.recording {
    animation: pulse 1.5s infinite;
}

.record-btn:disabled {
    box-shadow: none;
}

/* ---------- Record navigation ---------- */
.record-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    order: 4;
}

.record-nav.is-empty {
    display: none;
}

.nav-arrow {
    min-width: 38px;
    padding: 9px 12px;
    font-size: 1em;
    line-height: 1;
}

.record-position {
    min-width: 82px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 0.86em;
    font-weight: 650;
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.retention-note {
    padding: 0;
    margin-left: auto;
    background: none;
    border: none;
    border-radius: 0;
    color: var(--muted);
    font-size: 0.68em;
    font-weight: 400;
    letter-spacing: 0;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.2;
    order: 5;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: calc(var(--actionbar-height) + 16px);
    right: 20px;
    background: var(--navy);
    color: white;
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    z-index: 1000;
    animation: slideIn 0.25s ease;
    font-size: 0.92em;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 1280px) {
    html:not(.is-docked) .action-btn {
        padding: 8px 14px;
        font-size: 0.84em;
    }
}

@media (max-width: 820px) {
    .app-menubar {
        height: 56px;
        padding: 0 10px;
        gap: 8px;
        flex-wrap: nowrap;
    }

    .app-menubar h1 {
        font-size: 0.92em;
    }

    .menubar-brand {
        flex: 0 1 auto;
        min-width: 0;
    }

    .menubar-center,
    .menubar-user {
        flex: 0 1 auto;
        min-width: 0;
    }

    .user-name {
        display: none;
    }

    .action-btn {
        padding: 7px 11px;
        font-size: 0.78em;
    }

    .tab-btn {
        padding: 6px 12px;
        font-size: 0.82em;
    }

    .app-actionbar {
        padding: 8px 12px;
    }
}
