/* Internal Administration — visual language of the CSD ePRO clickable prototype v0.23.1. */
:root {
    --bg: #f6f8fb; --panel: #fff; --muted-bg: #f9fafc; --head-bg: #fafbfd;
    --line: #e5eaf1; --line2: #d7e0eb;
    --ink: #142239; --muted: #65758e; --faint: #8b98aa;
    --blue: #0A72C9; --bluedark: #085DA6; --bluesoft: #edf4ff;
    --orange: #ef7925; --orangesoft: #fff3e9;
    --green: #188452; --greensoft: #eaf7f0;
    --red: #c5404c; --redsoft: #fff0f1;
    --purple: #7150aa;
    --shadow: 0 2px 18px rgba(24, 46, 80, .055);
    --font: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; min-width: 320px; font-family: var(--font); font-size: 13px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--bluedark); text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid #7899ba; outline-offset: 2px; }

h1 { font-size: 24px; letter-spacing: -.7px; line-height: 1.24; font-weight: 760; margin: 0 0 4px; }
h2 { font-size: 15px; letter-spacing: -.25px; font-weight: 740; margin: 28px 0 12px; }
h3 { font-size: 13.5px; font-weight: 720; margin: 16px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }

/* Top bar */
.topbar { height: 67px; background: #fff; border-bottom: 1px solid var(--line); display: flex; gap: 20px; align-items: center; padding: 0 26px; position: sticky; top: 0; z-index: 40; }
.brand { display: flex; gap: 10px; align-items: center; flex-shrink: 0; color: inherit; }
.brand:hover { text-decoration: none; color: inherit; }
.logo { width: 35px; height: 35px; flex: none; display: block; }
.brandname { font-size: 16px; font-weight: 780; letter-spacing: -.4px; line-height: 1.1; }
.brandsub { font-size: 10px; color: var(--faint); letter-spacing: .05em; }
.nav { display: flex; align-items: stretch; gap: 4px; align-self: stretch; overflow-x: auto; margin-left: 18px; }
.nav a { display: flex; align-items: center; padding: 0 13px; white-space: nowrap; font-weight: 560; color: var(--muted); border-bottom: 2.5px solid transparent; border-top: 2.5px solid transparent; }
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--blue); border-bottom-color: var(--orange); font-weight: 730; }
.topright { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.env-context { display: inline-flex; align-items: center; gap: 6px; border: 1px solid; border-radius: 8px; padding: 6px 10px; font-size: 11.5px; font-weight: 730; white-space: nowrap; line-height: 1.15; background: #fff4e6; border-color: #f6dbb4; color: #99550c; text-transform: capitalize; }
.env-context.production { background: #eaf7f0; border-color: #ccebd9; color: #12643d; }
.env-context::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.account { position: relative; }
.account > summary { list-style: none; display: flex; align-items: center; gap: 9px; border: 1px solid #e2e7ed; background: #fff; padding: 4px 10px 4px 5px; border-radius: 9px; min-height: 39px; color: #2c3a4b; cursor: pointer; }
.account > summary::-webkit-details-marker { display: none; }
.account > summary:hover, .account[open] > summary { background: #f8fafc; border-color: #c9d3df; }
.account-name { font-size: 12px; font-weight: 580; white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.account-caret { color: #8693a2; font-size: 11px; }
.avatar { background: #e9eef5; color: #536274; width: 29px; height: 29px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 650; font-size: 11.5px; flex: none; }
.account-menu { position: absolute; right: 0; top: calc(100% + 9px); width: 275px; padding: 16px; background: #fff; border: 1px solid #dce4ec; border-radius: 11px; box-shadow: 0 12px 40px #1b304628; z-index: 90; }
.account-menu strong { display: block; font-weight: 640; font-size: 13px; }
.account-menu .muted { font-size: 11.5px; word-break: break-all; }
.account-menu hr { border: 0; border-top: 1px solid #edf0f3; margin: 12px 0; }
.account-menu form button { width: 100%; }

/* Page */
main { width: 100%; max-width: 1380px; margin: 0 auto; padding: 24px 27px 76px; min-width: 0; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 15px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pagehead p { margin: 6px 0 0; max-width: 760px; color: var(--muted); }
.pagehead .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumbs { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 10px; font-size: 11.5px; color: var(--muted); }
.breadcrumbs a { font-weight: 700; }
.breadcrumbs .sep { color: var(--faint); }
.breadcrumbs .current { color: #293950; font-weight: 750; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 28px 0 12px; }
.section-head h2 { margin: 0; }
.section-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }

/* Surfaces */
.card, .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card { padding: 18px 20px; }
.card > :last-child { margin-bottom: 0; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.panelhead { padding: 14px 19px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.panelhead h2, .panelhead h3 { margin: 0; font-size: 14px; }
.panelhead p { margin: 2px 0 0; font-size: 11.5px; color: var(--muted); }
.panelbody { padding: 16px 19px; }
.panelbody > :last-child { margin-bottom: 0; }
.panel > table, .panel > .table-wrap > table { border: 0; border-radius: 0 0 12px 12px; box-shadow: none; margin: 0; }
.callout { border: 1px solid var(--line); border-left: 3px solid var(--orange); padding: 12px 14px; border-radius: 9px; background: #fffdf9; margin-bottom: 16px; }
.callout.info { border-left-color: var(--blue); background: #fbfdff; }

.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.split { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 15px 17px; border: 1px solid var(--line); border-radius: 11px; background: linear-gradient(125deg, #f1f4f8 0%, #fff 75%); min-height: 88px; color: inherit; display: block; }
a.stat:hover { text-decoration: none; color: inherit; border-color: #aac4e4; box-shadow: 0 4px 18px #15284b16; }
.stat .lbl { font-size: 11.5px; color: var(--muted); }
.stat .num { font-size: 22px; font-weight: 780; letter-spacing: -.6px; margin-top: 4px; line-height: 1.2; }
.stat .note { font-size: 10.5px; color: var(--faint); margin-top: 3px; }
.stat.green { background: linear-gradient(125deg, #e4f6eb 0%, #f6fbf8 55%, #fff 100%); }
.stat.orange { background: linear-gradient(125deg, #fff0df 0%, #fffaf4 55%, #fff 100%); }

.kv { display: grid; grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); margin: 0; }
.kv dt, .kv dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
.kv dt { color: #5d6c83; font-weight: 650; padding-right: 14px; }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 20px; overflow-x: auto; }
.tabs a { padding: 11px 14px; border-bottom: 2px solid transparent; color: var(--muted); font-weight: 650; white-space: nowrap; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--blue); border-bottom-color: var(--orange); }
.tabs .count { display: inline-block; min-width: 18px; margin-left: 5px; padding: 0 6px; border-radius: 100px; background: #edf2f8; color: #728097; font-size: 10.5px; font-weight: 700; text-align: center; }
.js .tabpanel:not(.active) { display: none; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 16px; }
th, td { text-align: left; padding: 12px 15px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 12.5px; }
tr:last-child > th, tr:last-child > td { border-bottom: 0; }
thead th { background: var(--head-bg); color: #8794a7; font-size: 10px; text-transform: uppercase; letter-spacing: .6px; font-weight: 700; white-space: nowrap; }
tbody tr:hover > td { background: #fbfcff; }
tbody th, table:not(:has(thead)) th { width: 220px; font-weight: 650; color: #5d6c83; background: transparent; font-size: 12.5px; text-transform: none; letter-spacing: 0; }
td a { font-weight: 600; }
td .sub { display: block; color: var(--muted); font-size: 11.5px; }
td.actions { text-align: right; white-space: nowrap; width: 1%; }
td.actions > :not(dialog) { display: inline-flex; vertical-align: middle; }
td.empty, .empty { padding: 30px 20px; text-align: center; color: var(--muted); }
.card table { border: 0; border-radius: 0; box-shadow: none; margin: 0; }
.card table th:first-child, .card table td:first-child { padding-left: 0; }
.card table tbody tr:hover > td { background: transparent; }
tr.revoked td { color: var(--faint); }
tr.revoked td a { color: var(--faint); }
.table-wrap { overflow-x: auto; }
.num-cell { font-variant-numeric: tabular-nums; }

/* Forms */
label { display: block; font-size: 11.5px; color: var(--muted); font-weight: 700; margin: 14px 0 6px; }
input, select, textarea { width: 100%; border: 1px solid var(--line2); border-radius: 9px; background: #fff; padding: 9px 11px; color: var(--ink); font: inherit; outline: 0; transition: border-color .14s, box-shadow .14s; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px #0A72C91f; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--blue); margin: 0; }
input[type=file] { padding: 7px; background: var(--muted-bg); }
select[multiple] { min-height: 110px; }
textarea { min-height: 80px; resize: vertical; }
.helper { font-size: 11px; color: var(--faint); margin-top: 5px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--ink); font-weight: 500; margin: 0; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.fields.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-actions { display: flex; gap: 9px; justify-content: flex-end; align-items: center; margin-top: 18px; flex-wrap: wrap; }
.form-actions .muted { margin-right: auto; font-size: 11.5px; }

button, .button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 14px; border: 1px solid transparent; border-radius: 9px; background: var(--blue); color: #fff; font: inherit; font-size: 12.5px; font-weight: 680; line-height: 1.3; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .14s, border-color .14s, transform .14s; }
button:hover, .button:hover { background: var(--bluedark); color: #fff; text-decoration: none; transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: .46; transform: none; }
button.secondary, .button.secondary { background: #fff; color: var(--ink); border-color: var(--line2); }
button.secondary:hover, .button.secondary:hover { background: var(--muted-bg); color: var(--ink); }
button.danger, .button.danger { background: var(--red); }
button.danger:hover, .button.danger:hover { background: #a9333e; }
button.danger-outline, .button.danger-outline { background: #fff; color: var(--red); border-color: #f2c6cc; }
button.danger-outline:hover, .button.danger-outline:hover { background: var(--redsoft); color: var(--red); }
button.link, .button.link { background: transparent; color: var(--blue); padding: 5px 6px; }
button.link:hover, .button.link:hover { background: var(--bluesoft); color: var(--bluedark); }
button.sm, .button.sm { font-size: 11.5px; padding: 6px 10px; border-radius: 8px; }
.button.muted[aria-disabled] { opacity: .45; pointer-events: none; }
form > p:last-child { margin: 18px 0 0; }

.inline { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline > * { width: auto; flex: 1 1 160px; }
.inline > button, .inline > .button, .inline > form { flex: 0 0 auto; }
.inline label { margin-top: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

/* Feedback */
.flash, .errors { display: flex; gap: 10px; padding: 12px 14px; border-radius: 9px; margin-bottom: 18px; border: 1px solid var(--line); border-left-width: 3px; background: #fff; }
.flash { border-left-color: var(--green); color: #12643d; background: #f6fbf8; }
.errors { border-left-color: var(--red); color: #8d2e37; background: #fff8f8; }
.errors ul { margin: 0; padding-left: 18px; }

.badge { display: inline-flex; align-items: center; gap: 6px; border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 600; border: 1px solid #e4e8ed; color: #748195; background: #f7f9fb; text-transform: capitalize; white-space: nowrap; line-height: 1.5; vertical-align: middle; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: #94a3b8; flex: none; }
.badge.active, .badge.published, .badge.reviewed, .badge.signed, .badge.ok { background: #f3f9f5; border-color: #dceadf; color: #2f6c4a; }
.badge.active::before, .badge.published::before, .badge.reviewed::before, .badge.signed::before, .badge.ok::before { background: var(--green); }
.badge.pending, .badge.setup, .badge.draft, .badge.entry_closed, .badge.warn { background: #fffbf3; border-color: #f4e3c7; color: #94631c; }
.badge.pending::before, .badge.setup::before, .badge.draft::before, .badge.entry_closed::before, .badge.warn::before { background: #e89027; }
.badge.disabled, .badge.locked, .badge.closed, .badge.revoked, .badge.danger { background: #fff7f7; border-color: #f0dcdd; color: #a54a53; }
.badge.disabled::before, .badge.locked::before, .badge.closed::before, .badge.revoked::before, .badge.danger::before { background: var(--red); }
.badge.info { background: #f5f8fc; border-color: #dfe8f2; color: #3e6894; }
.badge.info::before { background: var(--blue); }
.badge.archived, .badge.inactive { background: #f4f6f8; color: #7a8696; }

/* Dialogs */
dialog.modal { border: 0; padding: 0; width: min(560px, calc(100vw - 32px)); border-radius: 15px; box-shadow: 0 30px 85px #121b2b40; color: var(--ink); }
/* A closed dialog stays hidden whatever layout rule matches it (the UA rule loses to author CSS). */
dialog.modal:not([open]) { display: none; }
dialog.modal.wide { width: min(860px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: #111b2e77; }
.modalhead { padding: 18px 22px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.modalhead h2 { font-size: 17px; margin: 0; }
.modalhead p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.modalclose { background: transparent; color: var(--faint); padding: 2px 8px; font-size: 20px; line-height: 1; }
.modalclose:hover { background: var(--muted-bg); color: var(--ink); transform: none; }
.modalbody { padding: 6px 22px 20px; max-height: 70vh; overflow: auto; }
.modalfoot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; background: var(--head-bg); border-radius: 0 0 15px 15px; }

/* Content helpers */
pre { background: var(--muted-bg); border: 1px solid var(--line); padding: 14px; border-radius: 9px; overflow: auto; font-size: 12px; margin: 0; }
code, pre, .mono { font-family: var(--mono); }
code { font-size: 11.5px; background: #f0f3f7; color: #3b4a5f; padding: 1px 6px; border-radius: 5px; }
pre code { background: none; padding: 0; }
.codes { columns: 2; font-family: var(--mono); font-size: 16px; letter-spacing: .05em; background: var(--muted-bg); border-radius: 9px; padding: 16px 20px; }
details { margin-top: 8px; }
details > summary { cursor: pointer; color: var(--blue); font-weight: 650; }
.pagination { margin-top: 4px; }
.pagination nav { align-items: center; }
.pagination nav > * { flex: 0 0 auto; }
.diff .before { color: var(--red); text-decoration: line-through; }
.diff .after { color: var(--green); }
.texts td:first-child { width: 240px; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.texts textarea { min-height: 38px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.order-list { display: grid; gap: 6px; }
.order-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 12px; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--muted-bg); }
.order-row input[type=number] { padding: 6px 8px; text-align: center; }

/* Sign-in pages */
.authpage { min-height: 100vh; display: grid; grid-template-columns: minmax(300px, 1.1fr) minmax(360px, .9fr); }
/* Left half: the ClinStatDevice brand artwork (logo and strapline are part of the image). */
.authleft { background: #F7861E url("clinstatdevice-artwork.jpg") center / cover no-repeat; padding: 24px; display: flex; align-items: flex-start; }
.authright { padding: 40px 6vw; display: flex; align-items: center; justify-content: center; background: #fff; }
.authbox { width: 100%; max-width: 400px; }
.authbrand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.authbrand img { width: 40px; height: 40px; flex: none; }
.authbox .card { padding: 28px; box-shadow: none; }
.authbox h1 { margin-bottom: 6px; color: #26385A; }
.authbox .card button:not(.secondary):not(.link) { width: 100%; background: #ED6B2C; }
.authbox .card button:not(.secondary):not(.link):hover { background: #D45A1E; }
.authfoot { margin: 22px 0 0; font-size: 11px; color: var(--faint); text-align: center; }

@media (max-width: 1030px) {
    .topbar { flex-wrap: wrap; height: auto; min-height: 62px; padding: 10px 16px; gap: 8px 16px; }
    .nav { order: 3; flex-basis: 100%; height: 40px; margin-left: 0; }
    .nav a { padding: 0 10px; }
    main { padding: 20px 16px 48px; }
    .grid.two, .grid.three, .grid.split { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .authpage { display: block; }
    .authleft { height: min(62vw, 320px); padding: 14px; }
    .authright { padding: 28px 16px; }
    .account-name, .account-caret { display: none; }
    table { display: block; overflow-x: auto; }
    .kv { grid-template-columns: 1fr; }
    .kv dt { border-bottom: 0; padding-bottom: 0; }
    .fields.two { grid-template-columns: 1fr; }
}
