/* MLIMS design language
   A restrained clinical data-interface layer over the existing application.
   This file intentionally uses the existing class names so data and behavior stay intact. */
:root {
  --background: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --text-primary: #172033;
  --text-secondary: #526176;
  --text-muted: #7b8798;
  --border: #e2e7ee;
  --primary: #2563a8;
  --primary-hover: #1d4f87;
  --success: #247a52;
  --warning: #a66a16;
  --danger: #b74343;
  --info: #26758c;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 2px rgba(23, 32, 51, .03), 0 6px 18px rgba(23, 32, 51, .045);
}

html { font-size: 15px; }
body {
  background: var(--background);
  color: var(--text-primary);
}

/* App chrome */
.sid {
  background: #172334;
  border-right: 1px solid #26364a;
  box-shadow: 8px 0 24px rgba(23, 32, 51, .08);
}
.sid-brand { min-height: 68px; padding: 16px; border-bottom-color: #26364a; }
.sid-ico { border-radius: var(--radius-sm); }
.sid-txt h2 { font-size: .98rem; }
.sid-txt span { color: #93a4b8; }
.sid-nav { padding: 10px 8px; }
.nav-sec { padding: 16px 10px 6px; color: #8092a8; font-size: .66rem; }
.navi { margin: 2px 0; padding: 10px 12px; border-left: 3px solid transparent; border-radius: var(--radius-sm); color: #b4c0cf; }
.navi:hover { color: #fff; background: rgba(255,255,255,.06); }
.navi.act { color: #fff; background: rgba(54, 126, 194, .22); border-left-color: #5da2d8; }
.sid-foot { padding: 12px; border-top-color: #26364a; }
.topbar {
  height: 64px;
  padding: 0 28px;
  background: rgba(255,255,255,.96);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(23,32,51,.03);
  backdrop-filter: none;
}
.tb-left h1 { font-size: 1.08rem; font-weight: 650; }
.tb-left p { color: var(--text-muted); }
.ca { padding: 24px 28px 32px; }

/* Page headers */
.page-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 0 22px; }
.page-intro h2 { margin-top: 3px; font-size: 1.55rem; line-height: 1.2; letter-spacing: -.025em; font-weight: 700; }
.page-intro p { margin-top: 5px; color: var(--text-secondary); font-size: .88rem; }
.eyebrow { color: var(--primary); font-size: .68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.page-intro-meta { display: inline-flex; align-items: center; gap: 7px; color: var(--text-secondary); font-size: .78rem; white-space: nowrap; }
.page-intro-meta i { color: var(--success); }

/* Surfaces and hierarchy */
#pg-dashboard::before { display: none; }
.stat-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.sc, .dash-stat {
  --card-tint: #eef5fb;
  min-height: 138px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface) 56%, var(--card-tint) 150%);
  box-shadow: var(--shadow-card);
}
.sc::before { content: ''; position: absolute; width: 150px; height: 150px; right: -62px; top: -70px; border-radius: 50%; background: var(--card-tint); opacity: .85; pointer-events: none; }
.sc::after { display: none; }
#pg-dashboard .sc::before { inset: -70px -62px auto auto; width: 150px; height: 150px; background: var(--card-tint); opacity: .85; }
#pg-dashboard .sc::after { display: none; }
.sc.gn, .dash-stat.gn { --card-tint: #edf7f0; }
.sc.am, .dash-stat.am { --card-tint: #fff7e8; }
.sc.re, .dash-stat.re { --card-tint: #fdf0f0; }
.sc.pu, .dash-stat.pu { --card-tint: #eef5f7; }
.sc:hover { transform: translateY(-1px); border-color: #c9d5e2; box-shadow: 0 7px 20px rgba(23,32,51,.08); }
.sc-top, .dash-stat .sc-top { margin-bottom: 16px; }
.sc-ico, .dash-stat .sc-ico { width: 36px; height: 36px; border-radius: 8px; box-shadow: none; }
.sc-val, .dash-stat .sc-val { font-size: 1.85rem; font-weight: 700; letter-spacing: -.035em; }
.sc-lbl, .dash-stat .sc-lbl { margin-top: 7px; font-size: .78rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--text-secondary); }
.dash-grid { gap: 16px; }
.panel, .dash-panel, .tbar, .twrap, .inventory-sheet, .recv-card, .a-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}
.panel, .dash-panel { padding: 18px; }
.ptitle { margin-bottom: 14px; font-size: .92rem; }
.ptitle i { color: var(--primary); }

/* Controls */
.btn { border-radius: var(--radius-sm); box-shadow: none; }
.bp { background: var(--primary); }
.bp:hover:not(:disabled) { background: var(--primary-hover); }
.bo { background: var(--surface); border-color: #cfd8e3; color: var(--text-secondary); }
.bo:hover:not(:disabled) { background: #f4f7fa; border-color: #b7c6d6; }
.sbox, .flt, .ff input, .ff select, .ff textarea { border-color: #cfd8e3; border-radius: var(--radius-sm); }
.sbox:focus-within, .flt:focus, .ff input:focus, .ff select:focus, .ff textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,168,.11); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 2px solid #4c93ca; outline-offset: 2px; }

/* Tables and status */
.twrap { overflow: hidden; }
thead th { padding: 10px 12px; background: #f6f8fb; color: var(--text-secondary); border-bottom-color: var(--border); font-size: .7rem; }
tbody td { padding: 11px 12px; border-bottom-color: #edf0f4; font-size: .86rem; }
tbody tr:hover td { background: #f8fbfd; }
.bdg { padding: 4px 9px; border-radius: 999px; font-size: .72rem; font-weight: 650; }
.b-ok { background: #eaf5ef; color: #247a52; }
.b-low { background: #fff5df; color: #946017; }
.b-red { background: #fbecec; color: #b74343; }
.b-acc { background: #eaf2fa; color: #2563a8; }
.b-pur, .b-tl { background: #e8f4f5; color: #26758c; }
.b-grey { background: #eef1f4; color: #68778a; }

/* Analytics keeps its existing charts and filters, while sharing the same panel language. */
.analytics-filters, .analytics-tabbar { background: var(--surface); border-color: var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-card); backdrop-filter: none; }
.analytics-brand-badge { border-radius: 9px; background: var(--primary); box-shadow: none; }
.a-tab-btn.act { background: var(--primary); box-shadow: none; }
.a-card { background: var(--surface); }
.a-card-hd { padding: 14px 16px; }
.a-card-bd { padding: 15px 16px; }
.a-stat, .a-table-wrap, .a-empty, .a-error { border-radius: var(--radius-md); box-shadow: none; }
.a-stat { padding: 14px; }
.a-skel { border-radius: var(--radius-md); }

/* Responsive behavior */
@media (max-width: 1180px) { .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 768px) {
  .topbar { padding: 0 16px 0 58px; }
  .ca { padding: 18px 14px 24px; }
  .page-intro { align-items: flex-start; flex-direction: column; gap: 8px; margin-bottom: 18px; }
  .page-intro h2 { font-size: 1.35rem; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .sc, .dash-stat { min-height: 126px; padding: 15px; }
  .sc-val, .dash-stat .sc-val { font-size: 1.65rem; }
  .panel, .dash-panel { padding: 15px; }
  .dash-grid { gap: 12px; }
}
@media (max-width: 520px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page-intro-meta { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Dark theme: preserve semantic colors while stepping surfaces down together. */
html[data-theme="dark"] {
  --background: #0f1722; --surface: #172334; --surface-muted: #1d2b3c;
  --text-primary: #edf3f8; --text-secondary: #b2c0cf; --text-muted: #8495a8; --border: #2b3b4e;
  --primary: #67a5d5; --primary-hover: #82b9e0; --success: #63bf8d; --warning: #e2ad5d; --danger: #eb8585; --info: #6db9c5;
  --shadow-card: 0 1px 2px rgba(0,0,0,.18), 0 8px 20px rgba(0,0,0,.16);
  --bg: #0f1722; --sur: #172334; --sur2: #1d2b3c; --sur3: #243447; --bg2: #1a293a;
  --ink: #edf3f8; --ink2: #b2c0cf; --ink3: #8495a8; --ink4: #687b90;
  --acc: #67a5d5; --acc2: #82b9e0; --acc-s: rgba(103,165,213,.16); --grn: #63bf8d; --grn-s: rgba(99,191,141,.16);
  --amb: #e2ad5d; --amb-s: rgba(226,173,93,.16); --red: #eb8585; --red-s: rgba(235,133,133,.16);
  --pur: #7fc5c9; --pur-s: rgba(127,197,201,.16); --tl: #6db9c5; --tl-s: rgba(109,185,197,.16); --bdr: #2b3b4e; --bdr2: #3a4d62;
}
html[data-theme="dark"] body { background: var(--background); }
html[data-theme="dark"] .sid { background: #111c2b; border-right-color: #26384d; }
html[data-theme="dark"] .topbar { background: #172334; border-bottom-color: var(--border); }
html[data-theme="dark"] .icon-btn, html[data-theme="dark"] .sbox, html[data-theme="dark"] .flt,
html[data-theme="dark"] .ff input, html[data-theme="dark"] .ff select, html[data-theme="dark"] .ff textarea { background: #1d2b3c; color: var(--text-primary); border-color: var(--border); }
html[data-theme="dark"] .panel, html[data-theme="dark"] .dash-panel, html[data-theme="dark"] .tbar, html[data-theme="dark"] .twrap,
html[data-theme="dark"] .inventory-sheet, html[data-theme="dark"] .recv-card, html[data-theme="dark"] .a-card, html[data-theme="dark"] .a-stat,
html[data-theme="dark"] .a-table-wrap, html[data-theme="dark"] .a-empty, html[data-theme="dark"] .a-error,
html[data-theme="dark"] .analytics-filters, html[data-theme="dark"] .analytics-tabbar { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .sc, html[data-theme="dark"] .dash-stat { --card-tint: #21364a; background: linear-gradient(135deg, var(--surface) 0%, var(--surface) 58%, var(--card-tint) 150%); border-color: var(--border); }
html[data-theme="dark"] .sc.gn, html[data-theme="dark"] .dash-stat.gn { --card-tint: #203c37; }
html[data-theme="dark"] .sc.am, html[data-theme="dark"] .dash-stat.am { --card-tint: #403628; }
html[data-theme="dark"] .sc.re, html[data-theme="dark"] .dash-stat.re { --card-tint: #402d32; }
html[data-theme="dark"] thead th, html[data-theme="dark"] .a-table thead th { background: #1d2b3c; color: var(--text-secondary); border-bottom-color: var(--border); }
html[data-theme="dark"] tbody td, html[data-theme="dark"] .a-table tbody td { border-bottom-color: #26384b; }
html[data-theme="dark"] tbody tr:hover td, html[data-theme="dark"] .a-table tbody tr:hover td { background: #1d2d40; }
html[data-theme="dark"] .tfooter, html[data-theme="dark"] .mft, html[data-theme="dark"] .inventory-footer { background: #1d2b3c; border-color: var(--border); }
html[data-theme="dark"] .bo { background: transparent; color: var(--text-secondary); border-color: var(--border); }
html[data-theme="dark"] .bp, html[data-theme="dark"] .analytics-brand-badge, html[data-theme="dark"] .a-tab-btn.act { background: #3e7cad; color: #fff; }
html[data-theme="dark"] .mo.open { background: rgba(0,0,0,.68); }
html[data-theme="dark"] .md, html[data-theme="dark"] .load-card { background: var(--surface); color: var(--text-primary); }
html[data-theme="dark"] #login-screen { background: #0f1722; }
html[data-theme="dark"] .l-pane { background: #172334; }
html[data-theme="dark"] .lcard { background: #1d2b3c; border-color: var(--border); box-shadow: var(--shadow-card); }
html[data-theme="dark"] .lcard-head h3, html[data-theme="dark"] .l-mini-brand { color: var(--text-primary); }
html[data-theme="dark"] .lf input { background: #172334; color: var(--text-primary); border-color: var(--border); }
