:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #111827;
  --bg-card: #161f30;
  --bg-hover: #1f2d44;
  --border-color: #27354f;
  --border-highlight: #3b82f6;
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.25);
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --accent-purple: #8b5cf6;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  user-select: none;
}

/* ================= Header ================= */
.app-header {
  background: linear-gradient(180deg, #161f30 0%, #111827 100%);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 15px var(--accent-cyan-glow);
}

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  text-transform: uppercase;
}

.pacs-status-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg-card);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.status-node {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.node-label {
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 700;
}

.node-value {
  color: var(--text-main);
  font-family: var(--font-mono);
  font-weight: 600;
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse 2s infinite;
}

.pulse-indicator.offline {
  background: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
  animation: none;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ================= Buttons ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-sans);
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: linear-gradient(180deg, #0284c7 0%, #0369a1 100%);
  border-color: #38bdf8;
  box-shadow: 0 2px 8px rgba(3, 105, 161, 0.4);
}
.btn-primary:hover {
  background: #0284c7;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.5);
}

.btn-success {
  background: linear-gradient(180deg, #059669 0%, #047857 100%);
  border-color: #34d399;
  box-shadow: 0 2px 8px rgba(4, 120, 87, 0.4);
}
.btn-success:hover {
  background: #059669;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.5);
}

.btn-danger {
  background: linear-gradient(180deg, #dc2626 0%, #b91c1c 100%);
  border-color: #f87171;
}
.btn-danger:hover {
  background: #dc2626;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-outline:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
}

.btn-accent {
  background: linear-gradient(180deg, #7c3aed 0%, #6d28d9 100%);
  border-color: #a78bfa;
}
.btn-accent:hover {
  background: #7c3aed;
  box-shadow: 0 0 12px rgba(167, 139, 250, 0.5);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
}

/* ================= Tabs Navigation ================= */
.main-nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  padding: 0 20px;
  gap: 4px;
}

.nav-tab {
  padding: 12px 18px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.03);
}

.nav-tab.active {
  color: var(--accent-cyan);
  border-bottom-color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.05);
}

.tab-badge {
  background: var(--border-color);
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
}

/* ================= App Body ================= */
.app-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.tab-pane {
  display: none;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.tab-pane.active {
  display: flex;
  flex-direction: column;
}

/* ================= Worklist Pane ================= */
.worklist-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 16px;
  gap: 14px;
  overflow-y: auto;
}

.toolbar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.input-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 6px 12px;
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s;
}

.input-box:focus {
  border-color: var(--accent-cyan);
}

.select-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 6px 12px;
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.table-container {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: auto;
}

.dicom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.dicom-table th {
  background: #141c2c;
  color: var(--text-dim);
  padding: 10px 14px;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border-color);
  z-index: 10;
}

.dicom-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  white-space: nowrap;
}

.dicom-table tbody tr {
  cursor: pointer;
  transition: background-color 0.1s;
}

.dicom-table tbody tr:hover {
  background-color: var(--bg-hover);
}

.dicom-table tbody tr.selected {
  background-color: rgba(6, 182, 212, 0.15);
  border-left: 3px solid var(--accent-cyan);
}

.tag-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-mono);
}

.tag-badge.modality-ct { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid #3b82f6; }
.tag-badge.modality-mr { background: rgba(168, 85, 247, 0.2); color: #c084fc; border: 1px solid #a855f7; }
.tag-badge.modality-dx { background: rgba(16, 185, 129, 0.2); color: #34d399; border: 1px solid #10b981; }
.tag-badge.modality-us { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid #f59e0b; }

/* ================= Acquisition Console Layout ================= */
.acquisition-layout {
  display: grid;
  grid-template-columns: 340px 1fr 340px;
  height: 100%;
  gap: 12px;
  padding: 12px;
  background: #090d15;
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  background: #141c2d;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-body {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* DICOM Viewer Center Stage */
.viewport-panel {
  background: #000;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.viewport-canvas-container {
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

#dicomCanvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

/* Medical Viewport Overlays (HUD) */
.hud-overlay {
  position: absolute;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #06b6d4;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
  line-height: 1.4;
  z-index: 5;
}

.hud-top-left { top: 12px; left: 12px; }
.hud-top-right { top: 12px; right: 12px; text-align: right; }
.hud-bottom-left { bottom: 12px; left: 12px; }
.hud-bottom-right { bottom: 12px; right: 12px; text-align: right; }

.viewport-controls-bar {
  background: rgba(17, 24, 39, 0.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-color);
  width: 100%;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 10;
}

.slider-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.slider-label {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-width: 60px;
}

.range-slider {
  flex: 1;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

/* Window Presets Buttons */
.presets-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.btn-preset {
  background: #1e293b;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.btn-preset:hover {
  background: var(--bg-hover);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

/* ================= Log Terminal ================= */
.logs-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 14px;
  gap: 12px;
}

.terminal-window {
  flex: 1;
  background: #06090f;
  border: 1px solid #1e293b;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px;
  overflow-y: auto;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.log-entry {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.4;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.02);
}

.log-time {
  color: var(--text-dim);
  font-size: 11px;
  min-width: 80px;
}

.log-badge {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  min-width: 60px;
  text-align: center;
  text-transform: uppercase;
}

.log-badge.SUCCESS { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.log-badge.DICOM { background: rgba(6, 182, 212, 0.2); color: #38bdf8; }
.log-badge.INFO { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.log-badge.WARNING { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.log-badge.ERROR { background: rgba(239, 68, 68, 0.2); color: #f87171; }

.log-content {
  flex: 1;
  word-break: break-all;
}

/* ================= Modal ================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 580px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalEnter 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalEnter {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 14px 18px;
  background: #141c2e;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
}
.modal-close:hover { color: #fff; }

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 75vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 12px 18px;
  background: #111827;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ================= Progress Bar ================= */
.progress-bar-container {
  width: 100%;
  height: 8px;
  background: #1f2937;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green));
  transition: width 0.2s ease;
}

/* Responsive adjustment */
@media (max-width: 1200px) {
  .acquisition-layout {
    grid-template-columns: 280px 1fr 280px;
  }
}
