/* Brand colors come from the RxQuorum brand notes (Project: brand/rxquorum-brand.md). */
:root {
  --bg: #eef2f3;
  --surface: #ffffff;
  --text: #1f2d34;
  --muted: #5b6b73;
  --border: #d6dfe2;
  --accent: #17a38b;          /* brand teal */
  --accent-text: #0e7c69;     /* darker teal so teal text and links stay readable on light surfaces */
  --accent-soft: #e3f4f1;
  --primary: #1f2d34;         /* brand slate: primary buttons */
  --primary-ink: #f4f8f8;
  --sidebar: #1f2d34;
  --sidebar-text: #b4c4cb;
  --danger: #b3261e;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f171c;
    --surface: #17232a;
    --text: #e4ecf0;
    --muted: #8fa3ac;
    --border: #263640;
    --accent: #3fd1b8;
    --accent-text: #3fd1b8;
    --accent-soft: #163a3a;
    --primary: #3fd1b8;
    --primary-ink: #1f2d34;
    --sidebar: #1f2d34;
    --danger: #ff8a80;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1 { font-size: 1.6rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
a { color: var(--accent-text); }
.muted { color: var(--muted); }
.pad, .boot { padding: 1.5rem; }
.lead { color: var(--muted); margin: 0 0 1.5rem; }

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

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

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 1rem .75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .25rem .5rem 1rem;
  text-decoration: none;
}

.wordmark {
  font-family: Sora, system-ui, sans-serif;
  font-weight: 700;
  font-size: 1.45rem;
  letter-spacing: -0.03em;
  color: #f4f8f8;
}
.wordmark span { color: #3fd1b8; }

.nav-section {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 1rem .75rem .35rem;
  opacity: .7;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .75rem;
  border-radius: 6px;
  color: var(--sidebar-text);
  text-decoration: none;
}
.nav-link:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav-link.active { background: #26b8a0; color: #1f2d34; font-weight: 600; }

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: center;
  padding: .6rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.pharmacy-banner { min-width: 0; }
.pharmacy-name { font-weight: 600; }
.pharmacy-chain { margin-left: .4rem; color: var(--muted); font-size: .8rem; }
.pharmacy-code { margin-left: .4rem; padding: .05rem .4rem; border-radius: 4px; background: var(--border); color: var(--muted); font-size: .75rem; font-weight: 600; }
.pharmacy-details { display: flex; flex-wrap: wrap; gap: .1rem 1rem; font-size: .8rem; color: var(--muted); }
.user-menu { margin-left: auto; flex-shrink: 0; }
.user-menu { display: flex; align-items: center; gap: .75rem; }
.user-name { font-weight: 600; }
.user-roles { font-size: .8rem; color: var(--muted); }

.content { padding: 1.5rem; max-width: 1200px; width: 100%; }

/* Cards and tiles */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}
.card ul { margin: 0; padding-left: 1.2rem; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  color: inherit;
  text-decoration: none;
}
.tile:hover { border-color: var(--accent); }
.tile strong { display: block; color: var(--accent-text); margin-bottom: .25rem; }
.tile span { color: var(--muted); font-size: .9rem; }

/* Forms and buttons */
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: .45rem .9rem;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn-primary:hover { border-color: var(--accent); }
.btn-primary:disabled { opacity: .6; cursor: default; }

.field { display: block; margin-bottom: 1rem; }
.field span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.field input {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.error { color: var(--danger); margin: 0 0 1rem; }
.validation-message { color: var(--danger); font-size: .85rem; }
.hint { background: var(--accent-soft); border-radius: 6px; padding: .6rem .8rem; font-size: .85rem; margin-top: 1rem; }

/* Intake: tabs, tables, forms */
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; }
.tab {
  border: 1px solid transparent; border-bottom: none; background: transparent; color: var(--muted);
  padding: .5rem 1rem; border-radius: 6px 6px 0 0; font: inherit; cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); border-color: var(--border); color: var(--accent-text); font-weight: 600; margin-bottom: -1px; }

.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--accent-soft); border-radius: 6px; padding: .6rem .8rem; margin-bottom: 1rem;
}

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; margin-bottom: 1rem; }
.inline { display: flex; flex-direction: column; font-size: .85rem; color: var(--muted); }
.inline.check { flex-direction: row; align-items: center; gap: .4rem; }

.grid { width: 100%; border-collapse: collapse; font-size: .92rem; }
.grid th { text-align: left; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); padding: .4rem .5rem; }
.grid td { border-bottom: 1px solid var(--border); padding: .5rem; vertical-align: top; }
.grid small { display: block; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn + .btn { margin-left: .25rem; }
.reject-row td { background: var(--accent-soft); }

.btn-small { padding: .2rem .6rem; font-size: .85rem; }

.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .8rem; border: 1px solid var(--border); }
.badge-new { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.badge-progress { border-color: var(--muted); }
.badge-done { border-color: var(--accent); color: var(--accent-text); }
.badge-rejected { border-color: var(--danger); color: var(--danger); }

.group { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem .25rem; margin: 0 0 1rem; }
.group legend { padding: 0 .4rem; font-weight: 600; color: var(--muted); font-size: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0 1rem; }
.field select, .field textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--text); font: inherit;
}
.field select:focus, .field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.field.check { display: flex; align-items: center; gap: .5rem; padding-top: 1.3rem; }
.field.check span { margin: 0; }
.field.check input { width: auto; }
.toolbar select, .tab:focus-visible, .btn:focus-visible { outline-offset: 1px; }
.toolbar select {
  padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit;
}
.error-text { display: block; color: var(--danger); font-size: .85rem; }
.small { font-size: .85rem; }
.actions { display: flex; gap: .5rem; margin: .5rem 0 1rem; }

.lookup-chosen { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .4rem .7rem; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent-soft); }
.lookup-results { list-style: none; margin: .25rem 0 0; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.lookup-results li + li { border-top: 1px solid var(--border); }
.lookup-results button { width: 100%; text-align: left; padding: .5rem .7rem; border: none; background: transparent; color: var(--text); font: inherit; cursor: pointer; }
.lookup-results button:hover, .lookup-results button:focus-visible { background: var(--accent-soft); }

/* Patients */
.grow { grid-column: span 2; }
.pager { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; }
.section { margin-bottom: 1.25rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section-head h2 { margin: 0; }
.record-list { list-style: none; margin: .75rem 0 0; padding: 0; }
.record-list > li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: .5rem 1rem; padding: .75rem 0; border-top: 1px solid var(--border); }
.record-list > li > form { width: 100%; }
.record-actions { display: flex; align-items: center; gap: .5rem; }
.btn-danger { border-color: var(--danger); color: var(--danger); }

.fills-row > td { background: var(--accent-soft); }
.section-head .field { margin: 0; display: flex; flex-direction: row; align-items: center; gap: .5rem; }
.section-head .field span { margin: 0; }

.chips { list-style: none; margin: .35rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .05rem .55rem; border-radius: 999px; font-size: .8rem; background: var(--accent-soft); color: var(--accent-text); }
.chip-remove { border: none; background: transparent; color: inherit; cursor: pointer; font: inherit; padding: 0 .1rem; }
.chip-remove:disabled { opacity: .35; cursor: not-allowed; }
.upload-form { width: 100%; margin-bottom: 1rem; }
.record-main { flex: 1 1 24rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { display: flex; justify-content: center; margin-bottom: 1.25rem; }

/* Logo lockup: light version by default, reversed in dark mode */
.logo-lockup { display: block; max-width: 100%; }
.logo-lockup svg { display: block; width: 100%; height: auto; }
.logo-dark { display: none !important; }
@media (prefers-color-scheme: dark) {
  .logo-light { display: none !important; }
  .logo-dark { display: block !important; }
}

/* Blazor error banner */
#blazor-error-ui {
  display: none;
  position: fixed;
  inset: auto 0 0 0;
  background: #fff3cd;
  color: #3b2f00;
  padding: .6rem 1.25rem;
  z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; }
}

/* Entering a script from a queue item: the form, with the script image beside it on wide screens. */
.entry-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.5rem; align-items: start; }
@media (min-width: 1100px) { .entry-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); } .script-image-panel { position: sticky; top: 1rem; } }
.script-image-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem 1rem 1rem; background: var(--surface, #fff); }
.script-image-panel h3 { margin: 0 0 .5rem; font-size: 1rem; }
.script-image { display: block; width: 100%; max-height: 75vh; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.script-pdf { height: 75vh; }
.script-image-manage { margin-top: 1rem; }
.script-image-manage > summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.chip-active { background: var(--accent); color: #0b1418; }
button.chip { cursor: pointer; border: 1px solid var(--border); }

/* PV1 review */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: .35rem 1rem; margin: .75rem 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts .sig { font-weight: 600; }
.finding { display: flex; gap: .6rem; align-items: baseline; padding: .5rem .65rem; margin: .4rem 0; border: 1px solid var(--border); border-left-width: 4px; border-radius: 6px; }
.finding-critical { border-left-color: var(--danger); }
.finding-warning { border-left-color: var(--accent); }
.pv1-checks { border: 1px solid var(--border); border-radius: 6px; margin: 1rem 0; padding: .75rem 1rem; }
.pv1-checks legend { padding: 0 .4rem; color: var(--muted); }
.pv1-answers .field span { font-weight: 600; }
.pv1-answers textarea, .pv1-reject textarea, .pv1-reject select { width: 100%; }
.pv1-reject { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.pv1-main { min-width: 0; }

.nav-count { min-width: 1.4rem; padding: 0 .4rem; border-radius: 999px; background: #3fd1b8; color: #1f2d34; font-size: .75rem; font-weight: 700; text-align: center; line-height: 1.4rem; }
.nav-link.active .nav-count { background: #1f2d34; color: #fff; }

/* Intake: eRx message panel and the document folder panel */
.erx-warnings { margin: 0 0 .75rem; padding: .5rem .75rem .5rem 1.5rem; border: 1px solid var(--danger); border-radius: 6px; font-size: .85rem; }
.erx-xml summary { cursor: pointer; color: var(--muted); }
.erx-xml pre { max-height: 20rem; overflow: auto; font-size: .75rem; background: var(--accent-soft); border-radius: 6px; padding: .5rem .75rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.folder-panel { margin-bottom: 1rem; }
.folder-panel code { overflow-wrap: anywhere; }
.scan-messages { margin: .5rem 0 0; padding-left: 1.25rem; font-size: .85rem; }

/* A value the system works out, shown where a field would be (for example a prescription's expiry date). */
output.calculated { display: block; padding: .5rem .75rem; border: 1px dashed var(--border, #c9d1d9); border-radius: 6px; background: var(--surface-muted, rgba(127, 127, 127, .08)); min-height: 2.25rem; }

/* Orders */
.choice { border: 1px solid var(--border); border-radius: 6px; padding: .5rem .9rem .7rem; margin: 0 0 1rem; }
.choice legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }
.choice .inline.check { display: flex; margin: .25rem 0; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; }

/* Fulfillment: label preview and order cards */
.label-text { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; white-space: pre-wrap; border: 1px dashed var(--border); border-radius: 6px; padding: .6rem .8rem; background: var(--accent-soft); }
.order-card { margin-bottom: 1rem; }
.order-card h2 { margin-top: 0; }
.ship-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }

/* Order-level fulfilment: one block per fill inside an order */
.fill-block { border: 1px solid var(--border, #d8dde3); border-radius: 6px; padding: 12px 16px; margin: 0 0 16px; }
.fill-block legend { font-weight: 600; padding: 0 6px; }
.fill-heading { display: flex; gap: 12px; align-items: baseline; margin: 24px 0 8px; }

/* DSCSA package scanning in Dispensing */
.scan-box { display: grid; gap: 8px; margin: 0 0 16px; padding: 12px; border: 1px dashed var(--border, #d8dde3); border-radius: 6px; }
.scan-box .field { margin: 0; }
.scan-box .btn { justify-self: start; }
.scanned-packages li { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* Label preview: the label drawn from its ZPL */
.label-view { max-width: 420px; }
.label-view svg { display: block; width: 100%; height: auto; background: #fff; border-radius: 4px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.label-notes { margin: .5rem 0 0; padding-left: 1.1rem; font-size: .9rem; color: var(--muted, #5b6573); }
.label-preview { margin-top: .5rem; }

/* Package label images (DailyMed) */
.label-title { margin: .75rem 0 .35rem; font-weight: 600; }
.label-gallery { display: flex; flex-wrap: wrap; gap: .75rem; }
.label-gallery a { display: block; border: 1px solid var(--border, #d0d7de); border-radius: 6px; background: #fff; padding: .25rem; }
.label-gallery img { display: block; max-width: 100%; max-height: 220px; width: auto; height: auto; }
.small { font-size: .85rem; }

/* FDA label text */
.label-text { overflow-wrap: anywhere; line-height: 1.45; max-height: 28rem; overflow: auto; padding: .25rem 0; }
.label-section { border-top: 1px solid var(--border); padding: .4rem 0; }
.label-section > summary { cursor: pointer; font-weight: 600; }
.boxed-warning { border: 2px solid #b42318; border-radius: 6px; padding: .6rem .8rem; margin: .5rem 0; }
.boxed-warning strong { color: #b42318; }
@media (prefers-color-scheme: dark) { .boxed-warning, .boxed-warning strong { border-color: #f97066; color: inherit; } .boxed-warning strong { color: #f97066; } }

/* Medication Guide */
.med-guide { border: 1px solid var(--border); border-radius: 6px; padding: .5rem .75rem; margin: .5rem 0; }
.guide-pdf { width: 100%; height: 38rem; border: 1px solid var(--border); border-radius: 6px; margin-top: .5rem; }
.mg-heading { margin: 1rem 0 .25rem; font-size: 1rem; }
.mg-text { margin: .35rem 0; white-space: pre-line; }
.mg-list { margin: .35rem 0; }
.mg-item { display: flex; gap: .5rem; margin: .15rem 0; }
.mg-marker { flex: none; min-width: 1.25rem; }
.mg-table { border-collapse: collapse; margin: .5rem 0; }
.mg-table td { border: 1px solid var(--border); padding: .25rem .5rem; }

.version-info { margin: 1.25rem .5rem 0; font-size: .75rem; color: var(--sidebar-text); opacity: .75; }
.login-wrap .version-info { color: var(--muted); text-align: center; }
.version-warn { color: var(--danger); font-weight: 600; }

/* Reports */
.report-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.report-tile {
  display: flex; flex-direction: column; gap: .3rem; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: .85rem 1rem; font: inherit;
}
.report-tile:hover { border-color: var(--accent); }
.report-tile.selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--accent-soft); }
.report-tile .muted { font-size: .85rem; }
.report-tile-kind { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); font-weight: 700; }
.report-run { margin-bottom: 1.25rem; }
.report-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin: 0 0 .75rem; }
.report-toolbar-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }

.report-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-bottom: 2rem; }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; padding: 1rem 1.25rem; background: var(--sidebar); color: #fff; border-bottom: 3px solid var(--accent); }
.report-head h2 { margin: 0; font-size: 1.5rem; color: #fff; }
.report-brand { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #3fd1b8; }
.report-where { display: flex; flex-direction: column; align-items: flex-end; text-align: right; font-size: .9rem; color: #b4c4cb; }
.report-where strong { color: #fff; font-size: 1.05rem; }
.report-figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; padding: 1rem 1.25rem 0; }
.report-figure { background: var(--accent-soft); border-radius: 8px; padding: .6rem .8rem; display: flex; flex-direction: column; gap: .1rem; }
.report-figure strong { font-size: 1.35rem; line-height: 1.2; }
.report-figure span { font-size: .78rem; color: var(--muted); }
.report-scroll { overflow: auto; max-height: 70vh; margin: 1rem 0 0; border-top: 1px solid var(--border); }
.report-table { font-size: .86rem; }
.report-table thead th { position: sticky; top: 0; background: var(--sidebar); color: #fff; border-bottom: none; padding: .55rem .6rem; white-space: nowrap; z-index: 1; }
.report-table td { padding: .4rem .6rem; }
.report-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.report-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-table .nw { white-space: nowrap; }
.report-table td.attn { color: #8a3b12; }
@media (prefers-color-scheme: dark) { .report-table td.attn { color: #f0a070; } }
.report-table tfoot td { font-weight: 700; background: var(--accent-soft); border-top: 2px solid var(--accent); border-bottom: none; padding: .5rem .6rem; position: sticky; bottom: 0; }
.report-empty { padding: 2rem 1.25rem; color: var(--muted); font-size: 1.05rem; }
.report-note { margin: .75rem 1.25rem 0; font-size: .8rem; color: var(--muted); }
.report-foot { margin: .75rem 1.25rem 1rem; padding-top: .5rem; border-top: 1px solid var(--border); font-size: .75rem; color: var(--muted); }

@media print {
  .sidebar, .topbar, .report-chrome, .report-toolbar { display: none !important; }
  .shell, .main, .content { display: block; padding: 0; max-width: none; }
  body { background: #fff; }
  .report-sheet { border: none; border-radius: 0; }
  .report-head, .report-table thead th, .report-table tfoot td, .report-figure { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .report-scroll { max-height: none; overflow: visible; }
  .report-table thead th, .report-table tfoot td { position: static; }
  .report-table tr { break-inside: avoid; }
  @page { size: landscape; margin: .5in; }
}
