*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(180deg, #f5f8fc 0%, var(--bg-canvas) 100%);
  color: var(--text-default);
  font: 14px/1.5 var(--font-sans);
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(107, 122, 144, 0.45) transparent;
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: rgba(107, 122, 144, 0.45);
  background-clip: padding-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

*::-webkit-scrollbar-button:single-button,
*::-webkit-scrollbar-button:horizontal:decrement,
*::-webkit-scrollbar-button:horizontal:increment,
*::-webkit-scrollbar-button:vertical:decrement,
*::-webkit-scrollbar-button:vertical:increment {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  max-width: 0 !important;
  max-height: 0 !important;
  border: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  -webkit-appearance: none !important;
  appearance: none !important;
  background: transparent !important;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

.stack {
  display: grid;
  gap: var(--space-3);
}

.stack--lg {
  gap: var(--space-4);
}

.eyebrow {
  display: inline-block;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 42px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.button--primary {
  background: var(--primary);
  color: var(--text-inverse);
}

.button--primary:hover {
  background: var(--primary-strong);
}

.button--secondary {
  background: var(--text-strong);
  color: var(--text-inverse);
}

.button--ghost {
  background: transparent;
  border-color: var(--border-soft);
  color: var(--text-default);
}

.button--danger {
  background: var(--danger);
  color: var(--text-inverse);
}

.button--sm {
  min-height: 34px;
  padding: 0 var(--space-3);
  font-size: 13px;
}

.button--xs {
  min-height: 26px;
  padding: 0 var(--space-2);
  font-size: 11px;
  border-radius: var(--radius-1);
}

.button--block {
  width: 100%;
}

.field {
  display: grid;
  gap: 6px;
}

.field--inline {
  min-width: 180px;
}

.field__label {
  color: var(--text-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.field__control {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  color: var(--text-strong);
}

.field__control--textarea {
  min-height: 120px;
  padding: 12px 14px;
  resize: vertical;
}

.field__control--dense {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 12px;
}

.field__control:focus {
  outline: 2px solid rgba(29, 78, 216, 0.15);
  border-color: var(--primary);
}

.field__message {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
}

.field__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 12px;
}

.field__static {
  padding: 6px 0;
  font-size: 14px;
  color: var(--text-primary);
}

.code-block {
  background: var(--surface-sunken, #f4f5f7);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 12px 16px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  color: var(--text-primary);
}

.auth-page {
  position: relative;
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, 0.12), transparent 32%),
    radial-gradient(circle at bottom right, rgba(12, 114, 140, 0.12), transparent 28%),
    #f3f7fb;
}

.auth-meta {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: rgba(17, 24, 39, 0.55);
  white-space: nowrap;
}
.auth-meta a {
  color: inherit;
  text-decoration: none;
  padding: 4px 2px;
  transition: color 0.15s ease;
}
.auth-meta a:hover,
.auth-meta a:focus-visible {
  color: rgba(17, 24, 39, 0.9);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.auth-meta__sep {
  opacity: 0.55;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(360px, 0.92fr);
  min-height: 100vh;
}

.auth-hero,
.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 4vw, 72px);
}

.auth-hero__content {
  max-width: min(520px, 100%);
}

.auth-hero h1 {
  margin: var(--space-3) 0 var(--space-4);
  color: var(--text-strong);
  font-size: clamp(36px, 4vw, 52px);
  line-height: 1.05;
}

.auth-hero p {
  margin: 0 0 var(--space-5);
  color: var(--text-default);
  font-size: 17px;
}

.auth-points {
  display: grid;
  gap: var(--space-3);
  padding: 0;
  margin: 0;
  list-style: none;
}

.auth-points li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.auth-points li::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
}

.auth-card {
  width: min(460px, 100%);
  padding: clamp(24px, 2.6vw, 34px);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  box-shadow: var(--shadow-md);
}

.auth-system-notice {
  display: grid;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--info-soft);
  color: var(--text-default);
}

.auth-system-notice strong {
  color: var(--text-strong);
}

.auth-system-notice span {
  color: var(--text-muted);
}

.auth-card__divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-2) 0;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}
.auth-card__divider::before,
.auth-card__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-default);
}

.app-shell {
  display: grid;
  grid-template-columns: clamp(236px, 16vw, 280px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: var(--space-6);
  background: linear-gradient(180deg, var(--bg-sidebar) 0%, var(--bg-sidebar-accent) 100%);
  color: var(--text-inverse);
}

.sidebar__main {
  display: grid;
  gap: var(--space-4);
}

.sidebar__brand {
  padding-bottom: var(--space-6);
}

.sidebar__logo {
  display: inline-block;
  color: var(--text-inverse);
  font-size: 28px;
  font-weight: 800;
}

.sidebar__tag {
  margin: 8px 0 0;
  color: rgba(247, 251, 255, 0.72);
}

.sidebar__nav {
  display: grid;
  gap: var(--space-2);
}

.sidebar__footer {
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-5);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar__storage {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
}

.sidebar__storage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar__storage-header strong {
  color: var(--text-inverse);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar__storage-header span,
.sidebar__storage-empty,
.sidebar__storage-copy span,
.sidebar__storage-stats,
.sidebar__storage-meta {
  color: rgba(247, 251, 255, 0.64);
  font-size: 11px;
}

.sidebar__storage-list {
  display: grid;
  gap: 8px;
}

.sidebar__storage-card {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(3, 10, 20, 0.22);
}

.sidebar__storage-card--warning {
  border-color: rgba(245, 158, 11, 0.46);
  background: rgba(120, 53, 15, 0.22);
}

.sidebar__storage-card--critical {
  border-color: rgba(248, 113, 113, 0.56);
  background: rgba(127, 29, 29, 0.26);
}

.sidebar__storage-card--unavailable {
  border-color: rgba(148, 163, 184, 0.3);
}

.sidebar__storage-top {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.sidebar__storage-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(87, 173, 255, 0.22), rgba(87, 173, 255, 0.08));
  border: 1px solid rgba(120, 196, 255, 0.24);
}

.sidebar__storage-icon span {
  position: relative;
  z-index: 1;
  color: rgba(247, 251, 255, 0.94);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.sidebar__storage-icon::before {
  content: "";
  position: absolute;
  left: 6px;
  right: 6px;
  top: 8px;
  height: 2px;
  border-radius: 999px;
  background: rgba(247, 251, 255, 0.72);
  box-shadow: 0 6px 0 rgba(247, 251, 255, 0.22);
}

.sidebar__storage-icon::after {
  content: "";
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #7dd3fc;
}

.sidebar__storage-copy {
  display: grid;
  gap: 2px;
}

.sidebar__storage-copy strong {
  color: var(--text-inverse);
  font-size: 12px;
}

.sidebar__storage-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.sidebar__storage-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #38bdf8, #0ea5e9);
}

.sidebar__storage-card--warning .sidebar__storage-bar span {
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
}

.sidebar__storage-card--critical .sidebar__storage-bar span {
  background: linear-gradient(90deg, #fb7185, #dc2626);
}

.sidebar__storage-card--warning .sidebar__storage-icon {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.34), rgba(245, 158, 11, 0.12));
  border-color: rgba(251, 191, 36, 0.42);
}

.sidebar__storage-card--critical .sidebar__storage-icon {
  background: linear-gradient(180deg, rgba(248, 113, 113, 0.34), rgba(127, 29, 29, 0.18));
  border-color: rgba(248, 113, 113, 0.46);
}

.sidebar__storage-stats {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar__user {
  display: grid;
  gap: var(--space-1);
}

.sidebar__user-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.sidebar__user strong {
  color: var(--text-inverse);
  font-size: 14px;
}

.sidebar__user span {
  color: rgba(247, 251, 255, 0.68);
  font-size: var(--text-xs);
  text-transform: capitalize;
}

.sidebar__user .sidebar__idle-badge {
  flex: 0 0 auto;
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(238, 243, 248, 0.32);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(245, 248, 252, 0.24), rgba(238, 243, 248, 0.16));
  box-shadow: inset 0 1px 0 rgba(247, 251, 255, 0.18);
  color: rgba(247, 251, 255, 0.9);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  line-height: 1;
  text-transform: none;
}

.sidebar__logout {
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text-inverse);
}

.sidebar__logout:hover {
  background: rgba(255, 255, 255, 0.08);
}

.sidebar__meta {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  row-gap: var(--space-2);
  margin: 12px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(247, 251, 255, 0.54);
}

.sidebar__meta a {
  color: inherit;
  text-decoration: none;
  transition: color 0.15s ease;
}

.sidebar__meta a:hover,
.sidebar__meta a:focus-visible {
  color: rgba(247, 251, 255, 0.92);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sidebar__meta-sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(247, 251, 255, 0.32);
}

.sidebar__version {
  flex-basis: 100%;
  color: inherit;
  line-height: 1;
  opacity: 0.72;
  text-align: center;
  text-transform: none;
}

.sidebar__group {
  display: grid;
  gap: 6px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: rgba(247, 251, 255, 0.74);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.sidebar__link:hover,
.sidebar__link.is-active {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-inverse);
}

.sidebar__link--toggle {
  width: 100%;
}

.sidebar__caret {
  font-size: 12px;
  transition: transform 160ms ease;
}

.sidebar__group.is-open .sidebar__caret {
  transform: rotate(180deg);
}

.sidebar__subnav {
  display: none;
  gap: 6px;
  padding: 0 0 0 10px;
}

.sidebar__group.is-open .sidebar__subnav {
  display: grid;
}

.sidebar__sublink {
  padding: 10px 12px;
  border-radius: 12px;
  color: rgba(247, 251, 255, 0.68);
  font-size: 13px;
  font-weight: 600;
}

.sidebar__sublink:hover,
.sidebar__sublink.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-inverse);
}

.workspace {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-content {
  padding: clamp(18px, 2vw, 24px) clamp(18px, 2.4vw, 32px) clamp(24px, 2.8vw, 36px);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-content > .page-section--dashboard-fill {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-section--dashboard-fill > .panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.page-section--dashboard-fill > .panel > .table-shell {
  flex: 1;
}

.page-section {
  display: grid;
  gap: var(--space-4);
  align-content: start;
  margin-bottom: var(--space-5);
}

.queue-btn-wrap {
  position: relative;
  display: inline-flex;
}

.queue-btn-wrap .queue-badge {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger, #ef4444);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

.queue-btn-wrap.has-items .queue-badge {
  animation: queue-pulse 2s ease-in-out infinite;
}

@keyframes queue-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

.page-section--dashboard-top {
  gap: 8px;
  margin-bottom: 14px;
}

.page-section--patient-detail {
  gap: 10px;
  margin-bottom: 0;
}

.dashboard-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.panel__header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-toggle {
  display: inline-flex;
  background: var(--bg-muted, #f0f2f5);
  border-radius: 6px;
  padding: 2px;
  gap: 1px;
}
.view-toggle__btn {
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-tertiary);
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.view-toggle__btn:hover {
  color: var(--text-secondary);
}
.view-toggle__btn.is-active {
  background: var(--bg-surface, #fff);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.view-toggle--setting .view-toggle__btn {
  padding: 6px 18px;
  font-size: 0.8rem;
}

.view-card-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 6px;
}
.view-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  border: 2px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  text-align: center;
}
.view-card svg {
  color: var(--text-tertiary);
  transition: color 0.2s;
}
.view-card strong {
  font-size: 0.85rem;
  color: var(--text-primary);
}
.view-card span {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}
.view-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}
.view-card.is-active {
  border-color: var(--accent);
  background: var(--bg-accent-soft, rgba(59, 130, 246, 0.06));
  box-shadow: 0 0 0 1px var(--accent);
}
.view-card.is-active svg {
  color: var(--accent);
}

.section-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  position: relative;
  z-index: 8;
  pointer-events: auto;
  align-items: center;
}

.section-nav__link {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-default);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  position: relative;
  z-index: 1;
  pointer-events: auto;
  cursor: pointer;
  transition: 120ms ease;
}

.section-nav__link:hover:not(.is-active) {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(29, 78, 216, 0.25);
  color: var(--primary);
}

.section-nav__link.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
}

.page-intro,
.panel,
.metric-card,
.settings-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.page-intro {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  padding: clamp(16px, 1.6vw, 22px);
}

.page-intro--compact {
  padding: clamp(12px, 1.2vw, 16px) clamp(14px, 1.4vw, 20px);
}

.page-intro h2 {
  margin: var(--space-1) 0 var(--space-2);
  color: var(--text-strong);
  font-size: clamp(24px, 2.1vw, 30px);
  line-height: 1.15;
}

.page-intro--compact h2 {
  margin: 4px 0 6px;
  font-size: clamp(20px, 1.6vw, 22px);
  line-height: 1.1;
}

.page-intro p {
  margin: 0;
  color: var(--text-muted);
}

.page-intro--compact p {
  font-size: 13px;
}

.page-intro__modalities {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.page-intro__modality-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--bg-canvas);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.page-intro__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: flex-end;
  min-width: 0;
  gap: var(--space-2);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}

.stats-grid--dashboard {
  grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  gap: 8px;
}

.metric-card {
  padding: clamp(16px, 1.8vw, 20px);
}

.stats-grid--dashboard .metric-card {
  padding: 10px 12px;
  border-radius: 18px;
}

.metric-card__label {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  color: var(--text-strong);
  font-size: clamp(24px, 2.2vw, 32px);
}

.stats-grid--dashboard .metric-card strong {
  font-size: clamp(18px, 1.4vw, 22px);
  line-height: 1.05;
}

.metric-card span {
  color: var(--text-muted);
  font-size: 13px;
}

.stats-grid--dashboard .metric-card span,
.stats-grid--dashboard .metric-card__label {
  font-size: 10px;
  line-height: 1.15;
}

.settings-row {
  display: grid;
  gap: var(--space-4);
}
.settings-row--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.settings-row > .panel {
  margin: 0;
}

.services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  padding: 4px 18px 18px;
}

.service-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
  border-left: 4px solid var(--text-muted);
}

.service-card:hover {
  box-shadow: var(--shadow-md);
}

.service-card--running {
  border-left-color: var(--success);
}

.service-card--stopped {
  border-left-color: var(--danger);
}

.service-card--unknown {
  border-left-color: var(--warning);
}

.service-card--unavailable {
  border-left-color: var(--danger);
  background: linear-gradient(90deg, var(--danger-soft), var(--bg-surface) 42%);
}

.service-card--down {
  border-left-color: var(--danger);
}

.service-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.service-card__title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.service-card__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-strong);
  color: var(--text-muted);
}

.service-card--running .service-card__icon {
  background: var(--success-soft);
  color: var(--success);
}

.service-card--stopped .service-card__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.service-card--unknown .service-card__icon {
  background: var(--warning-soft);
  color: var(--warning);
}

.service-card--unavailable .service-card__icon,
.service-card--down .service-card__icon {
  background: var(--danger-soft);
  color: var(--danger);
}

.service-card__info {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.service-card__name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-strong);
  line-height: 1.3;
  letter-spacing: -0.01em;
  word-break: break-word;
}

.service-card__desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}

.service-card__badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.service-card__badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.service-card__badge--running {
  background: var(--success-soft);
  color: var(--success);
}

.service-card__badge--stopped {
  background: var(--danger-soft);
  color: var(--danger);
}

.service-card__badge--unknown {
  background: var(--warning-soft);
  color: var(--warning);
}

.service-card__badge--unavailable,
.service-card__badge--down {
  background: var(--danger-soft);
  color: var(--danger);
}

.service-card__badge--unknown::before {
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.service-card__actions {
  display: flex;
  gap: 6px;
  padding-top: 2px;
  border-top: 1px solid var(--border-soft);
}

.service-card__actions .button--xs {
  flex: 1;
  justify-content: center;
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 8px;
}

@media (max-width: 600px) {
  .services-grid {
    grid-template-columns: 1fr;
  }
}

.button--xs {
  padding: 2px 8px;
  font-size: 11px;
  line-height: 1.4;
  border-radius: 4px;
}

.button--danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}
.button--danger:hover {
  opacity: 0.85;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, minmax(620px, 1.7fr)) minmax(320px, 0.95fr);
  gap: var(--space-5);
  align-items: start;
}

.dashboard-grid--fit {
  grid-template-columns: minmax(0, 1fr);
  min-height: auto;
  align-items: start;
}

.dashboard-side {
  display: grid;
  gap: var(--space-5);
}

.dashboard-side--fit {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.dashboard-main-panel {
  min-height: 0;
}

.panel {
  overflow: hidden;
}

.panel--scroll {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel--embedded {
  background: #f9fbfd;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: none;
}

.panel__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: clamp(14px, 1.4vw, 18px) clamp(18px, 1.9vw, 24px) clamp(10px, 1.1vw, 14px);
}

.panel__header h3 {
  margin: 0 0 4px;
  color: var(--text-strong);
  font-size: clamp(18px, 1.5vw, 20px);
}

.panel__header p,
.panel__meta {
  margin: 0;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: 0 clamp(18px, 1.9vw, 24px) clamp(12px, 1.3vw, 16px);
}

.toolbar--dense {
  gap: 8px;
  padding-top: 0;
  padding-bottom: 8px;
}

.toolbar--dense .field--inline {
  min-width: 148px;
}

.toolbar--dense .field {
  gap: 4px;
}

.toolbar--dense .field__label {
  font-size: 10px;
}

.toolbar--dense .field__control {
  min-height: 36px;
  padding: 0 10px;
  border-radius: 12px;
}

.toolbar--dense .button {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.toolbar__actions {
  display: flex;
  gap: var(--space-2);
  align-items: end;
}

#patient-filters .toolbar__actions {
  margin-left: auto;
}

.toolbar__page-size-controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: var(--space-2);
}

.toolbar__page-size-controls .page-size-control {
  min-width: 92px;
}

.toolbar__page-size-controls .field__control {
  min-width: 76px;
}

.form-grid {
  display: grid;
  gap: var(--space-4);
  align-items: start;
}

.form-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: end;
}

.table-shell {
  overflow: auto;
  border-top: 1px solid var(--border-soft);
}

.panel--scroll .table-shell {
  flex: 1;
  min-height: 0;
}

.table-shell--compact {
  max-height: clamp(280px, 34vh, 420px);
}

.dashboard-side--fit .table-shell--compact {
  max-height: none;
}

.dashboard-side--fit > .panel {
  height: clamp(210px, 24vh, 300px);
  max-height: clamp(210px, 24vh, 300px);
}

.dashboard-main-panel .pagination {
  padding-top: 8px;
  padding-bottom: 8px;
  flex-shrink: 0;
}

.data-table {
  width: 100%;
  min-width: 840px;
  border-collapse: collapse;
}

.data-table--compact {
  min-width: 520px;
}

.queue-section + .queue-section {
  margin-top: 24px;
}
.queue-section__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg-muted, #f4f6f8);
}
.queue-section__header h4 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.queue-section__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--bg-surface, #fff);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 0 0 1px var(--border-soft, #e2e8f0);
}
.queue-section__empty {
  padding: 24px 0;
  text-align: center;
  color: var(--text-muted, #a0aec0);
  font-size: 0.82rem;
}

.data-table th,
.data-table td {
  padding: 9px clamp(10px, 1vw, 14px);
  border-bottom: 1px solid #edf2f7;
  text-align: left;
  vertical-align: middle;
}

.dashboard-main-panel .data-table th,
.dashboard-main-panel .data-table td,
.dashboard-side--fit .data-table th,
.dashboard-side--fit .data-table td {
  padding: 7px 8px;
}

.dashboard-main-panel .data-table th,
.dashboard-side--fit .data-table th {
  font-size: 11px;
}

.dashboard-main-panel .data-table td,
.dashboard-side--fit .data-table td {
  font-size: 13px;
  line-height: 1.3;
}

.cell-center {
  text-align: center !important;
}

.table-row-link {
  cursor: pointer;
}

.table-row-link:hover {
  background: #f9fbfd;
}

.data-table th {
  position: sticky;
  top: 0;
  background: #f9fbfd;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
}

.table-state {
  color: var(--text-muted);
  text-align: center !important;
  padding: 32px !important;
}


.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6) var(--space-4);
}

.list-footer .pagination {
  flex: 1;
  padding: 0;
}

.page-size-control {
  min-width: 96px;
}

.page-size-control .field__control {
  min-height: 36px;
  border-radius: 12px;
}

.icon-button--danger {
  color: var(--danger);
}

.icon-button--danger:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.pagination {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  padding: 12px 24px 16px;
}

.pagination__ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  min-height: 38px;
  color: var(--text-muted);
  font-weight: 700;
}

.pagination button {
  min-width: 38px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--bg-surface);
  cursor: pointer;
}

.pagination button.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-inverse);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge--success {
  background: var(--success-soft);
  color: var(--success);
}

.status-badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.status-badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-badge--processing {
  background: rgba(139, 92, 246, 0.15);
  color: #a78bfa;
}

.status-badge--processing::before {
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-badge--info {
  background: var(--info-soft);
  color: var(--info);
}

.status-badge--neutral {
  background: var(--bg-muted, #f0f2f5);
  color: var(--text-tertiary);
}

.phase-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-left: var(--space-1);
  white-space: nowrap;
}

.phase-label--failure {
  color: var(--danger);
  font-weight: 600;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

.settings-grid--wide {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.settings-card {
  display: block;
  min-width: 0;
  padding: clamp(16px, 1.8vw, 22px);
}

.settings-card h3 {
  margin: 10px 0 8px;
  color: var(--text-strong);
}

.settings-card p {
  margin: 0;
  color: var(--text-muted);
}

.settings-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
  padding: 0 clamp(18px, 1.9vw, 24px) clamp(18px, 1.9vw, 24px);
}

.settings-overview--wide {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.overview-item {
  padding: 20px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: #f9fbfd;
}

.overview-item h4 {
  margin: 10px 0 8px;
  color: var(--text-strong);
  font-size: 18px;
}

.overview-item p {
  margin: 0;
  color: var(--text-muted);
}

.dialog {
  border: none;
  padding: 0;
  border-radius: 24px;
  width: min(560px, calc(100vw - 32px));
  box-shadow: var(--shadow-md);
}

.dialog--wide {
  width: min(1040px, calc(100vw - 32px));
}

.dialog::backdrop {
  background: rgba(16, 32, 51, 0.36);
}

.dialog__surface {
  background: var(--bg-surface);
}

.dialog__header,
.dialog__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 20px 24px;
}

.dialog__body {
  padding: 0 24px 24px;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  font-size: 22px;
}

.inline-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.panel-form {
  padding: 0 24px 24px;
}

.toolbar--tight {
  padding: 0;
}

.result-box {
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: #f9fbfd;
  color: var(--text-default);
  white-space: pre-wrap;
  word-break: break-word;
}

.field--full {
  grid-column: 1 / -1;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-default);
  font-weight: 600;
}

.toggle--card {
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: #f9fbfd;
}

.toggle--card span {
  display: grid;
  gap: 4px;
}

.toggle--card small {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 400;
}

.restart-all-layout {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  width: 100%;
}

.restart-all-layout__copy {
  flex: 1 1 auto;
  min-width: 0;
}

.restart-all-layout__actions {
  flex: 0 0 auto;
  justify-content: flex-end;
  margin-left: auto;
}

.restart-all-layout__actions .toolbar__actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.network-pacs-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 0;
}

.network-pacs-actions__toggle {
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: #f9fbfd;
  font-size: 13px;
}

.network-pacs-actions__button {
  flex: 0 0 auto;
  min-width: 172px;
}

.analysis-shell {
  display: grid;
  grid-template-columns: clamp(200px, 16vw, 260px) minmax(0, 1fr);
  gap: var(--space-4);
  padding: 0 clamp(18px, 1.9vw, 24px) clamp(18px, 1.9vw, 24px);
}

.analysis-shell--system {
  align-items: start;
  gap: 20px;
}

.panel--system-workspace {
  background:
    radial-gradient(circle at top right, rgba(29, 78, 216, 0.06), transparent 30%),
    rgba(255, 255, 255, 0.88);
}

.panel--system-workspace > .panel__header {
  padding-bottom: 10px;
}

.panel--system-workspace > .panel__header h3 {
  font-size: clamp(20px, 1.7vw, 24px);
}

.panel--system-workspace > .panel__header p {
  max-width: 760px;
}

.analysis-sidebar--system {
  position: sticky;
  top: 24px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(248, 250, 252, 0.98), rgba(240, 245, 252, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.analysis-content {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
}

.analysis-sidebar {
  display: grid;
  gap: var(--space-2);
  align-content: start;
  min-width: 0;
}

.segment-button {
  display: grid;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 16px 18px;
  padding: 15px 16px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  text-align: left;
  cursor: pointer;
  transition: 160ms ease;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.7);
}

.segment-button strong {
  color: var(--text-strong);
  font-size: 15px;
  line-height: 1.2;
}

.segment-button span {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.35;
}

.segment-button.is-active {
  background: linear-gradient(180deg, rgba(29, 78, 216, 0.16), rgba(255, 255, 255, 0.98));
  border-color: rgba(29, 78, 216, 0.34);
  box-shadow: 0 8px 20px rgba(29, 78, 216, 0.08);
}

.segment-button:hover {
  border-color: rgba(29, 78, 216, 0.22);
  background: rgba(255, 255, 255, 0.96);
}

.system-panel {
  display: none;
  gap: var(--space-4);
}

.system-panel.is-active {
  display: grid;
}

.draft-banner {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid rgba(217, 119, 6, 0.22);
  border-radius: 20px;
  background:
    linear-gradient(180deg, #fffaf0, #fff7e6);
}

.draft-banner strong {
  color: #b45309;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.draft-banner span {
  color: #8a5a06;
  line-height: 1.45;
}

.draft-banner--neutral {
  border-color: rgba(29, 78, 216, 0.18);
  background:
    linear-gradient(180deg, #f3f8ff, #edf4ff);
}

.draft-banner--neutral strong {
  color: #1d4ed8;
}

.draft-banner--neutral span {
  color: #1e40af;
}

.license-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid rgba(217, 119, 6, 0.28);
  background: linear-gradient(180deg, #fff8eb, #fff2d6);
}

.license-banner__icon {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #d97706;
  color: #fff;
  font-weight: 700;
  line-height: 28px;
  text-align: center;
}

.license-banner__body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.license-banner__title {
  color: #92400e;
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.license-banner__message {
  color: #78350f;
  line-height: 1.45;
}

.license-banner--info {
  border-color: rgba(29, 78, 216, 0.22);
  background: linear-gradient(180deg, #f3f8ff, #edf4ff);
}

.license-banner--info .license-banner__icon {
  background: #1d4ed8;
}

.license-banner--info .license-banner__title {
  color: #1d4ed8;
}

.license-banner--info .license-banner__message {
  color: #1e40af;
}

.parameter-section {
  display: grid;
  gap: var(--space-4);
}

.parameter-section__header h4 {
  margin: 0 0 6px;
  color: var(--text-strong);
  font-size: 26px;
}

.parameter-section__header p {
  margin: 0;
  color: var(--text-muted);
}

.parameter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-4);
}

.parameter-card {
  display: grid;
  gap: var(--space-4);
  min-width: 0;
  padding: 18px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.parameter-card--wide {
  grid-column: 1 / -1;
}

.parameter-card h5,
.option-box h6 {
  margin: 0;
  color: var(--text-strong);
  font-size: 15px;
}

.parameter-card .field,
.parameter-card .field__control,
.option-box .field,
.option-box .field__control {
  min-width: 0;
}

.dual-option-grid,
.triple-field-grid {
  display: grid;
  gap: var(--space-3);
}

.dual-option-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.triple-field-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.option-box {
  display: grid;
  gap: var(--space-3);
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background: #f8fbff;
}

.matrix-table {
  overflow: auto;
  max-width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  background: #fcfdff;
}

.matrix-table .data-table {
  min-width: 560px;
}

#io-transfer-table {
  table-layout: fixed;
}

#io-transfer-table th:first-child,
#io-transfer-table td:first-child {
  width: var(--io-label-column-width, 46%);
}

#io-transfer-table [data-io-column] {
  width: var(--io-modality-column-width, 18%);
  text-align: center;
}

#io-transfer-table td[data-io-column] input[type="checkbox"] {
  display: inline-block;
  margin: 0 auto;
}

.panel--embedded .panel__header {
  padding-bottom: 12px;
}

.panel--embedded .panel__header h3 {
  font-size: clamp(17px, 1.25vw, 19px);
}

.panel--embedded .panel__header p {
  max-width: 620px;
  line-height: 1.45;
}

.panel--embedded .panel-form,
.analysis-form {
  min-width: 0;
}

.panel--embedded .toggle--card {
  background: var(--bg-surface);
}

.form-grid--2 > .panel--embedded {
  align-self: stretch;
}

.service-status {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 16px 20px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: var(--bg-surface-strong);
}

.service-status__indicator {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
}

.service-status__indicator--running {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(15, 138, 82, 0.15);
}

.service-status__indicator--stopped {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(194, 59, 50, 0.15);
}

.service-status__indicator--loading {
  background: var(--warning);
  animation: pulse-dot 1.2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.service-status__info {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.service-status__info strong {
  color: var(--text-strong);
  font-size: 15px;
}

.service-status__info span {
  color: var(--text-muted);
  font-size: 13px;
}

.service-status__details {
  display: flex;
  gap: var(--space-4);
  color: var(--text-muted);
  font-size: 12px;
  white-space: nowrap;
}

.service-status__details span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.service-status__details strong {
  color: var(--text-default);
  font-weight: 600;
}

.analysis-form .toolbar--tight {
  padding-top: 4px;
}

.analysis-form .toolbar__actions {
  justify-content: flex-end;
}

.settings-grid--stacked {
  align-items: stretch;
}

.permission-editor {
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--border-soft);
  border-radius: 22px;
  background: #f9fbfd;
}

.permission-editor__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.permission-editor__header h4,
.permission-card__header h5 {
  margin: 0 0 4px;
  color: var(--text-strong);
}

.permission-editor__header p,
.permission-card__header p {
  margin: 0;
  color: var(--text-muted);
}

.permission-editor__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.permission-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.9);
}

.permission-card .data-table {
  min-width: 0;
  width: 100%;
}

.permission-card .data-table td {
  white-space: nowrap;
}

.permission-select {
  width: 100%;
  min-width: 80px;
  max-width: 140px;
}

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

.panel--settings-workspace {
  gap: 18px;
  padding: 0 24px 24px;
}

.panel--settings-workspace .panel__header {
  align-items: end;
  margin: 0 -24px;
}

.panel--settings-workspace .toolbar {
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: #f9fbfd;
  margin-bottom: 6px;
}

.panel--settings-workspace .table-shell {
  border-radius: 12px;
  border: 1px solid var(--border-soft);
  overflow-x: auto;
}

.panel--settings-workspace .data-table {
  min-width: 0;
  width: 100%;
}

.panel--settings-workspace .data-table th,
.panel--settings-workspace .data-table td {
  vertical-align: middle;
  padding: 10px 12px;
  font-size: 13px;
}

.panel--settings-workspace .data-table th {
  font-size: 11px;
  white-space: nowrap;
}

.panel--settings-workspace .inline-actions {
  gap: 6px;
  flex-wrap: nowrap;
}

.permission-card .data-table th,
.permission-card .data-table td {
  padding-top: 10px;
  padding-bottom: 10px;
}

.permission-card .data-table td:first-child {
  font-weight: 600;
  color: var(--text-strong);
}

.dialog--wide .dialog__surface {
  border: 1px solid var(--border-soft);
  border-radius: inherit;
  overflow: hidden;
}

.dialog--wide .dialog__header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, #ffffff, #f8fbfd);
}

.dialog--wide .dialog__body {
  padding: 20px 24px 24px;
}

.dialog--wide .dialog__footer {
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
  background: #fbfcfe;
}

@media (max-width: 1280px) {
  .analysis-shell {
    grid-template-columns: 1fr;
  }

  .analysis-sidebar {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .analysis-sidebar--system {
    position: static;
    top: auto;
  }

  .parameter-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }

  .triple-field-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1120px) {
  .section-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .section-nav__link {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .panel__header {
    flex-wrap: wrap;
  }

  .toolbar {
    gap: 12px;
  }

  .toolbar__actions {
    flex-wrap: wrap;
  }

  .restart-all-layout {
    flex-wrap: wrap;
  }

  .restart-all-layout__actions {
    width: 100%;
  }

  .settings-grid,
  .settings-grid--wide,
  .settings-overview,
  .parameter-grid {
    grid-template-columns: 1fr;
  }

  .form-grid--2,
  .inline-form-grid,
  .dual-option-grid,
  .triple-field-grid,
  .permission-editor__grid {
    grid-template-columns: 1fr;
  }

  .parameter-card {
    padding: 16px;
    border-radius: 18px;
  }

  .matrix-table .data-table {
    min-width: 480px;
  }
}

@media (max-width: 860px) {
  .analysis-sidebar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segment-button {
    padding: 14px 14px;
    border-radius: 16px;
  }

  .segment-button strong {
    font-size: 14px;
  }

  .segment-button span {
    font-size: 11px;
  }

  .matrix-table .data-table {
    min-width: 420px;
  }
}

@media (max-width: 640px) {
  .analysis-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .analysis-sidebar {
    grid-template-columns: 1fr;
  }

  .parameter-section__header h4 {
    font-size: 22px;
  }

  .matrix-table .data-table {
    min-width: 360px;
  }

  .network-pacs-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .network-pacs-actions__toggle,
  .network-pacs-actions__button {
    width: 100%;
  }

  .permission-editor {
    padding: 16px;
    border-radius: 18px;
  }
}

.patient-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
}

.patient-viewer {
  --patient-stage-max-height: min(60vh, 620px);
  display: grid;
  grid-template-columns: minmax(170px, clamp(170px, 15vw, 280px)) minmax(0, 1fr);
  gap: var(--space-5);
  align-items: stretch;
}

.patient-overview-panel {
  border-color: var(--border-soft);
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-surface-strong) 100%);
  box-shadow: var(--shadow-sm);
}

.patient-series-panel {
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.patient-viewer-panel {
  height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.patient-series-list {
  display: grid;
  gap: 8px;
  align-content: start;
  grid-auto-rows: max-content;
  padding: 0 16px 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-width: none;
}

.patient-series-list::-webkit-scrollbar {
  display: none;
}

.series-item {
  display: grid;
  gap: 2px;
  width: 100%;
  min-height: 78px;
  padding: 10px 12px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: #f9fbfd;
  text-align: left;
  cursor: pointer;
}

.series-item__top {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 18px;
  margin-bottom: 0;
}

.series-item__badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.series-item__badge--store {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.series-item__badge--pacs {
  background: rgba(8, 145, 178, 0.14);
  color: #0f766e;
}

.series-item__badge--source {
  background: rgba(168, 85, 247, 0.12);
  color: #7c3aed;
}

.series-item__badge--neutral {
  background: rgba(107, 122, 144, 0.14);
  color: #5b6878;
}

.series-item strong {
  color: var(--text-strong);
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.2;
}

.series-item span,
.series-item small {
  color: var(--text-muted);
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
  line-height: 1.15;
}

.series-item.is-active {
  border-color: rgba(29, 78, 216, 0.3);
  background: #eff6ff;
}

.patient-series-panel .panel__header {
  padding-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

.patient-series-panel .panel__header,
.patient-series-panel .patient-series-list {
  padding-left: 16px;
  padding-right: 16px;
}

.series-source-filter {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: #f9fbfd;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

.series-source-filter__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: 140ms ease;
  white-space: nowrap;
}

.series-source-filter__button.is-active {
  background: var(--text-strong);
  color: var(--text-inverse);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.18);
}

.series-source-filter__button:hover {
  color: var(--text-strong);
  background: rgba(15, 23, 42, 0.06);
}

.patient-viewer-stage {
  padding: 0 clamp(14px, 1.6vw, 20px) 14px;
  display: flex;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 0;
  align-items: center;
}

.summary-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.summary-zoom-controls[hidden] {
  display: none;
}

.summary-zoom-button,
.preview-zoom-button {
  width: 34px;
  padding: 0;
  justify-content: center;
}

.summary-zoom-icon,
.preview-zoom-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.patient-viewer-image {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  max-height: var(--patient-stage-max-height);
  max-width: 100%;
  border-radius: 22px;
  overflow: hidden;
  background: #08111c;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.patient-viewer-image.is-loading img {
  opacity: 0.32;
}

.patient-viewer-image.is-zoomable {
  cursor: ns-resize;
}

.patient-viewer-image.is-dragging {
  cursor: ns-resize;
}

.patient-viewer-image.is-panning {
  cursor: grab;
}

.patient-viewer-image.is-panning:active {
  cursor: grabbing;
}

.patient-viewer-image img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 100%;
  max-width: 100%;
  object-fit: contain;
  background: #08111c;
  transform-origin: center center;
  will-change: transform;
}

.patient-viewer-overlay {
  position: absolute;
  left: 20px;
  bottom: 20px;
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(8, 17, 28, 0.72);
  color: #f8fbff;
}

.patient-viewer-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  background: linear-gradient(180deg, rgba(8, 17, 28, 0.18), rgba(8, 17, 28, 0.36));
  color: #f8fbff;
  text-align: center;
  pointer-events: none;
}

.patient-viewer-loading strong {
  font-size: 14px;
}

.patient-viewer-loading span:last-child {
  color: rgba(248, 251, 255, 0.76);
  font-size: 12px;
}

.patient-viewer-loading.is-error {
  background: linear-gradient(180deg, rgba(69, 10, 10, 0.22), rgba(69, 10, 10, 0.4));
}

.patient-viewer-loading__spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(248, 251, 255, 0.22);
  border-top-color: #f8fbff;
  border-radius: 50%;
  animation: viewer-spin 0.8s linear infinite;
}

@keyframes viewer-spin {
  to {
    transform: rotate(360deg);
  }
}

.patient-frame-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(56px, 3.6vw, 68px);
  gap: 8px;
  overflow-x: auto;
  padding: 0 clamp(14px, 1.6vw, 20px) 12px;
  flex-shrink: 0;
  scrollbar-width: none;
}

.patient-frame-strip::-webkit-scrollbar {
  display: none;
}

.patient-frame-strip:has(> .table-state) {
  grid-auto-flow: row;
  grid-auto-columns: auto;
}

.patient-frame-strip > .table-state {
  min-width: 200px;
}

.patient-viewer-image > .table-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  color: var(--text-muted);
  font-size: 14px;
}

.frame-thumb {
  display: grid;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  background: #f9fbfd;
  cursor: pointer;
}

.frame-thumb img {
  width: 100%;
  height: clamp(32px, 2.4vw, 42px);
  object-fit: contain;
  border-radius: 8px;
  background: #08111c;
}

.frame-thumb span {
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.1;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.frame-thumb.is-active {
  border-color: rgba(29, 78, 216, 0.3);
  background: #eff6ff;
}

.detail-kv {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  padding: 0 24px 24px;
}

.detail-kv--compact {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (min-width: 1200px) {
  .patient-overview-panel .detail-kv--compact {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

.patient-overview-panel .detail-kv {
  gap: var(--space-3);
  padding: var(--space-6);
}

.detail-kv__item {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: #f9fbfd;
}

.detail-kv--compact .detail-kv__item {
  gap: 4px;
  padding: 10px 12px;
}

.patient-overview-panel .detail-kv__item {
  border-color: var(--border-soft);
  background: var(--bg-surface);
}

.page-section--patient-detail > .panel > .panel__header {
  padding-top: 14px;
  padding-bottom: 10px;
}

.detail-kv__label {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-kv__value {
  color: var(--text-strong);
  word-break: break-word;
}

.error-detail {
  display: block;
  margin-bottom: 6px;
  max-width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  word-break: normal;
}

.error-detail__message {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.error-detail__solution {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

.detail-stack {
  display: grid;
  gap: var(--space-4);
  padding: 0 24px 24px;
}

.status-summary {
  display: grid;
  gap: 12px;
}

.status-summary__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 14px 16px;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  background: #f9fbfd;
}

.status-summary__row span {
  color: var(--text-muted);
  font-weight: 600;
}

.toast-root {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: var(--space-2);
  z-index: 1000;
}

.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  color: var(--text-strong);
}

.feedback {
  margin: 0 24px 20px;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 13px;
}

.feedback--error {
  background: var(--danger-soft);
  color: var(--danger);
}

.feedback--info {
  background: var(--info-soft);
  color: var(--info);
}

.feedback--warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.feedback--success {
  background: var(--success-soft);
  color: var(--success);
}

@media (max-width: 920px) {
  .auth-layout,
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .page-content {
    padding-left: 20px;
    padding-right: 20px;
  }

  .page-intro {
    flex-direction: column;
  }

  .page-intro__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .stats-grid,
  .settings-grid,
  .settings-grid--wide,
  .settings-overview,
  .dashboard-grid,
  .patient-detail-grid,
  .patient-viewer,
  .form-grid--2,
  .inline-form-grid,
  .analysis-shell,
  .parameter-grid,
  .dual-option-grid,
  .triple-field-grid,
  .detail-kv--compact,
  .detail-kv {
    grid-template-columns: 1fr;
  }

  .patient-viewer {
    --patient-stage-max-height: min(58vh, 560px);
    --patient-panel-height: auto;
  }

  .patient-series-panel,
  .patient-viewer-panel,
  .patient-overview-panel {
    height: auto;
  }

  .patient-overview-panel .detail-kv {
    padding: var(--space-4);
  }

  .dashboard-grid--fit,
  .dashboard-side--fit {
    min-height: auto;
  }

  .dashboard-side--fit {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .stats-grid--dashboard {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .dashboard-main-panel {
    min-height: auto;
  }

  .dashboard-side--fit > .panel {
    height: auto;
    max-height: none;
  }
}

/* Expandable patient rows */
.expand-toggle {
  cursor: pointer;
  width: 24px;
  text-align: center;
  color: var(--text-muted);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
  user-select: none;
  font-size: 0.7rem;
}

.expand-toggle:hover {
  color: var(--primary);
}

.expand-toggle.expanded {
  transform: rotate(90deg);
  color: var(--primary);
}

/* Parent row expanded state */
.table-row-link--expanded {
  background-color: var(--bg-surface-strong) !important;
  box-shadow: inset 3px 0 0 var(--primary);
}

.table-row-link--expanded td:first-child {
  border-left: none;
}

/* Child row - container for study cards */
.table-row--child {
  background-color: var(--bg-surface-strong);
}

.table-row--child td {
  padding: 0 !important;
  border-bottom: none !important;
}

.table-row--child td[colspan] {
  padding: 0 var(--space-4) var(--space-3) 40px !important;
}

/* Expand/collapse animation wrapper */
.sub-row-wrapper {
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.3s ease;
  max-height: 0;
  opacity: 0;
}

.sub-row-wrapper.is-open {
  max-height: 600px;
  opacity: 1;
}

/* Study card inside expanded row — 2-row layout */
.study-card {
  display: flex;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  margin-bottom: var(--space-2);
  box-shadow: 0 1px 3px rgba(16, 32, 51, 0.04);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
}

.study-card:last-child {
  margin-bottom: 0;
}

.study-card:hover {
  box-shadow: 0 2px 8px rgba(16, 32, 51, 0.08);
  border-color: var(--primary);
}

/* Left connector bar */
.study-card__connector {
  width: 4px;
  align-self: stretch;
  background: var(--border-soft);
  flex-shrink: 0;
  transition: background 0.2s ease;
}

.study-card:hover .study-card__connector {
  background: var(--primary);
}

/* Main content area — stacked vertically */
.study-card__content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

/* Row 1: title bar with modality badge, description, status, detail button */
.study-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-surface);
}

.study-card__title-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

.study-card__index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg-canvas);
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  flex-shrink: 0;
}

.study-card__modality {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 6px;
  font-size: 0.6875rem;
  font-weight: 700;
  background: var(--info-soft);
  color: var(--info);
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.study-card__desc {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-strong);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* Row 2: metadata chips */
.study-card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0;
  padding: 0 var(--space-4);
  background: var(--bg-surface-strong);
}

.study-card__meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px var(--space-4) 10px 0;
  margin-right: var(--space-4);
  border-right: 1px solid var(--border-soft);
}

.study-card__meta-item:last-child {
  border-right: none;
  margin-right: 0;
}

.study-card__meta-label {
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
  line-height: 1;
}

.study-card__meta-value {
  font-size: 0.8125rem;
  color: var(--text-default);
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.3;
}

.study-card__meta-value--mono {
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-size: 0.75rem;
  color: var(--info);
  font-weight: 500;
}

/* Empty studies message */
.study-empty {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px dashed var(--border-soft);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.runs-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.8125rem;
  background-color: var(--info-soft);
  color: var(--info);
  font-weight: 500;
}

/* Detail link — button style */
.detail-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-soft);
  background: var(--bg-surface);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.detail-link__icon {
  display: inline-flex;
  align-items: center;
}

.detail-link:hover {
  text-decoration: none;
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(29, 78, 216, 0.25);
}

.detail-link:hover .detail-link__icon svg {
  stroke: #fff;
}

/* Responsive: stack study card on narrow screens */
@media (max-width: 768px) {
  .study-card__top {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .study-card__title-row {
    flex-wrap: wrap;
  }

  .study-card__meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .table-row--child td[colspan] {
    padding-left: var(--space-4) !important;
  }
}

/* ─── Modal ─── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.modal__header h3 {
  margin: 0;
  font-size: 16px;
}

.modal__close {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.modal__close:hover {
  color: var(--color-text-primary);
}

.modal__body {
  padding: 16px 20px;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
}

/* ─── Upload Page ─── */

/* ─── Upload: Dropzone ─── */
.upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 56px 32px;
  border: 2px dashed var(--border-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color 0.25s, background 0.25s, transform 0.2s;
  background: linear-gradient(180deg, #f8fafd 0%, #ffffff 100%);
}

.upload-dropzone:hover {
  border-color: var(--primary);
  background: linear-gradient(180deg, #eef4ff 0%, #f8fafd 100%);
  transform: translateY(-1px);
}

.upload-dropzone--active {
  border-color: var(--primary);
  border-style: solid;
  background: linear-gradient(180deg, #e0ecff 0%, #eef4ff 100%);
  transform: scale(1.005);
}

.upload-dropzone--compact {
  padding: 16px 24px;
  flex-direction: row;
  gap: 12px;
  border-style: solid;
  border-color: var(--primary-light, #93b4f0);
  background: linear-gradient(180deg, #eef4ff 0%, #f8fafd 100%);
}

.upload-dropzone--compact .upload-dropzone__icon {
  width: 36px;
  height: 36px;
}

.upload-dropzone--compact .upload-dropzone__icon svg {
  width: 20px;
  height: 20px;
}

.upload-dropzone--compact .upload-dropzone__text {
  font-size: 13px;
  font-weight: 500;
}

.upload-dropzone--compact .upload-dropzone__hint {
  display: none;
}

.upload-dropzone--disabled {
  opacity: 0.5;
  pointer-events: none;
}

.upload-dropzone__icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--bg-canvas);
  color: var(--text-muted);
  transition: color 0.2s, background 0.2s;
}

.upload-dropzone:hover .upload-dropzone__icon,
.upload-dropzone--active .upload-dropzone__icon {
  color: var(--primary);
  background: rgba(29, 78, 216, 0.08);
}

.upload-dropzone__text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-strong);
  margin: 0;
}

.upload-dropzone__hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}

/* ─── Upload: Summary Chips ─── */
.upload-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 var(--space-6) var(--space-4);
}

.upload-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--info-soft);
  color: var(--info);
}

.upload-chip--muted {
  background: var(--bg-canvas);
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── Upload: File Table ─── */
.upload-table-wrap {
  max-height: 360px;
  overflow-y: auto;
  padding: 0 var(--space-6) var(--space-6);
}

.upload-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.upload-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.upload-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg-surface-strong);
  border-bottom: 1px solid var(--border-soft);
}

.upload-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #eef2f7;
  color: var(--text-default);
}

.upload-table tbody tr:hover {
  background: #f5f8fc;
}

.upload-table__idx {
  width: 48px;
  text-align: center !important;
  color: var(--text-muted) !important;
  font-size: 12px;
}

.upload-table__name code {
  font-family: "SF Mono", "Cascadia Code", "Fira Code", monospace;
  font-size: 12.5px;
  color: var(--text-default);
  background: none;
  padding: 0;
}

.upload-table__size {
  width: 90px;
  text-align: right !important;
  color: var(--text-muted) !important;
  font-variant-numeric: tabular-nums;
}

.upload-table__more td {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 12px;
}

/* ─── Upload: Progress ─── */
.upload-progress-hero {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: var(--space-8);
}

.upload-progress-hero--active .upload-ring__fill {
  stroke: var(--primary);
}

.upload-progress-hero--success .upload-ring__fill {
  stroke: var(--success);
}

.upload-progress-hero--error .upload-ring__fill {
  stroke: var(--danger);
}

.upload-progress-hero--warn .upload-ring__fill {
  stroke: var(--warning);
}

/* Circular ring */
.upload-ring {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.upload-ring__svg {
  width: 120px;
  height: 120px;
  transform: rotate(-90deg);
}

.upload-ring__track {
  fill: none;
  stroke: var(--bg-canvas);
  stroke-width: 8;
}

.upload-ring__fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s ease, stroke 0.3s;
}

.upload-ring__label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-ring__pct {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}

/* Progress info */
.upload-progress-info {
  flex: 1;
  min-width: 0;
}

.upload-progress-info h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-strong);
}

.upload-progress-sub {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.upload-progress-bar-wrap {
  height: 6px;
  background: var(--bg-canvas);
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.35s ease;
}

.upload-progress-hero--success .upload-progress-bar {
  background: var(--success);
}

.upload-progress-hero--error .upload-progress-bar {
  background: var(--danger);
}

.upload-progress-hero--warn .upload-progress-bar {
  background: var(--warning);
}

/* ─── Upload: Result ─── */
.upload-result {
  padding: 0 var(--space-8) var(--space-6);
  border-top: 1px solid var(--border-soft);
}

.upload-result__stats {
  display: flex;
  gap: 24px;
  padding: 20px 0 16px;
}

.upload-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  padding: 12px 20px;
  border-radius: 12px;
  background: var(--bg-canvas);
}

.upload-stat--success {
  background: var(--success-soft);
}

.upload-stat--fail {
  background: var(--danger-soft);
}

.upload-stat__num {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.upload-stat--success .upload-stat__num {
  color: var(--success);
}

.upload-stat--fail .upload-stat__num {
  color: var(--danger);
}

.upload-stat__label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.upload-result__title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 8px 0 8px;
}

.upload-err-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: var(--danger-soft);
  font-size: 12.5px;
  color: var(--danger);
  line-height: 1.4;
}

.upload-err-item svg {
  flex-shrink: 0;
  margin-top: 1px;
}

.upload-err-more {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  padding-left: 12px;
}

.panel__actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ─── Modal ─── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-surface, #fff);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  width: 520px;
  max-width: 92vw;
}

.modal--wide {
  width: 800px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-default, #e2e8f0);
}

.modal__header h3 {
  margin: 0;
  font-size: 16px;
}

.modal__close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text-muted, #64748b);
  padding: 4px 8px;
  border-radius: 4px;
}

.modal__close:hover {
  background: var(--bg-hover, #f1f5f9);
}

.modal__body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.pipeline-log-content {
  background: var(--bg-inset, #f8fafc);
  border: 1px solid var(--border-default, #e2e8f0);
  border-radius: 8px;
  padding: 16px;
  font-family: var(--font-mono, 'SF Mono', 'Fira Code', monospace);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre;
  word-break: normal;
  margin: 0;
  max-height: 60vh;
  overflow: auto;
  color: var(--text-default, #1e293b);
}

/* ─── Manual Analysis Page ─── */

.analyze-body {
  padding: 0 clamp(18px, 1.8vw, 22px) clamp(18px, 1.8vw, 22px);
}

.source-dir-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
}

.source-dir-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 16px 18px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: #f9fbfd;
  cursor: pointer;
  transition: border-color 160ms, background 160ms, box-shadow 160ms;
}

.source-dir-card:hover {
  border-color: rgba(29, 78, 216, 0.3);
  background: #f3f8ff;
  box-shadow: 0 4px 16px rgba(29, 78, 216, 0.06);
}

.source-dir-card.is-selected {
  border-color: rgba(29, 78, 216, 0.4);
  background: linear-gradient(180deg, rgba(29, 78, 216, 0.08), rgba(255, 255, 255, 0.98));
  box-shadow: 0 4px 16px rgba(29, 78, 216, 0.1);
}

.source-dir-card input[type="radio"] {
  accent-color: var(--primary);
  margin: 0;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.source-dir-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 20px;
  flex-shrink: 0;
}

.source-dir-card__info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
}

.source-dir-card__name {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-strong);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-dir-card__meta {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* ─── Analysis Settings ─── */

.analyze-settings {
  display: flex;
  align-items: flex-end;
  gap: var(--space-5);
  flex-wrap: wrap;
  padding: 0 clamp(18px, 1.8vw, 22px) clamp(18px, 1.8vw, 22px);
}

.analyze-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.analyze-field__label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.analyze-field__value {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-strong);
  padding: 10px 14px;
  background: #f9fbfd;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.analyze-field .input,
.analyze-field .field__control {
  width: 100%;
  min-width: 180px;
  min-height: 42px;
  padding: 0 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  color: var(--text-default);
  font-size: 0.8125rem;
  outline: none;
  transition: border-color 160ms, box-shadow 160ms;
}

.analyze-field .input:focus,
.analyze-field .field__control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

/* ─── Analysis Progress ─── */

.analyze-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: 0 clamp(18px, 1.8vw, 22px) clamp(18px, 1.8vw, 22px);
}

.analyze-progress__status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 14px 18px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  background: var(--bg-surface-strong);
}

.analyze-progress__spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: analyze-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.analyze-progress__spinner--done {
  border-color: var(--success);
  border-top-color: var(--success);
  animation: none;
}

.analyze-progress__spinner--fail {
  border-color: var(--danger);
  border-top-color: var(--danger);
  animation: none;
}

@keyframes analyze-spin {
  to { transform: rotate(360deg); }
}

.analyze-progress__text {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-default);
}

/* ─── ROI + Phase Side-by-Side Row ─── */

.roi-phase-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  align-items: stretch;
}

.roi-phase-row__left,
.roi-phase-row__right {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.roi-phase-row__right .phase-graph-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.roi-phase-row__right .phase-graph-wrap canvas {
  flex: 1;
  min-height: 180px;
}

@media (max-width: 1100px) {
  .roi-phase-row {
    grid-template-columns: 1fr;
  }
}

/* ─── ROI Dual Viewer ─── */

.roi-dual-viewer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2) var(--space-2);
  flex: 1;
}

.roi-smip-toggle.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(29, 78, 216, 0.08);
}

.roi-smip-dropdown {
  --roi-smip-stage-bg: #000;
  --roi-smip-stage-border: rgba(255, 255, 255, 0.08);
  display: grid;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}

.roi-smip-dropdown[hidden] {
  display: none;
}

.roi-smip-dropdown__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-soft);
}

.roi-smip-dropdown__header strong {
  display: block;
  color: var(--text-strong);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.roi-smip-dropdown__header span {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.roi-smip-dropdown__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  height: clamp(320px, 48vh, 560px);
  padding: var(--space-4);
  overflow: auto;
  background: var(--roi-smip-stage-bg);
  border-top: 1px solid var(--roi-smip-stage-border);
}

.roi-smip-dropdown__stage img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: calc(clamp(320px, 48vh, 560px) - var(--space-8));
  object-fit: contain;
}

.roi-smip-dropdown__message {
  max-width: 320px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--roi-smip-stage-border);
  border-radius: 12px;
  color: var(--text-inverse);
  font-size: 0.8125rem;
  font-weight: 600;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
}

.roi-smip-dropdown__message--unavailable,
.roi-smip-dropdown__message--error {
  color: var(--danger-soft);
  border-color: rgba(194, 59, 50, 0.35);
  background: rgba(194, 59, 50, 0.16);
}

.roi-smip-dropdown__message--loading {
  color: var(--info-soft);
  border-color: rgba(12, 114, 140, 0.35);
  background: rgba(12, 114, 140, 0.16);
}

.roi-dual-viewer__pane {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.roi-dual-viewer__pane + .roi-dual-viewer__pane {
  border-left: none;
}

.roi-pane__header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--text-strong);
  padding: 8px 12px;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.roi-pane__header strong {
  font-weight: 600;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.roi-pane__slice-info {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.roi-pane__canvas-wrap {
  position: relative;
  border-radius: 0;
  overflow: hidden;
  cursor: crosshair;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.roi-pane__canvas-wrap canvas {
  display: block;
  width: 92%;
  height: auto;
  margin: 0 auto;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 2px 12px rgba(0, 0, 0, 0.4);
  cursor: crosshair;
}

.roi-viewer__slice {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.roi-viewer__footer {
  padding: var(--space-3) clamp(18px, 1.8vw, 22px) clamp(18px, 1.8vw, 22px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.roi-viewer__hint {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin: 0;
}


@media (max-width: 768px) {
  .roi-dual-viewer {
    grid-template-columns: 1fr;
  }

  .roi-dual-viewer__pane + .roi-dual-viewer__pane {
    border-left: none;
  }
}

/* ─── Phase Timing ─── */

.phase-graph-wrap {
  padding: clamp(10px, 1.2vw, 16px) clamp(14px, 1.4vw, 20px);
  background: linear-gradient(180deg, #08111c 0%, #0b1524 100%);
  border-radius: 12px;
  margin: 0 clamp(14px, 1.4vw, 20px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.phase-graph-wrap canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

.phase-controls {
  padding: clamp(14px, 1.2vw, 20px) clamp(18px, 1.8vw, 22px);
}

.phase-controls__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 10px;
  margin-bottom: var(--space-3);
}

.phase-tp-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.phase-tp-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.phase-tp-field input {
  padding: 7px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  background: var(--bg-surface-strong);
  color: var(--text-default);
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  width: 100%;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.phase-tp-field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.phase-controls__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding-top: var(--space-2);
}

/* ─── Rotation Angle ─── */

.rotation-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: clamp(16px, 1.5vw, 24px) clamp(18px, 1.8vw, 22px);
}

.rotation-viewer__preview {
  background: #08111c;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, calc((100% - var(--space-2)) / 2));
}

.rotation-viewer__stage {
  position: relative;
  display: flex;
  width: 92%;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
}

.rotation-viewer__stage img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  transition: transform 0.2s ease;
  transform-origin: center;
}

.rotation-viewer__hline-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.rotation-viewer__blocked {
  width: 100%;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
}

.rotation-viewer__blocked-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-default);
}

.rotation-viewer__blocked-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.rotation-viewer__controls {
  width: 100%;
  max-width: 480px;
}

.rotation-angle-display {
  text-align: center;
}

.rotation-angle-input {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.rotation-angle-input input {
  width: 80px;
  text-align: center;
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 6px 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-default);
}

.rotation-angle-input input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.rotation-angle-unit {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-muted);
}

.rotation-viewer__footer {
  padding: clamp(14px, 1.2vw, 20px) clamp(18px, 1.8vw, 22px);
}

@media (max-width: 768px) {
  .rotation-viewer__preview {
    width: 100%;
  }
}

.roi-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.roi-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.roi-dot--arterial {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25), 0 0 8px rgba(239, 68, 68, 0.4);
}

.roi-dot--venous {
  background: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25), 0 0 8px rgba(96, 165, 250, 0.4);
}

/* ─── ROI Phase Actions Bar ─── */

.roi-phase-actions {
  display: flex;
  justify-content: flex-end;
  padding: var(--space-3) 0;
}

.roi-phase-actions .phase-controls__actions {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  padding: 6px 8px;
  box-shadow: var(--shadow-sm);
  gap: var(--space-2);
}

/* ─── Complete Panel ─── */

.complete-body {
  text-align: center;
  padding: clamp(32px, 3vw, 48px) clamp(18px, 1.8vw, 22px);
}

.complete-body__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  border-radius: 50%;
  background: rgba(34, 197, 94, 0.12);
  color: #22c55e;
  font-size: 32px;
  line-height: 64px;
  font-weight: 700;
}

.complete-body__text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-default);
  margin-bottom: var(--space-2);
}

.complete-body__sub {
  font-size: 14px;
  color: var(--text-muted);
}

.complete-footer {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  padding: clamp(14px, 1.2vw, 20px) clamp(18px, 1.8vw, 22px);
  border-top: 1px solid var(--border-default);
}
