/* Pathology Report Delivery */
:root {
  --ink: #13232c;
  --muted: #5b6b74;
  --line: #dde5e8;
  --bg: #f3f6f7;
  --card: #ffffff;
  --brand: #0e6f69;
  --brand-dark: #0a524e;
  --brand-soft: #e3f2f0;
  --ok: #157a3b;   --ok-bg: #e5f5ea;
  --bad: #b3261e;  --bad-bg: #fdecea;
  --warn: #8a5a00; --warn-bg: #fff4dc;
  --info: #2c5d8f; --info-bg: #e8f0f9;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--brand); }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 .4rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--brand-soft); padding: 1px 5px; border-radius: 4px; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.wrap.wide { max-width: 1200px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: var(--mono); }

/* Top bar */
.topbar { background: var(--card); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; gap: 20px; min-height: 58px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; font-size: 1.05rem; }
.brand small { font-weight: 500; color: var(--muted); }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; line-height: 1; }
.topbar-note { margin-left: auto; color: var(--muted); font-size: .9rem; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 6px 12px; border-radius: 7px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--brand-soft); color: var(--brand-dark); }
.logout { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }

main.wrap { padding-top: 28px; padding-bottom: 40px; }

/* Cards & forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.card.narrow { max-width: 420px; margin: 20px auto; }

label { display: block; font-weight: 600; margin: 16px 0 6px; font-size: .95rem; }
label .hint { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=password], input:not([type]), select {
  width: 100%; font: inherit; padding: 11px 12px; border: 1px solid #c9d4d8; border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, .btn:focus-visible, .dropzone:focus-visible { outline: 3px solid rgba(14,111,105,.25); border-color: var(--brand); }
input.caps { text-transform: uppercase; letter-spacing: .04em; font-family: var(--mono); font-size: 1.05rem; }
input.caps::placeholder { color: #a7b3b8; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600;
  padding: 10px 18px; border-radius: 8px; border: 1px solid #c9d4d8; background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; margin-top: 22px; padding: 13px; font-size: 1.02rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }
.linkbtn.danger { color: var(--bad); }

.alert { padding: 12px 14px; border-radius: 8px; margin: 14px 0; border: 1px solid transparent; }
.alert-error { background: var(--bad-bg); color: #7a1a14; border-color: #f4c7c3; }
.alert-success { background: var(--ok-bg); color: #10522a; border-color: #bfe3cb; }
.alert-info { background: var(--info-bg); color: #1f4468; border-color: #c8d9ee; }

/* Patient lookup */
.lookup { max-width: 440px; margin: 24px auto 0; padding: 30px 28px; }
.lookup h1 { font-size: 1.6rem; }

/* Patient report */
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap;
  padding-bottom: 18px; border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.eyebrow { margin: 0 0 4px; color: var(--ok); font-weight: 650; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.meta { display: flex; gap: 28px; margin: 8px 0 0; }
.meta div { margin: 0; }
.meta dt { color: var(--muted); font-size: .8rem; }
.meta dd { margin: 0; font-family: var(--mono); font-weight: 600; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.pdf-frame { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #e9eef0; }
.pdf-frame iframe { display: block; width: 100%; height: 78vh; min-height: 520px; border: 0; }
.show-mobile { display: none; }

.foot { color: var(--muted); font-size: .85rem; text-align: center; padding-bottom: 30px; }

/* Admin */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--muted);
  font-size: .9rem; text-decoration: none; }
.stat span { display: block; font-size: 1.6rem; font-weight: 700; color: var(--ink); line-height: 1.2; }
a.stat:hover { border-color: var(--brand); }
.stat-bad span { color: var(--bad); }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.filters input { flex: 1 1 220px; width: auto; }
.filters select { flex: 0 0 auto; width: auto; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card .table-wrap { margin-top: 16px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em;
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: #fafcfc; white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f7fafa; }
.table .empty { text-align: center; color: var(--muted); padding: 30px; }
.row-actions { white-space: nowrap; display: flex; gap: 14px; align-items: center; }
.row-actions form { margin: 0; }
.ua { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.tag-active, .tag-imported { background: var(--ok-bg); color: var(--ok); }
.tag-replaced, .tag-skipped { background: var(--info-bg); color: var(--info); }
.tag-deleted, .tag-failed { background: var(--bad-bg); color: var(--bad); }
.tag-pending { background: #eef2f3; color: var(--muted); }
.tag-busy, .tag-warn { background: var(--warn-bg); color: var(--warn); }

.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin: 18px 0; color: var(--muted); }

/* Upload */
.dropzone { margin-top: 16px; border: 2px dashed #b9c8cd; border-radius: var(--radius); padding: 34px 16px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 10px; background: #fafcfc; transition: .15s; }
.dropzone strong { font-size: 1.1rem; }
.dropzone span { color: var(--muted); }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.drop-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.upload-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }
.upload-toolbar > div:last-child { display: flex; gap: 8px; }
.upload-toolbar[hidden], .table[hidden], .progress[hidden], .alert[hidden] { display: none; }
.progress { height: 8px; background: #e3eaec; border-radius: 99px; overflow: hidden; margin-top: 14px; }
.progress div { height: 100%; width: 0; background: var(--brand); transition: width .2s; }

@media (max-width: 640px) {
  main.wrap { padding: 18px 12px 30px; }
  .card { padding: 18px; }
  .lookup { padding: 24px 18px; margin-top: 8px; }
  .hide-mobile { display: none; }
  .show-mobile { display: inline-flex; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
  .topbar-note { display: none; }
  .logout { margin-left: 0; }
}
