/* Matches www.clinilabs.co.uk: Poppins, near-black headings, royal-blue actions, light grey page */
:root {
  --ink: #111111;
  --text: #4a5260;
  --muted: #6b7385;
  --line: #e3e8f0;
  --bg: #f4f7fa;
  --card: #ffffff;
  --blue: #2463eb;
  --blue-dark: #1d4fc4;
  --blue-soft: #e9effd;
  --green: #108474;
  --red: #d0473e;
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body > main, body > .loading { flex: 1 0 auto; width: 100%; }
a { color: var(--blue); }
[hidden] { display: none !important; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.topbar {
  background: var(--blue); color: #fff; text-align: center;
  font-size: 13px; font-weight: 600; padding: 8px 16px;
}

.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; gap: 14px; height: 68px; }
.logo img { height: 28px; display: block; }
.header-label {
  font-size: 13px; font-weight: 600; color: var(--blue);
  background: var(--blue-soft); border-radius: 999px; padding: 4px 12px;
}
.header-link { margin-left: auto; font-size: 13px; color: var(--muted); text-decoration: none; }
.header-link:hover { color: var(--blue); }

.hero { padding: 36px 0 20px; max-width: 720px; }
.hero h1 { font-size: clamp(28px, 4.5vw, 44px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.1; }
.hero p { margin-top: 12px; color: var(--text); font-size: 16px; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; padding-bottom: 48px; }

.search { position: relative; margin-bottom: 14px; }
.search svg { position: absolute; left: 18px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; }
.search input {
  width: 100%; height: 52px; border: 1px solid var(--line); border-radius: 999px; background: #fff;
  padding: 0 20px 0 50px; font: inherit; color: var(--ink); outline: none;
}
.search input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer;
}
.chip:hover { border-color: var(--blue); color: var(--blue); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; }
.card h2 { font-size: 18px; font-weight: 700; }
.card-desc { color: var(--muted); font-size: 13px; margin: 2px 0 14px; }
.group-title { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin: 16px 0 4px; }
.card h2 + .group-title { margin-top: 10px; }

.item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.card h2 + .item, .group-title + .item { border-top: 0; }
.item.selected .item-name { color: var(--blue); }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.item-info { flex: 1; min-width: 0; }
.item-name { font-weight: 600; font-size: 15px; }
.item-meta { font-size: 12.5px; color: var(--muted); }
.item-meta .pack { color: var(--text); font-weight: 500; }

.qty { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; flex: none; background: #fff; }
.qty button {
  width: 36px; height: 36px; border: 0; background: none; font-size: 20px; line-height: 1; color: var(--ink);
  cursor: pointer; border-radius: 50%;
}
.qty button:hover { background: var(--blue-soft); color: var(--blue); }
.qty button:disabled { color: #c3c8d2; background: none; cursor: default; }
.qty input {
  width: 38px; height: 36px; border: 0; text-align: center; font: inherit; font-weight: 600; background: none;
  -moz-appearance: textfield; outline: none;
}
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.item.selected .qty { border-color: var(--blue); }

.no-results { color: var(--muted); text-align: center; padding: 24px 0; }

.field { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.req { color: var(--red); }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.opt { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
.field input, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
  font: inherit; color: var(--ink); background: #fff; outline: none;
}
textarea { resize: vertical; }
input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.invalid { border-color: var(--red) !important; box-shadow: 0 0 0 3px #fbe9e7 !important; }
.hp { position: absolute; left: -9999px; }

.side-col { position: sticky; top: 16px; }
.summary { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.summary h2 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }
.summary-list { list-style: none; max-height: 44vh; overflow: auto; }
.summary-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.summary-list li span:last-child { font-weight: 700; white-space: nowrap; }
.summary-empty { color: var(--muted); font-size: 13.5px; padding: 6px 0 12px; }
.summary-total { display: flex; justify-content: space-between; padding: 12px 0 16px; font-weight: 600; }
.small { font-size: 12.5px; color: var(--muted); margin-top: 12px; text-align: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 52px; padding: 0 28px;
  border-radius: 999px; font: inherit; font-weight: 600; font-size: 15px; cursor: pointer; border: 1.5px solid transparent;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--blue); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { background: #a8b8e6; cursor: default; }
.btn-outline { background: #fff; border-color: var(--blue); color: var(--blue); }
.btn-outline:hover { background: var(--blue-soft); }

.mobile-bar { display: none; }

.modal { position: fixed; inset: 0; background: rgba(17,17,17,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal-card { background: #fff; border-radius: 20px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 28px; position: relative; }
.modal-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 14px; }
.modal-close { position: absolute; top: 14px; right: 16px; width: 36px; height: 36px; border: 0; background: none; font-size: 26px; color: var(--muted); cursor: pointer; border-radius: 50%; }
.modal-close:hover { background: var(--bg); }
.review-section { margin-bottom: 16px; }
.review-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
.review-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.review-table td { padding: 7px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.review-table td:last-child { text-align: right; font-weight: 700; white-space: nowrap; padding-left: 12px; }
.review-table .ref { color: var(--muted); font-size: 12px; }
.review-kv { font-size: 13.5px; white-space: pre-line; }
.modal-actions { display: flex; gap: 12px; margin-top: 8px; }
.modal-actions .btn { flex: 1; width: auto; }
.form-error { color: var(--red); font-size: 13.5px; margin: 6px 0 10px; }

.done { text-align: center; }
.tick { width: 64px; height: 64px; border-radius: 50%; background: var(--green); display: flex; align-items: center; justify-content: center; margin: 4px auto 16px; }
.tick svg { width: 32px; height: 32px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.done p { color: var(--text); margin-bottom: 20px; }

.site-footer { border-top: 1px solid var(--line); background: #fff; padding: 20px 0; font-size: 12.5px; color: var(--muted); text-align: center; }
.site-footer a { color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; border-radius: 12px; padding: 12px 18px; font-size: 14px;
  max-width: calc(100% - 32px); box-shadow: 0 8px 30px rgba(0,0,0,.2);
}

.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side-col { display: none; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; bottom: 0; z-index: 20; background: #fff; border-top: 1px solid var(--line);
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  }
  .mobile-bar .btn { width: auto; height: 46px; }
  .mobile-bar span { color: var(--muted); font-size: 13.5px; }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: 1fr; }
  .header-link { display: none; }
  .card { padding: 18px 16px; }
  .item-name { font-size: 14px; }
  .modal-card { padding: 22px 18px; }
  .modal-actions { flex-direction: column-reverse; }
}

/* ---------- Portal: account, sign-in, tabs ---------- */
.header-account { margin-left: auto; display: flex; align-items: center; gap: 14px; min-width: 0; }
.clinic-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-btn { background: none; border: 0; font: inherit; font-size: 13.5px; color: var(--blue); cursor: pointer; padding: 6px 0; white-space: nowrap; }
.link-btn:hover { text-decoration: underline; }

.loading { display: flex; justify-content: center; padding: 64px 0; }
.spinner.dark { border-color: rgba(36,99,235,.2); border-top-color: var(--blue); width: 28px; height: 28px; }

.signin { display: flex; justify-content: center; padding: 56px 16px 72px; }
.signin-card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 36px 32px; width: 100%; max-width: 440px; }
.signin-card h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.signin-card > p { color: var(--text); margin: 8px 0 22px; }
.signin-card input { width: 100%; height: 52px; border: 1px solid var(--line); border-radius: 12px; padding: 0 16px; font: inherit; font-size: 17px; letter-spacing: .08em; text-transform: uppercase; outline: none; margin-bottom: 14px; }
.signin-card input::placeholder { letter-spacing: normal; text-transform: none; color: #a0a7b4; }
.signin-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }

.tabs { display: flex; gap: 6px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 5px; width: fit-content; margin-top: 24px; }
.tab { border: 0; background: none; font: inherit; font-weight: 600; font-size: 14px; color: var(--text); padding: 9px 20px; border-radius: 999px; cursor: pointer; }
.tab:hover { color: var(--blue); }
.tab.active { background: var(--blue); color: #fff; }

/* ---------- Order history ---------- */
.history-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; max-width: none; }
.btn-sm { height: 42px; padding: 0 20px; font-size: 14px; }
.history-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; padding-bottom: 48px; }
.history-empty { color: var(--muted); text-align: center; padding: 40px 0 64px; }
.order-card { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; font: inherit; color: var(--ink); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.order-card:hover { border-color: var(--blue); box-shadow: 0 4px 18px rgba(36,99,235,.08); }
.order-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.order-ref { font-weight: 700; font-size: 15.5px; letter-spacing: .01em; }
.order-date { color: var(--muted); font-size: 13px; }
.order-summary { color: var(--text); font-size: 13.5px; margin: 10px 0 12px; }
.bar { height: 8px; background: #eef1f6; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.bar.big { height: 10px; margin-top: 14px; }
.bar-label { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.st-received { background: var(--blue-soft); color: var(--blue); }
.st-partial { background: #fff4d6; color: #8a5a00; }
.st-done { background: #e3f4f0; color: var(--green); }
.st-warn { background: #fdeceb; color: var(--red); }
.st-cancelled { background: #eef1f6; color: var(--muted); }

.modal-card.wide { max-width: 760px; }
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding-right: 36px; }
.detail-head h2 { margin-bottom: 2px; }
.table-wrap { overflow-x: auto; margin: 18px 0; }
.lines-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.lines-table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 0 8px 8px 0; border-bottom: 1px solid var(--line); }
.lines-table td { padding: 10px 8px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.lines-table .num { text-align: right; font-weight: 600; white-space: nowrap; }
.lines-table th.num { text-align: right; }
.line-name { font-weight: 600; }
.summary-list small { color: var(--muted); }

@media (max-width: 560px) {
  .clinic-name { max-width: 140px; font-size: 13px; }
  .signin { padding-top: 28px; }
  .signin-card { padding: 26px 20px; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 9px 10px; }
  .history-hero { flex-direction: column; align-items: flex-start; }
  .history-list { grid-template-columns: minmax(0, 1fr); }
  .header-label { display: none; }
  /* Order detail: one stacked card per item */
  .lines-table thead { display: none; }
  .lines-table, .lines-table tbody { display: block; }
  .lines-table tr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .lines-table td { border: 0; padding: 0; }
  .lines-table td:first-child, .lines-table td.st { grid-column: 1 / -1; }
  .lines-table td.num { text-align: left; font-size: 13px; }
  .lines-table td.num::before { content: attr(data-label) ' '; font-weight: 400; color: var(--muted); }
}
