:root {
  --blue: #1f4e9c;
  --blue-dark: #163a75;
  --gold: #f2a900;
  --bg: #f4f6fa;
  --card: #ffffff;
  --line: #e2e7ef;
  --text: #1c2430;
  --muted: #6a7684;
  --green: #1a8f4c;
  --red: #c0392b;
  --amber: #b9770e;
  --shadow: 0 1px 3px rgba(20, 40, 80, 0.08), 0 6px 20px rgba(20, 40, 80, 0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--blue); }
button {
  font: inherit;
  cursor: pointer;
  border: none;
  border-radius: 7px;
  padding: 9px 15px;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
}
button:hover { background: var(--blue-dark); }
button.ghost { background: #eef1f7; color: var(--blue); }
button.ghost:hover { background: #e0e6f1; }
button.gold { background: var(--gold); color: #3a2a00; }
button.gold:hover { filter: brightness(0.95); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.sm { padding: 6px 11px; font-size: 13px; }
input, select, textarea {
  font: inherit;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
}
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.field { margin-bottom: 12px; }

/* Layout */
.topbar {
  background: var(--blue);
  color: #fff;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow);
}
.topbar .logo { font-weight: 800; letter-spacing: 0.5px; }
.topbar .logo b { color: var(--gold); }
.topbar nav { display: flex; gap: 4px; margin-left: 12px; }
.topbar nav a {
  color: #dce6f7; padding: 7px 12px; border-radius: 7px; cursor: pointer;
  font-weight: 600; text-decoration: none;
}
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,0.14); color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 13px; opacity: 0.9; }
.topbar .who .role { background: var(--gold); color:#3a2a00; padding:1px 8px; border-radius:20px; font-size:11px; font-weight:700; margin-left:6px; text-transform:uppercase; }

.wrap { max-width: 1080px; margin: 22px auto; padding: 0 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card h2 { margin: 0 0 14px; font-size: 17px; }
.card h3 { margin: 18px 0 8px; font-size: 14px; color: var(--blue-dark); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 720px){ .row, .row3 { grid-template-columns: 1fr; } }
.muted { color: var(--muted); }
.right { text-align: right; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex.wrap-actions { flex-wrap: wrap; }

/* Login */
.login-screen { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg,#1f4e9c,#163a75); }
.login-card { background:#fff; width: 360px; max-width: 92vw; border-radius: 14px; padding: 28px; box-shadow: 0 18px 50px rgba(0,0,0,0.3); }
.login-card .brand { text-align:center; margin-bottom: 6px; font-weight: 800; font-size: 20px; color: var(--blue); }
.login-card .brand b { color: var(--gold); }
.login-card .sub { text-align:center; color: var(--muted); margin-bottom: 20px; font-size: 13px; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
tr.clickable:hover { background: #f7f9fc; cursor: pointer; }

/* Badges */
.badge { display:inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: capitalize; }
.badge.draft { background:#eef1f7; color:#5a6577; }
.badge.under_checking { background:#fdf0d5; color: var(--amber); }
.badge.approved { background:#dff3e6; color: var(--green); }
.badge.issued { background:#dbeafe; color: var(--blue); }
.badge.revised { background:#f3e8ff; color:#7c3aed; }
.badge.cancelled { background:#fde2e1; color: var(--red); }
.result.Conforms { color: var(--green); font-weight:700; }
.result.incomplete { color: var(--amber); font-weight:700; }
.result { font-weight: 700; }
.result-does { color: var(--red); font-weight: 700; }

/* Tiles */
.tiles { display:grid; grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); gap: 14px; }
.tile { background:#fff; border:1px solid var(--line); border-radius:12px; padding:16px; }
.tile .n { font-size: 28px; font-weight: 800; color: var(--blue); }
.tile .l { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* Test cards */
.test { border:1px solid var(--line); border-radius:10px; margin-bottom:12px; overflow:hidden; }
.test .head { display:flex; align-items:center; gap:10px; padding:12px 14px; background:#f7f9fc; cursor:pointer; }
.test .head .seq { width:26px; height:26px; border-radius:50%; background:var(--blue); color:#fff; display:grid; place-items:center; font-weight:700; font-size:12px; flex:none; }
.test .head .title { flex:1; font-weight:600; }
.test .body { padding: 14px; border-top:1px solid var(--line); }
.et-table td, .et-table th { padding:6px; }
.et-table input { padding:6px 8px; }
.et-table input.exceed { color: var(--red); font-weight: 800; border-color: var(--red); background:#fff5f5; }
.ideal { color: var(--muted); font-size: 12px; white-space: nowrap; }
.result-select-does { color: var(--red); font-weight:700; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background:#1c2430; color:#fff; padding:11px 18px; border-radius:9px; box-shadow: var(--shadow); z-index: 50; font-weight:600; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
.spin { text-align:center; padding:40px; color:var(--muted); }
.hint { font-size:12px; color:var(--muted); margin-top:6px; }
.pill-src { background:#fde2e1; color:var(--red); padding:1px 8px;border-radius:20px;font-size:11px;font-weight:700;}

/* field rule hints + validation */
.rule-hint { font-size: 11px; color: var(--muted); margin-top: 3px; }
.rule-hint .req { color: var(--red); font-weight: 700; }
input.exceed, select.exceed { color: var(--red); font-weight: 700; border-color: var(--red); background:#fff5f5; }
label .req-star { color: var(--red); }

/* input + right-side expected-value badge */
.field-inline { display:flex; gap:8px; align-items:center; }
.field-inline > input, .field-inline > select { flex:1; min-width:0; }
.exp { flex:none; font-size:12px; font-weight:700; color: var(--blue-dark); background:#eef2fb;
  border:1px solid #dbe3f5; border-radius:6px; padding:5px 9px; white-space:nowrap; }
.exp.req { color: var(--amber); background:#fdf4e0; border-color:#f3e0b8; }
.editlink { font-size:12px; font-weight:700; color: var(--blue); cursor:pointer; margin-left:10px; }
.editlink:hover { text-decoration:underline; }
/* High / Low flag (like a pathology report's H/L) */
.hl-flag { flex:none; width:18px; text-align:center; font-weight:800; font-size:13px; }
.hl-flag.high, .hl-flag.low { color: var(--red); }

/* centered modal dialog */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,30,60,0.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 14px; max-width: 460px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden; }
.modal .m-head { padding: 16px 20px; font-weight: 800; font-size: 16px; display:flex; align-items:center; gap:10px; }
.modal .m-head.warn { background: #fdf0d5; color: var(--amber); }
.modal .m-body { padding: 16px 20px; }
.modal .m-body ul { margin: 8px 0 0; padding-left: 18px; }
.modal .m-body li { margin: 3px 0; }
.modal .m-foot { padding: 12px 20px 18px; text-align: right; }
