/* Theme variables */
:root{
	--bg: #f8fafc;
	--text: #0f172a;
	--muted: #64748b;
	--card-bg: #ffffff;
	--border: #e2e8f0;
	--primary: #1976d2;
	--primary-contrast: #ffffff;
	--danger: #d32f2f;
	--radius-lg: 12px;
	--focus-ring: 0 0 0 3px rgba(25, 118, 210, 0.25);
}

body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;margin:0;background:var(--bg);color:var(--text);} 
a{color:#0ea5e9;text-decoration:none;}
.wrap{max-width:1100px;margin:0 auto;padding:16px;}
.topbar{background:#0f172a;color:#fff;}
.topbar a{color:#fff;margin-right:12px;}
.topbar nav{float:right;margin-top:10px;}
.topbar h1{display:inline-block;margin:0;padding:16px 0;}
.card{background:var(--card-bg);border-radius:var(--radius-lg);padding:16px;margin:16px 0;box-shadow:0 2px 8px rgba(0,0,0,0.05);} 
.portal.portal-blue-light .card{ border-radius: 0; margin: 0; }
.portal.portal-blue-light .maxw-400, 
.portal.portal-blue-light .maxw-900 {
	max-width: 100%; /* stretch to feel like one section */
}
table{border-collapse:collapse;width:100%;background:#fff;border-radius:12px;overflow:hidden;}
th,td{padding:10px 12px;border-bottom:1px solid var(--border);text-align:left;} th{background:#f1f5f9;}
form .row{display:grid;grid-template-columns:repeat(3,minmax(240px,1fr));gap:12px;align-items:start;margin-bottom:12px;}
@media(max-width:1100px){form .row{grid-template-columns:repeat(2,minmax(240px,1fr));}}
@media(max-width:700px){form .row{grid-template-columns:1fr;}}
/* Inline rows: label and control side-by-side */
form .row.inline-row{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
form .row.inline-row > label{ margin:0; min-width:90px; }
form .row.inline-row > input[type="date"],
form .row.inline-row > input[type="number"],
form .row.inline-row > input[type="text"],
form .row.inline-row > select{ width:auto; min-width:200px; }
form .row.inline-row .muted{ margin-left:8px; }
/* Admin exchange rates pair row: keep all on one line */
form .row.pair-row{ display:flex !important; align-items:center; gap:8px; flex-wrap:nowrap; }
form .row.pair-row > label{ margin:0 8px 0 0; }
form .row.pair-row select{ width:auto; min-width:100px; }
form .row.pair-row .hint{ margin-left:8px; color:var(--muted); font-size:12px; }
@media(max-width:600px){ form .row.pair-row{ flex-wrap:wrap; } }
form .row .col{min-width:0;display:flex;flex-direction:column;}
form label{display:block;font-weight:600;font-size:14px;line-height:1.2;margin:0 0 6px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
input[type=text],input[type=number],input[type=date],input[type=password],select{width:100%;height:44px;font-size:14px;padding:0 12px;border:1px solid #cbd5e1;border-radius:8px;background:#fff;box-sizing:border-box;}
.form-control:focus-visible,
input[type=text]:focus-visible,
input[type=number]:focus-visible,
input[type=date]:focus-visible,
input[type=password]:focus-visible,
select:focus-visible { outline:none; box-shadow: var(--focus-ring); border-color: var(--primary); }
.btn{display:inline-block;background:var(--primary);color:var(--primary-contrast);border:1px solid var(--primary);padding:10px 14px;border-radius:8px;cursor:pointer;transition:filter .15s ease, background-color .15s ease, border-color .15s ease;}
.btn:hover{filter:brightness(0.98);} 
.btn:focus{outline:none;}
.btn:focus-visible{box-shadow:var(--focus-ring);} 
.btn.compact{display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 14px;line-height:1;}
.btn.secondary{background:#f5f9ff;color:var(--primary);border-color:var(--primary);} 
.btn.danger{background:var(--danger);border-color:var(--danger);color:#fff;}
.btn.danger-outline{background:#fff;color:var(--danger);border:1px solid var(--danger);} 
.btn.danger-outline:hover,.btn.danger-outline:focus{filter:brightness(0.98);} 
.btn-outline{background:transparent;color:var(--primary);border:1px solid var(--primary);} 
.btn-ghost{background:transparent;color:var(--primary);border-color:transparent;} 
.actions a{margin-right:8px;}
.alert{padding:10px 12px;border-radius:8px;margin:10px 0;}
.alert.success{background:#dcfce7;color:#166534;}
.alert.error{background:#fee2e2;color:#991b1b;}
.small{font-size:12px;color:var(--muted);} 

/* Clients index extracted styles */
.filters-actions-inline{display:flex;gap:10px;align-items:flex-end;flex-wrap:wrap;}
.filters-actions-inline input[name="q"]{min-width:320px;}
.filters-actions-inline .btn{background:#1976d2;border:1px solid #1976d2;color:#fff !important;padding:10px 16px;border-radius:8px;line-height:1;height:38px;display:inline-flex;align-items:center;}
.filters-actions-inline .btn.secondary{background:#1976d2;border-color:#1976d2;color:#fff !important;}
.filters-actions-inline .btn.wide{min-width:160px;justify-content:center;}
.filters-actions-inline .btn.danger{background:#d32f2f;border-color:#d32f2f;color:#fff !important;}
.filters-actions-inline .btn.danger:hover,.filters-actions-inline .btn.danger:focus{background:#b71c1c;border-color:#b71c1c;}
.filters-actions-inline .q-wrap{flex:0 0 auto;}
.filters-actions-inline .q-wrap input[name="q"]{width:360px;}
.filters-actions-inline .btn.equal{height:38px;width:140px;padding:10px 0;display:inline-flex;align-items:center;justify-content:center;}
.clients-actions-bar{display:flex;gap:12px;align-items:flex-end;flex-wrap:wrap;}
.clients-actions-bar .btn{display:inline-flex;align-items:center;justify-content:center;height:42px;padding:0 18px;line-height:1;border:none;border-radius:10px;box-sizing:border-box;}
.clients-actions-bar .btn,.clients-actions-bar .btn.secondary{background:#1976d2;color:#fff;}
.clients-actions-bar .btn-red{background:#e53935;color:#fff;}
.table-compact table{width:100%;border-collapse:collapse;table-layout:fixed;}
.table-compact table{overflow:visible !important;}
.table-compact{overflow:visible !important;}
.table-compact th,.table-compact td{padding:6px 8px;line-height:1.25;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.table-compact .col-name{width:24%;}
.table-compact .col-mother{width:16%;}
.table-compact .col-birth{width:10%;}
.table-compact .col-gender{width:8%;}
.table-compact .col-mrn{width:15%;}
.table-compact .col-phone{width:12%;}
.table-compact .col-actions{width:15%;overflow:visible !important;}
.pager{display:flex;gap:6px;flex-wrap:wrap;align-items:center;margin-top:8px;}
.pager a,.pager span{padding:4px 8px;border:1px solid #ddd;border-radius:4px;text-decoration:none;}
.pager .current{background:#f0f0f0;font-weight:bold;}
.pager .muted{border:none;padding:0 4px;color:#666;}

/* Actions dropdown (moved from clients/index.php) */
.actions-dropdown { position: relative; display: inline-block; }
.actions-btn { background:#0ea5e9; color:#fff; border:1px solid #0ea5e9; border-radius:6px; padding:6px 10px; font-size:13px; line-height:1.2; cursor:pointer; box-shadow:0 1px 2px rgba(0,0,0,.1); }
.actions-btn:focus { outline:2px solid #0369a1; outline-offset:2px; }
.actions-menu { position:absolute; top:100%; right:0; min-width:160px; background:#fff; border:1px solid #d0d7de; border-radius:8px; padding:4px 0; margin-top:4px; box-shadow:0 4px 18px -2px rgba(0,0,0,.15); display:none; z-index:9999; }
.actions-menu a { display:block; padding:8px 12px; font-size:13px; color:#0f172a; text-decoration:none; white-space:nowrap; }
.actions-menu a:hover, .actions-menu a:focus { background:#f1f5f9; }
.actions-dropdown.open > .actions-menu { display:block; }
.col-actions { overflow:visible !important; }
.dropdown-content { display:none; }

/* Visits index page CSS moved from inline */
.filters-line{ display:flex; gap:8px; align-items:flex-end; flex-wrap:nowrap; }
.filters-line .field{ display:flex; flex-direction:column; }
/* Compact heights for the four filters */
.filters-line .field input,
.filters-line .field select{ height:34px; line-height:34px; padding:0 8px; box-sizing:border-box; font-size:14px; border:1px solid var(--border); border-radius:8px; }
/* Specific widths to keep on one row */
.filters-line input[name="inv"]{ width:120px; }
.filters-line input[name="df"],
.filters-line input[name="dt"]{ width:140px; }
.filters-line input[name="name"]{ min-width:280px; flex:1; height:34px !important; line-height:34px !important; padding:0 8px; }
/* Ensure identical heights across all four filter controls */
.filters-line input[name="inv"],
.filters-line input[name="name"],
.filters-line input[name="df"],
.filters-line input[name="dt"]{
	height:34px !important;
	line-height:34px !important;
	padding:0 8px !important;
	box-sizing:border-box;
}
.filters-row-actions .btn{ height:40px; display:inline-flex; align-items:center; justify-content:center; padding:0 16px !important; line-height:1 !important; box-sizing:border-box; -webkit-appearance:none; appearance:none; }
.filters-row-actions .btn.wide{ min-width:160px; }
.filters-row-fields{ display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap; }
.filters-row-actions{ display:flex; gap:8px; align-items:center; }
.mt-10{ margin-top:10px; }
.filter-invoice input[type="text"]{ width:140px; }
.mini { width:180px; }
.mini input[type="date"]{ height:40px; padding:0 10px; box-sizing:border-box; width:100%; }
.filters-row-actions .btn{ height:40px; display:inline-flex; align-items:center; justify-content:center; }
.filters-row-actions .btn.wide{ min-width:160px; }
.filters-row-actions .btn.danger{ background:#d32f2f; border-color:#d32f2f; color:#fff; }
.filters-row-actions .btn.danger:hover{ background:#b71c1c; border-color:#b71c1c; }
.filters-actions-inline .mini { width: 160px; }
.filters-actions-inline .mini input[type="date"] { height: 40px; padding: 0 10px; box-sizing: border-box; width: 100%; }
.filters-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.btn:hover { filter: brightness(0.96); }
.btn.wide { min-width: 140px; }
.filters-actions-inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: nowrap; }
.filters-actions-inline a.btn,
.filters-actions-inline button.btn,
.filters-actions-inline .btn { display: inline-flex !important; align-items: center; justify-content: center; box-sizing: border-box; height: 40px; padding: 0 16px !important; line-height: 1 !important; font-size: 14px; border-radius: 8px; background: #1976d2; color: #fff !important; border: 1px solid #1976d2; text-decoration: none; }
.filters-actions-inline button.btn { -webkit-appearance: none; appearance: none; }
.filters-actions-inline .btn.wide { min-width: 160px; }
.filters-actions-inline input[type="date"] { height: 40px; padding: 0 10px; box-sizing: border-box; }
.filters-actions-inline .btn.danger{ background:var(--danger); border-color:var(--danger); color:#fff !important; }
.filters-actions-inline .btn.danger:hover,
.filters-actions-inline .btn.danger:focus{ filter:brightness(0.95); }
.row { display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; }
.col { min-width:220px; }
.btn.secondary { background:#f5f9ff; color:#1976d2; }
.btn.small { padding:4px 8px; font-size:12px; }
/* Users page: keep Edit button text white */
.users-actions a.btn.small{ color:#fff !important; }
.users-actions a.btn.small:hover,
.users-actions a.btn.small:focus,
.users-actions a.btn.small:visited{ color:#fff !important; }
/* Client Portal: ensure Print button text stays white */
.portal a.btn.small,
.portal a.btn.small:hover,
.portal a.btn.small:focus,
.portal a.btn.small:visited{ color:#fff !important; }
/* Visits Create: force white text on Add/Remove buttons */
#selected-grid .btn.small,
#selected-grid .btn.small:hover,
#selected-grid .btn.small:focus,
#selected-grid .btn.small:visited{ color:#fff !important; }
button.js-add-test.btn.small,
button.js-add-test.btn.small:hover,
button.js-add-test.btn.small:focus,
button.js-add-test.btn.small:visited{ color:#fff !important; }
table.visits { width:100%; border-collapse:collapse; table-layout:fixed; font-size:14px; }
table.visits th, table.visits td { padding:6px 10px; border-bottom:1px solid #e6e6e6; text-align:left; vertical-align:middle; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
table.visits th { background:#f7f7f7; font-weight:600; }
.visits tbody tr:nth-child(odd){ background:#fafafa; }
.visits tbody tr:hover{ background:#eef6ff; }
.th-sort { color:#2d6cdf; text-decoration:none; }
.th-sort span { opacity:.66; font-size:11px; margin-left:4px; }
table.visits th:nth-child(1), table.visits td:nth-child(1) { width:10%; }
table.visits th:nth-child(2), table.visits td:nth-child(2) { width:14%; }
table.visits th:nth-child(3), table.visits td:nth-child(3) { width:30%; }
table.visits th:nth-child(4), table.visits td:nth-child(4) { width:14%; }
table.visits th:nth-child(5), table.visits td:nth-child(5) { width:8%;  }
table.visits th:nth-child(6), table.visits td:nth-child(6) { width:11%; }
table.visits th:nth-child(7), table.visits td:nth-child(7) { width:13%; }
td.actions { position:relative; overflow:visible !important; }
.dropdown { position:relative; display:inline-block; }
.dropbtn { background:#2196f3; color:#fff; padding:4px 10px; font-size:13px; border:none; border-radius:4px; cursor:pointer; line-height:1.3; }
.dropdown-content { display:none; position:absolute; right:0; top:100%; min-width:200px; background:#fff; border-radius:6px; box-shadow:0 2px 10px rgba(0,0,0,.15); z-index:9999; overflow:hidden; }
.dropdown-content a { display:block; padding:9px 12px; font-size:13px; color:#333; text-decoration:none; }
.dropdown-content a:hover { background:#f5f5f5; }
.dropdown.open .dropdown-content { display:block; }
.pager { display:flex; gap:6px; align-items:center; flex-wrap:wrap; margin-top:10px; }
.pager a, .pager span { padding:4px 8px; border:1px solid #ddd; border-radius:4px; text-decoration:none; color:#333; background:#fff; }
.pager span.current { background:#333; color:#fff; border-color:#333; }
.pager .muted { color:#666; border:none; background:transparent; padding:0; }
.dropdown-content.is-floating{ position: fixed !important; left: 0; top: 0; right: auto !important; bottom: auto !important; max-height: calc(100vh - 16px); overflow: auto; z-index: 100000; }

/* ---- Client portal login header/logo ---- */
.portal-header { display:flex; justify-content:flex-start; align-items:center; padding:16px; }
.portal-logo { height:48px; width:auto; }
@media (max-width: 768px){
		.portal-header { justify-content:center; }
	.portal-logo { height:56px; }
}

/* ---- Client portal login form sizing/centering ---- */
.portal-login form { display:flex; flex-direction:column; align-items:center; }
.portal-login form label { align-self:center; width:100%; max-width:280px; }
.portal-login form input[type="text"],
.portal-login form input[type="password"],
.portal-login form input,
.portal-login form select { width:100%; max-width:280px; }
.portal-login form input{
	border:1px solid #cbd5e1; border-radius:4px; height:44px; padding:0 12px; box-sizing:border-box;
}
.portal-login form input:focus{ outline:none; box-shadow: var(--focus-ring); border-color: var(--primary); }
.portal-login form input[type="text"],
.portal-login form input[type="password"]{
	height:44px; padding:0 12px; border:1px solid #cbd5e1; border-radius:4px;
	background:#fff; box-sizing:border-box; -webkit-appearance:none; appearance:none;
}
.portal-login form .btn { width:100%; max-width:280px; justify-content:center; margin-top:8px; }
.portal-login h2{ text-align:center; margin: 0 0 8px; }

/* ---- Staff Login page header/logo ---- */
.login-header{ display:flex; align-items:center; justify-content:flex-start; padding:16px; }
.login-logo{ height:48px; width:auto; display:block; }
@media (max-width: 768px){
	.login-header{ justify-content:center; }
	.login-logo{ height:56px; }
}

/* ---- Staff Login form centering ---- */
.login-box .login-form{ display:flex; justify-content:center; }
.login-box .login-fields{ display:flex; flex-direction:column; align-items:center; width:100%; }
.login-box .login-fields label{ align-self:center; width:100%; max-width:320px; }
.login-box .login-fields input[type="text"],
.login-box .login-fields input[type="password"],
.login-box .login-fields input,
.login-box .login-fields select{ width:100%; max-width:320px; height:44px; }
.login-box .login-fields .btn{ width:100%; max-width:320px; justify-content:center; margin-top:8px; }

/* ---- Added extra margin below password field to create more space before the login button ---- */
.login-fields input[type="password"] {
    margin-bottom: 20px;
}

/* ---- Generic responsive helpers (staff UI) ---- */
.table-responsive{ width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.table-responsive table{ width:100%; min-width:700px; }

/* ---- Subtests page mobile tweaks ---- */
.subtests-page .filters { display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; }
.subtests-page #test_id { width:260px; min-width:260px; }
.subtests-page .tests-table-wrap table.tests.subtests { min-width: 680px; }
@media (max-width: 768px){
	.subtests-page .filters > div { flex: 1 1 100%; min-width: 0; }
	.subtests-page #test_id { width:100%; min-width:0; }
	.subtests-page .filters .actions { display:flex; gap:8px; flex-wrap:wrap; }
	.subtests-page .filters .actions .btn { flex: 1 1 auto; min-width: 140px; }
	.subtests-page table.tests.subtests th, 
	.subtests-page table.tests.subtests td { padding:6px 8px; }
}

/* ---- Guarantors page layout tweaks ---- */
.guarantors-page .row { gap:8px; }
.guarantors-page .lnum-inline input[type="number"]{ height:36px; padding:0 10px; flex:1 1 200px; min-width:180px; }
.guarantors-page .lnum-inline .btn { height:36px; display:inline-flex; align-items:center; padding:0 12px; line-height:1; flex:0 0 auto; }
.guarantors-page .chk-inline{ display:flex; align-items:center; gap:6px; white-space:nowrap; flex:0 0 auto; }
.guarantors-page .chk-inline input[type="checkbox"]{ width:auto; height:auto; }
/* Make Name a bit wider; ensure controls don't overlap */
.guarantors-page .name-col{ flex: 1.2 1 0; min-width: 280px; }
.guarantors-page .lnum-col{ flex: 1 1 0; min-width: 240px; }
.guarantors-page .lnum-inline{ display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
@media (max-width: 768px){
	.guarantors-page .row{ flex-wrap:wrap; }
	.guarantors-page .col{ min-width: 100%; }
	.guarantors-page .lnum-inline{ flex-wrap:wrap; }
}

/* ---- Guarantors pricing controls ---- */
.guarantors-pricing .gp-controls{ display:flex; gap:10px; align-items:flex-end; flex-wrap:wrap; }
.guarantors-pricing .gp-controls select{ height:36px; padding:0 10px; }
.guarantors-pricing .gp-controls .btn{ height:36px; display:inline-flex; align-items:center; padding:0 12px; line-height:1; }
@media (max-width: 768px){
	.guarantors-pricing .gp-controls > *{ flex:1 1 auto; }
}

/* ---- Guarantors pricing table responsive ---- */
.guarantors-pricing .tests-table-wrap table.tests{ min-width: 720px; }
@media (max-width: 768px){
	.guarantors-pricing #filter{ width:100%; max-width:none; }
	.guarantors-pricing table.tests th,
	.guarantors-pricing table.tests td{ padding:6px 8px; }
	.guarantors-pricing table.tests input[type="number"]{ width:100%; box-sizing:border-box; }
	.guarantors-pricing .form-actions{ flex-wrap:wrap; }
}

/* ---- Users index responsive tweaks ---- */
.users-page .tests-table-wrap table.tests{ min-width: 720px; }
@media (max-width: 768px){
	.users-page .tests-table-wrap table.tests th,
	.users-page .tests-table-wrap table.tests td{ padding:6px 8px; }
	.users-page .flex.mb-10{ gap:8px; }
}

/* Visits filters: stack on small screens */
@media (max-width: 768px){
	.filters-line{ flex-wrap: wrap; align-items: stretch; }
	.filters-line .field{ flex: 1 1 100%; min-width: 0; }
	.filters-line input[name="inv"],
	.filters-line input[name="df"],
	.filters-line input[name="dt"],
	.filters-line input[name="name"]{ width:100% !important; min-width:0 !important; }
	.filters-row-actions{ flex-wrap: wrap; gap: 8px; }
	.filters-row-actions .btn{ flex: 1 1 auto; min-width: 140px; }
}

/* Visits index page scoped tweaks */
.visits-page .table-responsive table.visits{ min-width: 760px; }
@media (max-width: 768px){
  .visits-page .filters-line{ flex-wrap: wrap; }
  .visits-page .filters-row-actions{ flex-wrap: wrap; gap:8px; }
  .visits-page .filters-row-actions .btn{ flex:1 1 auto; min-width:140px; }
  .visits-page table.visits th, 
  .visits-page table.visits td { padding:6px 8px; }
}

/* Moved from inline styles in _header.php to support CSP strict */
.topbar .wrap {
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 100%;
}
.topbar h1 {
	margin: 0;
	padding: 0;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 18px;
}
.topbar h1 img { height: 40px; width: auto; display: block; }
.topbar nav {
	display: flex;
	gap: 20px;
	align-items: center;
	flex-wrap: wrap;
	margin-left: 40px;
}
.topbar nav a,
.topbar nav span.welcome {
	font-size: 14px;
	line-height: 1.4;
}
.topbar nav a.active{ background: rgba(25,118,210,0.12); padding: 6px 10px; border-radius: 8px; font-weight: 600; }
/* Mobile header */
.menu-toggle{ display:none; }
.menu-select{ display:none; margin-left:auto; background:#ffffff; color:#0f172a; border:1px solid var(--border); padding:8px 10px; border-radius:8px; }
/* no inline logout on desktop; logout is inside nav */
.logout-inline{ display:none; }
@media (max-width: 768px){
	.topbar .wrap{ flex-direction: column; align-items: stretch; gap:8px; }
	.topbar h1{ justify-content: center; }
	.menu-select{ display:block; width:92%; max-width:520px; margin:4px auto 0; font-size:16px; box-sizing:border-box; }
	.topbar nav{ display:none; }
	.topbar nav a, .topbar nav span.welcome, .topbar nav form{ width:100%; }
	.topbar nav form .linklike{ text-align:left; padding:6px 0; }
	.logout-inline{ display:none; }
}
/* Button styled as link for POST logout */
.linklike {
	background: none;
	border: none;
	padding: 0;
	margin: 0;
	color: #0a58ca;
	text-decoration: underline;
	cursor: pointer;
	font: inherit;
}

	/* ---- Utility classes to replace inline styles ---- */
	.mx-auto { margin-left:auto; margin-right:auto; }
	.my-40 { margin-top:40px; margin-bottom:40px; }
	.my-80 { margin-top:80px; margin-bottom:80px; }
/* Generic page header (used by editor pages) */
.page-header { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; }
	.mt-20 { margin-top:20px; }
	.maxw-400 { max-width:400px; }
	.maxw-460 { max-width:460px; }
	.maxw-900 { max-width:900px; }
	.d-inline { display:inline; }
	.w-100 { width:100%; }
	.flex { display:flex; }
	.gap-8 { gap:8px; }
	.justify-between { justify-content:space-between; }
	.items-center { align-items:center; }
	.mb-10 { margin-bottom:10px; }
	.mt-12 { margin-top:12px; }
	.overflow-visible { overflow:visible; }
	.is-disabled { pointer-events:none; opacity:.6; }
	.cursor-default { cursor:default; }
	.maxw-420 { max-width:420px; }
	.ml-auto { margin-left:auto; }
	.mb-6 { margin-bottom:6px; }
	.flex-wrap { flex-wrap:wrap; }
	.text-center { text-align:center; }
	.text-right { text-align:right; }
.minw-360 { min-width:360px; }

	/* Tests index page styles moved from inline */
.mt-6 { margin-top:6px; }
.mt-8 { margin-top:8px; }
.ml-8 { margin-left:8px; }
	.tests-table-wrap { overflow-x:auto; overflow-y:visible; }
	/* Tests page: responsive layout */
	.tests-page .filters { display:flex; gap:10px; align-items:flex-end; flex-wrap:nowrap; }
	.tests-page .filters .col-input { min-width:260px; flex:0 0 auto; }
	.tests-page .filters .col-input input[name="q"]{ width:360px; }
	.tests-page .filters .col-actions { display:flex; gap:8px; align-items:flex-end; flex-wrap:nowrap; flex:0 0 auto; }
	.tests-page .filters .col-actions .btn { height:36px; display:inline-flex; align-items:center; justify-content:center; padding:0 12px; line-height:1; }
	.tests-page .filters select[name="per_page"] { height:36px; }
	.tests-page .tests-table-wrap table.tests { min-width: 760px; }
	@media (max-width: 900px){
		.tests-page .filters { gap:8px; }
		.tests-page .filters { flex-wrap:wrap; }
		.tests-page .filters .col-input { flex:1 1 100%; min-width:0; }
		.tests-page .filters .col-actions { width:100%; flex-wrap:wrap; }
		.tests-page .filters .col-actions > * { flex: 1 1 auto; }
		.tests-page table.tests th, .tests-page table.tests td { padding:6px 8px; }
	}
/* Visits edit page specific styles */
.form-grid{ display:grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap:10px; }
.clients-create .form-grid{ grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); }
.clients-create .grid-4{ grid-template-columns: repeat(4, minmax(200px,1fr)); }
@media (max-width: 900px){ .clients-create .grid-4{ grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); } }
.clients-create .grid-5{ grid-template-columns: repeat(5, minmax(180px,1fr)); }
@media (max-width: 1100px){ .clients-create .grid-5{ grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); } }
.field label{ display:block; font-size:12px; color:#666; margin-bottom:4px; }
.section { border:1px solid #eee; border-radius:10px; padding:12px; margin:12px 0; background:#fff; }
.sublist { display:grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap:8px; margin-top:8px; }
label.chk { display:flex; align-items:center; gap:8px; cursor:pointer; }
.price-inline { display:flex; gap:8px; align-items:center; }
.price-inline input[type="number"] { width:120px; }
.psrc { font-size:12px; padding:2px 6px; border-radius:6px; margin-left:8px; background:#eef2ff; color:#4152a3; }
.psrc.ovr { background:#ffe9e9; color:#a53535; }
.totals { font-size:13px; color:#333; }
.totals b { font-size:14px; }
	table.tests { width: 100%; border-collapse: collapse; table-layout: auto; font-size: 14px; }
	.tests th, .tests td { padding: 6px 8px; border-bottom: 1px solid #e2e8f0; white-space: nowrap; text-overflow: ellipsis; vertical-align: middle; }
	.tests th { background:#f7f7f7; font-weight:600; }
	.tests .col-id      { min-width: 70px; }
	.tests .col-cat     { min-width: 140px; }
	.tests .col-name    { min-width: 300px; }
	.tests .col-code    { width: 64px;  min-width: 60px; text-align:center; }
	.tests .col-weight  { width: 72px;  min-width: 68px; text-align:right; }
	.tests .col-sort    { width: 70px;  min-width: 60px; text-align:right; }
	.tests .col-act     { width: 70px;  min-width: 60px; text-align:center; }
	.tests .col-actions { width: 170px; min-width: 150px; text-align:center; overflow: visible !important; }
	.filters { display:flex; gap:10px; align-items:end; flex-wrap:wrap; margin-bottom:10px; }
	.filters .col-input { min-width: 320px; flex: 1 1 320px; }
	.filters .col-actions { display:flex; gap:8px; }
	.btn.small { padding:6px 10px; font-size:12px; line-height:1.2; }
	.pager a.btn, .pager span.btn { background:#2d6cdf; color:#fff; border:none; }
	.pager a.btn[disabled], .is-disabled { opacity:.5; pointer-events:none; }
	.dropbtn { background-color:#2d6cdf; color:#fff; border:none; border-radius:4px; padding:6px 10px; font-size:12px; line-height:1.2; cursor:pointer; }
	#floating-action-menu { position: fixed; z-index: 100000; display: none; min-width: 180px; background:#fff; border-radius:6px; box-shadow:0 2px 12px rgba(0,0,0,.18); overflow:hidden; }
	#floating-action-menu a, #floating-action-menu button { display:block; width:100%; text-align:left; padding:9px 12px; font-size:13px; background:#fff; color:#333; border:none; cursor:pointer; text-decoration:none; }
	#floating-action-menu a:hover, #floating-action-menu button:hover { background:#f5f5f5; }

/* Results page styles (moved from visits/results.php inline) */
.results-header { display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; }
.table { width:100%; border-collapse:collapse; table-layout:fixed; }
.table th, .table td { border:1px solid #eee; padding:6px 8px; vertical-align:middle; word-wrap:break-word; }
.table th { background:#fafafa; text-align:left; }
.table-striped tbody tr:nth-child(odd){ background:#fafafa; }
.table-hover tbody tr:hover{ background:#eef6ff; }
.mini { font-size:12px; }
.mini th, .mini td { padding:6px 8px; }
.unit { white-space:nowrap; }
.override-cell textarea { min-height:56px; }
.muted { color:#666; }

/* Results table column sizing - Fixed widths for consistency */
.results-table th:nth-child(1){ width:120px; min-width:120px; }  /* Test */
.results-table th:nth-child(2){ width:140px; min-width:140px; } /* Subtest */
.results-table th:nth-child(3){ width:120px; min-width:120px; } /* Result */
.results-table th:nth-child(4){ width:100px; min-width:100px; }  /* Remarks */
.results-table th:nth-child(5){ width:140px; min-width:140px; } /* Previous Result */
.results-table th:nth-child(6){ width:60px; min-width:60px; }  /* Unit */
.results-table th:nth-child(7){ width:180px; min-width:180px; } /* Reference Range */
.results-table th:nth-child(8){ width:120px; min-width:120px; }  /* Normal Value Override */
.results-table th:nth-child(9){ width:110px; min-width:110px; }  /* Mark as Abnormal */
.results-table th:nth-child(10){ width:100px; min-width:100px; } /* Mark as Normal */

/* Results table responsive behavior */
.results-table-wrap { width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.results-table { min-width: 1290px; width: 1290px; table-layout: fixed; }
.results-table td input.input,
.results-table td textarea.input { width:100%; max-width:100%; min-width:0; box-sizing:border-box; }
.results-table .unit { white-space:nowrap; }
.results-table .previous-result { 
  white-space: normal; 
  word-wrap: break-word; 
  line-height: 1.3;
  font-size: 0.9em;
  color: #666;
}
.results-table th:nth-child(5) { 
  font-size: 0.9em;
  padding: 8px 4px;
}
.results-table th { 
  box-sizing: border-box;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.results-table td {
  box-sizing: border-box;
}

/* Specific column header styling to prevent overlap */
.results-table th:nth-child(8) { 
  font-size: 0.8em !important; 
  white-space: normal !important;
  line-height: 1.0 !important;
  padding: 4px 6px !important;
  border-right: 2px solid #ddd !important;
}
.results-table th:nth-child(9) { 
  font-size: 0.8em !important; 
  white-space: normal !important;
  line-height: 1.0 !important;
  padding: 4px 6px !important;
  border-right: 2px solid #ddd !important;
}
.results-table th:nth-child(10) { 
  font-size: 0.8em !important; 
  white-space: normal !important;
  line-height: 1.0 !important;
  padding: 4px 6px !important;
}

/* Force column separation with borders */
.results-table th,
.results-table td {
  border-right: 1px solid #e2e8f0 !important;
  box-sizing: border-box !important;
  max-width: none !important;
}

/* Ensure text doesn't overflow */
.results-table th:nth-child(8),
.results-table th:nth-child(9),
.results-table th:nth-child(10) {
  word-break: break-word !important;
  hyphens: auto !important;
}
@media (max-width: 768px){
	.results-header { gap: 8px; }
	.results-header .flex { width: 100%; justify-content: space-between; }
	.results-table th, .results-table td { padding:6px 4px; }
	.results-table { font-size: 11px; }
	.results-table th:nth-child(1){ width:8%; }   /* Test */
	.results-table th:nth-child(2){ width:10%; } /* Subtest */
	.results-table th:nth-child(3){ width:10%; } /* Result */
	.results-table th:nth-child(4){ width:8%; }  /* Remarks */
	.results-table th:nth-child(5){ width:16%; } /* Previous Result */
	.results-table th:nth-child(6){ width:5%; }  /* Unit */
	.results-table th:nth-child(7){ width:18%; } /* Reference Range */
	.results-table th:nth-child(8){ width:10%; } /* Normal Value Override */
	.results-table th:nth-child(9){ width:7%; }  /* Mark as Abnormal */
	.results-table th:nth-child(10){ width:8%; } /* Mark as Normal */
}
@media (max-width: 480px){
	.results-table { min-width: 900px; }
	.results-header h2 { font-size: 18px; }
	.results-header .minw-260 { min-width: 200px; }
}

/* Select Subtests page styles (moved from visits/select_subtests_bulk.php inline) */
.subtests-actions { display:flex; gap:8px; align-items:center; margin-bottom:10px; }
.test-card { border:1px solid #e7e7e7; border-radius:8px; padding:10px; margin-bottom:12px; background:#fff; }
.test-title { font-weight:600; margin-bottom:6px; }
table.subs { width:100%; border-collapse:collapse; }
.subs th, .subs td { border:1px solid #ddd; padding:6px 8px; vertical-align:top; }
.subs th { background:#f8f8f8; text-align:left; }
.select-subtests-table th:nth-child(1){ width:60px; }
.select-subtests-table th:nth-child(3){ width:120px; }
.select-subtests-table th:nth-child(4){ width:150px; }
.select-subtests-table th:nth-child(5){ width:150px; }

/* Utility additions */
.m-0 { margin:0; }
.w-auto { width:auto; }
.minw-180 { min-width:180px; }
.minw-260 { min-width:260px; }
.justify-end { justify-content:flex-end; }
.mb-8 { margin-bottom:8px; }
/* NSSF invoice styles (was inline in nssfinv.php) */
.sheet { max-width: 900px; margin: 0 auto; padding: 16px 18px; background: #fff; }
.logo { height: 64px; }
.info-row { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-top:10px; font-size:14px; line-height:1.4; }
.info-row b { font-size:15px; }
table.inv { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 14px; }
table.inv th, table.inv td { border: 1px solid #ddd; padding: 8px 10px; vertical-align: middle; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.inv th { background: #f7f7f7; }
.totals { margin-top: 14px; width: 360px; border:1px solid #ddd; border-radius:8px; padding:10px 12px; font-size:14px; }
.totals .row { display:flex; justify-content:space-between; margin:4px 0; }
.totals .row b { font-size:15px; }
@media print { body * { visibility: hidden !important; } #print-area, #print-area * { visibility: visible !important; } #print-area { position: absolute; left: 0; top: 0; width: 100%; margin: 0; padding: 0; box-shadow: none; background: #fff; } .no-print { display: none !important; } a[href]:after { content: "" !important; } }
/* Proforma page styles formerly inline */
.inline-field { display:flex; align-items:center; gap:12px; margin:6px 0; }
.inline-field .title { min-width:180px; font-weight:600; color:#333; }
.inline-field .value-wrap { flex:1; }
.inline-field .value-wrap input[type="date"],
.inline-field .value-wrap input[type="number"],
.inline-field .value-wrap select { max-width:280px; }
.inline-field .metric { font-weight:600; color:#444; }
.top-actions { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
.mt-6 { margin-top:6px; }
.mt-8 { margin-top:8px; }
.mt-12 { margin-top:12px; }
.mt-4 { margin-top:4px; }

/* Print rules for proforma: print only the quote area */
@media print {
	body * { visibility: hidden !important; }
	#quote-root, #quote-root * { visibility: visible !important; }
	#quote-root { position: absolute; left: 0; top: 0; width: 100%; }
	.no-print { display: none !important; }
	#selected-grid th:nth-child(2),
	#selected-grid td:nth-child(2),
	#selected-grid th:nth-child(3),
	#selected-grid td:nth-child(3),
	#selected-grid th:last-child,
	#selected-grid td:last-child { display: none !important; }
	#selected-grid input.price-input { border:0 !important; padding:0 !important; width:auto !important; outline:none !important; background:transparent !important; }
}

/* Proforma: mobile tweaks */
@media (max-width: 768px){
	.proforma .inline-field { flex-direction: column; align-items: stretch; gap:6px; }
	.proforma .inline-field .title { min-width: 0; }
	.proforma .inline-field .value-wrap input[type="date"],
	.proforma .inline-field .value-wrap input[type="number"],
	.proforma .inline-field .value-wrap select { max-width: 100%; width: 100%; }
	.proforma .top-actions { justify-content: space-between; gap: 8px; }
	.proforma .tests-table th, .proforma .tests-table td { padding: 6px 8px; }
	.proforma #tests-table tbody tr { cursor: pointer; }
	.proforma #tests-table tbody tr:hover { background: #f1f5f9; }
}

/* Proforma: ensure Add button text is white */
/* Proforma: make Add button blue with white text */
.proforma .tests-table .btn.small,
.proforma .tests-table .btn.small:hover,
.proforma .tests-table .btn.small:focus,
.proforma .tests-table .btn.small:visited{
	background:#1976d2 !important;
	border-color:#1976d2 !important;
	color:#fff !important;
}

/* Additional utilities and visits/create page styles */
.mt-4 { margin-top:4px; }
.mt-12 { margin-top:12px; }
.minw-260 { min-width:260px; }
.totals-row { margin-top:6px; gap:24px; align-items:center; }
.scrollbox-360 { border:1px solid #eee; max-height:360px; overflow:auto; }
.grid.compact th, .grid.compact td { padding: 4px 6px; font-size: 12px; line-height: 1.25; }
.grid.compact input.price-input { width: 90px; padding: 2px 4px; font-size: 12px; }
.grid-selected th:nth-child(1) { width:36%; }
.grid-selected th:nth-child(2) { width:12%; }
.grid-selected th:nth-child(3) { width:12%; }
.grid-selected th:nth-child(4) { width:18%; }
.grid-selected th:nth-child(5) { width:10%; }
.tests-table th:nth-child(2) { width:90px; }
.form-actions { display:flex; gap:8px; }
@media (max-width: 768px){
	.clients-create .form-actions { flex-wrap: wrap; }
	.clients-edit .form-actions { flex-wrap: wrap; }
}

/* Antibiogram editor table sizing */
.antibiogram-table th:nth-child(1){ width:120px; }
.antibiogram-table th:nth-child(3){ width:140px; }
.antibiogram-table th:nth-child(4){ width:180px; }
.antibiogram-table th:nth-child(5){ width:260px; }

/* Dark mode (prefers-color-scheme) */
@media (prefers-color-scheme: dark){
	:root{ --bg:#0b1220; --text:#e6edf3; --card-bg:#0f172a; --border:#24314a; }
	body{ background:var(--bg); color:var(--text); }
	.card{ background:var(--card-bg); }
	table, .table, .visits{ background:var(--card-bg); }
	th{ background:#16233e; }
	.dropdown-content{ background:var(--card-bg); }
	.pager a, .pager span{ background:var(--card-bg); color:var(--text); border-color:var(--border); }
	input[type=text],input[type=number],input[type=date],input[type=password],select{ background:#0b1428; color:var(--text); border-color:var(--border); }
}

/* ---- Portal Blue Light theme (scoped to portal only) ---- */
.portal.portal-blue-light{
	--pbg: #f5f9ff;
	--pglow1: rgba(59,130,246,.12); /* blue-500 glow */
	--pglow2: rgba(14,165,233,.10); /* sky-500 glow */
	--pcard: rgba(255,255,255,.80);
	--pborder: rgba(25,118,210,.25);
	--ptext: #0f172a;
	--pmuted: #475569;
	--pprimary: #1976d2;
	--pprimary-strong: #0b66c3;
	--pfocus: 0 0 0 3px rgba(25,118,210,.25);
	--pshadow: 0 10px 30px rgba(2,6,23,.08);
	color: var(--ptext);
	/* Single, subtle vertical gradient for a unified background */
	background: linear-gradient(180deg, #f7fbff 0%, #eef6ff 100%);
}
.portal.portal-blue-light .portal-header{ background: transparent; }
.portal.portal-blue-light .portal-logo{ filter: drop-shadow(0 1px 4px rgba(2,6,23,.1)); }
.portal.portal-blue-light .card{
	background: transparent; /* blend with page background */
	border: none;
	box-shadow: none;
	color: var(--ptext);
}
.portal.portal-blue-light .card.portal-login{ 
	padding-top: 20px; padding-bottom: 20px; /* keep comfortable spacing */
}
.portal.portal-blue-light .portal-header{ padding-bottom: 0; }
.portal.portal-blue-light h1,.portal.portal-blue-light h2,.portal.portal-blue-light h3,.portal.portal-blue-light h4{ color: var(--ptext); }
.portal.portal-blue-light .muted { color: var(--pmuted); }
.portal.portal-blue-light a { color: var(--pprimary); }
.portal.portal-blue-light .btn{ background: var(--pprimary); border-color: var(--pprimary); color:#fff; }
.portal.portal-blue-light .btn.secondary{ background: #f0f7ff; color: var(--pprimary); border-color: rgba(25,118,210,.35); }
.portal.portal-blue-light .btn.small{ background: var(--pprimary); border-color: var(--pprimary); color:#fff; }
.portal.portal-blue-light .btn:hover{ filter: brightness(0.98); }
.portal.portal-blue-light .btn:focus-visible{ box-shadow: var(--pfocus); }
.portal.portal-blue-light input[type="text"],
.portal.portal-blue-light input[type="password"],
.portal.portal-blue-light input[type="date"],
.portal.portal-blue-light input[type="number"],
.portal.portal-blue-light select{
	background: #fff;
	color: var(--ptext);
	border: 1px solid #cbd5e1;
	border-radius: 10px;
}
.portal.portal-blue-light input:focus-visible,
.portal.portal-blue-light select:focus-visible{ outline:none; box-shadow: var(--pfocus); border-color: var(--pprimary); }
.portal.portal-blue-light table{ background: transparent; }
.portal.portal-blue-light th{ background: transparent; color: #0f172a; }
.portal.portal-blue-light table,
.portal.portal-blue-light .table{
	background: transparent;
	border-radius: 0;
	overflow: visible;
}
.portal.portal-blue-light td{ color: var(--ptext); }
.portal.portal-blue-light .alert{ background: #e6f4ff; color: #0b66c3; border: 1px solid rgba(25,118,210,.25); }
.portal.portal-blue-light .alert.error{ background: #ffefef; color: #9b1c1c; border-color: rgba(211,47,47,.25); }
.portal.portal-blue-light .table-responsive table{ min-width: 560px; }

/* Make login form elements center nicely */
.portal.portal-blue-light .portal-login form label{ color: var(--pmuted); }
.portal.portal-blue-light .portal-login form .btn{ background: var(--pprimary); border-color: var(--pprimary); }

/* Print safety inside portal theme */
@media print{
	.portal.portal-blue-light{ background:#fff !important; color:#000 !important; }
	.portal.portal-blue-light .card{ background:#fff !important; border-color:#ddd !important; box-shadow:none !important; }
}

/* ---- Client Portal mobile tweaks (scoped) ---- */
.portal .table-responsive{ width:100%; overflow-x:auto; -webkit-overflow-scrolling:touch; }
.portal .table-responsive table{ width:100%; min-width:480px; }
@media (max-width: 768px){
	.portal .card{ margin:12px; padding:12px; }
  .portal .card{ margin:12px; padding:12px; }
  .portal h2{ font-size:18px; margin:0 0 8px; }
  .portal h3{ font-size:16px; margin:10px 0 6px; }
  .portal .btn.small{ padding:6px 10px; font-size:12px; }
  .portal table th, .portal table td{ padding:6px 8px; }
}
