/* ==========================================================================
   Blue Ocean Interventional - billing portal
   Mobile-first. No framework, no CDN, no build step.
   ========================================================================== */

:root {
  /* Brand, pulled from the logo mark */
  --brand:        #378ADD;
  --brand-dark:   #2A6FB4;
  --brand-violet: #7F77DD;
  --brand-wash:   #EAF2FB;

  /* Neutrals */
  --ink:          #23262C;
  --ink-2:        #4A5058;
  --muted:        #7A828D;
  --line:         #E1E6EC;
  --surface:      #FFFFFF;
  --page:         #F4F7FA;

  /* Status */
  --ok:           #1D7A5F;
  --ok-wash:      #E8F5F0;
  --warn:         #A96A10;
  --warn-wash:    #FDF3E3;
  --danger:       #B22F35;
  --danger-wash:  #FBEDEE;

  --radius:       10px;
  --radius-sm:    7px;

  /* Brand sizing - change these two and everything follows */
  --logo-topbar:  50px;   /* logo height in the top ribbon */
  --logo-auth:    46px;   /* logo height on the sign-in card */
  --shadow:       0 1px 2px rgba(35,38,44,.06), 0 8px 24px rgba(35,38,44,.07);
}

*, *::before, *::after { box-sizing: border-box; }

/* The browser's own [hidden] rule is display:none at the lowest possible
   priority, so ANY class rule setting display beats it - .check, .proc-list
   and .total-bar all did, which left elements the JS had hidden fully
   visible. This restores it once, for everything. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* --- Brand lockup ------------------------------------------------------- */

.brand { display: flex; align-items: center; gap: 10px; }
.brand svg { flex-shrink: 0; }
.brand-name {
  font-size: 15px; font-weight: 600; letter-spacing: .04em; line-height: 1.1;
}
.brand-sub {
  font-size: 10.5px; color: var(--muted);
  letter-spacing: .19em; line-height: 1.1;
}

/* The pulse rule - a nod to the mark, used once per screen as a divider. */
.pulse-rule {
  height: 10px; width: 100%; display: block;
  color: var(--brand); opacity: .5;
}

/* --- Auth shell --------------------------------------------------------- */

.auth-wrap {
  min-height: 100vh;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px 16px 40px;
}

.auth-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 22px 26px;
}

.auth-card--wide { max-width: 520px; }

.auth-head { margin-bottom: 24px; }
.auth-title {
  font-size: 21px; font-weight: 600; margin: 18px 0 4px; letter-spacing: -.01em;
}
.auth-sub { font-size: 14px; color: var(--muted); margin: 0; }

.auth-foot {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--muted); text-align: center;
}

.auth-legal {
  margin-top: 20px; font-size: 12px; color: var(--muted);
  text-align: center; max-width: 420px;
}

/* --- Forms -------------------------------------------------------------- */

.field { margin-bottom: 16px; }

label {
  display: block; font-size: 13.5px; font-weight: 500;
  color: var(--ink-2); margin-bottom: 6px;
}

.hint { font-size: 12.5px; color: var(--muted); font-weight: 400; }

input[type=text], input[type=email], input[type=password],
input[type=date], input[type=number], select, textarea {
  width: 100%;
  /* 16px minimum: anything smaller makes iOS Safari zoom on focus and
     never zoom back out. */
  font-size: 16px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  min-height: 46px;
  transition: border-color .12s ease, box-shadow .12s ease;
}

textarea { min-height: 80px; resize: vertical; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(55,138,221,.16);
}

input[aria-invalid=true] { border-color: var(--danger); }

/* --- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; min-height: 48px; padding: 0 20px;
  font-family: inherit; font-size: 15.5px; font-weight: 500;
  color: #fff; background: var(--brand);
  border: 1px solid var(--brand); border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.btn:hover  { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid rgba(55,138,221,.4); outline-offset: 2px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.btn-quiet {
  color: var(--ink-2); background: var(--surface); border-color: var(--line);
}
.btn-quiet:hover { background: var(--page); border-color: var(--line); }

.btn-inline { width: auto; min-height: 40px; font-size: 14px; }

a { color: var(--brand-dark); }

/* Links that look like buttons - <a class="btn"> must not inherit link
   underline or colour, or it renders as an underlined blue-on-blue button. */
a.btn, a.btn:hover, a.btn:visited { text-decoration: none; color: #fff; }
a.btn-quiet, a.btn-quiet:hover, a.btn-quiet:visited { color: var(--ink-2); }
a:focus-visible { outline: 3px solid rgba(55,138,221,.4); outline-offset: 2px; border-radius: 3px; }

/* --- Notices ------------------------------------------------------------ */

.notice {
  display: flex; gap: 9px;
  padding: 11px 13px; margin-bottom: 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; line-height: 1.5;
}
.notice-error { background: var(--danger-wash); color: #7E2126; }
.notice-ok    { background: var(--ok-wash);     color: #145443; }
.notice-warn  { background: var(--warn-wash);   color: #7A4C0B; }
.notice-info  { background: var(--brand-wash);  color: #1B4F82; }
.notice strong { font-weight: 600; }

/* --- MFA code entry ----------------------------------------------------- */

.code-input {
  font-size: 26px !important;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: .5em;
  text-indent: .5em;      /* recentre against the trailing letter-space */
  text-align: center;
  min-height: 60px;
}

/* --- Enrolment ---------------------------------------------------------- */

.qr-frame {
  display: flex; justify-content: center;
  padding: 16px; margin: 4px 0 16px;
  background: #fff;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.qr-frame svg { width: 190px; height: 190px; display: block; }

.secret-manual {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px; letter-spacing: .06em; word-break: break-all;
  background: var(--page); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; text-align: center;
}

.steps { counter-reset: step; margin: 0 0 20px; padding: 0; list-style: none; }
.steps li {
  counter-increment: step;
  position: relative; padding-left: 30px; margin-bottom: 11px;
  font-size: 14.5px; color: var(--ink-2);
}
.steps li::before {
  content: counter(step);
  position: absolute; left: 0; top: 1px;
  width: 21px; height: 21px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-wash); color: var(--brand-dark);
  border-radius: 50%; font-size: 12px; font-weight: 600;
}

/* --- Backup codes ------------------------------------------------------- */

.code-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px;
  margin: 16px 0 20px;
}
.code-grid li {
  list-style: none;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px; letter-spacing: .04em; text-align: center;
  background: var(--page); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 9px 4px;
}

/* --- Checkbox ----------------------------------------------------------- */

.check {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 4px 0 18px;
  font-size: 14px; color: var(--ink-2); cursor: pointer;
}
.check input {
  width: 20px; height: 20px; margin: 1px 0 0; flex-shrink: 0;
  accent-color: var(--brand); cursor: pointer;
}

/* --- App shell (post-login placeholder) --------------------------------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar-user { font-size: 13.5px; color: var(--muted); }

.page { max-width: 780px; margin: 0 auto; padding: 24px 16px 48px; }
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 18px; box-shadow: var(--shadow);
}
.panel h1 { font-size: 20px; font-weight: 600; margin: 0 0 6px; }
.panel p  { color: var(--ink-2); font-size: 15px; }

.meta { font-size: 13.5px; color: var(--muted); }
.meta dt { font-weight: 500; color: var(--ink-2); }
.meta dd { margin: 0 0 10px; }

@media (min-width: 560px) {
  .auth-card { padding: 32px 30px 30px; }
  .code-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ==========================================================================
   Step 3 — submissions
   ========================================================================== */

.page-title { font-size: 21px; font-weight: 600; margin: 0 0 16px; letter-spacing: -.01em; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.page-head .page-title { margin: 0; }

.panel + .panel, .panel + .proc-list, .proc-list + .panel { margin-top: 12px; }
.panel-quiet { background: transparent; border-style: dashed; box-shadow: none; }
.panel-sub { font-size: 14px; font-weight: 600; color: var(--ink-2); margin: 0 0 12px; }
.muted-copy { color: var(--muted); font-size: 14.5px; margin: 0; }

/* --- procedure rows ----------------------------------------------------- */

.proc-list { display: flex; flex-direction: column; gap: 8px; }

.proc {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  transition: border-color .12s ease;
}
.proc.has-qty { border-color: var(--brand); background: #FBFDFF; }

.proc-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.proc-id  { min-width: 0; }
.proc-code { font-size: 16px; font-weight: 600; letter-spacing: .01em; }
.proc-rate { font-size: 12.5px; color: var(--muted); margin-top: 1px; }

.proc-line {
  text-align: right; font-size: 15px; font-weight: 600;
  margin-top: 6px; color: var(--ink);
}
.proc-line.is-zero { color: var(--muted); font-weight: 400; }

/* --- stepper ------------------------------------------------------------ */

.stepper { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.step-btn {
  width: 44px; height: 44px; padding: 0;
  font-size: 21px; font-family: inherit; line-height: 1;
  color: var(--ink-2); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.step-btn:hover { background: var(--page); border-color: var(--brand); color: var(--brand-dark); }
.step-btn:active { transform: scale(.94); }
.step-btn:focus-visible { outline: 3px solid rgba(55,138,221,.4); outline-offset: 1px; }

.step-qty {
  min-width: 30px; text-align: center;
  font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums;
}

/* --- total bar ---------------------------------------------------------- */

.total-bar {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-top: 12px; padding: 14px 16px;
  background: var(--brand-wash); border-radius: var(--radius);
}
.total-label  { font-size: 13.5px; color: #1B4F82; font-weight: 500; }
.total-count  { font-size: 12.5px; color: #2E6DA8; }
.total-note   { font-size: 12px; color: #2E6DA8; margin-top: 3px; font-style: italic; }
.total-amount {
  font-size: 26px; font-weight: 600; color: #11396B;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
}

#submit-row { margin-top: 16px; }
.draft-note { font-size: 12px; color: var(--muted); text-align: center; margin: 8px 0 0; min-height: 16px; }

/* --- submission list ---------------------------------------------------- */

.sub-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.sub-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 13px 14px; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.sub-row:hover { border-color: var(--brand); }
.sub-main { min-width: 0; }
.sub-facility { font-size: 15.5px; font-weight: 600; }
.sub-meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.sub-no   { font-size: 11.5px; color: var(--muted); margin-top: 3px;
            font-variant-numeric: tabular-nums; }
.sub-side { text-align: right; flex-shrink: 0; }
.sub-amount { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* --- status pills ------------------------------------------------------- */

.pill {
  display: inline-block; margin-top: 5px; padding: 3px 9px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  border-radius: 20px;
}
.pill-submitted    { background: #EEF0F3; color: #3C4149; }
.pill-under_review { background: var(--warn-wash);  color: #7A4C0B; }
.pill-approved     { background: var(--brand-wash); color: #1B4F82; }
.pill-paid         { background: var(--ok-wash);    color: #145443; }
.pill-rejected     { background: var(--danger-wash);color: #7E2126; }
.pill-returned     { background: #FBE9D8; color: #8A4213; }

/* --- line table (detail view) ------------------------------------------- */

.line-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.line-table th {
  text-align: left; font-size: 12px; font-weight: 400; color: var(--muted);
  padding: 0 0 8px; border-bottom: 1px solid var(--line);
}
.line-table td { padding: 10px 0; font-size: 14.5px; border-bottom: 1px solid var(--line); }
.line-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.line-table .hint { display: block; font-size: 12px; }
.line-table .line-total td { font-weight: 600; font-size: 16px; border-bottom: none; }

/* --- timeline ----------------------------------------------------------- */

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  padding-left: 15px; margin-bottom: 14px; position: relative;
  border-left: 2px solid var(--line);
}
.timeline li::before {
  content: ''; position: absolute; left: -5px; top: 5px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
}
.tl-what { font-size: 14.5px; font-weight: 500; }
.tl-when { font-size: 12.5px; color: var(--muted); }
.tl-note { font-size: 13.5px; color: var(--ink-2); margin-top: 3px; }

@media (min-width: 560px) {
  .page { padding: 28px 20px 56px; }
  .proc { padding: 14px 16px; }
}

/* ==========================================================================
   Step 5 — doctor dashboard
   ========================================================================== */

/* --- needs attention ---------------------------------------------------- */

.attention {
  background: #FDF4EC; border: 1px solid #F0D3B8;
  border-radius: var(--radius); padding: 14px 15px; margin-bottom: 18px;
}
.attention-head {
  font-size: 14.5px; font-weight: 600; color: #8A4213; margin: 0 0 10px;
}
.attention-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; margin-bottom: 7px;
  background: #fff; border: 1px solid #F0D3B8; border-radius: var(--radius-sm);
  text-decoration: none; color: inherit;
}
.attention-row:last-child { margin-bottom: 0; }
.attention-row:hover { border-color: #C98A4B; }
.attention-title { font-size: 14.5px; font-weight: 500; }
.attention-why   { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.attention-go    { font-size: 13.5px; color: #8A4213; white-space: nowrap; font-weight: 500; }

/* --- summary ------------------------------------------------------------ */

.stat-grid {
  display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 16px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value {
  font-size: 22px; font-weight: 600; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; margin-top: 1px;
}
.stat-sub { font-size: 12.5px; color: var(--muted); }

/* --- filters ------------------------------------------------------------ */

.filter-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.filter-row select { flex: 1; min-width: 145px; min-height: 42px; font-size: 15px; }

/* --- month grouping ----------------------------------------------------- */

.month { margin-bottom: 22px; }
.month-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; padding: 0 2px 8px;
  border-bottom: 1px solid var(--line); margin-bottom: 9px;
}
.month-label { font-size: 15px; font-weight: 600; margin: 0; }
.month-sum { text-align: right; }
.month-total {
  font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.month-count { font-size: 12.5px; color: var(--muted); display: block; }

.month-paid {
  font-size: 12.5px; color: #145443; background: var(--ok-wash);
  padding: 5px 10px; border-radius: var(--radius-sm); margin-bottom: 9px;
  display: inline-block;
}
.month-part {
  font-size: 12.5px; color: #1B4F82; background: var(--brand-wash);
  padding: 5px 10px; border-radius: var(--radius-sm); margin-bottom: 9px;
  display: inline-block;
}

.tag-air {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  font-size: 11px; font-weight: 500; vertical-align: 1px;
  background: var(--brand-wash); color: #1B4F82; border-radius: 20px;
}
.sub-guarantee {
  font-size: 11px; color: var(--muted); font-style: italic; margin-top: -1px;
}

@media (min-width: 620px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
}

.list-count { font-size: 12.5px; color: var(--muted); margin: 0 0 9px 2px; }

/* --- logo sizing -------------------------------------------------------- */
/* Heights come from --logo-topbar / --logo-auth at the top of this file. */
.brand img { display: block; width: auto; max-width: 100%; }
.topbar .brand img    { height: var(--logo-topbar); }
.auth-card .brand img { height: var(--logo-auth); }

/* --- read-only fields when correcting a returned submission ------------- */
.locked-field {
  padding: 11px 12px; min-height: 46px;
  font-size: 16px; color: var(--ink-2);
  background: var(--page); border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* --- Signed-in topbar ----------------------------------------------------
   Sign out lives here rather than at the foot of the page - on a list that
   grows with every submission, a link at the bottom is effectively hidden. */

.topbar-nav {
  display: flex; align-items: center; gap: 8px;
  font-size: 13.5px;
}

/* Sea-salt green. Built from the existing --ok family so the nav sits in
   the same palette as the approve button and the success notices, rather
   than introducing a third accent colour. */
.topbar-nav a {
  display: inline-flex; align-items: center;
  padding: 7px 14px; min-height: 36px;
  border: 1px solid #BFE0D4; border-radius: var(--radius-sm);
  background: var(--ok-wash); color: #14624C;
  font-weight: 500; text-decoration: none; white-space: nowrap;
}
.topbar-nav a:hover {
  background: #D8EDE5; border-color: #96CDB8; color: #0F4E3C;
}

.topbar-nav .topbar-user {
  font-weight: 600; color: var(--ink);
  padding: 0 6px; white-space: nowrap;
}

/* Two class selectors, so this beats .topbar-nav a above without
   reaching for !important. */
.topbar-nav .topbar-signout {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.topbar-nav .topbar-signout:hover {
  background: var(--brand-dark); border-color: var(--brand-dark); color: #fff;
}

@media (max-width: 560px) {
  /* In a cramped bar the name is the least useful thing there. */
  .topbar-nav .topbar-user { display: none; }
  .topbar-nav { gap: 6px; }
  .topbar-nav a { padding: 7px 11px; }
}

/* ==========================================================================
   Step 6 — biller dashboard

   Uses the tokens and components already defined above. In particular it
   does NOT redefine .pill, .pill-submitted..., .btn, .btn-quiet or the
   bare .filter-row — those belong to Steps 1-5 and are reused as-is.
   Anything biller-specific is either a new class or scoped inside
   .biller-filters so the doctor screens are untouched.
   ========================================================================== */

/* --- Header row ---------------------------------------------------------- */

.biller-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.biller-head h1 {
  font-size: 21px; font-weight: 600; margin: 0; letter-spacing: -.01em;
}

.crumb { margin: 0 0 12px; font-size: 13.5px; }

/* Buttons here size to their label. The base .btn is width:100% for the
   phone layout, which stretches Export CSV across the whole window. */
.biller-head .btn,
.filter-actions .btn,
.pay-bar .btn,
.decision-form .btn,
.reject-block .btn,
.inline-form .btn,
.pager .btn {
  width: auto; min-height: 40px; font-size: 14px;
}

/* --- Quick filter chips -------------------------------------------------- */

.biller-chips { display: flex; gap: 7px; flex-wrap: wrap; margin-bottom: 14px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px; min-height: 36px;
  font-size: 13.5px; color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px;
  text-decoration: none;
}
.chip:hover { border-color: var(--brand); }
.chip.is-on {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
a.chip, a.chip:visited { text-decoration: none; }
a.chip.is-on, a.chip.is-on:visited { color: #fff; }
.chip-n { font-weight: 600; font-variant-numeric: tabular-nums; }

.chip-warn { border-color: #E7CFA6; color: #7A4C0B; }
.chip-warn.is-on { background: var(--warn); border-color: var(--warn); color: #fff; }

/* --- Filter panel -------------------------------------------------------- */

.biller-filters {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 14px;
}

/* Scoped: the bare .filter-row belongs to the doctor screens. */
.biller-filters .filter-row {
  display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 10px;
}
.biller-filters .filter-row label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12.5px; color: var(--ink-2);
}
.biller-filters .filter-row label.grow { flex: 1 1 15rem; }
.biller-filters .filter-row select { flex: 0 1 auto; min-width: 150px; }

.filter-status { border: 0; padding: 0; margin: 0 0 10px; }
.filter-status legend { font-size: 12.5px; color: var(--ink-2); padding: 0 0 5px; }

.status-check {
  display: inline-flex; align-items: center; gap: 6px;
  margin-right: 14px; font-size: 13.5px; min-height: 34px;
}
.status-check input { width: 17px; height: 17px; margin: 0; }

.filter-actions { display: flex; gap: 8px; }

.biller-summary {
  font-size: 12.5px; color: var(--muted); margin: 0 0 9px 2px;
}

/* --- The list ------------------------------------------------------------ */

.biller-table, .lines-table {
  width: 100%; max-width: 100%; border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 14px;
}
.biller-table th, .biller-table td,
.lines-table th,  .lines-table td {
  padding: 9px 10px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.biller-table tbody tr:last-child td,
.lines-table tbody tr:last-child td { border-bottom: 0; }

.biller-table thead th, .lines-table thead th {
  font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
  background: var(--page);
  border-bottom: 1px solid var(--line);
}
.biller-table tbody tr:hover { background: var(--brand-wash); }
.biller-table tr.is-payable td:first-child    { box-shadow: inset 3px 0 0 var(--brand); }
.biller-table tr.is-reviewable td:first-child { box-shadow: inset 3px 0 0 var(--line); }

.col-amount { text-align: right; font-variant-numeric: tabular-nums; }
.col-qty    { text-align: center; }
.col-tick   { width: 38px; }
.col-tick input { width: 17px; height: 17px; margin: 0; }
.col-detail { color: var(--ink-2); }

.lines-table tfoot th { text-align: right; font-weight: 500; }
.lines-table tfoot td { font-variant-numeric: tabular-nums; }
.lines-table tfoot .row-total th,
.lines-table tfoot .row-total td {
  font-size: 16px; font-weight: 600; border-top: 2px solid var(--line);
}

/* Sub-notes wrap rather than run into the next column. */
.sub-note {
  display: block; font-size: 11.5px; color: var(--muted);
  font-weight: 400; white-space: normal; overflow-wrap: anywhere;
}
.col-amount .sub-note { text-align: right; }

.guarantee-note {
  font-size: 12.5px; color: var(--muted); font-style: italic;
  margin: -6px 0 14px 2px;
}

/* Pills: the base set covers submitted/under_review/approved/paid/
   rejected/returned. These three are new. */
.pill-warn     { background: var(--warn-wash);  color: #7A4C0B; }
.pill-air      { background: var(--brand-wash); color: #1B4F82; }
.pill-internal { background: #EEF0F3;           color: #3C4149; }

/* --- Payment bar --------------------------------------------------------- */

.pay-bar {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--brand); border-radius: var(--radius);
  box-shadow: 0 -2px 14px rgba(35,38,44,.10);
}
.pay-bar-count {
  font-size: 14px; margin-right: 6px; white-space: nowrap;
  /* The bar aligns on flex-end, so without this the count sits level with
     the bottom edge of the inputs rather than their middle - the fields
     each carry a label above them and the count does not. */
  padding-bottom: 10px;
}
.pay-bar-count strong { font-variant-numeric: tabular-nums; }
.pay-bar label {
  display: flex; flex-direction: column; gap: 3px;
  font-size: 12.5px; color: var(--ink-2);
}
.pay-bar input { min-height: 42px; }

/* The bar holds two alternative actions, shown one at a time. The global
   [hidden] rule near the top of this file keeps the display declarations
   below from overriding the hidden attribute. */
.bar-panel {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px;
}

.bar-mixed {
  flex: 1 1 100%; margin: 0;
  font-size: 13px; color: #7A4C0B;
}
.bar-mixed strong { font-weight: 600; }

/* --- Detail page --------------------------------------------------------- */

.meta-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 12px 20px; margin: 0 0 18px;
}
.meta-grid dt {
  font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.meta-grid dd { margin: 2px 0 0; font-size: 14.5px; }

.note-block, .review-panel, .history {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 16px;
}
.note-block h2, .review-panel h2, .history h2 {
  font-size: 15px; font-weight: 600; margin: 0 0 10px;
}
.note-block p { font-size: 14.5px; color: var(--ink-2); margin: 0; }
.note-internal { background: var(--page); }

.decision-form {
  border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px;
}
.decision-form:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.decision-form label {
  display: block; margin-bottom: 10px; font-size: 12.5px; color: var(--ink-2);
}
.decision-form input, .decision-form textarea {
  display: block; width: 100%; margin-top: 3px;
}
.req { color: var(--danger); font-size: 11.5px; font-weight: 500; }
.inline-form { display: inline-block; margin-bottom: 10px; }

.reject-block { margin-top: 14px; }
.reject-block summary {
  cursor: pointer; color: var(--danger); font-size: 13.5px;
  padding: 8px 0; min-height: 36px;
}
.reject-block p { font-size: 12.5px; }

.btn-approve { background: var(--ok);         border-color: var(--ok); }
.btn-approve:hover { background: #17624C;     border-color: #17624C; }
.btn-return  { background: var(--warn);       border-color: var(--warn); }
.btn-return:hover  { background: #8C560D;     border-color: #8C560D; }
.btn-reject  { background: var(--danger);     border-color: var(--danger); }
.btn-reject:hover  { background: #92262B;     border-color: #92262B; }
.btn-pay     { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-pay:hover     { background: #23598F;     border-color: #23598F; }

/* The biller views use .btn-secondary for View PDF and Send it again.
   Without a definition those inherit the full-width primary button. */
.btn-secondary {
  width: auto; min-height: 40px; font-size: 14px;
  color: var(--ink-2); background: var(--surface); border-color: var(--line);
}
.btn-secondary:hover { background: var(--page); border-color: var(--brand); }
a.btn-secondary, a.btn-secondary:hover, a.btn-secondary:visited { color: var(--ink-2); }

/* --- History ------------------------------------------------------------- */

.history-list { list-style: none; margin: 0; padding: 0; }
.history-list li {
  padding: 9px 0 9px 12px; margin-bottom: 4px;
  border-left: 3px solid var(--line);
}
.history-list li.is-internal {
  border-left-color: var(--muted); background: var(--page);
}
.history-when { font-size: 11.5px; color: var(--muted); }
.history-what { font-size: 14px; }
.history-note { font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }

/* --- Empty state and pager ----------------------------------------------- */

.empty-state {
  text-align: center; padding: 40px 16px; color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.empty-state p { margin: 0 0 6px; }

/* The email-failed callout uses .notice and holds a form. */
.notice form { margin: 6px 0 0; }
.notice .btn { width: auto; min-height: 38px; font-size: 13.5px; }

.pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin: 14px 0 32px; font-size: 13.5px; color: var(--muted);
}

/* --- Page width ----------------------------------------------------------
   The biller views wrap themselves in .page like every other view. The
   default 780px is too narrow for an eight-column table, so they use the
   wide modifier. Nothing else here touches layout. */

.page-wide { max-width: 1360px; }

/* --- Desktop widths ------------------------------------------------------
   Fixed layout stops a long facility name from squeezing the amount
   column until its sub-note collides with the status pill. */

@media (min-width: 900px) {
  /* Scoped to the biller list, which is the only .biller-table with a
     tickbox in column 1. The report tables reuse the same class with a
     different column order, so a fixed layout here would crush their
     first column to 38px. They lay out automatically instead. */
  #pay-form .biller-table { table-layout: fixed; }

  #pay-form .biller-table th:nth-child(1) { width: 38px;   }  /* tick       */
  #pay-form .biller-table th:nth-child(2) { width: 11rem;  }  /* number     */
  #pay-form .biller-table th:nth-child(3) { width: 10rem;  }  /* doctor     */
  #pay-form .biller-table th:nth-child(5) { width: 8.5rem; }  /* date       */
  #pay-form .biller-table th:nth-child(6) { width: 12rem;  }  /* procedures */
  #pay-form .biller-table th:nth-child(7) { width: 10rem;  }  /* amount     */
  #pay-form .biller-table th:nth-child(8) { width: 7.5rem; }  /* status     */

  #pay-form .biller-table td { overflow-wrap: anywhere; }

  /* Submission numbers and dates should never wrap. */
  .biller-table td a[href^="/biller/"] { white-space: nowrap; }
}

/* --- Phones: tables become cards ----------------------------------------- */

@media (max-width: 760px) {
  .biller-table thead, .lines-table thead { display: none; }

  .biller-table, .lines-table { border: 0; background: none; }

  .biller-table tr, .lines-table tbody tr {
    display: block; margin-bottom: 10px; padding: 8px 12px;
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius);
  }
  .biller-table td, .lines-table td {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 14px; padding: 4px 0; border: 0; text-align: right;
  }
  .biller-table td::before, .lines-table td::before {
    content: attr(data-label);
    flex: 0 0 auto; text-align: left;
    font-size: 11px; font-weight: 600; letter-spacing: .05em;
    text-transform: uppercase; color: var(--muted);
  }
  .biller-table td:empty { display: none; }
  .biller-table tr.is-payable td:first-child,
  .biller-table tr.is-reviewable td:first-child { box-shadow: none; }

  .lines-table tfoot tr { display: block; padding: 4px 12px; }
  .lines-table tfoot th { display: block; text-align: left; border: 0; padding: 2px 0; }
  .lines-table tfoot td { display: block; text-align: right; border: 0; padding: 0 0 6px; }

  /* 16px on inputs is what stops iOS zooming on focus. */
  .biller-filters input, .biller-filters select,
  .pay-bar input, .decision-form input, .decision-form textarea { font-size: 16px; }

  .pay-bar { position: fixed; left: 8px; right: 8px; bottom: 8px; }
  .pay-bar label { flex: 1 1 100%; }
  .pay-bar-count { flex: 1 1 100%; padding-bottom: 0; margin-right: 0; }
  .pay-bar .btn { width: 100%; }
  .bar-panel { flex: 1 1 100%; }
}


/* ==========================================================================
   Step 7 - reports

   Reuses the Step 6 table, chip and filter components. Only the aging
   buckets and the export list are new.
   ========================================================================== */

/* --- Aging buckets -------------------------------------------------------- */

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.bucket {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px;
}
.bucket-label {
  font-size: 11px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted);
}
.bucket-amount {
  font-size: 19px; font-weight: 600; margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.bucket-count { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Anything past 90 days is the one worth looking at. */
.bucket-old        { border-color: #E7CFA6; background: var(--warn-wash); }
.bucket-old .bucket-amount { color: #7A4C0B; }

.bucket-total      { border-color: var(--brand); }
.bucket-total .bucket-amount { color: var(--brand-dark); }

/* --- Days outstanding ----------------------------------------------------- */

.age {
  display: inline-block; min-width: 2.2em; text-align: center;
  padding: .1rem .4rem; border-radius: 4px;
  font-variant-numeric: tabular-nums; font-size: 12.5px;
}
.age-0-30   { background: var(--surface); color: var(--ink-2); }
.age-31-60  { background: var(--brand-wash); color: #1B4F82; }
.age-61-90  { background: var(--warn-wash);  color: #7A4C0B; }
.age-90plus { background: var(--danger-wash); color: #7E2126; font-weight: 600; }

/* --- Export list ---------------------------------------------------------- */

.export-block {
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; margin: 20px 0 40px;
}
.export-block h2 { font-size: 14px; font-weight: 600; margin: 0 0 4px; }
.export-list {
  list-style: none; margin: 10px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 6px 18px;
}
.export-list a { font-size: 13.5px; }
