:root {
  color-scheme: dark;
  --blue: #305c86;
  --blue2: #3974aa;
  --panel: #171b20;
  --line: #303943;
  --muted: #96a6b5;
  --green: #31c48d;
  --red: #ef6461;
}
@media print {
  body.no-export { visibility: hidden !important; }
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #0b0d10;
  color: #edf3f8;
  font:
    14px/1.4 Inter,
    system-ui,
    -apple-system,
    sans-serif;
}
.session-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  background: #0b0d10;
  text-align: center;
}
.session-view h1, .session-view p { margin: 0; }
.session-view p { color: var(--muted); }
.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top, #18324a, #0b0d10 55%);
}
.auth-card {
  width: min(420px, 100%);
  display: grid;
  gap: 16px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #141a20;
  box-shadow: 0 24px 70px #0008;
}
.auth-card h1, .auth-card p { margin: 0; }
.auth-card label, .user-form > label { display: grid; gap: 6px; color: var(--muted); }
.auth-card input, .user-form input, .study-assignment input { accent-color: var(--blue2); }
.auth-card input, .user-form > label > input, .study-assignment-search {
  background: #0e1216; border: 1px solid #3b4651; color: #fff; padding: 10px; border-radius: 4px;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar {
  height: 58px;
  background: #10151b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 18px;
}
.brand small {
  color: var(--muted);
  font-size: 12px;
}
.menu {
  font-size: 20px;
}
.status {
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #8b949e;
}
.dot.ok {
  background: var(--green);
}
.worklists {
  height: 48px;
  background: var(--blue);
  display: flex;
  align-items: end;
  padding: 0 28px;
  gap: 6px;
}
.worklists button {
  border: 0;
  background: transparent;
  color: #c7d5e1;
  padding: 14px 20px 11px;
  text-transform: uppercase;
  font-weight: 650;
  border-bottom: 3px solid transparent;
}
.worklists button.active {
  color: #fff;
  border-color: #fff;
  background: #254d72;
}
main {
  padding: 18px;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px;
  margin-bottom: 14px;
}
.filters label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
}
.filters input,
.filters select,
.page-size select,
.sync-options-grid input,
.sync-options-grid select {
  background: #0e1216;
  border: 1px solid #3b4651;
  color: #fff;
  padding: 9px;
  border-radius: 4px;
  min-width: 150px;
}
.worklist-filters {
  display: grid;
  grid-template-columns: minmax(230px, 1.5fr) repeat(5, minmax(130px, 1fr));
}
.worklist-filters .filter-search,
.worklist-filters .date-range-filter {
  grid-column: span 2;
}
.worklist-filters button,
.worklist-filters .sync-state,
.worklist-filters .saved-view-control {
  align-self: end;
}
.saved-view-control {
  display: grid;
  gap: 6px;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
}
.saved-view-control select {
  background: #0e1216;
  border: 1px solid #3b4651;
  color: #fff;
  padding: 9px;
  border-radius: 4px;
  min-width: 150px;
}
.date-range-filter span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.date-range-filter input {
  min-width: 135px;
  width: 100%;
}
button {
  cursor: pointer;
  border: 1px solid #44515e;
  background: #222932;
  color: #fff;
  border-radius: 4px;
  padding: 8px 12px;
  font-weight: 650;
}
button:hover {
  border-color: #6b7c8d;
}
.primary {
  background: var(--blue2);
  border-color: #4385c2;
}
.secondary {
  background: #202730;
}
.sync-state {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 2px;
  color: var(--muted);
}
.pagination-summary {
  min-width: 190px;
}
.page-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  flex: 1;
}
.page-buttons button {
  min-width: 38px;
}
.page-buttons .page-number.active {
  background: var(--blue2);
  border-color: #5b98d0;
}
.page-buttons button:disabled,
button:disabled {
  cursor: not-allowed;
  opacity: .45;
}
.page-ellipsis {
  padding: 0 3px;
}
.page-size {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.page-size select {
  min-width: 72px;
  padding: 7px;
}
.sync-dialog {
  width: min(760px, 94vw);
}
.columns-dialog {
  width: min(620px, 94vw);
}
.users-dialog { width: min(1180px, 96vw); max-height: 92vh; }
.users-layout { display: grid; grid-template-columns: 240px 1fr; gap: 18px; margin-top: 20px; }
.users-layout > aside { border-right: 1px solid var(--line); padding-right: 14px; }
.users-list { display: grid; gap: 6px; margin-top: 12px; }
.users-list button { display: grid; gap: 2px; text-align: left; }
.users-list button.active { background: var(--blue); }
.users-list small, .user-form small, .study-assignment small { color: var(--muted); }
.user-form { display: grid; gap: 14px; }
.user-form fieldset { border: 1px solid var(--line); padding: 14px; }
.user-form legend { color: #cbd9e4; padding: 0 6px; font-weight: 650; }
.switch-row { display: flex; align-items: center; gap: 8px; margin: 8px 0; color: #d8e3eb; }
.study-assignments { max-height: 300px; overflow: auto; display: grid; gap: 5px; margin-top: 10px; }
.study-assignment { display: flex; gap: 9px; align-items: start; padding: 8px; background: #11171c; border: 1px solid #28333d; }
.study-assignment span { display: grid; gap: 2px; }
.assignment-filters { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 10px; }
.assignment-filters label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; text-transform: uppercase; }
.assignment-filters input, .assignment-filters select { min-width: 0; width: 100%; background: #0e1216; border: 1px solid #3b4651; color: #fff; padding: 8px; border-radius: 4px; }
.assignment-search { grid-column: span 2; }
.assignment-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.assignment-actions .dialog-hint { margin-left: auto; }
.danger { background: #742b2b; border-color: #a54545; margin-right: auto; }
.report-dialog { width: min(1380px, 96vw); height: 92vh; max-width: 96vw; max-height: 94vh; padding: 16px; overflow: hidden; }
.report-dialog > h2 { margin: 0 36px 14px 0; font-size: 18px; }
.report-dialog #panelBody { height: calc(100% - 44px); }
.report-viewer { height: 100%; display: grid; grid-template-columns: 230px minmax(0, 1fr); border: 1px solid #3c4650; background: #eef0f2; }
.report-sidebar { overflow: auto; background: #20262c; border-right: 1px solid #3c4650; padding: 0; }
.report-sidebar-heading { padding: 13px 14px; color: #cbd2d9; font-size: 12px; font-weight: 650; text-transform: uppercase; border-bottom: 1px solid #3c4650; }
.report-entry { display: flex; flex-direction: column; gap: 5px; width: 100%; padding: 15px 14px; text-align: left; border: 0; border-bottom: 1px solid #3c4650; border-radius: 0; background: transparent; color: #dce2e8; }
.report-entry:hover { background: #303942; }
.report-entry.active { background: #365c78; box-shadow: inset 3px 0 #8fc5ed; }
.report-entry-date { font-size: 13px; }
.report-entry-age { font-size: 12px; }
.report-entry strong { font-size: 12px; font-weight: 550; }
.report-entry small { color: #c8d0d9; font-size: 10px; }
.report-document { min-width: 0; height: 100%; }
.report-document iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
.report-empty { padding: 24px; }
@media (max-width: 640px) { .report-viewer { grid-template-columns: 150px minmax(0, 1fr); } .report-entry { padding: 12px 9px; } }
.restricted-filters { justify-content: flex-start; }
.restricted-filters label { min-width: min(520px, 100%); }
.restricted-filters input { width: 100%; }
.sync-dialog form {
  margin: 0;
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}
.dialog-heading h2 {
  margin: 0 0 4px;
  font-size: 20px;
}
.dialog-heading p,
.dialog-hint {
  margin: 0;
  color: var(--muted);
}
.sync-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0 12px;
}
.sync-options-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.column-choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 22px 0 12px;
}
.column-choices label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #141a20;
  color: #d8e3eb;
}
.column-choices input {
  accent-color: var(--blue2);
}
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
}
@media (max-width: 1200px) {
  .worklist-filters { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
}
@media (max-width: 760px) {
  .worklist-filters { grid-template-columns: 1fr; }
  .worklist-filters .filter-search,
  .worklist-filters .date-range-filter { grid-column: auto; }
  .pagination { align-items: stretch; flex-direction: column; }
  .page-buttons { justify-content: flex-start; overflow-x: auto; }
  .sync-options-grid { grid-template-columns: 1fr; }
  .column-choices { grid-template-columns: 1fr; }
  .users-layout { grid-template-columns: 1fr; }
  .users-layout > aside { border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 14px; }
  .assignment-filters { grid-template-columns: 1fr; }
  .assignment-search { grid-column: auto; }
}
.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  background: var(--panel);
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 950px;
}
th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #29313a;
  text-align: left;
}
th {
  color: #aac0d1;
  font-size: 11px;
  text-transform: uppercase;
  background: #12171c;
  position: sticky;
  top: 0;
}
tr:hover td {
  background: #1b232b;
}
#studies tr[data-study] {
  cursor: default;
}
.local-yes {
  color: var(--green);
}
.local-no {
  color: var(--muted);
}
h2 {
  font-size: 16px;
  margin: 22px 0 10px;
}
.accession {
  display: block;
  color: var(--muted);
  margin-top: 2px;
  font-size: 11px;
}
.case-status {
  display: inline-block;
  min-width: 66px;
}
.case-status.complete {
  color: var(--green);
}
.case-status.partial {
  color: #f5b942;
}
.case-status.data-only {
  color: #5c9bd5;
}
.case-status.remote {
  color: var(--muted);
}
.row-actions {
  white-space: nowrap;
}
.row-actions button + button {
  margin-left: 6px;
}
.hidden {
  display: none !important;
}
.notice {
  padding: 10px 12px;
  margin: 0 0 12px;
  background: #263341;
  border-left: 3px solid #5c9bd5;
}
.notice.error {
  border-color: var(--red);
}
.viewer-view {
  position: fixed;
  inset: 0;
  background: #060708;
  z-index: 5;
}
.viewer-header {
  height: 62px;
  background: #303030;
  display: flex;
  align-items: center;
  padding: 0 4px;
  border-bottom: 1px solid #202020;
  position: relative;
}
.header-plus {
  border: 0;
  background: transparent;
  padding: 0;
  width: 18px;
  min-width: 18px;
  font-size: 19px;
  align-self: flex-start;
  margin-top: 1px;
}
.case-identity {
  width: 410px;
  align-self: flex-start;
  padding-top: 3px;
  display: grid;
  grid-template-columns: 108px 1fr;
  grid-template-rows: 15px 15px;
  column-gap: 2px;
  font: 700 11px/13px Arial, sans-serif;
  white-space: nowrap;
  overflow: hidden;
}
#caseTitle {
  grid-row: 1 / 3;
  overflow: hidden;
  text-overflow: ellipsis;
}
#caseDescription,
#caseDate {
  overflow: hidden;
  text-overflow: ellipsis;
}
.viewer-header small {
  display: block;
  color: #fff;
}
.clinical-tools {
  position: absolute;
  left: 458px;
  top: 32px;
  display: flex;
  gap: 3px;
  white-space: nowrap;
}
.clinical-tools button {
  height: 29px;
  min-width: 29px;
  padding: 2px 5px;
  border-radius: 0;
  border-color: #666;
  background: #383838;
  font: 700 14px Arial, sans-serif;
}
.clinical-tools button.active {
  background: #1717e8;
  border-color: #3131ff;
}
.clinical-tools .wide-tool {
  min-width: 68px;
  text-align: left;
}
.viewer-exit {
  margin-left: auto;
  display: flex;
  gap: 1px;
  align-self: flex-start;
  padding-top: 27px;
}
.viewer-exit button {
  border: 0;
  background: transparent;
  padding: 0;
  min-width: 26px;
  height: 31px;
  font: 700 31px/28px Arial, sans-serif;
}
.viewer-shell {
  height: calc(100vh - 62px);
  display: grid;
  grid-template-columns: 96px 1fr;
}
.viewer-shell aside {
  background: #080808;
  border-right: 1px solid #303030;
  overflow: hidden auto;
}
.series-card {
  height: 82px;
  padding: 1px 3px 3px;
  border: 1px dotted transparent;
  cursor: pointer;
  position: relative;
}
.series-card.active {
  border-color: #f00000;
}
.series-card.loaded:not(.active) {
  border-color: #dfdf00;
}
.series-card img {
  width: 100%;
  height: 65px;
  object-fit: contain;
  background: #000;
}
.series-title {
  display: block;
  height: 13px;
  font: 10px/12px Arial, sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thumb-wrap {
  height: 65px;
  position: relative;
}
.pending-label {
  display: grid;
  place-items: center;
  width: 100%;
  height: 65px;
  background: repeating-linear-gradient(135deg, #111 0 7px, #181818 7px 14px);
  color: #8e8e8e;
  font: 9px Arial, sans-serif;
  text-transform: uppercase;
}
.series-state {
  position: absolute;
  right: -2px;
  bottom: -3px;
  font: 700 23px/18px Arial, sans-serif;
  text-shadow: 0 1px 1px #000;
}
.series-state.ok {
  color: #00d900;
}
.series-state.off {
  color: #ff2929;
}
.viewport-area {
  display: block;
  min-width: 0;
  min-height: 0;
}
.viewport-grid {
  display: grid;
  background: #000;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.viewport-grid.one-up {
  grid-template-columns: 1fr;
}
.viewport-grid.four-up {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}
.viewport {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid #282828;
  min-height: 0;
}
.viewport.active {
  border: 1px dashed #ef1515;
  z-index: 1;
}
.viewport-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  opacity: 0;
  transition: opacity 70ms linear;
  will-change: opacity;
}
.viewport-image.is-visible {
  opacity: 1;
}
.overlay {
  position: absolute;
  z-index: 2;
  font: 700 10px/11px Arial, sans-serif;
  color: white;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}
.overlay-top-left {
  top: 3px;
  left: 7px;
  text-align: left;
}
.overlay-top-right {
  top: 3px;
  right: 7px;
  text-align: right;
}
.overlay-bottom-right {
  bottom: 8px;
  right: 7px;
  text-align: right;
}
.series-name {
  position: absolute;
  z-index: 2;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font: 700 10px/11px Arial, sans-serif;
  white-space: nowrap;
  pointer-events: none;
}
.orientation {
  position: absolute;
  z-index: 2;
  font: 700 10px Arial, sans-serif;
  pointer-events: none;
}
.orientation-top {
  top: 3px;
  left: 50%;
}
.orientation-left {
  top: 50%;
  left: 3px;
}
.orientation-right {
  top: 50%;
  right: 3px;
}
.scale-ruler {
  position: absolute;
  z-index: 2;
  top: 50%;
  right: 7px;
  width: 24px;
  height: 134px;
  transform: translateY(-50%);
  border-right: 1px solid #fff;
  background: repeating-linear-gradient(to bottom, transparent 0 8px, #fff 8px 9px) right/10px 100% no-repeat;
  opacity: 0.9;
  pointer-events: none;
}
.pane-status {
  position: absolute;
  z-index: 2;
  left: 7px;
  bottom: 6px;
  width: 15px;
  height: 15px;
  background: #00ed17;
  pointer-events: none;
}
.scrubber {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: #161a1f;
}
@media (max-width: 1100px) {
  .case-identity { width: 310px; grid-template-columns: 100px 1fr; }
  .clinical-tools { left: 50%; transform: translateX(-43%) scale(.88); transform-origin: center bottom; }
  .overlay { font-size: 9px; line-height: 10px; }
}
.scrubber input {
  flex: 1;
}
.scrubber span {
  min-width: 110px;
  text-align: right;
}
.close {
  float: right;
  font-size: 22px;
  padding: 0 8px;
}
dialog {
  width: min(760px, 90vw);
  max-height: 80vh;
  overflow: auto;
  background: #20252b;
  color: #fff;
  border: 1px solid #596673;
  border-radius: 8px;
}
dialog::backdrop {
  background: #000b;
}
dialog pre {
  white-space: pre-wrap;
  background: #111820;
  padding: 14px;
  border-radius: 4px;
}
dialog a {
  color: #80bfff;
}
.viewer-context-root { position: fixed; inset: 0; z-index: 1000; pointer-events: none; }
.viewer-context-panel { position: fixed; width: 236px; max-width: calc(100vw - 8px); max-height: calc(100vh - 8px); overflow-y: auto; background: #898989; border: 1px solid #555; box-shadow: 2px 3px 10px #0008; padding: 2px 0; pointer-events: auto; font: 14px/22px Arial,sans-serif; }
.viewer-menu-item { display: block; position: relative; width: 100%; min-height: 25px; border: 0; border-radius: 0; background: transparent; color: #fff; padding: 1px 20px 1px 8px; text-align: left; font: inherit; cursor: pointer; }
.viewer-menu-item:hover, .viewer-menu-item:focus { background: #236d39; outline: 1px solid #b9edc9; outline-offset: -1px; }
.viewer-menu-item[aria-disabled="true"] { color: #e0e0e0; cursor: help; }
.menu-arrow { position: absolute; right: 8px; top: 0; }
.menu-reason { display: none; font-size: 11px; line-height: 14px; color: #fff; }
.viewer-menu-item[aria-disabled="true"]:focus .menu-reason { display: block; }
.viewer-annotations { position: absolute; top: 50%; left: 50%; z-index: 1; pointer-events: none; overflow: visible; transform-origin: center; }
.viewport.annotation-tool { cursor: crosshair; }
.study-id-badge { display: none; position: absolute; z-index: 3; bottom: 22px; left: 7px; color: #fff; background: #0008; font: 10px/13px Arial,sans-serif; pointer-events: none; }
.overlays-hidden .study-id-badge { display: block; }
.display-mode-badge { position: absolute; z-index: 3; left: 7px; top: 44%; max-width: 85%; color: #fff000; background: #0008; font: 10px/13px Arial,sans-serif; pointer-events: none; }
.overlays-hidden .overlay, .overlays-hidden .orientation { visibility: hidden; }
.viewport { touch-action: none; }
@media print { .viewer-context-root { display: none; } }
