@font-face {
    font-family: "Manrope";
    src: url("/assets/fonts/manrope-latin.woff2") format("woff2");
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
}

@font-face {
    font-family: "IBM Plex Mono";
    src: url("/assets/fonts/ibm-plex-mono-latin.woff2") format("woff2");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

:root {
    --paper: #f3efe4;
    --paper-raised: #fffdf7;
    --ink: #172427;
    --ink-muted: #5c6969;
    --teal: #0b766e;
    --teal-soft: #d7ebe6;
    --warning: #a35d00;
    --warning-soft: #f5e3bf;
    --danger: #a83b32;
    --danger-soft: #f5d8d3;
    --rule: #cbc8bd;
    --focus-ring: #006d77;
    --space-1: .35rem;
    --space-2: .65rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2.25rem;
    --radius: .35rem;
    --shadow: 0 14px 35px rgba(29, 43, 43, .08);
}

.medpl-page { min-height: 100vh; }
.medpl-sidebar { background: linear-gradient(180deg, #123d3b 0%, #0c2928 100%); border: 0; box-shadow: 12px 0 40px rgba(10, 39, 37, .12); }
.medpl-sidebar .container-fluid { min-height: 100%; align-items: stretch; }
.medpl-brand { display: flex; align-items: center; gap: .75rem; color: #f7fbfa; }
.medpl-brand:hover { color: white; }
.medpl-brand > span:last-child { display: grid; }
.medpl-brand small { color: #9bc6c1; font-size: .68rem; letter-spacing: .08em; text-transform: uppercase; }
.medpl-sidebar .nav-link { display: flex; align-items: center; gap: .7rem; min-height: 44px; color: #c8ddda; border-radius: .55rem; }
.medpl-sidebar .nav-link i { font-size: 1.25rem; }
.medpl-sidebar .nav-link:hover, .medpl-sidebar .nav-link[aria-current="page"] { color: white; background: rgba(255,255,255,.1); }
.medpl-sidebar .nav-link[aria-current="page"] { box-shadow: inset 3px 0 #43b8aa; font-weight: 750; }
.medpl-sidebar .logout-form { margin-top: auto; }
.medpl-sidebar .nav-button { width: 100%; border: 0; background: transparent; }
.medpl-topbar { min-height: 68px; background: rgba(255,253,247,.92); border-bottom: 1px solid var(--rule); backdrop-filter: blur(16px); }
.medpl-topbar .session-state { display: flex; align-items: center; gap: .7rem; }
.medpl-topbar .session-state > span:last-child { display: grid; }
.medpl-topbar .avatar { color: white; background: var(--teal); }
.page-wrapper { min-width: 0; }
.page-body { padding: clamp(1rem, 3vw, 2.5rem) 0; }

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; background: var(--paper); }
body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    color: var(--ink);
    font: 400 1rem/1.5 "Manrope", sans-serif;
    background-color: var(--paper);
    background-image:
        linear-gradient(rgba(42, 61, 59, .035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(42, 61, 59, .025) 1px, transparent 1px);
    background-size: 28px 28px;
}
a { color: var(--teal); text-underline-offset: .2em; }
code, pre { font-family: "IBM Plex Mono", monospace; }
button, input, select, textarea { font: inherit; }
button, .button, .primary-nav a { min-height: 44px; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 100; left: 1rem; top: -5rem; padding: .7rem 1rem; background: var(--ink); color: white; }
.skip-link:focus { top: 1rem; }
.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; }

.site-header { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: .75rem clamp(1rem, 4vw, 3rem); background: rgba(255, 253, 247, .94); border-bottom: 1px solid var(--rule); }
.brand, .session-state { display: flex; align-items: center; gap: .75rem; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; color: white; background: var(--teal); border-radius: 50% 50% 45% 55%; font-weight: 800; }
.brand span:last-child, .session-state span:last-child { display: grid; }
.brand small, .session-state small { color: var(--ink-muted); font-size: .73rem; letter-spacing: .08em; text-transform: uppercase; }
.session-state { max-width: min(50vw, 28rem); font-size: .85rem; }
.session-state strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-dot { flex: 0 0 auto; width: .7rem; height: .7rem; background: var(--teal); border-radius: 50%; box-shadow: 0 0 0 4px var(--teal-soft); }

.app-shell { display: grid; grid-template-columns: 13rem minmax(0, 1fr); max-width: 100rem; margin: 0 auto; }
.primary-nav { min-height: calc(100vh - 72px); display: flex; flex-direction: column; gap: .25rem; padding: var(--space-4) var(--space-3); border-right: 1px solid var(--rule); background: rgba(255, 253, 247, .55); }
.primary-nav a, .nav-button { display: flex; align-items: center; width: 100%; padding: .55rem .8rem; border: 0; border-radius: var(--radius); color: var(--ink); background: transparent; text-decoration: none; cursor: pointer; }
.primary-nav a:hover, .nav-button:hover, .primary-nav a[aria-current="page"] { background: var(--teal-soft); color: #075b55; }
.primary-nav a[aria-current="page"] { font-weight: 750; box-shadow: inset 3px 0 0 var(--teal); }
.logout-form { margin-top: auto; }
.main-content { min-width: 0; padding: clamp(1rem, 3vw, 2.5rem); }

.page-heading { margin-bottom: var(--space-4); }
.page-heading h1 { max-width: 24ch; margin: .1rem 0 .25rem; font-size: clamp(2rem, 5vw, 4rem); line-height: .98; letter-spacing: -.045em; }
.page-heading > p:last-child { max-width: 64ch; color: var(--ink-muted); }
.compact-heading { display: flex; align-items: end; justify-content: space-between; gap: var(--space-3); }
.compact-heading h1 { font-size: clamp(1.8rem, 4vw, 3.2rem); }
.eyebrow { margin: 0; color: var(--teal); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.breadcrumb { display: flex; gap: .55rem; margin-bottom: var(--space-3); font-size: .85rem; }
.error-state { max-width: 48rem; padding: clamp(1.5rem, 5vw, 4rem); background: var(--paper-raised); border: 1px solid var(--rule); border-top: 5px solid var(--danger); box-shadow: var(--shadow); }
.error-state h1 { margin: .25rem 0; font-size: clamp(2rem, 6vw, 4.5rem); letter-spacing: -.04em; }
.error-state p:not(.eyebrow) { max-width: 58ch; color: var(--ink-muted); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2); margin-bottom: var(--space-3); }
.metric-card, .ledger-panel, .filter-panel, .action-panel { background: var(--paper-raised); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); }
.metric-card { min-height: 8rem; display: flex; flex-direction: column; justify-content: space-between; padding: var(--space-3); }
.metric-card strong { font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1; }
.metric-label { color: var(--ink-muted); font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.warning-card { border-top: 4px solid var(--warning); background: linear-gradient(135deg, var(--paper-raised), var(--warning-soft)); }
.dashboard-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.ledger-panel { min-width: 0; padding: var(--space-3); }
.ledger-panel > header { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); padding-bottom: .75rem; border-bottom: 1px solid var(--rule); }
.ledger-panel h2, .action-panel h2 { margin: 0; font-size: 1.1rem; }
.ruled-list { list-style: none; margin: 0; padding: 0; }
.ruled-list li { display: flex; justify-content: space-between; gap: 1rem; padding: .7rem 0; border-bottom: 1px dotted var(--rule); }
.fleet-list li { align-items: center; }
.fleet-list li > span { display: grid; gap: .15rem; }
.fleet-list small, .fleet-list time { color: var(--ink-muted); font-size: .76rem; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-3); }
.compact-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin: 0; background: var(--rule); }
.compact-stats div { padding: .8rem; background: var(--paper-raised); }
.compact-stats dt { color: var(--ink-muted); font-size: .75rem; text-transform: uppercase; }
.compact-stats dd { margin: .15rem 0 0; font: 600 1.2rem "IBM Plex Mono", monospace; }
.good-state { color: var(--teal); font-weight: 700; }
.empty-state { padding: var(--space-4); color: var(--ink-muted); text-align: center; }

.filter-panel, .action-panel { margin-bottom: var(--space-3); }
.filter-panel summary, .action-panel summary { min-height: 44px; display: flex; align-items: center; padding: .7rem 1rem; cursor: pointer; font-weight: 750; }
.filter-grid, .correction-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .8rem; padding: 0 1rem 1rem; }
label { display: grid; gap: .3rem; min-width: 0; color: var(--ink-muted); font-size: .78rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 44px; padding: .55rem .65rem; border: 1px solid #9da9a7; border-radius: .25rem; color: var(--ink); background: white; }
textarea { min-height: 7rem; resize: vertical; }
.filter-actions, .full-field { grid-column: 1 / -1; }
.filter-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.button { display: inline-flex; align-items: center; justify-content: center; padding: .55rem .9rem; border: 1px solid transparent; border-radius: .25rem; font-weight: 750; text-decoration: none; cursor: pointer; transition: transform .16s ease, background-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button.primary { color: white; background: var(--teal); }
.button.ghost { color: var(--ink); border-color: var(--rule); background: transparent; }
.button.danger { color: white; background: var(--danger); }
.danger-panel { border-left: 4px solid var(--danger); }
.danger-panel form { display: grid; gap: .8rem; padding: 0 1rem 1rem; }

.table-panel { padding: 0; overflow: hidden; }
.table-panel > header { padding: var(--space-3); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .72rem .75rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
thead th { color: var(--ink-muted); background: #ebe8df; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
tbody tr:hover { background: rgba(215, 235, 230, .45); }
td small { display: block; color: var(--ink-muted); }
.detail-table th { width: 13rem; color: var(--ink-muted); }
.row-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 750; }
.load-more { margin: 1rem; }
.status-pill { display: inline-flex; align-items: center; min-height: 1.8rem; padding: .2rem .55rem; border: 1px solid currentColor; border-radius: 999px; color: #4d5d5d; background: #eef0ec; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.status-checked, .status-success, .status-complete { color: #075f50; background: var(--teal-soft); }
.status-submitted { color: #765200; background: var(--warning-soft); }
.status-archived, .status-internal_error { color: #8b312a; background: var(--danger-soft); }

.action-panel { padding-bottom: .25rem; }
.inline-actions { display: inline-flex; margin: .4rem .4rem .4rem 0; }
.timeline-panel { margin-top: var(--space-3); }
.timeline { list-style: none; margin: 1rem 0 0; padding: 0; }
.timeline > li { display: grid; grid-template-columns: 1rem minmax(0, 1fr); gap: .75rem; }
.timeline-marker { position: relative; width: .7rem; height: .7rem; margin-top: .35rem; border: 2px solid var(--teal); border-radius: 50%; background: var(--paper-raised); }
.timeline-marker::after { content: ""; position: absolute; left: 50%; top: .7rem; width: 1px; height: calc(100% + 1.5rem); background: var(--rule); }
.timeline li:last-child .timeline-marker::after { display: none; }
.timeline article { padding-bottom: 1.5rem; min-width: 0; }
.timeline article > header { display: flex; justify-content: space-between; gap: 1rem; }
.timeline time { color: var(--ink-muted); font-size: .8rem; }
blockquote { margin: .7rem 0; padding: .6rem .8rem; border-left: 3px solid var(--warning); background: var(--warning-soft); }
.diff-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
pre { max-height: 22rem; overflow: auto; margin: .5rem 0 0; padding: .75rem; color: #e5f3ef; background: #203131; border-radius: .25rem; font-size: .75rem; white-space: pre-wrap; word-break: break-word; }
.reveal { animation: reveal .28s ease-out both; }
@keyframes reveal { from { opacity: 0; transform: translateY(6px); } }

@media (max-width: 64rem) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-grid, .correction-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 48rem) {
    .medpl-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1050; width: min(18rem, 86vw); display: block; transform: translateX(-105%); transition: transform .2s ease; }
    .medpl-sidebar.is-open { transform: translateX(0); }
    body.nav-open::after { content: ""; position: fixed; inset: 0; z-index: 1040; background: rgba(8,24,23,.48); }
    body.nav-open { overflow: hidden; }
    .medpl-sidebar .container-fluid { display: flex; flex-direction: column; padding: 1rem; }
    .medpl-topbar { position: sticky; top: 0; z-index: 1030; }
    .site-header { position: relative; min-height: 64px; padding: .65rem 1rem; }
    .session-state strong { max-width: 9rem; }
    .app-shell { display: block; }
    .primary-nav { position: sticky; top: 0; z-index: 20; min-height: auto; flex-direction: row; overflow-x: auto; padding: .35rem .75rem; border-right: 0; border-bottom: 1px solid var(--rule); background: rgba(255, 253, 247, .97); }
    .primary-nav a, .nav-button { width: auto; white-space: nowrap; }
    .logout-form { margin: 0 0 0 auto; }
    .main-content { padding: 1rem; }
    .metric-grid, .dashboard-grid, .filter-grid, .correction-grid, .diff-grid { grid-template-columns: 1fr; }
    .compact-heading { align-items: start; }
    .responsive-table, .responsive-table tbody, .responsive-table tr, .responsive-table td { display: block; width: 100%; }
    .responsive-table thead, .detail-table th { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .responsive-table tr { margin: .75rem; width: calc(100% - 1.5rem); border: 1px solid var(--rule); border-radius: .3rem; background: var(--paper-raised); }
    .responsive-table td { display: grid; grid-template-columns: minmax(7rem, 38%) minmax(0, 1fr); gap: .65rem; min-height: 44px; padding: .65rem .75rem; overflow-wrap: anywhere; }
    .responsive-table [data-label]::before { content: attr(data-label); color: var(--ink-muted); font-size: .68rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
    .timeline article > header { display: grid; gap: .25rem; }
}

@media (max-width: 24rem) {
    .brand small, .session-state small { display: none; }
    .session-state strong { max-width: 7rem; }
    .metric-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

.dev-mock-controls .filter-grid { margin-bottom: 1rem; }
.dev-radiology-app { position: relative; overflow: hidden; }
.dev-radiology-app::after { content: "DEV"; position: absolute; right: -.75rem; bottom: -1.7rem; color: color-mix(in srgb, var(--teal) 10%, transparent); font-size: clamp(5rem, 16vw, 10rem); font-weight: 900; letter-spacing: -.08em; pointer-events: none; }
.dev-study-fields { position: relative; z-index: 1; display: grid; gap: .45rem; max-width: 44rem; }
.dev-study-fields p { display: grid; grid-template-columns: minmax(9rem, 1fr) minmax(0, 2fr); gap: 1rem; margin: 0; padding: .7rem 0; border-bottom: 1px solid var(--rule); }
.dev-study-fields .map-list-title { color: var(--ink-muted); font-size: .75rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.study-info { position: relative; z-index: 1; margin-top: 1rem; padding: 1rem; border-left: .3rem solid var(--teal); background: var(--paper-raised); }

@media (max-width: 36rem) {
    .dev-study-fields p { grid-template-columns: 1fr; gap: .2rem; }
}

/* Tabler shell overrides legacy navigation rules during the staged redesign. */
.medpl-sidebar .primary-nav { min-height: 0; padding: 0; border: 0; background: transparent; }
.medpl-sidebar .primary-nav .nav-link, .medpl-sidebar .nav-button { width: 100%; padding: .65rem .8rem; }
.medpl-page .main-content { padding: 0; }
.grid-shell { overflow: hidden; border: 1px solid var(--rule); border-radius: .65rem; background: var(--paper-raised); box-shadow: var(--shadow); }
.grid-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; padding: .75rem; border-bottom: 1px solid var(--rule); }
.grid-toolbar .grid-search { flex: 1 1 16rem; max-width: 28rem; }
.grid-toolbar .btn { min-height: 40px; }
.tabulator { border: 0; background: transparent; font-family: "Manrope", sans-serif; }
.tabulator .tabulator-header { border-bottom-color: var(--rule); background: #e9f0ee; }
.tabulator .tabulator-header .tabulator-col { background: transparent; }
.tabulator-row { min-height: 48px; background: var(--paper-raised); }
.tabulator-row.tabulator-row-even { background: #f8faf8; }
.tabulator-row:hover { background: var(--teal-soft); }
@media (max-width: 48rem) {
    .medpl-sidebar .primary-nav { position: static; display: flex; flex-direction: column; overflow: visible; }
    .medpl-sidebar .logout-form { margin: auto 0 0; }
}

/* Compact operations shell. These rules own portal geometry independently of Tabler breakpoints. */
:root {
    --sidebar-width: 15.5rem;
    --topbar-height: 3.75rem;
    --content-max: 100rem;
    --surface: #fffefa;
    --surface-muted: #eef2ef;
    --sidebar-start: #133b39;
    --sidebar-end: #0b2525;
}
html, body { overflow-x: clip; }
.medpl-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); align-items: stretch; }
.medpl-sidebar { position: sticky; top: 0; z-index: 40; width: var(--sidebar-width); height: 100vh; min-height: 100vh; overflow-y: auto; background: linear-gradient(180deg, var(--sidebar-start), var(--sidebar-end)); border-right: 1px solid rgba(255,255,255,.08); box-shadow: 10px 0 32px rgba(12,38,36,.12); }
.medpl-sidebar .container-fluid { width: 100%; min-height: 100%; display: flex; flex-direction: column; align-items: stretch; padding: 1.1rem .85rem .9rem; }
.medpl-brand { min-height: 3.25rem; padding: .2rem .45rem 1rem; text-decoration: none; }
.medpl-sidebar .primary-nav { display: flex; flex-direction: column; gap: .25rem; margin-top: .6rem; }
.medpl-sidebar .primary-nav .nav-link, .medpl-sidebar .nav-button { min-height: 2.75rem; padding: .62rem .72rem; border-radius: .5rem; font-size: .9rem; }
.medpl-sidebar .logout-form { margin-top: auto; padding-top: 1rem; }
.medpl-workspace { min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }
.medpl-topbar { position: sticky; top: 0; z-index: 30; min-height: var(--topbar-height); height: var(--topbar-height); padding: 0; background: rgba(255,254,250,.94); }
.medpl-topbar .container-xl { width: 100%; max-width: none; min-height: 100%; padding: 0 clamp(1rem,2.2vw,2rem); }
.medpl-topbar .navbar-toggler { display: none; }
.medpl-content { flex: 1; min-width: 0; padding: clamp(1.15rem,2.2vw,2rem); }
.medpl-container { width: min(100%,var(--content-max)); margin: 0 auto; }
.medpl-container-wide { width: 100%; max-width: none; }
.medpl-backdrop { display: none; }
.page-heading { margin-bottom: 1.15rem; }
.page-heading h1, .compact-heading h1 { max-width: none; margin: .15rem 0 .35rem; font-size: clamp(1.85rem,3vw,2.55rem); line-height: 1.08; letter-spacing: -.035em; }
.page-heading > p:last-child { margin: 0; font-size: .94rem; }
.metric-card { min-height: 7rem; }
.metric-card strong { font-size: clamp(1.8rem,3vw,2.6rem); }
.ledger-panel { border-radius: .65rem; box-shadow: 0 8px 24px rgba(29,43,43,.06); }
@media (max-width: 61.99rem) {
    .medpl-shell { display: block; }
    .medpl-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1050; width: min(var(--sidebar-width),86vw); transform: translateX(-102%); transition: transform .2s ease; }
    .medpl-sidebar.is-open { transform: translateX(0); }
    .medpl-backdrop { position: fixed; inset: 0; z-index: 1040; width: 100%; height: 100%; padding: 0; border: 0; background: rgba(7,25,24,.52); opacity: 0; pointer-events: none; transition: opacity .2s ease; }
    body.nav-open .medpl-backdrop { display: block; opacity: 1; pointer-events: auto; }
    .medpl-workspace { width: 100%; }
    .medpl-topbar .navbar-toggler { display: inline-flex; }
    .medpl-content { padding: 1rem; }
    .medpl-topbar .container-xl { padding: 0 1rem; }
}
@media (max-width: 40rem) {
    .medpl-topbar .session-state strong { max-width: 11rem; }
    .page-heading h1, .compact-heading h1 { font-size: clamp(1.65rem,8vw,2.15rem); }
}

/* Dense operational components. */
.ops-scroll { max-height: 22rem; overflow: auto; overscroll-behavior: contain; padding-right: .25rem; }
.dashboard-grid { grid-template-columns: repeat(12,minmax(0,1fr)); align-items: start; }
.dashboard-grid > .ledger-panel { grid-column: span 6; }
.dashboard-grid > .ledger-panel:nth-last-child(1):nth-child(odd) { grid-column: span 12; }
.ledger-panel > header { min-height: 3.25rem; align-items: center; padding: .8rem 1rem; }
.ledger-panel > header .eyebrow { margin-right: auto; }
.page-size-control { margin-left: auto; display: flex; align-items: center; justify-content: flex-end; gap: .65rem; }
.page-size-control label { display: flex; align-items: center; gap: .45rem; margin: 0; color: var(--muted); font-size: .82rem; }
.page-size-control input[type="number"] { width: 5rem; min-height: 2.25rem; padding: .3rem .45rem; }
.page-size-control .button { min-height: 2.25rem; padding: .35rem .65rem; }
.filter-panel, .action-panel { border-radius: .65rem; box-shadow: 0 6px 18px rgba(29,43,43,.045); }
.filter-panel summary, .action-panel summary { padding: .75rem 1rem; }
.filter-grid, .correction-grid { gap: .7rem; padding: .2rem 1rem 1rem; }
input, select, textarea { border-color: #aeb8b6; border-radius: .4rem; box-shadow: 0 1px 0 rgba(23,36,39,.03); }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(11,118,110,.13); outline: 0; }
.button, .btn { border-radius: .42rem; }
.table-panel { margin-bottom: 1rem; }
.table-viewport { width: 100%; overflow: auto; overscroll-behavior-inline: contain; }
.table-viewport > table { min-width: 46rem; }
.table-viewport thead th { position: sticky; top: 0; z-index: 2; }
th, td { padding: .58rem .7rem; }
thead th { background: #e7ece9; color: #53605f; }
tbody tr:nth-child(even) { background: rgba(238,242,239,.45); }
.grid-toolbar { position: relative; min-height: 3.5rem; padding: .65rem .8rem; background: #f7f8f5; }
.grid-toolbar .grid-search { max-width: 34rem; }
.grid-toolbar .form-control { min-height: 2.5rem; }
.grid-bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; padding: .7rem .8rem; border-bottom: 1px solid var(--rule); background: #eef7f2; }
.grid-bulk-actions > strong { min-width: 11rem; color: #175247; }
.grid-bulk-actions .btn { min-height: 2.4rem; }
.grid-bulk-dialog { width: min(32rem, calc(100% - 2rem)); padding: 0; border: 1px solid #b7c8c1; border-radius: .7rem; box-shadow: 0 1.4rem 4rem rgba(20,40,36,.25); color: var(--ink); }
.grid-bulk-dialog::backdrop { background: rgba(15,31,29,.45); }
.grid-bulk-dialog form { display: grid; gap: 1rem; padding: 1.2rem; }
.grid-bulk-dialog header { display: grid; gap: .35rem; }
.grid-bulk-dialog h2, .grid-bulk-dialog p { margin: 0; }
.grid-bulk-dialog label { display: grid; gap: .35rem; font-size: .82rem; font-weight: 700; color: #36514d; }
.grid-bulk-dialog footer { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .6rem; }
.grid-shell .tabulator { min-height: 18rem; max-height: 66vh; }
#reports-grid.tabulator { max-height: none; }
.tabulator { font-size: .84rem; }
.tabulator .tabulator-header { position: sticky; top: 0; z-index: 5; }
.tabulator .tabulator-header .tabulator-col { min-height: 2.8rem; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content { padding: .55rem .6rem; }
.tabulator-row { min-height: 44px; }
.tabulator-row .tabulator-cell { padding: .58rem .6rem; }
.tabulator-row .tabulator-cell.tabulator-editable { cursor: text; box-shadow: inset 0 -2px 0 rgba(11,118,110,.18); }
.tabulator-row .tabulator-cell.tabulator-editable:hover { background: rgba(58,190,180,.09); box-shadow: inset 0 -2px 0 var(--teal); }
.tabulator-row.is-saving { opacity: .62; pointer-events: none; }
.tabulator-row .tabulator-cell.has-grid-cell-actions { padding-right: 4.75rem; }
.tabulator .tabulator-row-header { display: flex; align-items: center; justify-content: center; }
.tabulator .tabulator-row-header input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; }
.grid-cell-actions { position: absolute; top: 50%; right: .3rem; z-index: 3; display: flex; align-items: center; gap: .25rem; transform: translateY(-50%); }
.grid-cell-actions button { width: 1.8rem; height: 1.8rem; display: inline-grid; place-items: center; padding: 0; border: 1px solid transparent; border-radius: .35rem; color: #fff; font-size: 1rem; font-weight: 800; line-height: 1; cursor: pointer; }
.grid-cell-actions button:focus-visible { outline: 3px solid rgba(15,118,110,.25); outline-offset: 2px; }
.grid-row-confirm { background: #16834f; border-color: #126b42 !important; }
.grid-row-confirm:hover { background: #126b42; }
.grid-row-cancel { background: #c43f3f; border-color: #9f3030 !important; }
.grid-row-cancel:hover { background: #9f3030; }
.grid-cell-actions button:disabled { opacity: .55; cursor: wait; }
.tabulator .tabulator-footer { background: #f4f6f3; }
.grid-toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 2000; max-width: min(28rem,calc(100vw - 2rem)); padding: .8rem 1rem; border: 1px solid #6a9d86; border-radius: .5rem; background: #eaf8ef; color: #174e35; box-shadow: 0 12px 36px rgba(13,36,34,.2); opacity: 0; transform: translateY(.6rem); pointer-events: none; transition: opacity .16s ease,transform .16s ease; }
.grid-toast.is-visible { opacity: 1; transform: translateY(0); }
.grid-toast.is-error { border-color: #c56b65; background: #fff0ee; color: #792b27; }
.grid-header-control, .grid-date-range { display: flex; gap: .25rem; align-items: center; width: 100%; }
.grid-header-select, .grid-date-range input { min-width: 0; height: 2.2rem; padding: .25rem .4rem; border: 1px solid #aebdbb; border-radius: .4rem; background: #fff; color: var(--ink); font: inherit; }
.grid-header-select { flex: 1; }
.grid-header-select { appearance: none; padding-right: 1.65rem; background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.25 6 6.25l5-5' fill='none' stroke='%23075b55' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .5rem center; background-size: .75rem .5rem; }
.grid-date-range { align-items: stretch; flex-direction: column; padding-right: 1.65rem; position: relative; }
.grid-date-range input { width: 100%; }
.grid-header-clear { flex: 0 0 1.65rem; width: 1.65rem; height: 1.65rem; padding: 0; border: 0; border-radius: 50%; background: #e9efed; color: #38504d; font-size: 1.15rem; line-height: 1; cursor: pointer; }
.grid-date-range .grid-header-clear { position: absolute; top: 50%; right: 0; transform: translateY(-50%); }
.grid-header-clear:hover, .grid-header-clear:focus-visible { background: #d4e4df; color: #0c5f58; }
.price-editor { overflow: visible; }
.price-editor > header, .price-editor > .grid-toolbar { position: sticky; z-index: 12; }
.price-editor > header { top: var(--topbar-height); background: var(--paper-raised); }
.price-editor > .grid-toolbar { top: calc(var(--topbar-height) + 3.25rem); }
.price-table-viewport { max-height: calc(100vh - 13.5rem); min-height: 22rem; border-top: 1px solid var(--rule); }
.price-table-viewport table { min-width: 62rem; }
.price-table-viewport tbody td:first-child { min-width: 25rem; }
.price-table-viewport input { min-height: 2.35rem; padding: .4rem .5rem; }
.price-table-viewport .button { min-height: 2.35rem; padding: .4rem .7rem; }
.page-actions { position: sticky; bottom: 0; z-index: 14; display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; padding: .75rem 1rem; border-top: 1px solid var(--rule); background: rgba(255,254,250,.96); box-shadow: 0 -8px 24px rgba(29,43,43,.08); }
.page-actions form { margin: 0; }
.empty-state.ledger-panel { max-width: 48rem; margin-inline: auto; padding: 2rem; }
.audit-code, td code { overflow-wrap: anywhere; }
.audit-details summary { cursor: pointer; color: var(--teal); font-weight: 700; }
.audit-details pre { max-width: 32rem; max-height: 14rem; overflow: auto; margin: .35rem 0 .7rem; padding: .55rem; background: #f3f6f3; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .75rem; }
.audit-pager { display: flex; align-items: center; justify-content: center; gap: .8rem; margin: 1rem 0 1.5rem; }
.audit-pager .button { min-height: 2.35rem; padding: .45rem .75rem; }
.audit-pager .is-disabled { opacity: .5; pointer-events: none; }
.statement-filter-card { margin-bottom: 1rem; padding: .85rem 1rem; overflow: visible; }
.statement-filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.statement-period-filter { width: min(15rem,100%); margin: 0; }
.statement-period-filter > span { display: block; margin-bottom: .35rem; font-weight: 700; }
.statement-employee-filter { position: relative; width: min(28rem,100%); }
.statement-employee-filter > summary { min-height: 2.45rem; cursor: pointer; list-style: none; }
.statement-employee-filter > summary::-webkit-details-marker { display: none; }
.statement-employee-menu { position: absolute; top: calc(100% + .35rem); left: 0; z-index: 30; width: 100%; max-height: 22rem; overflow: auto; padding: .65rem; border: 1px solid var(--rule); border-radius: .5rem; background: var(--paper-raised); box-shadow: 0 14px 32px rgba(13,36,34,.18); }
.statement-employee-menu .form-control { position: sticky; top: 0; z-index: 1; margin-bottom: .45rem; background: #fff; }
.statement-employee-option { display: flex; gap: .55rem; align-items: center; padding: .45rem .35rem; border-radius: .35rem; cursor: pointer; }
.statement-employee-option:hover { background: rgba(58,190,180,.09); }
.statement-employee-option[hidden] { display: none; }
.statement-filter-actions { display: flex; gap: .5rem; }

@media (max-width: 74rem) {
    .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .dashboard-grid > .ledger-panel { grid-column: span 12; }
}
@media (max-width: 61.99rem) {
    .price-editor > header { top: var(--topbar-height); }
    .price-editor > .grid-toolbar { top: calc(var(--topbar-height) + 3.25rem); }
    .price-table-viewport { max-height: calc(100vh - 12rem); }
}
@media (max-width: 48rem) {
    .metric-grid { grid-template-columns: 1fr 1fr; }
    .grid-toolbar { align-items: stretch; }
    .grid-toolbar .grid-search { flex-basis: 100%; max-width: none; }
    .grid-toolbar .btn { flex: 1 1 auto; }
    .grid-bulk-actions { align-items: stretch; }
    .grid-bulk-actions > strong, .grid-bulk-actions .btn { width: 100%; min-width: 0; }
    .grid-bulk-dialog footer .btn { width: 100%; }
    .ledger-panel > header:has(.page-size-control) { align-items: flex-start; flex-direction: column; }
    .page-size-control { width: 100%; margin-left: 0; justify-content: flex-start; flex-wrap: wrap; }
    .table-viewport .responsive-table { display: table; }
    .table-viewport .responsive-table thead { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
    .table-viewport .responsive-table tbody { display: table-row-group; }
    .table-viewport .responsive-table tr { display: table-row; margin: 0; width: auto; border: 0; background: transparent; }
    .table-viewport .responsive-table td { display: table-cell; width: auto; min-height: 0; padding: .55rem .65rem; }
    .table-viewport .responsive-table [data-label]::before { display: none; }
    .price-table-viewport { max-height: calc(100vh - 11rem); }
}
@media (max-width: 34rem) {
    .metric-grid { grid-template-columns: 1fr; }
    .medpl-topbar .session-state small { display: none; }
    .grid-toolbar .btn { width: 100%; }
}
