/* =====================================================================================================================
   LIMS design system - two brand colours: RED WINE and ROYAL BLUE.
   Royal blue = actions, links, navigation.  Red wine = identity, emphasis, accents.
   Green / amber / red keep their usual meaning (success / warning / danger) and are used only for status.
   The same hex values live in apps/core/theme.py (charts, printed documents); a test keeps both files in step.
   ===================================================================================================================== */
@import url("tokens.css");

* { box-sizing: border-box; }
:root { --pad: clamp(12px, 1.5vw, 28px); --app-h: 92px; }   /* the page side padding; the height of the sticky header (set by tables.js) */
html, body { height: 100%; }
body {
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--royal); }
a:hover { color: var(--royal-dark); }
h1, h2, h3, h4 { color: var(--royal-deep); }

/* ---------------------------------------------------------------- application header */
header.app { position: sticky; top: 0; z-index: 60; box-shadow: 0 2px 10px rgba(20, 41, 107, .28); }
header.app .topbar { background: linear-gradient(100deg, var(--wine-dark) 0%, var(--wine) 55%, var(--wine-mid) 100%); color: #fff; }
header.app .topbar .row { display: flex; align-items: center; gap: 14px; padding: 7px var(--pad); min-height: 46px; }
header.app .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .3px; color: #fff; text-decoration: none; white-space: nowrap; }
header.app .brand .mark { width: 30px; height: 30px; border-radius: 8px; background: #fff; color: var(--wine); display: grid; place-items: center; font-weight: 800; font-size: 13px; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
header.app .tools { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }
header.app .tools form { margin: 0; display: flex; align-items: center; gap: 10px; }
header.app .tools .who { opacity: .95; }
header.app .tools button { background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .45); color: #fff; padding: 5px 14px; box-shadow: none; }
header.app .tools button:hover { background: #fff; color: var(--wine); }
header.app nav.mainnav { background: var(--royal); border-bottom: 3px solid var(--royal-deep); display: flex; flex-wrap: wrap; gap: 2px; padding: 0 var(--pad); }
header.app nav.mainnav a, header.app nav.mainnav .item > span { color: #fff; text-decoration: none; padding: 11px 14px; display: block; cursor: pointer; font-weight: 500; font-size: 14px; border-bottom: 3px solid transparent; margin-bottom: -3px; }
header.app nav.mainnav a:hover, header.app nav.mainnav .item:hover > span, header.app nav.mainnav .item:focus-within > span { background: rgba(255, 255, 255, .13); border-bottom-color: var(--wine-mid); }
header.app nav.mainnav .item { position: relative; }
header.app nav.mainnav .dropdown { display: none; position: absolute; top: 100%; left: 0; background: #fff; min-width: 250px; max-height: 75vh; overflow-y: auto; box-shadow: 0 10px 28px rgba(20, 41, 107, .28); border-radius: 0 0 var(--radius) var(--radius); border-top: 3px solid var(--wine); z-index: 70; }
header.app nav.mainnav .item:hover .dropdown, header.app nav.mainnav .item:focus-within .dropdown { display: block; }
header.app nav.mainnav .dropdown a { color: var(--ink); padding: 9px 16px; font-weight: 400; border: 0; margin: 0; border-left: 3px solid transparent; font-size: 13.5px; }
header.app nav.mainnav .dropdown a:hover { background: var(--royal-faint); border-left-color: var(--wine); color: var(--royal-dark); }
header.app nav.mainnav .item.open > span { background: rgba(255, 255, 255, .13); border-bottom-color: var(--wine-mid); }
header.app nav.mainnav .item.open .dropdown { display: block; }
header.app nav.mainnav .dropdown .menu-search { display: block; position: sticky; top: 0; width: calc(100% - 20px); margin: 8px 10px; background: #fff; }

/* tool icons and the user menu (right side of the top bar) */
header.app .tools .tool { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .32); text-decoration: none; cursor: pointer; }
header.app .tools .tool:hover, header.app .tools .tool:focus-visible { background: #fff; color: var(--wine); }
header.app .tools .tool .count { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--royal); color: #fff; border: 2px solid var(--wine); font-size: 10.5px; font-weight: 700; line-height: 14px; text-align: center; }
header.app .usermenu { position: relative; }
header.app .usermenu > span { display: block; padding: 6px 14px; border-radius: 18px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .42); cursor: pointer; white-space: nowrap; }
header.app .usermenu > span:hover, header.app .usermenu:focus-within > span, header.app .usermenu.open > span { background: #fff; color: var(--wine); opacity: 1; }
header.app .tools .item { position: relative; }
header.app .tools .item .dropdown { display: none; position: absolute; right: 0; left: auto; top: calc(100% + 6px); min-width: 210px; background: #fff; color: var(--ink); border-top: 3px solid var(--royal); border-radius: 0 0 var(--radius) var(--radius); box-shadow: 0 10px 28px rgba(20, 41, 107, .3); z-index: 80; text-align: left; }
header.app .tools .item:hover .dropdown, header.app .tools .item:focus-within .dropdown, header.app .tools .item.open .dropdown { display: block; }
header.app .tools .item .dropdown::before { content: ""; position: absolute; top: -12px; left: 0; right: 0; height: 12px; } /* keeps the menu open while the pointer crosses the gap */
header.app .tools .item .dropdown > a, header.app .tools .dropdown button.linklike { display: block; width: 100%; text-align: left; color: var(--ink); background: none; padding: 9px 16px; font-weight: 400; font-size: 13.5px; border: 0; border-left: 3px solid transparent; border-radius: 0; box-shadow: none; text-decoration: none; cursor: pointer; font-family: inherit; }
header.app .tools .item .dropdown > a:hover, header.app .tools .dropdown button.linklike:hover { background: var(--royal-faint); border-left-color: var(--wine); color: var(--royal-dark); }
header.app .usermenu .dropdown form { display: block; margin: 0; border-top: 1px solid var(--line); }

/* notification bell */
header.app .bell .dropdown { width: 360px; max-width: 92vw; max-height: 75vh; overflow-y: auto; }
header.app .bell .bell-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--royal-faint); }
header.app .bell .bell-head strong { color: var(--royal-deep); }
header.app .bell .bell-head form { margin: 0; display: block; }
header.app .bell .bell-head button.linklike { width: auto; padding: 0; font-size: 12.5px; color: var(--royal); border: 0; font-weight: 600; }
header.app .bell .dropdown > a.bell-item { display: block; padding: 10px 16px 10px 13px; border-left: 3px solid transparent; border-bottom: 1px solid var(--line); line-height: 1.35; white-space: normal; }
header.app .bell .bell-item strong { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink); }
header.app .bell .bell-item span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
header.app .bell .bell-item em { display: block; font-size: 11.5px; color: var(--muted); font-style: normal; margin-top: 3px; }
header.app .bell .dropdown > a.bell-item.unread { background: var(--royal-faint); border-left-color: var(--royal); }
header.app .bell .dropdown > a.bell-item.unread.sev-critical { border-left-color: var(--danger); }
header.app .bell .dropdown > a.bell-item.unread.sev-warning { border-left-color: var(--warning); }
header.app .bell .bell-empty { margin: 0; padding: 22px 16px; text-align: center; color: var(--muted); }
header.app .bell .dropdown > a.bell-all { text-align: center; font-weight: 600; color: var(--royal); padding: 10px 16px; border-left: 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--royal); }
.dot.sev-warning { background: var(--warning); } .dot.sev-critical { background: var(--danger); }
tr.unread-row { background: var(--royal-faint); }
button.linklike { background: none; border: 0; box-shadow: none; color: var(--royal); padding: 0; font-weight: 500; }
button.linklike:hover { background: none; color: var(--royal-dark); text-decoration: underline; }

/* ---------------------------------------------------------------- page area */
main { width: 100%; max-width: none; margin: 0; padding: 22px var(--pad) 44px; }   /* the whole browser width, however wide */
main.narrow { max-width: 760px; margin: 0 auto; }   /* small single-column forms only */
.page-title { margin: 0 0 14px; font-size: 20px; font-weight: 700; color: var(--royal-deep); padding-left: 11px; border-left: 4px solid var(--wine); line-height: 1.2; }
.page-head h2, .hello h2 { color: var(--royal-deep); }
main > h2, main > .row-between > h2, main > .page-head > h2 { margin: 0 0 14px; font-size: 20px; font-weight: 700; color: var(--royal-deep); padding-left: 11px; border-left: 4px solid var(--wine); line-height: 1.2; }
main > .row-between > h2, main > .page-head > h2 { margin-bottom: 0; }
main > .row-between, main > .page-head { margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 20px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card > h3:first-child, .card > .row-between:first-child { margin-top: 0; }
.card h3 { font-size: 15.5px; margin: 0 0 10px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- buttons */
button, .btn { background: var(--royal); color: #fff; border: 1px solid var(--royal); border-radius: 6px; padding: 8px 16px; cursor: pointer; font-size: 14px; text-decoration: none; display: inline-block; font-weight: 600; font-family: inherit; box-shadow: 0 1px 2px rgba(20, 41, 107, .22); transition: background .12s, box-shadow .12s; }
button:hover, .btn:hover { background: var(--royal-dark); border-color: var(--royal-dark); color: #fff; }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--royal-ring); outline-offset: 1px; }
button.secondary, .btn.secondary { background: #fff; color: var(--royal); border: 1px solid var(--royal); box-shadow: none; }
button.secondary:hover, .btn.secondary:hover { background: var(--royal-faint); color: var(--royal-dark); }
button.wine, .btn.wine, button.accent, .btn.accent { background: var(--wine); border-color: var(--wine); }
button.wine:hover, .btn.wine:hover, button.accent:hover, .btn.accent:hover { background: var(--wine-dark); border-color: var(--wine-dark); }
button.secondary.wine, .btn.secondary.wine { background: #fff; color: var(--wine); border-color: var(--wine); }
button.secondary.wine:hover, .btn.secondary.wine:hover { background: var(--wine-faint); }
.btn.danger, button.danger { background: var(--danger); border-color: var(--danger); } .btn.danger:hover, button.danger:hover { background: #a01f14; border-color: #a01f14; }
.btn.green, button.green { background: var(--success); border-color: var(--success); } .btn.green:hover, button.green:hover { background: #17733d; border-color: #17733d; }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn.small, button.small { padding: 4px 11px; font-size: 12.5px; }

/* ---------------------------------------------------------------- forms */
input, select, textarea { padding: 7px 10px; border: 1px solid #c6cfe4; border-radius: 6px; width: 100%; font-size: 14px; font-family: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--royal); box-shadow: 0 0 0 3px var(--royal-ring); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--royal); }
input:disabled, select:disabled, textarea:disabled { background: #eceff6; color: var(--muted); }
label { display: block; margin: 0 0 3px; font-weight: 600; font-size: 12px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .25px; }
.req { color: var(--wine); }
.hint { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }
.err, .errorlist { color: var(--danger); margin: 3px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.msg { background: var(--success-soft); border: 1px solid #9ad5b0; border-left: 4px solid var(--success); padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; }
.msg.error { background: var(--danger-soft); border-color: #eba0a0; border-left-color: var(--danger); }
.msg.warning { background: var(--warning-soft); border-color: #ecd27a; border-left-color: var(--warning); }
.msg.info { background: var(--royal-soft); border-color: var(--royal-line); border-left-color: var(--royal); }
li { margin: 4px 0; }

/* ---------------------------------------------------------------- tables */
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { background: var(--royal-soft); font-size: 12px; text-transform: uppercase; letter-spacing: .25px; color: var(--royal-deep); border-bottom: 2px solid var(--royal-line); font-weight: 700; }
table.data tbody tr:hover, tbody tr:hover { background: var(--royal-faint); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: #8a93a8; padding: 26px 0; }
.scroll-x { overflow-x: auto; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.inline { display: inline; margin: 0; }

/* ---------------------------------------------------------------- tabs, filters, badges, KPIs, pager */
.tabbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabbar a { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink-soft); background: #fff; font-size: 13px; font-weight: 500; }
.tabbar a:hover { border-color: var(--royal-line); background: var(--royal-faint); }
.tabbar a.on { background: var(--royal); color: #fff; border-color: var(--royal); box-shadow: 0 1px 3px rgba(20, 41, 107, .3); }
.tabbar a .cnt { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 6px; border-radius: 10px; background: var(--wine-soft); color: var(--wine); font-size: 11.5px; text-align: center; font-weight: 700; }
.tabbar a.on .cnt { background: rgba(255, 255, 255, .25); color: #fff; }
.filterbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; align-items: end; }
.filterbar label { font-size: 11.5px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 11px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b-grey { background: #eceff4; color: #4a5568; } .b-blue { background: var(--royal-soft); color: var(--royal-dark); }
.b-purple, .b-wine { background: var(--wine-soft); color: var(--wine); } .b-green { background: var(--success-soft); color: #17733d; }
.b-orange { background: var(--warning-soft); color: #9a5b00; } .b-red { background: var(--danger-soft); color: #a62319; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; border-left: 4px solid var(--royal); box-shadow: var(--shadow); }
.kpi .v { font-size: 24px; font-weight: 700; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink); }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-top: 2px; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.wine, .kpi.purple { border-left-color: var(--wine); } .kpi.teal { border-left-color: var(--royal-dark); }
.kpi.green { border-left-color: var(--success); } .kpi.orange { border-left-color: #e69a00; } .kpi.red { border-left-color: var(--danger); }
.grid2c { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: 14px; } .grid3c { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 16px; align-items: end; }   /* a block of form fields: they spread over the width */
.pager { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager span.current { padding: 5px 11px; border: 1px solid var(--line); border-radius: 6px; text-decoration: none; color: var(--ink-soft); font-size: 13px; background: #fff; }
.pager a:hover { background: var(--royal-faint); border-color: var(--royal-line); }
.pager span.current, .pager span.cur { background: var(--royal); color: #fff; border-color: var(--royal); }
.pager span.cur { padding: 5px 11px; border: 1px solid var(--royal); border-radius: 6px; font-size: 13px; }
.pager { justify-content: space-between; }
.pager .pages { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pager .gap { color: var(--muted); padding: 0 4px; }
.pager select { width: auto; display: inline-block; padding: 4px 8px; }
.flagH, .flagL { color: #b86800; font-weight: 700; } .flagHH, .flagLL { color: #c4281b; font-weight: 800; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--royal-faint); border: 1px solid var(--royal-line); border-radius: 14px; padding: 3px 11px; font-size: 12.5px; }

/* ---------------------------------------------------------------- shared listing (export bar, search bar, columns dialog) */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink-soft); background: #fff; font-size: 13px; font-weight: 500; }
.tabs a:hover { border-color: var(--royal-line); background: var(--royal-faint); }
.tabs a.on { background: var(--royal); color: #fff; border-color: var(--royal); box-shadow: 0 1px 3px rgba(20, 41, 107, .3); }
.bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 12px; }
.bar > div { min-width: 170px; }
.bar > div.check { min-width: 0; align-self: end; padding-bottom: 8px; }
.bar > div.check label { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; display: flex; gap: 6px; align-items: center; margin: 0; }
.export { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.export a, .export button { padding: 5px 12px; font-size: 12px; border-radius: 5px; color: #fff; text-decoration: none; border: 0; cursor: pointer; font-weight: 600; box-shadow: none; }
.export .x-csv { background: #2e9e4f; } .export .x-xlsx { background: #1b6b3a; } .export .x-pdf { background: #d33a2c; }
.export .x-copy { background: var(--wine); } .export .x-print { background: var(--royal); }
.export a:hover, .export button:hover { filter: brightness(.9); color: #fff; }
.export .x-cols { background: #fff; color: var(--royal); border: 1px solid var(--royal); margin-left: auto; }
.export .x-cols:hover { background: var(--royal-faint); color: var(--royal-dark); filter: none; }
.scroll { overflow-x: auto; }
th a { color: inherit; text-decoration: none; }
td.trunc { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
dialog.cols-dialog { width: min(440px, 94vw); }
dialog.cols-dialog h3 { margin: 0 0 4px; }
.col-list { list-style: none; margin: 12px 0; padding: 0; max-height: 52vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.col-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.col-list li:last-child { border-bottom: 0; }
.col-list label { text-transform: none; letter-spacing: 0; font-size: 13.5px; font-weight: 500; margin: 0; display: flex; align-items: center; gap: 8px; color: var(--ink); }
.col-move { display: flex; gap: 4px; }
.col-move button { padding: 1px 8px; line-height: 1.4; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 0; }
@media print { .export, .bar, .pager { display: none !important; } }

/* ---------------------------------------------------------------- login page */
body.login-page { background: linear-gradient(135deg, var(--royal-deep) 0%, var(--royal) 48%, var(--wine) 100%); min-height: 100vh; }
body.login-page header.app, body.login-page .msg:empty { display: none; }
body.login-page main { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login-card { position: relative; overflow: hidden; width: min(400px, 94vw); background: #fff; border-radius: 14px; padding: 34px 30px 26px; box-shadow: 0 18px 50px rgba(8, 18, 60, .45); }
.login-card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 6px; background: linear-gradient(90deg, var(--wine-dark), var(--wine), var(--royal)); }
.login-card .mark { width: 46px; height: 46px; border-radius: 12px; background: var(--wine); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 19px; margin: 0 auto 10px; box-shadow: 0 4px 10px rgba(123, 30, 58, .4); }
.login-card h2 { text-align: center; margin: 0 0 2px; font-size: 21px; }
.login-card .sub { text-align: center; color: var(--muted); margin: 0 0 18px; font-size: 13px; }
.login-card button { width: 100%; padding: 10px; font-size: 15px; margin-top: 6px; }
.login-card label { margin-top: 12px; }

/* ---------------------------------------------------------------- dialogs */
dialog { border: 0; border-radius: 12px; box-shadow: 0 18px 50px rgba(8, 18, 60, .4); padding: 20px 22px; border-top: 4px solid var(--wine); overflow: hidden; }
dialog::backdrop { background: rgba(20, 41, 107, .38); }

@media (max-width: 760px) {
  header.app .topbar .row { padding: 7px 14px; }
  header.app nav.mainnav { padding: 0 8px; }
  header.app nav.mainnav a, header.app nav.mainnav .item > span { padding: 10px 10px; font-size: 13.5px; }
  main { padding: 14px 12px 36px; }
}
@media print { header, .noprint { display: none !important; } body { background: #fff; } .card, .kpi { box-shadow: none; } }

/* ---------------------------------------------------------------- history icon + drawer, error pages */
a.history-icon { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; color: var(--royal); text-decoration: none; border: 1px solid transparent; vertical-align: middle; }
a.history-icon:hover, a.history-icon:focus-visible { background: var(--royal-faint); border-color: var(--royal-line); color: var(--royal-dark); }
.history-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(410px, 94vw); background: #fff; border-left: 4px solid var(--wine); box-shadow: -12px 0 32px rgba(20, 41, 107, .28); transform: translateX(105%); transition: transform .18s ease; z-index: 120; overflow-y: auto; }
.history-drawer.open { transform: none; }
.history-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--royal-faint); position: sticky; top: 0; z-index: 1; }
.history-head strong { color: var(--royal-deep); font-size: 15px; }
.history-head button { margin-left: auto; padding: 1px 10px; font-size: 18px; line-height: 1.3; }
.history-list { list-style: none; margin: 0; padding: 12px 16px 24px 22px; }
.history-list > li { position: relative; padding: 2px 0 14px 18px; border-left: 2px solid var(--royal-line); margin: 0; }
.history-list > li::before { content: ""; position: absolute; left: -7px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--wine); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--wine); }
.h-top { font-size: 14px; }
.h-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.h-details { list-style: none; padding: 0; margin: 6px 0 0; font-size: 12.5px; }
.h-details li { margin: 2px 0; }
.h-details span { color: var(--muted); }
.history-body > .empty { padding: 30px 16px; }
.history-sub { margin: 4px 16px 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--wine); font-size: 13px; }
.error-card { text-align: center; padding: 34px 24px; }
.error-code { font-size: 54px; font-weight: 800; color: var(--wine); line-height: 1; margin-bottom: 6px; }

/* ---------------------------------------------------------------- right-to-left (Urdu): the page flips, numbers stay as they are */
[dir="rtl"] body { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Urdu Typesetting", "Segoe UI", Tahoma, sans-serif; line-height: 1.85; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; }
[dir="rtl"] .num { text-align: left; }
[dir="rtl"] header.app .tools { margin-left: 0; margin-right: auto; }
[dir="rtl"] header.app nav.mainnav .dropdown { left: auto; right: 0; text-align: right; }
[dir="rtl"] header.app nav.mainnav .dropdown a { border-left: 0; border-right: 3px solid transparent; }
[dir="rtl"] header.app nav.mainnav .dropdown a:hover { border-right-color: var(--wine); }
[dir="rtl"] header.app .tools .item .dropdown { right: auto; left: 0; text-align: right; }
[dir="rtl"] header.app .tools .item .dropdown > a, [dir="rtl"] header.app .tools .dropdown button.linklike { text-align: right; border-left: 0; border-right: 3px solid transparent; }
[dir="rtl"] header.app .tools .item .dropdown > a:hover, [dir="rtl"] header.app .tools .dropdown button.linklike:hover { border-right-color: var(--wine); }
[dir="rtl"] header.app .tools .tool .count { right: auto; left: -5px; }
[dir="rtl"] main > h2, [dir="rtl"] main > .row-between > h2, [dir="rtl"] main > .page-head > h2, [dir="rtl"] .page-title { padding-left: 0; padding-right: 11px; border-left: 0; border-right: 4px solid var(--wine); }
[dir="rtl"] .kpi { border-left: 1px solid var(--line); border-right: 4px solid var(--royal); }
[dir="rtl"] .export .x-cols { margin-left: 0; margin-right: auto; }
[dir="rtl"] .history-drawer { right: auto; left: 0; border-left: 0; border-right: 4px solid var(--wine); box-shadow: 12px 0 32px rgba(20, 41, 107, .28); transform: translateX(-105%); }
[dir="rtl"] .history-drawer.open { transform: none; }
[dir="rtl"] .history-head button { margin-left: 0; margin-right: auto; }
[dir="rtl"] .history-list { padding: 12px 22px 24px 16px; }
[dir="rtl"] .history-list > li { padding: 2px 18px 14px 0; border-left: 0; border-right: 2px solid var(--royal-line); }
[dir="rtl"] .history-list > li::before { left: auto; right: -7px; }
[dir="rtl"] input[type="number"], [dir="rtl"] input[type="tel"], [dir="rtl"] input[type="date"] { direction: ltr; text-align: right; }
[dir="rtl"] .kpi.wine, [dir="rtl"] .kpi.purple { border-right-color: var(--wine); } [dir="rtl"] .kpi.teal { border-right-color: var(--royal-dark); }
[dir="rtl"] .kpi.green { border-right-color: var(--success); } [dir="rtl"] .kpi.orange { border-right-color: #e69a00; } [dir="rtl"] .kpi.red { border-right-color: var(--danger); }

/* section headings inside long master forms */
h3.form-section { font-size: 13px; text-transform: uppercase; letter-spacing: .4px; color: var(--wine); margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--wine-line); }
h3.form-section:first-of-type { margin-top: 4px; }

/* the small row editor (core.rows.RowsField) */
.rows-editor { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px 10px; background: var(--card); }
.rows-table { width: 100%; }
.rows-table th { padding: 4px 6px; font-size: 11px; }
.rows-table td { padding: 3px 4px; border-bottom: 0; }
.rows-table input { padding: 5px 8px; }

/* ---------------------------------------------------------------- icons: the sprite in core/_icons.html, used as {% icon "name" %} */
.ico-svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; vertical-align: middle; }
.ico { position: relative; display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; margin: 0; border-radius: 6px; border: 1px solid transparent; background: transparent; color: var(--royal); text-decoration: none; cursor: pointer; box-shadow: none; font-size: 0; line-height: 1; }
.ico::after { content: ""; position: absolute; inset: -2px; }                       /* a 32 px touch target around the 28 px icon */
.ico:hover { background: var(--royal-faint); border-color: var(--royal-line); color: var(--royal-dark); }
.ico:focus-visible { outline: 3px solid var(--royal-ring); outline-offset: 1px; border-color: var(--royal); }
.ico.wine { color: var(--wine); } .ico.wine:hover { background: var(--wine-faint); border-color: var(--wine-line); color: var(--wine-dark); }
.ico.whatsapp { color: #1f9d55; } .ico.whatsapp:hover { background: #e9f8ef; border-color: #b6e3c8; color: #167a41; }
.ico.warn { color: var(--warning); } .ico.warn:hover { background: var(--warning-soft); border-color: #ecd27a; color: #9a5b00; }
.ico[aria-disabled="true"], .ico:disabled, .ico.off { color: #aab3c8; background: transparent; border-color: transparent; cursor: not-allowed; }
.ico[aria-disabled="true"]:hover, .ico:disabled:hover, .ico.off:hover { background: transparent; border-color: transparent; color: #aab3c8; }
.ico .sdot { position: absolute; top: 1px; right: 1px; z-index: 1; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #fff; }
.ico .sdot.red { background: var(--danger); } .ico .sdot.yellow { background: #e8b100; } .ico .sdot.green { background: var(--success); }
.acts { display: inline-flex; align-items: center; gap: 2px; white-space: nowrap; }
.acts .sep { width: 1px; height: 18px; background: var(--line); margin: 0 3px; }
.export a.xb, .export button.xb { display: inline-grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 6px; }
.export .xb .ico-svg { width: 18px; height: 18px; }
.export .xb:focus-visible { outline: 3px solid var(--royal-ring); outline-offset: 1px; }
[dir="rtl"] .ico-svg.flip { transform: scaleX(-1); }

/* ---------------------------------------------------------------- tables that fit (core/tables.js adds the rest) */
table.data, table.samples { font-size: 13px; }
table.data th, table.data td, table.samples > thead > tr > th, table.samples > tbody > tr > td { padding: 6px 9px; vertical-align: top; }
table.data tbody tr:nth-child(even) { background: #fafbfe; }
table.data tbody tr:hover { background: var(--royal-faint); }
table.data thead th, table.samples > thead > tr > th { position: sticky; top: var(--app-h); z-index: 3; vertical-align: bottom; }
td.num, th.num, td.nowrap, th.nowrap, td.date { white-space: nowrap; }
.clamp3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden; max-width: clamp(26ch, 3vw, 46ch); overflow-wrap: anywhere; }
.scroll-x.fits, .scroll.fits { overflow: visible; }                                      /* nothing to scroll: the header can stick to the page */
.tbl-wrap.scrolling { overflow: auto; max-height: calc(100vh - var(--app-h) - 16px); }   /* wide table: it scrolls inside its own box ... */
.tbl-wrap.scrolling thead th { top: 0; }                                                  /* ... and the header sticks inside the box */
.topscroll { overflow-x: auto; overflow-y: hidden; height: 15px; margin: 0 0 2px; }      /* a second scrollbar at the top of a wide table */
.topscroll > div { height: 1px; }
table td.stick, table th.stick { position: sticky; z-index: 2; background: #fff; box-shadow: 1px 0 0 var(--line); }
table th.stick { z-index: 4; background: var(--royal-soft); }
table tbody tr:nth-child(even) td.stick, table.samples tbody.booking:nth-of-type(even) td.stick { background: #fafbfe; }
table tbody tr:hover td.stick, table.samples tbody.booking:hover td.stick { background: var(--royal-faint); }
@media print { table.data thead th, table.samples > thead > tr > th { position: static; } .topscroll { display: none; } .tbl-wrap.scrolling { max-height: none; overflow: visible; } table td.stick, table th.stick { position: static; box-shadow: none; } }

/* ---------------------------------------------------------------- chips: a status word as a coloured pill, and a collection centre in its own colour */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chip-s { display: inline-block; padding: 1px 9px; border-radius: 11px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eceff4; color: #4a5568; }
.chip-s.green { background: var(--success-soft); color: #17733d; } .chip-s.orange { background: var(--warning-soft); color: #9a5b00; }
.chip-s.red { background: var(--danger-soft); color: #a62319; } .chip-s.blue { background: var(--royal-soft); color: var(--royal-dark); }
.chip-s.wine { background: var(--wine-soft); color: var(--wine); } .chip-s.grey { background: #eceff4; color: #4a5568; }
.chip-c { --chip: var(--royal); display: inline-block; max-width: 17ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; padding: 1px 10px; border-radius: 11px; font-size: 12.5px; font-weight: 600; color: color-mix(in srgb, var(--chip) 62%, #000); border: 1px solid var(--chip); background: color-mix(in srgb, var(--chip) 11%, #fff); }

/* ---------------------------------------------------------------- the Report print window (results/_print_dialog.html) */
dialog.pd-dialog { width: min(1000px, 96vw); max-height: 94vh; overflow: auto; padding: 0; }
.pd { padding: 14px 20px 18px; }
.pd-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.pd-head h3 { margin: 0; font-size: 16px; }
.pd-tests th, .pd-tests td { padding: 6px 9px; font-size: 13px; vertical-align: top; }
.pd-tests .pd-check { width: 30px; text-align: center; }
.pd-tests tr.off td { color: var(--muted); }
.pd-why { display: block; max-width: 300px; margin-top: 2px; color: var(--muted); font-size: 11.5px; line-height: 1.3; }
.pd-note { display: flex; align-items: center; gap: 8px; margin: 10px 0 0; padding: 8px 12px; border-radius: 6px; background: var(--warning-soft); border: 1px solid #ecd27a; font-size: 13px; }
.pd-settings, .pd-share { border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px 12px; margin: 12px 0 0; }
.pd-settings legend, .pd-share legend { padding: 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--royal-deep); display: flex; align-items: center; gap: 6px; }
.pd-settings { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.pd-settings legend { width: auto; }
.pd-settings .hint { flex-basis: 100%; margin: 0; }
.pd-opt { display: inline-flex; align-items: center; gap: 6px; margin: 0; text-transform: none; letter-spacing: 0; font-size: 13.5px; font-weight: 500; color: var(--ink); }
.pd-opt[hidden] { display: none; }
.pd-opt select { width: auto; padding: 2px 6px; }
.pd-share .pd-opt { margin-right: 22px; }
.pd-phone { display: block; max-width: 340px; margin-top: 8px; }
.pd-phone input { margin-top: 3px; }
.pd.share-first .pd-share { border-color: #1f9d55; box-shadow: 0 0 0 3px rgba(31, 157, 85, .18); }
.pd.invoice-mode .pd-tests { opacity: .45; }
.pd-error { margin: 10px 0 0; padding: 7px 12px; border-radius: 6px; background: var(--danger-soft); }
.pd-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.pd-actions button { display: inline-flex; align-items: center; gap: 6px; }
.pd-actions .ico-svg { width: 18px; height: 18px; }
.pd-preparing { color: var(--royal, #2f5bd8); font-size: 13px; }
.pd-spinner { display: inline-block; width: 14px; height: 14px; margin-right: 6px; vertical-align: middle; border: 2px solid #cdd6e6; border-top-color: #2f5bd8; border-radius: 50%; animation: pd-spin .8s linear infinite; }
@keyframes pd-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .pd-spinner { animation: none; } }
