/* Quiet clinical reference look: system font, white surfaces, one petrol-blue accent.
   The only emphasis on screen is the link between an answer, its numbered sources and the highlight in the document. */
:root {
  --ink: #1d2733;
  --ink-2: #3c4856;
  --muted: #5f6b79;
  --rule: #d8dde3;
  --rule-soft: #e7eaee;
  --surface: #ffffff;
  --canvas: #eef1f4;
  --accent: #155a74;
  --accent-hover: #0f4659;
  --accent-tint: #e8f1f5;
  --notice: #fff8e1;
  --notice-rule: #e9cf7a;
  --highlight: rgba(255, 214, 10, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --bar-h: 52px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- app bar */
.appbar {
  height: var(--bar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}
.appbar-title { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.app-name { font-size: 16px; font-weight: 600; white-space: nowrap; }
.app-org { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-env { color: var(--muted); font-size: 13px; white-space: nowrap; }
.appbar-end { display: flex; align-items: center; gap: 16px; }
/* Vendor mark: monochrome, set apart from the hospital context by a thin rule. */
.brand {
  display: flex;
  align-items: center;
  padding-left: 16px;
  border-left: 1px solid var(--rule);
  color: var(--ink);
}
.brand:hover { color: #000; }
.brand-logo { display: block; height: 30px; width: auto; }

/* ---------------------------------------------------------------- layout */
.workspace {
  display: grid;
  grid-template-columns: minmax(440px, 5fr) 6fr;
  height: calc(100vh - var(--bar-h));
}
.query-pane {
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--rule);
  padding: 24px 28px 56px;
}
.document-pane { overflow: hidden; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- search */
.search { display: flex; gap: 8px; }
.search-field { position: relative; flex: 1; min-width: 0; }
.search-icon {
  position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round;
}
.search input {
  width: 100%;
  height: 44px;
  padding: 0 12px 0 38px;
  border: 1px solid #b9c1ca;
  border-radius: 4px;
  background: var(--surface);
  font-size: 16px;
}
.search input::placeholder { color: #8a95a2; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.search button {
  height: 44px;
  padding: 0 20px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.search button:hover { background: var(--accent-hover); }
.search button:disabled { opacity: .6; cursor: default; }

.examples { margin: 14px 0 0; }
.examples summary {
  width: fit-content;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
}
.examples ul { list-style: none; margin: 8px 0 0; padding: 0; }
.examples li + li { margin-top: 2px; }
.example {
  padding: 3px 0;
  border: 0;
  background: none;
  color: var(--accent);
  text-align: left;
  font-size: 14.5px;
}
.example:hover { text-decoration: underline; }

.result { margin-top: 26px; }
.hint { margin: 0; max-width: 62ch; color: var(--muted); font-size: 14.5px; }

/* ---------------------------------------------------------------- answer */
.question {
  margin: 0 0 10px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.35;
}
.answer { max-width: 68ch; font-size: 15.5px; line-height: 1.6; }
.answer p { margin: 0 0 10px; }
.answer ul, .answer ol { margin: 4px 0 12px; padding-left: 20px; }
.answer li { margin-bottom: 6px; padding-left: 2px; }
.answer li::marker { color: var(--muted); }

.refs { font-size: 0.72em; line-height: 0; }
/* inline-block with a real box, so the small superscript number is easy to hit */
.ref {
  display: inline-block;
  padding: 0 1px;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: inherit;
  font-weight: 600;
  line-height: 1.2;
}
.ref:hover, .ref.is-active { text-decoration: underline; }
.ref-sep { color: var(--muted); }

.notice {
  max-width: 68ch;
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--notice-rule);
  background: var(--notice);
  font-size: 14px;
  color: var(--ink-2);
}

.sources { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--rule-soft); }
.sources-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sources h3 { margin: 0; font-size: 15px; font-weight: 600; }
.sources-note { color: var(--muted); font-size: 13px; }
.source-list { list-style: none; margin: 10px 0 0; padding: 0; }
.source {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 4px;
  margin: 0 -10px;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
}
.source:hover { background: #f5f7f9; }
.source.is-active { background: var(--accent-tint); }
.source-num { color: var(--accent); font-weight: 600; }
.source-doc { font-weight: 600; }
.source-code { margin-right: 6px; }
.source-where { color: var(--muted); font-size: 13.5px; }
.source-quote {
  margin: 6px 0 0;
  padding-left: 10px;
  border-left: 2px solid var(--rule);
  color: var(--ink-2);
  font-size: 14px;
}
.source.is-active .source-quote { border-left-color: var(--accent); }

.empty {
  display: flex;
  gap: 10px;
  max-width: 62ch;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #f8f9fa;
}
.empty svg { flex: none; width: 18px; height: 18px; margin-top: 2px; fill: none; stroke: var(--muted); stroke-width: 1.6; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--rule); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error { max-width: 62ch; padding: 10px 12px; border-left: 3px solid #c0392b; background: #fdf1f0; font-size: 14px; }
.error small { display: block; margin-top: 4px; color: var(--muted); }

/* ---------------------------------------------------------------- document viewer */
.viewer { display: flex; flex-direction: column; height: 100%; }
.doc-head { padding: 16px 24px 14px; background: var(--surface); border-bottom: 1px solid var(--rule); }
.doc-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.doc-kind { color: var(--muted); font-size: 13px; }
.doc-title { margin: 2px 0 10px; font-size: 17px; font-weight: 600; line-height: 1.35; }
.doc-title .code { margin-right: 6px; }
.doc-meta { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; font-size: 13.5px; }
.doc-meta dt { color: var(--muted); }
.doc-meta dd { margin: 0; }
.doc-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--rule); border-radius: 4px;
  background: var(--surface); color: var(--ink-2);
  font-size: 13.5px; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #b9c1ca; color: var(--ink); }
.btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.btn-icon { width: 32px; padding: 0; justify-content: center; }
.source-pos { color: var(--muted); font-size: 13.5px; padding: 0 4px; }
.mobile-only { display: none; }

.pages { flex: 1; overflow-y: auto; padding: 20px 24px 64px; }
.page {
  position: relative;
  max-width: 820px;
  margin: 0 auto 16px;
  background: #fff;
  border: 1px solid var(--rule);
}
.page img { display: block; width: 100%; height: 100%; }
.page-num { position: absolute; right: 8px; bottom: 6px; color: #8a95a2; font-size: 11px; }
.hl { position: absolute; background: var(--highlight); mix-blend-mode: multiply; }

/* ---------------------------------------------------------------- document list */
.library { padding: 22px 24px; overflow-y: auto; }
.library h2 { margin: 0; font-size: 16px; font-weight: 600; }
.library p { margin: 4px 0 16px; color: var(--muted); font-size: 14px; }
.doc-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--rule); font-size: 14px; }
.doc-table th {
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  background: #f6f7f9;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}
.doc-table td { padding: 9px 12px; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.doc-table tbody tr { cursor: pointer; }
.doc-table tbody tr:hover { background: #f5f7f9; }
.doc-table tr.child td:first-child { padding-left: 28px; }
.doc-table tr.child td { color: var(--ink-2); }
.doc-table .code { font-weight: 600; white-space: nowrap; }
.doc-table .nowrap { white-space: nowrap; color: var(--muted); }

/* ---------------------------------------------------------------- login (hosted demo only) */
.login-body { min-height: 100vh; }
.login {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 100vh;
  padding: 32px 16px;
}
.login-box {
  width: 100%;
  max-width: 420px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.login-box h1 { margin: 0; font-size: 20px; font-weight: 600; line-height: 1.3; }
.login-box p { margin: 0 0 12px; color: var(--ink-2); font-size: 14px; }
.login-box .login-org { margin: 4px 0 18px; color: var(--muted); }
.login-box label { display: block; margin: 20px 0 6px; font-size: 14px; font-weight: 600; }
.login-box input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid #b9c1ca;
  border-radius: 4px;
  font-size: 16px;
}
.login-box input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.login-box button {
  width: 100%;
  height: 42px;
  margin-top: 16px;
  border: 1px solid var(--accent);
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.login-box button:hover { background: var(--accent-hover); }
.login-box .login-error { margin: 10px 0 0; color: #b0302a; font-size: 14px; }
.login-brand { display: block; color: var(--muted); }
.login-brand:hover { color: var(--ink); }
.login-logo { display: block; height: 28px; width: auto; }

/* ---------------------------------------------------------------- small screens */
@media (max-width: 1000px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .query-pane { border-right: 0; padding: 18px 16px 48px; min-height: calc(100vh - var(--bar-h)); }
  .doc-toolbar { flex-direction: column-reverse; gap: 10px; }
  .doc-actions { width: 100%; }
  .doc-actions [data-close] { margin-left: auto; }
  .doc-title { font-size: 16px; margin-bottom: 8px; }
  .doc-meta { font-size: 13px; }
  .doc-meta .secondary { display: none; }
  .app-org { display: none; }
  .app-env { display: none; }
  .brand { padding-left: 0; border-left: 0; }
  .brand-logo { height: 26px; }
  .appbar { padding: 0 16px; }
  .document-pane { position: fixed; inset: 0; z-index: 10; background: var(--canvas); display: none; }
  body.viewer-open .document-pane { display: flex; }
  body.viewer-open { overflow: hidden; }
  .doc-head { padding: 12px 16px; }
  .pages { padding: 12px 10px 48px; }
  .mobile-only { display: inline-flex; }
  .library { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}
