:root { --ink:#1c2b3a; --line:#d7dee6; --brand:#0f6b5c; --brand-dark:#0a4a40; --bg:#f4f6f8; }
* { box-sizing: border-box; }
body { margin:0; font-family: "Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif; background:var(--bg); color:var(--ink); }
.ltr { direction:ltr; unicode-bidi:embed; }
a { color:var(--brand); text-decoration:none; }
main { max-width:1050px; margin:22px auto; padding:0 16px; }
.topbar { background:var(--brand); color:#fff; display:flex; align-items:center; gap:22px; padding:10px 18px; flex-wrap:wrap; }
.topbar .brand { font-weight:700; font-size:18px; }
.topbar .tagline { font-weight:400; font-size:12px; opacity:.8; margin-inline-start:8px; }
.topbar nav { display:flex; gap:14px; }
.topbar a { color:#fff; opacity:.92; }
.topbar a:hover { opacity:1; text-decoration:underline; }
.topbar-side { margin-inline-start:auto; display:flex; gap:14px; align-items:center; font-size:13px; }
.topbar .who { opacity:.85; }
.lang-toggle { border:1px solid rgba(255,255,255,.6); border-radius:6px; padding:2px 10px; }
h2 { font-size:20px; } h3 { font-size:16px; }
.page-head { display:flex; align-items:center; gap:14px; justify-content:space-between; flex-wrap:wrap; }
.card { background:#fff; border:1px solid var(--line); border-radius:10px; padding:16px 18px; margin:14px 0; }
table { width:100%; border-collapse:collapse; background:#fff; border:1px solid var(--line); border-radius:10px; overflow:hidden; margin:10px 0 18px; }
th, td { padding:9px 12px; border-bottom:1px solid var(--line); text-align:start; font-size:14px; }
thead th { background:#eef2f5; font-weight:600; }
tbody tr:last-child td { border-bottom:none; }
.badge { display:inline-block; padding:2px 10px; border-radius:20px; font-size:12px; background:#e8edf1; }
.badge.approved { background:#d7f0e3; color:#136f43; }
.badge.awaiting_approval { background:#fdf0d3; color:#8a5a00; }
.badge.pending_results, .badge.pending { background:#e8edf1; color:#5a6b7c; }
.badge.collected { background:#dcebf7; color:#155a8a; }
.badge.received { background:#d7f0e3; color:#136f43; }
.badge.needs-review { background:#fde3e3; color:#9c1f1f; }
.flag-H, .flag-L { color:#b3541e; font-weight:700; }
.flag-HH, .flag-LL { color:#b00020; font-weight:700; }
.stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(160px,1fr)); gap:12px; margin:16px 0; }
.stat { background:#fff; border:1px solid var(--line); border-radius:10px; padding:16px; text-align:center; font-size:14px; }
.stat .num { display:block; font-size:28px; font-weight:700; color:var(--brand); }
button, .button { display:inline-block; border:1px solid var(--line); background:#fff; color:var(--ink); border-radius:8px; padding:8px 16px; font-size:14px; cursor:pointer; font-family:inherit; }
button.primary, .button.primary { background:var(--brand); border-color:var(--brand); color:#fff; }
button.primary:hover, .button.primary:hover { background:var(--brand-dark); }
button[disabled] { opacity:.45; cursor:not-allowed; }
input, select { width:100%; border:1px solid var(--line); border-radius:8px; padding:8px 10px; font-size:14px; font-family:inherit; background:#fff; }
label { display:block; margin:10px 0; font-size:14px; }
label.check { display:flex; gap:8px; align-items:center; }
label.check input { width:auto; }
.form-grid { max-width:640px; }
.form-actions, .action-bar { display:flex; gap:10px; margin-top:14px; flex-wrap:wrap; align-items:center; }
.search-bar { display:flex; gap:10px; max-width:520px; margin:12px 0; }
.kv { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:8px 24px; }
.kv div { display:flex; gap:8px; font-size:14px; }
.kv b { min-width:110px; color:#5a6b7c; font-weight:600; }
.muted { color:#7b8a99; font-size:13px; }
.flashes { max-width:1050px; margin:12px auto 0; padding:0 16px; }
.flash { background:#fdf0d3; border:1px solid #e8d9a8; padding:10px 14px; border-radius:8px; margin:6px 0; font-size:14px; }
.flash.error { background:#fde3e3; border-color:#f2b8b8; color:#9c1f1f; }
.flash.warn { background:#fdf0d3; }
.test-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(280px,1fr)); gap:4px 18px; margin-bottom:14px; }
.test-item { display:flex; gap:8px; align-items:center; margin:4px 0; }
.test-item input { width:auto; }
.test-item .price { margin-inline-start:auto; color:#5a6b7c; font-size:13px; }
.section-head { color:var(--brand); border-bottom:1px solid var(--line); padding-bottom:4px; margin:14px 0 6px; }
.sample-card { display:flex; justify-content:space-between; gap:18px; align-items:center; flex-wrap:wrap; }
.barcode-val { font-size:12px; color:#5a6b7c; margin-top:4px; }
.barcode-wrap { margin-top:4px; }
.result-input { max-width:130px; }
.login-page { min-height:100vh; display:flex; align-items:center; justify-content:center; background:var(--bg); }
.login-card { background:#fff; border:1px solid var(--line); border-radius:12px; padding:28px 32px; width:380px; max-width:92vw; }
.login-card h1 { font-size:20px; color:var(--brand); margin:0 0 4px; }
.login-card h1.ok { color:#136f43; } .login-card h1.bad { color:#9c1f1f; }
.login-card form { margin:16px 0; }
.login-card button { width:100%; }
[dir="rtl"] body, [dir="rtl"] input, [dir="rtl"] select, [dir="rtl"] button { font-family:"Segoe UI", Tahoma, "Noto Naskh Arabic", sans-serif; }

/* ---------------------------------------------------------- v2 additions */
.topbar .brand { color:#fff; }
.topbar .scan { flex:1; max-width:320px; }
.topbar .scan input { background:rgba(255,255,255,.14); border-color:rgba(255,255,255,.35); color:#fff; padding:6px 10px; }
.topbar .scan input::placeholder { color:rgba(255,255,255,.75); }
.topbar .who { color:#fff; }
.mainnav { background:#fff; border-bottom:1px solid var(--line); display:flex; gap:4px; padding:0 14px; flex-wrap:wrap; }
.mainnav a { color:var(--ink); padding:10px 12px; border-bottom:3px solid transparent; font-size:14px; }
.mainnav a.on, .mainnav a:hover { border-bottom-color:var(--brand); color:var(--brand); }
.mainnav .sep { width:1px; background:var(--line); margin:8px 6px; }
main { max-width:1240px; }
.flashes { max-width:1240px; }
a.stat { color:var(--ink); }
a.stat:hover { border-color:var(--brand); }
.small, small { font-size:12px; }
.d-block { display:block; }
.nowrap { white-space:nowrap; }
.inline { display:inline-block; margin:0; }
.error-text { color:#9c1f1f; }
.mono { font-family: ui-monospace, Consolas, monospace; }
.narrow { max-width:110px; }
button.small, .button.small { padding:4px 10px; font-size:13px; }
button.danger { background:#b00020; border-color:#b00020; color:#fff; }
button.link { background:none; border:none; color:var(--brand); padding:0; text-decoration:underline; }
.button.wa { background:#25d366; border-color:#25d366; color:#fff; }
textarea { width:100%; border:1px solid var(--line); border-radius:8px; padding:8px 10px; font:inherit; font-size:14px; }
table.list td a { font-weight:500; }
table.compact td, table.compact th { padding:5px 8px; }
table.compact input { padding:5px 8px; }
tr.inactive td { opacity:.5; }
tr.sec-row td { background:#e3f1ee; color:var(--brand-dark); font-weight:700; font-size:13px; padding:6px 12px; }
tr.crit-row td { background:#fff1f1; }
tr.locked td { background:#fafbfc; color:#7b8a99; }
tr.total-row td { font-weight:700; border-top:2px solid var(--line); }
tr.refund td { color:#9c1f1f; }
td.memo { white-space:pre-wrap; direction:ltr; text-align:start; }
.scroll-x { overflow-x:auto; }
.grid-2 { display:grid; grid-template-columns:repeat(auto-fit, minmax(380px, 1fr)); gap:0 22px; }
.form-grid.two { display:grid; grid-template-columns:1fr 1fr; gap:0 18px; max-width:none; }
.form-grid.three { display:grid; grid-template-columns:repeat(3, 1fr); gap:0 18px; max-width:none; }
.span2 { grid-column:span 2; } .span3 { grid-column:span 3; }
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:0 10px; }
.kv.one { grid-template-columns:1fr; }
.badge.st-awaiting_sample { background:#e8edf1; color:#5a6b7c; }
.badge.st-pending_results, .badge.st-pending, .badge.st-collected { background:#dcebf7; color:#155a8a; }
.badge.st-awaiting_approval { background:#fdf0d3; color:#8a5a00; }
.badge.st-amending { background:#f6dcf2; color:#7a1f6d; }
.badge.st-approved, .badge.st-received, .badge.st-delivered { background:#d7f0e3; color:#136f43; }
.badge.st-cancelled, .badge.st-rejected { background:#fde3e3; color:#9c1f1f; }
.flag { display:inline-block; min-width:22px; text-align:center; border-radius:4px; font-weight:700; font-size:12px; padding:0 4px; }
.flag-H, .flag-L { color:#b3541e; background:#fff0e5; }
.flag-HH, .flag-LL { color:#fff; background:#b00020; }
.flag-A { color:#b3541e; background:#fff0e5; }
td.flag-H, td.flag-L, td.flag-A { color:#b3541e; font-weight:700; background:none; }
td.flag-HH, td.flag-LL { color:#b00020; font-weight:700; background:none; }
td.flag-N { background:none; }
input.abn { border-color:#e0a37a; background:#fff8f2; }
.result-input { max-width:170px; }
.result-input.calc { background:#f6f8fa; }
.result-memo { min-width:320px; direction:ltr; }
.samples { display:grid; grid-template-columns:repeat(auto-fill, minmax(330px, 1fr)); gap:0 14px; }
.sample-card { align-items:flex-start; margin:6px 0; }
.sample-card.st-rejected { border-color:#f2b8b8; background:#fffafa; }
.sample-actions { display:flex; flex-direction:column; gap:6px; align-items:stretch; }
.sample-actions form { margin:0; }
.sample-actions button { width:100%; }
details.reject summary, .danger-zone summary { cursor:pointer; color:#9c1f1f; font-size:13px; }
details.reject form { display:flex; flex-direction:column; gap:6px; margin-top:6px; }
.danger-zone { margin:26px 0; display:flex; flex-direction:column; gap:10px; }
.danger-zone form { margin-top:8px; display:flex; gap:8px; max-width:600px; }
.money div { display:flex; justify-content:space-between; padding:4px 0; border-bottom:1px dashed var(--line); font-size:14px; }
.money .due b { color:#b00020; font-size:18px; }
.money .refund b { color:#8a5a00; }
.money .ok b { color:#136f43; }
.pay-form { display:grid; grid-template-columns:1fr 1fr; gap:6px; margin-top:12px; }
.pay-form button { grid-column:span 2; }
.pin { font-family: ui-monospace, Consolas, monospace; font-size:16px; letter-spacing:2px; }
.main-actions { margin:6px 0 4px; }
.order-layout { display:grid; grid-template-columns:1fr 340px; gap:18px; align-items:start; }
.order-side .sticky { position:sticky; top:12px; }
.picked { list-style:none; padding:0; margin:0 0 8px; max-height:220px; overflow:auto; font-size:13px; }
.picked li { display:flex; justify-content:space-between; gap:8px; padding:3px 0; border-bottom:1px dotted var(--line); }
.totals div { display:flex; justify-content:space-between; padding:3px 0; }
.totals .net b { font-size:20px; color:var(--brand); }
.test-item.picked-item { background:#e9f6f2; border-radius:6px; }
.test-item { padding:3px 6px; }
.panel-item span b { font-weight:600; }
#test-filter { margin-bottom:8px; }
.tabs { display:flex; gap:4px; border-bottom:1px solid var(--line); margin:10px 0 14px; flex-wrap:wrap; }
.tabs a { padding:8px 14px; border:1px solid transparent; border-bottom:none; border-radius:8px 8px 0 0; color:var(--ink); }
.tabs a.on { background:#fff; border-color:var(--line); color:var(--brand); font-weight:600; margin-bottom:-1px; }
.search-bar { flex-wrap:wrap; max-width:none; align-items:center; }
.search-bar input, .search-bar select { max-width:340px; }
.inline-label { display:flex; align-items:center; gap:6px; margin:0; }
.critical-box { border:1px solid #f2b8b8; background:#fffafa; border-radius:10px; padding:10px 14px; margin:10px 0; }
.critical-box legend { color:#b00020; font-weight:700; }
.sticky-bottom { position:sticky; bottom:0; background:var(--bg); padding:10px 0; }
ul.plain { padding-inline-start:18px; }
td.details { font-size:11px; color:#5a6b7c; max-width:420px; word-break:break-all; }
.lang-link { display:inline-block; margin-top:10px; }
.hash { font-family: ui-monospace, Consolas, monospace; font-size:12px; }
.due { color:#b00020; font-weight:600; }
@media (max-width: 900px) {
  .order-layout { grid-template-columns:1fr; }
  .form-grid.two, .form-grid.three { grid-template-columns:1fr; }
  .span2, .span3 { grid-column:auto; }
}
@media print {
  .no-print, .topbar, .mainnav, .flashes, .search-bar, .action-bar { display:none !important; }
  body { background:#fff; }
  main { max-width:none; margin:0; }
  .card, table { border-color:#bbb; }
}

/* ===================== v3 — Future Lab identity ===================== */
@font-face { font-family:"Amiri"; src:url("/static/fonts/Amiri-Regular.ttf"); font-weight:400; font-display:swap; }
@font-face { font-family:"Amiri"; src:url("/static/fonts/Amiri-Bold.ttf"); font-weight:700; font-display:swap; }
:root {
  --brand:#2b307d; --brand-dark:#1d2160; --maroon:#a3233a; --gold:#f49a2a;
  --ink:#1f2340; --line:#dde1ee; --bg:#f3f4fa; --soft:#eef0fa;
  --shadow:0 1px 2px rgba(31,35,64,.06), 0 4px 14px rgba(31,35,64,.06);
}
body { background:var(--bg) radial-gradient(1200px 400px at 100% -10%, #e7e9f8 0, transparent 60%) no-repeat; }
.topbar { background:linear-gradient(100deg, var(--brand-dark) 0%, var(--brand) 55%, #4a3f8f 100%);
  box-shadow:0 2px 10px rgba(29,33,96,.25); padding:8px 18px; position:relative; }
.topbar::after { content:""; position:absolute; inset:auto 0 0 0; height:3px;
  background:linear-gradient(90deg, var(--maroon), var(--gold), var(--maroon)); }
.topbar .brand { display:flex; align-items:center; gap:10px; text-decoration:none !important; }
.brand-logo { background:#fff; border-radius:10px; width:46px; height:40px; display:grid; place-items:center; padding:3px;
  box-shadow:0 1px 4px rgba(0,0,0,.2); }
.brand-logo svg, .brand-logo img { width:100%; height:100%; object-fit:contain; }
.brand-text { display:flex; flex-direction:column; line-height:1.15; }
.brand-text b { font-size:17px; }
[dir=rtl] .brand-text b { font-family:"Amiri", serif; font-size:19px; }
.topbar .tagline { margin:0; font-size:11.5px; opacity:.8; }
.mainnav { box-shadow:var(--shadow); position:sticky; top:0; z-index:20; }
.mainnav a { transition:color .15s, border-color .15s; border-radius:6px 6px 0 0; }
.mainnav a.on { border-bottom-color:var(--maroon); color:var(--brand); font-weight:600; background:var(--soft); }
.mainnav a:hover { border-bottom-color:var(--gold); color:var(--brand); }
h2 { color:var(--brand); }
[dir=rtl] h2 { font-family:"Amiri", "Segoe UI", serif; font-size:24px; }
.card, table { box-shadow:var(--shadow); border-color:var(--line); }
.card { border-radius:12px; }
thead th { background:var(--soft); color:var(--brand); }
tbody tr:hover td { background:#fafbff; }
button, .button { transition:background .15s, box-shadow .15s, transform .05s; }
button:active, .button:active { transform:translateY(1px); }
button.primary, .button.primary { background:linear-gradient(180deg, #3a40a0, var(--brand)); border-color:var(--brand-dark);
  box-shadow:0 2px 6px rgba(43,48,125,.25); }
button.primary:hover, .button.primary:hover { background:var(--brand-dark); }
button.danger { background:var(--maroon); border-color:var(--maroon); }
input:focus, select:focus, textarea:focus { outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(43,48,125,.15); }
/* login */
.login-page { background:linear-gradient(160deg, #e9ebf9 0%, #f6eef3 55%, #eef1fb 100%); }
.login-page::before, .login-page::after { content:""; position:fixed; pointer-events:none; width:900px; height:900px; border-radius:50%; z-index:0; }
.login-page::before { background:rgba(43,48,125,.07); top:-520px; left:-300px; }
.login-page::after { background:rgba(163,35,58,.06); bottom:-560px; right:-280px; }
.login-card { position:relative; z-index:1; text-align:center; border:none; border-radius:18px; padding:30px 34px 22px;
  box-shadow:0 10px 40px rgba(31,35,64,.14); border-top:4px solid var(--maroon); }
.login-card form { text-align:start; }
.login-logo { width:120px; height:86px; margin:0 auto 6px; }
.login-logo svg, .login-logo img { width:100%; height:100%; object-fit:contain; }
.login-card h1 { color:var(--maroon); font-size:23px; }
[dir=rtl] .login-card h1 { font-family:"Amiri", serif; font-size:27px; }
.login-doc { margin:2px 0 0; color:var(--brand); font-weight:600; }
.login-contact { font-size:12.5px; color:#667; margin:4px 0 10px; }
/* settings branding */
.brand-upload { border:1px dashed var(--line); border-radius:10px; padding:12px; display:flex; flex-direction:column; gap:8px; }
.brand-preview { height:110px; display:grid; place-items:center; background:var(--soft); border-radius:8px; }
.brand-preview img, .brand-preview svg { max-height:100px; max-width:200px; }
.d-block { display:block; }

/* ===================== v3.1 — phones & tablets ===================== */
.nav-toggle { display:none; background:rgba(255,255,255,.14); border:1px solid rgba(255,255,255,.35); color:#fff;
  font-size:20px; line-height:1; padding:6px 11px; border-radius:8px; }
.table-scroll { max-width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table-scroll > table { margin-bottom:18px; }
img, svg, canvas { max-width:100%; }
@media (max-width: 900px) {
  main { margin:14px auto; padding:0 10px; }
  .topbar { gap:10px; padding:8px 12px; }
  .nav-toggle { display:inline-block; order:2; margin-inline-start:auto; }
  .topbar .brand { order:1; min-width:0; }
  .brand-text b { font-size:15px; }
  [dir=rtl] .brand-text b { font-size:17px; }
  .topbar .tagline { display:none; }
  .topbar .scan { order:4; flex:1 1 100%; max-width:none; }
  .topbar .scan input { width:100%; font-size:16px; }
  .topbar-side { order:3; flex:1 1 100%; justify-content:space-between; margin:0; }
  .mainnav { display:none; flex-direction:column; padding:6px 10px; gap:0; position:static; }
  body.nav-open .mainnav { display:flex; }
  .mainnav a { border-bottom:1px solid var(--line); border-radius:0; padding:12px 8px; }
  .mainnav a.on { border-bottom-color:var(--line); border-inline-start:4px solid var(--maroon); }
  .mainnav .sep { display:none; }
  .page-head { gap:8px; }
  .page-head h2 { margin:6px 0; }
  input, select, textarea { font-size:16px; }  /* stop iOS zooming into fields */
  button, .button { padding:10px 14px; }
  button.small, .button.small { padding:7px 10px; }
}
@media (max-width: 640px) {
  table.mcards, table.mcards tbody, table.mcards tr, table.mcards td { display:block; width:100%; }
  table.mcards { background:none; border:none; box-shadow:none; }
  table.mcards thead { display:none; }
  table.mcards tr { background:#fff; border:1px solid var(--line); border-radius:12px; margin:0 0 10px;
    padding:8px 12px; box-shadow:var(--shadow); }
  table.mcards td { border:none; padding:5px 0; display:flex; gap:6px 10px; align-items:center;
    justify-content:flex-start; flex-wrap:wrap; text-align:start; }
  table.mcards td[data-label]::before { content:attr(data-label); color:#6a6f8a; font-size:12.5px;
    font-weight:600; flex:0 0 auto; margin-inline-end:auto; }
  table.mcards td:empty { display:none; }
  table.mcards td:first-child { font-weight:600; font-size:15px; }
  table.mcards tr.sec-row { background:var(--soft); color:var(--brand); box-shadow:none; padding:6px 12px; }
  table.mcards tr.sec-row td { font-weight:700; }
  table.mcards tr.locked { opacity:.75; }
  /* result tables: compact cards (name line + value/unit/range/flag on one wrapped line) */
  table.rcards tr { padding:8px 12px 6px; margin-bottom:8px; }
  table.rcards td { display:inline-flex; width:auto; padding:2px 0; margin-inline-end:14px; vertical-align:middle; }
  table.rcards td:first-child { display:flex; width:100%; margin:0 0 2px; }
  table.rcards td[data-label]::before { display:none; }
  table.rcards td { color:#4a4f6a; font-size:13.5px; }
  table.rcards td:nth-child(2) { color:var(--ink); }
  table.rcards td:nth-child(2) { font-size:17px; font-weight:700; }
  table.rcards td .result-input, table.rcards td select { flex:0 0 auto; width:150px; }
  table.rcards td textarea { width:100%; }
  table.rcards td:has(textarea) { display:flex; width:100%; }
  table.rcards tr.sec-row td { display:block; width:100%; }
  table.mcards td .result-input, table.mcards td select, table.mcards td textarea { flex:1 1 100%; width:100%; }
  table.mcards td.nowrap { white-space:normal; justify-content:flex-start; }
  tbody tr:hover td { background:none; }
  .stats, .stat-grid { grid-template-columns:1fr 1fr !important; }
  .action-bar { position:sticky; bottom:0; }
}
