:root {
  /* Modern Medical / PACS Dark Theme */
  --bg: #0f1115;
  /* Very dark grey/blue, almost black */
  --panel: #181b21;
  /* Slightly lighter for cards/panels */
  --surface: #20242c;
  /* Elevated surface */
  --border: #2d3340;
  /* Subtle borders */

  --text-main: #e2e8f0;
  --text-muted: #94a3b8;

  --accent-primary: #3b82f6;
  /* Bright Blue */
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.15);

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);

  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3);

  --transition: 0.2s ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--accent-hover);
}

/* Layout & Typography */
h1,
h2,
h3,
h4 {
  margin: 0 0 1rem 0;
  font-weight: 600;
  color: #fff;
}

.site-header {
  background: rgba(24, 27, 33, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.site-header h1 {
  font-size: 1.25rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.site-header h1 a {
  color: #fff;
  font-weight: 700;
}

.site-header nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.site-header nav a {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
}

.site-header nav a:hover,
.site-header nav a.active {
  color: #fff;
}

main {
  max-width: 1100px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  min-height: 80vh;
}

.site-footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: 4rem;
}

/* Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-primary);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: var(--transition);
  gap: 0.5rem;
}

.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn.secondary {
  background: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  background: var(--border);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.input-group {
  margin-bottom: 1rem;
}

.label {
  display: block;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Flash Messages */
.flash-container {
  margin-bottom: 1.5rem;
}

.flash {
  padding: 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  border-left: 4px solid transparent;
  display: flex;
  align-items: center;
}

.flash.success {
  background: var(--success-bg);
  border-color: var(--success);
  color: #86efac;
}

.flash.warning {
  background: var(--warning-bg);
  border-color: var(--warning);
  color: #fcd34d;
}

.flash.danger {
  background: var(--danger-bg);
  border-color: var(--danger);
  color: #fca5a5;
}

.flash.info {
  background: var(--accent-soft);
  border-color: var(--accent-primary);
  color: #93c5fd;
}

/* Game / Play Area */
.play-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 900px) {
  .play-layout {
    grid-template-columns: 1fr;
  }
}

/* Viewer / Image Area */
.viewer-container {
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
  box-shadow: var(--shadow-md);
  /* Ensure it stays below headers/overlays */
}

.viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: rgba(30, 35, 45, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.9rem;
}

.viewer-tools .tool-btn {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.viewer-tools .tool-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.viewer-tools .tool-btn.active {
  background: var(--accent-primary);
  color: #fff;
}

.viewer-canvas {
  background: #000;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  /* Fix zoom overflow */
}

.viewer-canvas img {
  max-width: 100%;
  max-height: 80vh;
  display: block;
}

/* Grid Layout for X-rays */
.grid-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 10px;
}

/* Guessing Interface */
.guess-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.guess-input-wrapper {
  position: relative;
  display: flex;
  gap: 0.5rem;
}

.guess-input-wrapper input {
  padding-right: 3rem;
  background: var(--surface);
  border-color: var(--border);
}

.guesses-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1rem;
}

.guess-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

.guess-item.correct {
  background: var(--success-bg);
  border-color: var(--success);
  color: #fff;
}

.guess-item.incorrect {
  border-left: 3px solid var(--danger);
  color: var(--text-muted);
}

.remaining-badges {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.badge-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  transition: var(--transition);
}

.badge-dot.active {
  background: var(--text-muted);
}

.badge-dot.lost {
  background: var(--danger);
}

.badge-dot.won {
  background: var(--success);
}

/* Admin & specialized areas */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: var(--transition);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.dropzone-icon {
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.file-list {
  list-style: none;
  padding: 0;
  margin-top: 1rem;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.file-list li {
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
}

.file-list li:last-child {
  border-bottom: none;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.table th,
.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--surface);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Utilities */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

#citation-text,
#result-source,
#result-source-container {
  word-break: break-word;
  overflow-wrap: break-word;
}

.d-flex {
  display: flex;
}

.gap-2 {
  gap: 0.5rem;
}

.justify-between {
  justify-content: space-between;
}

.align-center {
  align-items: center;
}

/* Tooltips */
.help-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: bold;
  cursor: help;
  position: relative;
  margin-left: 6px;
}

.help-icon:hover {
  color: #fff;
  border-color: var(--accent-primary);
  background: var(--accent-primary);
}

.help-icon:hover::after {
  content: attr(aria-label);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #000;
  color: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  width: max-content;
  max-width: 250px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  font-weight: normal;
  pointer-events: none;
}

/* Series Tabs */
.series-tab-btn {
  background: transparent;
  border: none;
  padding: 0.75rem 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 500;
  transition: var(--transition);
}

.series-tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.series-tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

/* --- Result Overlay --- */
.result-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  /* removed !important to allow JS toggling */
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.result-card {
  background: var(--panel);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 10px 10px -5px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.result-header {
  padding: 2rem 1.5rem;
  text-align: center;
  color: #fff;
  flex-shrink: 0;
}

.result-header.success {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(16, 185, 129, 0.05));
  border-bottom: 1px solid var(--success-bg);
}

.result-header.danger {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.05));
  border-bottom: 1px solid var(--danger-bg);
}

.result-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.result-header p {
  margin: 0;
  opacity: 0.9;
}

.result-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.result-body h3 {
  font-size: 1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

/* --- Improved Guess Input --- */
.guess-row {
  position: relative;
  align-items: stretch;
}

.guess-row input {
  height: 46px;
  /* Match button height */
  padding-right: 1rem;
}

.guess-row .btn {
  width: 48px;
  height: 46px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.flex-grow-1 {
  flex-grow: 1;
}

.justify-center {
  justify-content: center;
}

/* System Chips */
.system-select-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.system-check {
  display: none;
}

.system-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50px;
  /* Pill shape */
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.system-chip:hover {
  background: var(--border);
  color: var(--text-main);
  transform: translateY(-1px);
}

.system-check:checked+.system-chip {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
  box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.4);
}

/* Modern File Input */
.file-upload-area {
  position: relative;
  overflow: hidden;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  background: var(--bg);
  cursor: pointer;
  transition: var(--transition);
}

.file-upload-area:hover {
  border-color: var(--accent-primary);
  background: var(--accent-soft);
}

.file-upload-area input[type=file] {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: block;
}

.upload-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.file-upload-area:hover .upload-icon,
.file-upload-area:hover .upload-text {
  color: var(--accent-primary);
}

/* Global Stats Chart */
.stats-chart {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}

.stat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.stat-label {
  width: 15px;
  text-align: right;
  font-weight: bold;
}

.stat-bar-container {
  flex-grow: 1;
}

.stat-bar {
  background-color: #374151;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: bold;
  text-align: right;
  min-width: 20px;
  transition: width 0.5s ease;
}

.stat-bar.highlight {
  background-color: var(--accent-primary);
}

.stat-bar.empty {
  background: transparent;
  color: var(--text-muted);
  text-align: left;
  padding-left: 0;
}

/* Modal & Image Manager */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--panel);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  padding: 2rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.series-manager-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.series-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.series-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  gap: 1rem;
}

.series-images {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 5px;
  min-height: 90px;
  align-items: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 5px;
}

.series-img-card {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.series-img-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.series-img-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.series-img-remove:hover {
  background: var(--danger);
}

/* ═══════════════════ OVERLAY EDITOR ════════════════════════════════════════ */
.oe-section { user-select: none; }

.oe-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.oe-tab {
  padding: 4px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: var(--transition);
}
.oe-tab:hover { border-color: var(--accent-primary); color: var(--text-main); }
.oe-tab.active { background: var(--accent-primary); border-color: var(--accent-primary); color: #fff; }

.oe-viewport {
  position: relative;
  width: 100%;
  height: 400px;
  overflow: hidden;
  background: #000;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.oe-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  transform-origin: 0 0;
}
#oe-img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  user-select: none;
}
#oe-svg {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
#oe-svg.oe-drawing .oe-ov { pointer-events: none; }

.oe-toolbar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.oe-tool {
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text-muted);
  font-size: 0.82rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.oe-tool:hover { border-color: var(--accent-primary); color: var(--text-main); }
.oe-tool.active { background: var(--accent-primary); border-color: var(--accent-primary); color: #fff; }

.oe-list-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  min-height: 80px;
  flex: 1;
}
.oe-list-item {
  padding: 5px 7px;
  border-radius: 4px;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  transition: var(--transition);
}
.oe-list-item:hover { background: var(--surface); border-color: var(--border); }
.oe-list-item.active { background: rgba(59,130,246,0.12); border-color: var(--primary); }
.oe-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.oe-scope { color: var(--text-muted); font-size: 0.75rem; }

.oe-settings-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 0.82rem;
}

.pz-stage {
  position: relative;
  overflow: hidden;
}

/* F3: play viewer overlay layer */
.overlay-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: visible;
  transform-origin: 0 0;
}

.tool-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #fff;
}

/* ------------------------------------------------------------------ */
/* Admin shell — unified tabs, breadcrumb, page header                 */
/* ------------------------------------------------------------------ */
.admin-shell {
  max-width: 1200px;
  margin: 0 auto;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.admin-tab {
  padding: 0.55rem 0.95rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.admin-tab:hover {
  background: var(--surface);
  color: var(--text-main);
}

.admin-tab.active,
.admin-tab.active:hover {
  background: var(--accent-primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.admin-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.1rem;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.admin-breadcrumb a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-muted);
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.admin-breadcrumb a:hover {
  color: var(--text-main);
  background: var(--surface);
}

.admin-breadcrumb .crumb-sep {
  color: var(--border);
  padding: 0 0.15rem;
  user-select: none;
}

.admin-breadcrumb .crumb-current {
  color: var(--text-main);
  font-weight: 500;
  padding: 0.3rem 0.55rem;
}

.admin-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.admin-title {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

.admin-subtitle {
  margin: 0.35rem 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 640px;
}

.admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 720px) {
  .admin-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .admin-tab { flex: 0 0 auto; }
  .admin-title { font-size: 1.3rem; }
}

/* Landing-page custom content blocks */
.home-message {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--accent-soft);
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-md);
}
.home-message h3 {
  margin: 0 0 0.5rem;
  color: #fff;
  font-size: 1.05rem;
}
.home-message p {
  margin: 0;
  color: var(--text-main);
  white-space: pre-wrap;
}

.home-contributors {
  margin-top: 1.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.home-contributors h3 {
  margin: 0 0 0.5rem;
  color: #fff;
  font-size: 1.05rem;
}
.home-contributors p {
  margin: 0;
  color: var(--text-muted);
  white-space: pre-wrap;
  line-height: 1.6;
}

/* ============================================================
   Button modifiers (used by no-case + PACS archive)
   ============================================================ */
.btn-primary { background: var(--accent-primary); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface);
  color: #fff;
}
.btn-lg {
  padding: 0.85rem 1.4rem;
  font-size: 1rem;
}
.btn-badge {
  background: rgba(255,255,255,0.18);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  margin-left: 0.15rem;
}

/* ============================================================
   Modality badges (shared)
   ============================================================ */
.modality-badge {
  display: inline-flex;
  align-items: center;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text-muted);
  white-space: nowrap;
}
.modality-badge.mod-xray,
.modality-badge.mod-xr {
  background: rgba(59,130,246,0.14);
  color: #93c5fd;
  border-color: rgba(59,130,246,0.35);
}
.modality-badge.mod-ct {
  background: rgba(245,158,11,0.14);
  color: #fcd34d;
  border-color: rgba(245,158,11,0.35);
}
.modality-badge.mod-mri {
  background: rgba(168,85,247,0.16);
  color: #d8b4fe;
  border-color: rgba(168,85,247,0.4);
}
.modality-badge.mod-ultrasound,
.modality-badge.mod-us {
  background: rgba(16,185,129,0.14);
  color: #6ee7b7;
  border-color: rgba(16,185,129,0.35);
}

/* ============================================================
   "No case today" landing
   ============================================================ */
.no-case-hero {
  text-align: center;
  padding: 3rem 1rem 2.5rem;
  background:
    radial-gradient(ellipse at top, rgba(59,130,246,0.10), transparent 60%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 2rem;
}
.no-case-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-primary);
}
.no-case-icon svg { width: 28px; height: 28px; }
.no-case-hero h2 {
  font-size: 1.85rem;
  margin: 0 0 0.5rem;
}
.no-case-sub {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 540px;
  margin: 0 auto 1.75rem;
}
.no-case-cta-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

.no-case-recent { margin-top: 1rem; }
.no-case-recent-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.no-case-recent-head h3 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  color: var(--text-main);
}
.link-quiet {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.link-quiet:hover { color: var(--accent-primary); }
.recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
}
.recent-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  transition: var(--transition);
}
.recent-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.recent-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.recent-card-date {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.recent-card-title {
  margin: 0;
  font-size: 0.98rem;
  color: var(--text-main);
  line-height: 1.35;
  flex-grow: 1;
}
.recent-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}
.recent-card-actions .btn { flex: 1; }

/* ============================================================
   PACS-style study archive (history page)
   ============================================================ */
.pacs-archive {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.pacs-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}
.pacs-title-row {
  display: flex;
  align-items: baseline;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
.pacs-title-row h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
}
.pacs-count {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 0.18rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}
.pacs-toolbar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
}
.pacs-search {
  flex: 1 1 280px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  color: var(--text-muted);
  transition: var(--transition);
}
.pacs-search:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
  color: var(--text-main);
}
.pacs-search input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.9rem;
}
.pacs-search input::placeholder { color: var(--text-muted); }
.pacs-modality-chips {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.mod-chip {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}
.mod-chip:hover {
  color: var(--text-main);
  border-color: var(--text-muted);
}
.mod-chip.active {
  background: var(--accent-soft);
  color: #fff;
  border-color: var(--accent-primary);
}

.pacs-table-wrap { overflow-x: auto; }
.pacs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.pacs-table thead th {
  text-align: left;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--surface);
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.pacs-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s ease;
}
.pacs-table tbody tr:hover { background: var(--surface); }
.pacs-table tbody tr:last-child { border-bottom: 0; }
.pacs-table td {
  padding: 0.7rem 0.85rem;
  vertical-align: middle;
}
.col-num { width: 64px; }
.col-thumb { width: 64px; }
.col-date { width: 130px; white-space: nowrap; }
.col-mod { width: 90px; }
.col-actions { width: 1%; white-space: nowrap; text-align: right; }

.pacs-idx {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.col-date time {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: var(--text-main);
}
.pacs-desc-title {
  color: var(--text-main);
  font-weight: 500;
  line-height: 1.3;
}
.pacs-desc-sub {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 0.15rem;
}
.col-actions .btn {
  margin-left: 0.35rem;
}

.pacs-thumb {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: var(--text-muted);
}
.pacs-thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.pacs-thumb.has-img .pacs-thumb-fallback { display: none; }
.pacs-thumb-fallback {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}
.pacs-thumb-count {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.62rem;
  font-weight: 700;
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
  z-index: 2;
}

.pacs-empty {
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--text-muted);
}
.pacs-empty-initial { padding: 4rem 1.25rem; }

@media (max-width: 640px) {
  .pacs-table .col-num,
  .pacs-table .col-thumb { display: none; }
  .col-actions .btn { margin-left: 0.25rem; padding: 0.35rem 0.6rem; }
  .recent-card-actions { flex-wrap: wrap; }
}
