/* ==========================================================
   LIMS Patient Registration — stylesheet
   ========================================================== */
:root {
  --bg: #f1f5f7;
  --surface: #ffffff;
  --ink: #0f2430;
  --muted: #62778a;
  --line: #dde5ea;
  --line-strong: #c5d1d9;
  --brand: #0b5c6b;
  --brand-dark: #08424d;
  --brand-soft: #e3f1f3;
  --accent: #0e7c8f;
  --ok: #15803d;      --ok-bg: #e6f5ec;
  --warn: #a15c07;    --warn-bg: #fdf1dc;
  --danger: #b42318;  --danger-bg: #fdeceb;
  --info: #1d5fa8;    --info-bg: #e6f0fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 36, 48, .06), 0 4px 14px rgba(15, 36, 48, .05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { 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);
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Top bar ---------- */
.topbar { background: var(--brand-dark); color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 0 20px; min-height: 60px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; padding: 8px 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px; background: #fff; color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text small { color: #a9cdd4; font-size: 12px; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  color: #d4e7ea; padding: 8px 14px; border-radius: 8px; font-weight: 500; font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255,255,255,.18); color: #fff; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1280px; margin: 0 auto; padding: 26px 20px 40px; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 18px; }
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.page-head h1 { font-size: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px;
}
.card-title {
  font-size: 16px; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.step {
  width: 24px; height: 24px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
  display: inline-grid; place-items: center; font-size: 13px; font-weight: 700;
}
.hint-inline { font-weight: 400; color: var(--muted); font-size: 13px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  font: 600 14px/1.2 var(--font); cursor: pointer; text-decoration: none !important;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: var(--brand); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--brand-soft); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #e8eef1; color: var(--ink); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f0c4c0; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn[disabled] { opacity: .6; cursor: wait; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(14, 124, 143, .35); outline-offset: 1px;
}

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.alert-success { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cc; }
.alert-error   { background: var(--danger-bg); color: var(--danger); border-color: #f4c7c3; }
.alert-warning { background: var(--warn-bg); color: var(--warn); border-color: #f2d9a8; }
.alert-info    { background: var(--info-bg); color: var(--info); border-color: #c4dbf3; }
.alert ul { margin: 6px 0 0 18px; padding: 0; font-weight: 400; }

/* ---------- Forms ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px 18px; }
.span-all { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.req { color: var(--danger); }
input[type=text], input[type=tel], input[type=date], input[type=number], input[type=search],
select, textarea {
  width: 100%; padding: 9px 11px; min-height: 40px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; color: var(--ink);
  font: inherit;
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.hint { display: block; margin-top: 4px; color: var(--muted); font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; padding: 4px 0 10px; }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 18px; box-shadow: var(--shadow); display: block; color: inherit;
}
a.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat .n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(14,124,143,.18); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 280px; max-width: 460px; }
.toolbar select { width: auto; min-width: 150px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
  background: #f7fafb; padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.list td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tbody tr:last-child td { border-bottom: none; }
table.list tbody tr:hover { background: #f8fbfc; }
td .sub { display: block; color: var(--muted); font-size: 12.5px; }
td.nowrap, th.nowrap { white-space: nowrap; }
td.name a { font-weight: 600; color: var(--ink); }
td.name a:hover { color: var(--accent); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; flex-wrap: nowrap; align-items: center; }
.row-actions form { margin: 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: #e8eef1; color: #42586a;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #edf1f3; color: var(--muted); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pages a, .pages span {
  min-width: 36px; height: 36px; padding: 0 10px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); font-weight: 600;
}
.pages a:hover { border-color: var(--accent); text-decoration: none; }
.pages .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.pages .gap { border: none; background: none; color: var(--muted); }

/* ---------- Detail view ---------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px 24px; margin: 0; }
.detail-grid div { min-width: 0; }
.detail-grid dt { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 2px; }
.detail-grid dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.detail-grid .span-all { grid-column: 1 / -1; }
.print-head { display: none; }

/* ---------- Catalog tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-strong); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a {
  padding: 10px 18px; font-weight: 600; color: var(--muted); border: 1px solid transparent;
  border-bottom: none; border-radius: 8px 8px 0 0; margin-bottom: -1px;
}
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs a.active { background: var(--surface); color: var(--brand); border-color: var(--line-strong); }
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1 1 200px; }
.inline-form .field.narrow { flex: 0 0 150px; }
table.list input[type=text], table.list select, table.list input[type=number] { min-height: 34px; padding: 5px 8px; }
table.list input[type=number] { width: 80px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.check input { width: 16px; height: 16px; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .container { padding: 18px 14px 32px; }
  .card { padding: 16px; }
  .page-head h1 { font-size: 21px; }
  .nav a { padding: 7px 10px; }
}

/* ---------- Print ---------- */
@media print {
  body { background: #fff; font-size: 12.5px; }
  .no-print, .topbar, .footer, .toolbar, .pagination { display: none !important; }
  .container { max-width: none; padding: 0; }
  .card, .table-wrap { box-shadow: none; border-color: #999; }
  .print-head { display: block; text-align: center; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 2px solid #000; }
  .print-head h2 { font-size: 18px; }
  .print-head p { margin: 2px 0 0; color: #333; }
  table.list th { background: #eee !important; color: #000; }
  a { color: #000; }
}
