:root {
  --bg: #1a1a2e;
  --chrome: #10101a;
  --surface: #22243a;
  --surface-2: #1a1f3a;
  --text: #e0e0e0;
  --muted: #a0a0a0;
  --accent: #00aaff;
  --accent-hover: #0080cc;
  --ok: #2a9d8f;
  --warn: #f59e0b;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --font: "Figtree", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--chrome);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: baseline;
  gap: 4px;
  text-decoration: none;
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0.04em;
}
.brand .mark { color: var(--accent); }
.brand small {
  margin-left: 8px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted);
  font-size: 12px;
}
.topbar-mid { flex: 1; display: flex; align-items: center; gap: 8px; color: var(--muted); }
.crumb { color: var(--muted); text-decoration: none; }
a.crumb:hover { color: var(--accent); }
.sep { opacity: 0.4; }
.pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 170, 255, 0.16);
  color: var(--accent);
}

.wrap { max-width: 1100px; margin: 0 auto; padding: 28px 20px 48px; }
.wrap-wide { max-width: none; padding: 28px 40px 48px; }
.page-head h1 { margin: 0 0 6px; font-size: 28px; }
.page-head p { margin: 0 0 16px; color: var(--muted); }
.filtros {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin: 0 0 18px;
}
.filtros label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.filtros select { min-width: 200px; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}
.fila { width: 100%; border-collapse: collapse; }
.fila th, .fila td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.fila th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.fila tr:last-child td { border-bottom: 0; }
.fila-recebidos {
  table-layout: fixed;
  width: 100%;
}
.fila-recebidos th, .fila-recebidos td {
  padding: 20px 32px;
  white-space: nowrap;
}
.fila-recebidos td:nth-child(2),
.fila-recebidos td:nth-child(3) {
  white-space: normal;
}
.row-link { cursor: pointer; }
.row-link:hover td { background: rgba(0, 170, 255, 0.08); }
.row-link:focus { outline: none; }
.row-link:focus td { background: rgba(0, 170, 255, 0.12); }
.muted { color: var(--muted); font-size: 13px; }

.status {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
}
.status-recebido { background: rgba(0, 170, 255, 0.16); color: var(--accent); }
.status-em_laudo { background: rgba(245, 158, 11, 0.18); color: var(--warn); }
.status-entregue { background: rgba(42, 157, 143, 0.18); color: var(--ok); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--accent-hover); color: #fff; }
.btn:disabled,
.btn.primary:disabled {
  opacity: 1;
  cursor: not-allowed;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border-color: var(--border);
}
.btn.ghost { background: transparent; }
.icon-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
}
.icon-btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.workstation {
  display: grid;
  grid-template-columns: minmax(340px, 42%) 1fr;
  gap: 12px;
  padding: 12px;
  height: calc(100vh - 56px);
}
.laudo-col, .imgs-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.laudo-col { overflow: hidden; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.card-head-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.patient { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.patient h1 { margin: 0; font-size: 20px; }
.patient p { margin: 4px 0 0; color: var(--muted); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 { margin: 0; font-size: 15px; }
.hint { margin: 8px 0 10px; color: var(--muted); font-size: 13px; }

.grupos details { border-top: 1px solid var(--border); }
.grupos summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 600;
}
.frases { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }
.frase {
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: inherit;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font: inherit;
}
.frase:hover { border-color: var(--accent); }
.frase strong { display: block; font-size: 13px; color: var(--accent); }
.frase span { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4; }

.editor { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.editor label { font-weight: 600; margin-bottom: 8px; }
.editor textarea {
  flex: 1 1 46%;
  min-height: 140px;
  resize: vertical;
  background: #12131f;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font: inherit;
  line-height: 1.5;
}
.editor textarea:focus { outline: 2px solid rgba(0, 170, 255, 0.35); }
.editor-tabs { display: flex; gap: 4px; }
.editor-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.editor-tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.editor-tab.is-active { color: var(--accent); background: rgba(0, 170, 255, 0.12); }
.editor-pane { display: none; flex: 1; min-height: 220px; flex-direction: column; gap: 10px; }
.editor-pane.is-active { display: flex; }
.editor-pane[hidden] { display: none !important; }
.editor-pane .facil {
  flex: 1 1 48%;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
}
.editor-pane .facil .hint { margin-top: 6px; }
.editor-pane .frase { background: #12131f; }
.editor-pane iframe {
  flex: 1;
  min-height: 280px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: #0b0c14;
}
.pill.demo { background: rgba(245, 158, 11, 0.18); color: var(--warn); }
.pill.live { background: rgba(42, 157, 143, 0.18); color: var(--ok); }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.export-row, .save-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.save-row { margin-top: 10px; justify-content: space-between; }

.viewport { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.viewport-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.stage {
  flex: 1;
  min-height: 280px;
  background: #05060c;
  border: 0;
  border-radius: 8px;
  padding: 0;
  cursor: zoom-in;
  overflow: hidden;
}
.stage img { width: 100%; height: 100%; object-fit: contain; display: block; }
.comentario { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 13px; font-weight: 600; }
.comentario input {
  font: inherit;
  font-weight: 400;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #12131f;
  color: var(--text);
}
.comentario input:focus { outline: 2px solid rgba(0, 170, 255, 0.35); }

.filmstrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.thumb {
  flex: 0 0 132px;
  border: 2px solid transparent;
  background: #05060c;
  color: var(--muted);
  border-radius: 8px;
  padding: 0 0 6px;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
}
.thumb img { width: 100%; height: 84px; object-fit: cover; display: block; border-radius: 6px 6px 0 0; }
.thumb span { display: block; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb.is-active { border-color: var(--accent); color: var(--text); }
.dicom-line { margin: 0; font-size: 12px; }

.lightbox { border: 0; padding: 0; background: rgba(0,0,0,0.86); max-width: 100vw; max-height: 100vh; width: 100%; height: 100%; }
.lightbox::backdrop { background: rgba(0,0,0,0.8); }
.lightbox form {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
}
.lightbox img { max-width: min(1200px, 92vw); max-height: 78vh; object-fit: contain; }
.lightbox p { margin: 0; color: var(--text); }

.topbar { height: auto; min-height: 56px; flex-wrap: wrap; }
.main-nav { display: flex; gap: 4px; }
.main-nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
}
.main-nav a:hover, .main-nav a.is-active { color: var(--text); background: rgba(255,255,255,0.06); }
.main-nav a.is-active { color: var(--accent); }
.status-designado { background: rgba(0, 170, 255, 0.16); color: var(--accent); }
.status-chamado { background: rgba(245, 158, 11, 0.18); color: var(--warn); }
.status-posicionado { background: rgba(42, 157, 143, 0.18); color: var(--ok); }
.status-em_exame_sala { background: rgba(42, 157, 143, 0.18); color: var(--ok); }
.status-liberado_sala { background: rgba(255,255,255,0.08); color: var(--muted); }
.status-assinado { background: rgba(42, 157, 143, 0.18); color: var(--ok); }
select, .sel-medico {
  font: inherit;
  background: #12131f;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.row-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.medico-switch { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.sala-grid, .medico-grid { display: grid; gap: 14px; }
.sala-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.medico-grid { grid-template-columns: minmax(280px, 0.9fr) 1.2fr; align-items: start; }
.sala-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.notify-list { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.notify-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--surface-2);
}
.notify-item.is-unread { border-color: var(--accent); }
.notify-item span, .notify-item small { color: var(--muted); font-size: 13px; }
.bell { position: relative; }
.bell summary { list-style: none; cursor: pointer; position: relative; padding: 6px 8px; color: var(--muted); }
.bell summary::-webkit-details-marker { display: none; }
.bell-count {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
}
.bell-list {
  position: absolute;
  right: 0;
  top: 40px;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow);
  z-index: 20;
}
.bell-list p { margin: 0 0 10px; font-size: 13px; }
.bell-list p.is-unread strong { color: var(--accent); }
.entregar .muted { margin: 10px 0 0; }
@media (max-width: 980px) {
  .medico-grid { grid-template-columns: 1fr; }
  .workstation { grid-template-columns: 1fr; height: auto; }
  .stage { min-height: 240px; }
}
