:root {
  --navy: #0d3857;
  --blue: #2b4872;
  --sky: #eaf4f8;
  --red: #df3f3f;
  --green: #1f8a70;
  --ink: #17212b;
  --muted: #667380;
  --line: #dbe3ea;
  --surface: #ffffff;
  --soft: #f5f8fa;
  --shadow: 0 18px 48px rgba(13, 56, 87, .13);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: Inter, Roboto, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(135deg, #ffffff 0%, #f7fbfe 44%, #e7f5fd 100%);
  letter-spacing: 0;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.login-screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    repeating-linear-gradient(135deg, rgba(13, 56, 87, .055) 0 1px, transparent 1px 9px),
    linear-gradient(135deg, #ffffff 0%, #f3f9fd 45%, #e6f4fb 100%);
  overflow: auto;
}
.login-shell {
  width: min(1220px, 100%);
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 22px;
  align-items: stretch;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}
.brand-lockup strong { display: block; font-size: 24px; line-height: 1; }
.brand-lockup small { display: block; color: var(--muted); margin-top: 4px; }
.brand-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 8px;
  background: white;
}
.rail .brand-logo {
  width: 42px;
  height: 42px;
}
.rail-head {
  display: grid;
  gap: 11px;
  align-items: start;
  min-width: 0;
  margin-bottom: 22px;
}
.rail-brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-name {
  display: block;
  color: var(--navy);
  font-size: 20px;
  line-height: 1.05;
}
.login-hero {
  display: grid;
  grid-template-columns: minmax(420px, 1.02fr) minmax(360px, .98fr);
  gap: 42px;
  align-items: center;
}
.login-visual {
  margin: 0;
  border-radius: 8px;
  overflow: hidden;
  min-height: 420px;
  box-shadow: 0 22px 60px rgba(43, 72, 114, .16);
  background: white;
}
.login-visual img {
  width: 100%;
  height: 100%;
  min-height: 420px;
  object-fit: cover;
  display: block;
  animation: hero-breathe 8s ease-in-out infinite;
  transform-origin: center;
}
@keyframes hero-breathe {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
.login-copy { color: var(--ink); max-width: 640px; justify-self: end; }
.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  font-weight: 800;
  font-size: 11px;
  color: var(--green);
  letter-spacing: .08em;
}
.login-copy .eyebrow { color: var(--green); }
h1, h2, h3, p { margin: 0; }
.login-copy h1 {
  font-size: clamp(42px, 5.8vw, 72px);
  line-height: .96;
  max-width: 680px;
  color: var(--navy);
}
.login-copy p:last-child {
  margin-top: 22px;
  color: var(--muted);
  font-size: 18px;
  max-width: 620px;
}
.login-panel {
  background: rgba(255,255,255,.96);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: minmax(360px, .9fr) minmax(420px, 1.1fr);
  gap: 16px;
  align-items: end;
}
.login-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}
.quick-access {
  display: grid;
  gap: 9px;
}
.quick-access p {
  color: var(--navy);
  font-weight: 800;
  font-size: 14px;
}
.field { display: grid; gap: 7px; }
.field label, .filter-builder span { color: var(--muted); font-size: 12px; font-weight: 700; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}
textarea { resize: vertical; min-height: 112px; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43,72,114,.12); }
.primary {
  border: 0;
  border-radius: 8px;
  background: var(--navy);
  color: white;
  padding: 12px 16px;
  font-weight: 800;
  min-height: 46px;
}
.primary:hover { background: #092d46; }
.access-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.access-list button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  background: var(--soft);
  min-height: 70px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.access-list button:hover {
  transform: translateY(-2px);
  border-color: var(--blue);
  box-shadow: 0 10px 24px rgba(43,72,114,.12);
}
.access-list b, .access-list span { display: block; }
.access-list span { color: var(--muted); font-size: 12px; margin-top: 3px; overflow-wrap: anywhere; }
.form-error { color: var(--red); min-height: 18px; font-size: 13px; grid-column: 1 / -1; }

.app {
  height: 100svh;
  min-height: 0;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  overflow: hidden;
  background:
    repeating-linear-gradient(135deg, rgba(13, 56, 87, .055) 0 1px, transparent 1px 9px),
    linear-gradient(135deg, #ffffff 0%, #f3f9fd 45%, #e6f4fb 100%);
}
.rail {
  background: rgba(255,255,255,.92);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-rows: auto 1fr;
  align-content: start;
}
nav { display: grid; gap: 6px; align-content: start; }
.nav-item {
  border: 0;
  border-radius: 8px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: var(--muted);
  text-align: left;
}
.nav-item.active, .nav-item:hover {
  background: var(--navy);
  color: white;
}
.switch-user {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.ui-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.content {
  min-width: 0;
  min-height: 0;
  padding: 22px 26px 3px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}
.user-pill {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
  margin-top: 0;
  padding: 10px 0 11px;
}
.user-pill strong,
.user-pill small {
  display: block;
  text-align: left;
}
.user-pill strong {
  color: var(--navy);
  font-size: 12px;
  line-height: 1.2;
}
.user-pill small {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}
.avatar-placeholder {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef4f6, #dfe9ef);
  color: var(--blue);
  border: 1px solid var(--line);
}
.avatar-placeholder .ui-icon {
  width: 16px;
  height: 16px;
}

.view { display: none; }
.view.active { display: block; animation: rise .22s ease both; min-height: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.workspace {
  display: none;
  grid-template-columns: minmax(350px, .86fr) minmax(520px, 1.14fr);
  gap: 18px;
  align-items: stretch;
  min-height: 0;
}
.workspace.active { display: grid; height: 100%; }
.history-view {
  display: none;
  grid-template-columns: minmax(300px, .72fr) minmax(560px, 1.28fr);
  gap: 18px;
  min-height: 0;
}
.history-view.active { display: grid; height: 100%; }
.query-column, .result-column, .secondary-layout, .history-column {
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(13,56,87,.07);
}
.result-slot {
  min-width: 0;
  min-height: 0;
  display: grid;
}
.result-slot .result-column {
  height: 100%;
}
.history-column {
  min-height: 0;
  overflow: hidden;
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}
.compact-title { margin-bottom: 0; }
.compact-title h3 { font-size: 22px; }
.history-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding-right: 4px;
}
.history-day {
  display: grid;
  gap: 7px;
}
.history-day-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.history-item {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  padding: 9px 10px;
  display: grid;
  gap: 4px;
  text-align: left;
}
.history-item.active {
  border-color: var(--navy);
  background: #eef6fb;
}
.history-item b {
  color: var(--navy);
  font-size: 12px;
}
.history-item span {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
}
.history-item small {
  color: var(--muted);
  font-size: 11px;
}
.history-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.query-column {
  padding: 16px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto auto auto;
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}
.result-column {
  padding: 18px;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
}
.query-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.query-tabs::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  flex: 0 0 auto;
}
.chip.active { background: var(--navy); color: white; border-color: var(--navy); }
.examples-title {
  text-align: center;
  color: var(--navy);
  font-size: 13px;
  line-height: 1.2;
  margin: 0;
}
.examples {
  display: grid;
  gap: 8px;
  justify-items: center;
}
.example {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: left;
  width: min(100%, 440px);
}
.example:hover { border-color: var(--blue); box-shadow: 0 8px 22px rgba(43,72,114,.09); }
.example span { display: block; color: var(--ink); font-size: 13px; line-height: 1.35; white-space: normal; overflow: visible; text-overflow: clip; }
.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}
.composer textarea {
  animation: query-pulse 2.8s ease-out infinite;
  min-height: 52px;
  max-height: 118px;
}
.composer textarea:focus {
  animation: none;
}
@keyframes query-pulse {
  0% {
    border-color: rgba(42, 111, 219, .46);
    box-shadow: 0 0 0 0 rgba(42, 111, 219, .38);
  }
  55% {
    border-color: rgba(42, 111, 219, .95);
    box-shadow:
      0 0 0 9px rgba(42, 111, 219, .16),
      0 0 0 18px rgba(42, 111, 219, .07);
  }
  100% {
    border-color: rgba(42, 111, 219, .46);
    box-shadow:
      0 0 0 18px rgba(42, 111, 219, 0),
      0 0 0 30px rgba(42, 111, 219, 0);
  }
}
.composer-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; align-self: center; }
.send-btn {
  border: 0;
  border-radius: 999px;
  width: 48px;
  height: 48px;
  background: var(--navy);
  color: white;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.send-btn:hover { background: #092d46; }
.send-btn .ui-icon {
  width: 20px;
  height: 20px;
}
.icon-btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  border-radius: 8px;
  width: 46px;
  height: 46px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
}
.chat-log {
  display: grid;
  gap: 10px;
  max-height: none;
  min-height: 0;
  align-content: start;
  overflow: auto;
  padding-right: 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}
.message {
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.4;
  font-size: 14px;
}
.message.user { background: var(--navy); color: white; margin-left: 34px; justify-self: end; max-width: 88%; }
.message.assistant { background: var(--sky); color: var(--ink); margin-right: 34px; justify-self: start; max-width: 92%; }
.bot-message {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
}
.bot-message small {
  display: block;
  color: var(--navy);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 3px;
}
.bot-message span {
  display: block;
}
.bot-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(43,72,114,.18);
  background: white;
}

.result-head { display: flex; justify-content: space-between; gap: 16px; align-items: start; margin-bottom: 14px; }
.result-head h3 { font-size: 24px; }
.result-actions { display: flex; align-items: center; gap: 8px; }
.mobile-flow-actions {
  display: none;
}
.result-tabs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding: 0 0 2px;
  overflow: visible;
}
.result-tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 9px 2px 10px;
  font-size: 12px;
  font-weight: 900;
}
.result-tabs button.active {
  background: transparent;
  color: var(--navy);
  border-bottom-color: var(--navy);
}
.result-tabs button:hover:not(.active) {
  border-bottom-color: var(--line);
  background: transparent;
  color: var(--navy);
}
.filter-btn, .ghost-btn {
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}
.filter-btn:hover, .ghost-btn:hover { border-color: var(--blue); }
.filter-btn.is-restricted {
  opacity: .62;
  border-style: dashed;
}
.small-primary {
  min-height: 36px;
  padding: 8px 12px;
  font-size: 12px;
}
.cache-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: var(--muted);
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 800;
}
.app-footer {
  padding-top: 8px;
  font-size: 9px;
  line-height: 1.25;
  color: var(--muted);
}
.app-footer a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: inherit;
  text-decoration: none;
}
.app-footer a:hover { color: var(--navy); }
.app-footer img {
  max-height: 30px;
  width: auto;
  display: block;
}
.result-intro {
  min-height: 0;
  border-radius: 8px;
  overflow: hidden;
  background: #edf6fb;
  display: grid;
}
.result-intro img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
  display: block;
}
.result-data {
  min-height: 0;
  overflow: hidden;
}
.result-panel {
  display: none;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
}
.result-panel.active {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.filter-popover {
  position: absolute;
  top: 64px;
  right: 18px;
  z-index: 8;
  width: min(520px, calc(100% - 36px));
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}
.filter-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.filter-grid label { display: grid; gap: 6px; }
.filter-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.filter-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.loading {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.9);
  z-index: 5;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 10px;
}
.loading strong { font-size: 22px; }
.loading span,
.loading-note {
  color: var(--muted);
}
.loading-note {
  display: block;
  max-width: 360px;
  font-size: 13px;
  line-height: 1.35;
}
.progress {
  width: 260px;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  justify-self: center;
}
.progress::before {
  content: "";
  display: block;
  height: 100%;
  width: 42%;
  background: var(--green);
  border-radius: inherit;
  animation: slide 1.1s ease-in-out infinite alternate;
}
@keyframes slide { from { transform: translateX(-20%); } to { transform: translateX(160%); } }
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.metric { background: white; padding: 13px; }
.metric b { display: block; font-size: 22px; color: var(--navy); }
.metric span { color: var(--muted); font-size: 12px; }
.mode-panel {
  display: grid;
  gap: 12px;
  align-content: start;
}
.panel-title {
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.patient-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  background: var(--line);
}
.patient-summary section {
  background: white;
  padding: 12px;
}
.patient-summary b,
.evidence-panel b,
.source-links b {
  color: var(--navy);
}
.patient-summary p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.case-timeline,
.semantic-doc-list {
  display: grid;
  gap: 8px;
}
.timeline-events,
.doc-results {
  display: grid;
  gap: 8px;
}
.timeline-events article,
.doc-results article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.86);
  padding: 11px 12px;
}
.timeline-events article {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 12px;
  border-left: 3px solid var(--green);
}
.timeline-events time,
.doc-results span,
.timeline-events small,
.doc-results small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.timeline-events b,
.doc-results b {
  color: var(--navy);
}
.timeline-events p,
.doc-results p {
  margin-top: 5px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}
.doc-results article {
  display: grid;
  gap: 6px;
}
.doc-results span,
.doc-results small {
  display: block;
  margin-top: 3px;
}
.evidence-list {
  display: grid;
  gap: 8px;
}
.evidence-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255,255,255,.82);
  padding: 11px 12px;
}
.evidence-list header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.evidence-list header span {
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}
.evidence-list p {
  margin-top: 7px;
  color: var(--ink);
  line-height: 1.45;
  font-size: 13px;
}
.evidence-list small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}
.snippet-actions {
  display: flex;
  gap: 7px;
  margin-top: 9px;
}
.snippet-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
  color: var(--muted);
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 800;
  cursor: not-allowed;
  opacity: .72;
}
mark {
  background: #d9efff;
  color: var(--navy);
  border-radius: 3px;
  padding: 0 2px;
}
.source-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.source-links a {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
  background: var(--soft);
}
.source-links a:hover {
  border-color: var(--blue);
}
.source-links span {
  color: var(--muted);
  font-size: 12px;
}
.audit-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
  padding: 11px 12px;
  display: grid;
  gap: 7px;
}
.audit-note b {
  color: var(--navy);
  font-size: 12px;
  text-transform: uppercase;
}
.audit-note ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.audit-note p {
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
}
.visual-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  align-content: start;
  min-height: 0;
}
canvas {
  width: 100%;
  height: 220px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfe;
}
.table-wrap {
  min-height: 0;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.table-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  min-height: 0;
  flex: 1 1 auto;
}
.table-toolbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 0 8px;
  background: rgba(255,255,255,.98);
  border-bottom: 1px solid var(--line);
}
.table-title {
  color: var(--navy);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  margin: 0;
}
table { border-collapse: collapse; width: 100%; min-width: 0; table-layout: fixed; background: white; }
th, td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
  vertical-align: top;
  overflow-wrap: anywhere;
}
th {
  color: var(--muted);
  background: var(--soft);
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: auto;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 0;
  color: var(--muted);
  font-size: 12px;
  flex: 0 0 auto;
}
.pagination button {
  border: 1px solid var(--line);
  background: white;
  color: var(--navy);
  border-radius: 8px;
  padding: 7px 10px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.pagination .ui-icon {
  width: 15px;
  height: 15px;
}
.pagination button:disabled {
  opacity: .45;
  cursor: default;
}
.secondary-layout { padding: 22px; overflow: auto; }
.section-title { margin-bottom: 18px; }
.section-title h3 { font-size: 28px; }
.filter-builder {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.filter-builder label { display: grid; gap: 7px; }
.rule-board, .case-layout, .audit-table {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}
.rule-board { grid-template-columns: repeat(3, 1fr); }
.rule-board article, .timeline-list div, .summary-note, .audit-table div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 14px;
}
.rule-board b, .timeline-list b, .summary-note b, .audit-table b { display: block; color: var(--navy); }
.rule-board span, .timeline-list span, .summary-note p, .audit-table span { display: block; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.case-layout { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.timeline-list { display: grid; gap: 10px; }
.audit-table div { display: grid; grid-template-columns: 80px minmax(0, 1fr) 90px; gap: 12px; align-items: center; }
.audit-table em {
  justify-self: end;
  font-style: normal;
  color: var(--green);
  font-weight: 800;
}

@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; overflow: auto; }
  .rail {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-rows: auto auto;
    gap: 12px;
    overflow: visible;
    padding: 14px 18px;
  }
  .rail-head { margin-bottom: 0; }
  nav { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .switch-user { margin-top: 0; border-top: 0; padding-top: 11px; }
  .nav-item { justify-content: center; }
  .nav-item b { display: none; }
  .workspace.active, .history-view.active, .login-hero, .login-panel, .visual-row, .case-layout { grid-template-columns: 1fr; }
  .workspace.active { height: auto; }
  .login-copy { justify-self: start; }
  .login-fields { grid-template-columns: 1fr 1fr; }
  .login-fields .primary { grid-column: 1 / -1; }
  .user-pill { justify-content: flex-start; }
  .user-pill strong, .user-pill small { text-align: left; }
}

@media (max-width: 720px) {
  .app {
    height: 100svh;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
  }
  .login-screen { padding: 16px; }
  .login-shell { gap: 16px; }
  .login-visual { min-height: 280px; }
  .login-visual img { min-height: 280px; }
  .login-copy h1 { font-size: 40px; }
  .login-fields, .access-list { grid-template-columns: 1fr; }
  .rail {
    padding: 10px 10px 8px;
    gap: 8px;
  }
  .rail-head {
    gap: 8px;
  }
  .rail .brand-logo {
    width: 38px;
    height: 38px;
  }
  .brand-name {
    font-size: 17px;
  }
  .user-pill {
    gap: 6px;
    margin-top: 0;
  }
  .avatar-placeholder {
    width: 26px;
    height: 26px;
  }
  .avatar-placeholder .ui-icon {
    width: 14px;
    height: 14px;
  }
  .user-pill strong {
    font-size: 11px;
  }
  .user-pill small {
    font-size: 10px;
  }
  nav {
    gap: 4px;
  }
  .nav-item {
    min-height: 40px;
    padding: 8px 5px;
  }
  .nav-item .ui-icon {
    width: 17px;
    height: 17px;
  }
  .content {
    min-height: 0;
    overflow: hidden;
    padding: 10px 10px 3px;
  }
  .workspace.active {
    height: 100%;
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 0;
  }
  .history-view.active {
    height: 100%;
    min-height: 0;
    gap: 10px;
  }
  .workspace[data-mobile-panel="result"] .query-column,
  .workspace[data-mobile-panel="query"] .result-slot {
    display: none;
  }
  .query-column,
  .result-column,
  .history-column {
    height: 100%;
    min-height: 0;
    box-shadow: 0 8px 22px rgba(13,56,87,.08);
  }
  .query-column {
    grid-template-rows: minmax(0, 1fr) auto auto auto auto;
    gap: 10px;
    padding: 12px;
  }
  .result-column {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px;
  }
  .query-tabs {
    gap: 4px;
    padding-bottom: 2px;
  }
  .chip {
    padding: 6px 8px;
    font-size: 11px;
  }
  .chat-log {
    padding-bottom: 10px;
  }
  .examples {
    gap: 6px;
  }
  .example {
    padding: 8px 10px;
  }
  .example span {
    font-size: 12px;
    line-height: 1.28;
  }
  .composer textarea {
    min-height: 86px;
    max-height: 140px;
  }
  .result-head {
    align-items: center;
    margin-bottom: 0;
  }
  .result-head h3 {
    font-size: 18px;
    line-height: 1.2;
  }
  .result-actions {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .filter-btn,
  .ghost-btn {
    padding: 7px 8px;
    font-size: 11px;
    gap: 5px;
  }
  .filter-btn .ui-icon,
  .ghost-btn .ui-icon {
    width: 15px;
    height: 15px;
  }
  .result-tabs {
    gap: 18px;
  }
  .result-tabs button {
    font-size: 11px;
    padding-bottom: 8px;
  }
  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }
  .pagination {
    width: 100%;
    justify-content: space-between;
  }
  .result-intro {
    height: 100%;
  }
  .result-data {
    min-height: 0;
  }
  .mobile-flow-actions {
    display: flex;
    justify-content: center;
    padding-top: 10px;
  }
  .mobile-flow-actions .primary,
  .mobile-flow-actions .filter-btn {
    min-height: 44px;
    justify-content: center;
    min-width: 160px;
  }
  .result-column.has-results .mobile-start,
  .result-column:not(.has-results) .mobile-to-query,
  .result-column.is-loading .mobile-flow-actions {
    display: none;
  }
  .metrics-grid, .filter-builder, .filter-grid, .rule-board, .patient-summary, .source-links { grid-template-columns: 1fr; }
  .composer-actions { align-items: stretch; }
  .composer { grid-template-columns: 1fr auto; }
  .secondary-layout {
    height: 100%;
  }
}
