:root {
  --sidebar-width: 272px;
  --ink: #1e2524;
  --muted: #66746f;
  --line: #d9e2de;
  --surface: #ffffff;
  --surface-soft: #f4f7f5;
  --sidebar: #202321;
  --emerald: #087a5d;
  --coral: #d95d4f;
  --gold: #b88712;
  --sky: #217f97;
  --violet: #6f5aa7;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(8, 122, 93, 0.1), transparent 34%),
    linear-gradient(240deg, rgba(217, 93, 79, 0.08), transparent 34%),
    var(--surface-soft);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[data-bs-theme="dark"] body {
  --ink: #edf6f2;
  --muted: #aebdb7;
  --line: #37443f;
  --surface: #171c1a;
  --surface-soft: #101412;
  --sidebar: #161817;
  background: #101412;
}

a {
  text-decoration: none;
}

.btn-primary {
  --bs-btn-bg: var(--emerald);
  --bs-btn-border-color: var(--emerald);
  --bs-btn-hover-bg: #066a51;
  --bs-btn-hover-border-color: #066a51;
}

.btn-outline-primary {
  --bs-btn-color: var(--emerald);
  --bs-btn-border-color: var(--emerald);
  --bs-btn-hover-bg: var(--emerald);
  --bs-btn-hover-border-color: var(--emerald);
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 20px;
  color: #fff;
  background: var(--sidebar);
}

.brand,
.brand-large {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
}

.brand:hover {
  color: #fff;
}

.brand small {
  display: block;
  color: #aab8b2;
}

.brand-mark {
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--emerald), var(--coral));
}

.sidebar-nav {
  gap: 8px;
  margin-top: 32px;
}

.sidebar-nav .nav-link,
.sidebar-footer .btn,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.sidebar-nav .nav-link {
  min-height: 42px;
  border-radius: 8px;
  color: #d8e2ef;
}

.sidebar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
  margin-top: auto;
}

.app-main {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
}

.auth-main {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 84px;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(16px);
}

.topbar-actions,
.summary-tags,
.auth-metrics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.content-wrap {
  width: min(1280px, calc(100vw - var(--sidebar-width) - 40px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.auth-main .content-wrap {
  width: min(1120px, calc(100vw - 32px));
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 0;
}

.eyebrow {
  color: var(--emerald);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.icon-btn {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

.icon-btn.subtle {
  width: 34px;
  height: 34px;
  color: var(--emerald);
}

.user-chip,
.auth-metrics span,
.summary-tags span,
.widget-list span {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 10px;
  color: var(--muted);
  background: var(--surface);
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 430px;
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.14);
}

.auth-visual {
  display: flex;
  min-height: 620px;
  flex-direction: column;
  justify-content: space-between;
  padding: 42px;
  color: #fff;
  background:
    linear-gradient(rgba(23, 31, 28, 0.72), rgba(23, 31, 28, 0.7)),
    url("https://images.unsplash.com/photo-1581093458791-9d7d8f1400d6?auto=format&fit=crop&w=1400&q=80")
      center/cover;
}

.auth-visual h1 {
  max-width: 620px;
  font-size: clamp(2rem, 5vw, 4.8rem);
  line-height: 1;
}

.brand-large {
  font-size: 1.35rem;
  font-weight: 800;
}

.login-box,
.stack-form {
  display: flex;
  flex-direction: column;
}

.login-box {
  gap: 24px;
  justify-content: center;
  padding: 34px;
}

.stack-form {
  gap: 16px;
}

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

.demo-account {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: left;
  color: var(--ink);
  background: var(--surface-soft);
}

.demo-account span,
.demo-account small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.demo-account small {
  color: var(--muted);
}

.dashboard-grid,
.two-column,
.three-column,
.stats-grid,
.module-grid {
  display: grid;
  gap: 18px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
}

.two-column {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.three-column,
.stats-grid,
.module-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

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

.role-panel,
.chart-panel,
.panel,
.metric-card,
.module-card,
.patient-summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.08);
}

.role-panel {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 18px;
  padding: 24px;
}

.role-icon {
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--emerald), var(--sky));
}

.role-panel h2,
.panel h2,
.chart-panel h2 {
  margin: 0;
  font-size: 1.1rem;
}

.widget-list {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-panel,
.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.search-form {
  display: flex;
  width: min(100%, 520px);
  gap: 10px;
}

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

.metric-card,
.module-card {
  display: grid;
  min-height: 128px;
  gap: 8px;
  padding: 18px;
}

.metric-card i,
.module-card i {
  color: var(--emerald);
}

.accent-card:nth-child(2n) i {
  color: var(--coral);
}

.accent-card:nth-child(3n) i {
  color: var(--gold);
}

.metric-card strong {
  font-size: 2rem;
}

.metric-card span,
.module-card span,
.stack-list span,
.patient-summary p {
  color: var(--muted);
}

.stack-list {
  display: grid;
  gap: 10px;
}

.stack-list article {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.task-list article {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.78rem;
  font-weight: 700;
}

.status-pill.high {
  border-color: color-mix(in srgb, var(--coral) 45%, var(--line));
  color: var(--coral);
}

.status-pill.normal {
  border-color: color-mix(in srgb, var(--gold) 45%, var(--line));
  color: var(--gold);
}

.role-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.role-check {
  min-height: 42px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px 8px 34px;
  background: var(--surface-soft);
}

.admin-layout {
  align-items: start;
}

.patient-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
}

.empty-state {
  display: grid;
  min-height: 360px;
  place-items: center;
  text-align: center;
}

.empty-state.compact {
  min-height: 280px;
  color: var(--muted);
}

.ai-workbench {
  align-items: start;
}

.model-footnote {
  display: grid;
  gap: 6px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.model-disclosure {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.84rem;
}

.model-disclosure summary {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.model-disclosure summary::-webkit-details-marker {
  display: none;
}

.model-disclosure summary span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.model-disclosure summary > .lucide {
  transition: transform 160ms ease;
}

.model-disclosure[open] summary > .lucide {
  transform: rotate(180deg);
}

.model-detail-list {
  display: grid;
  gap: 7px;
  padding: 0 0 14px 26px;
}

.model-detail-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.model-detail-list strong {
  color: var(--ink);
}

.model-detail-list span {
  text-align: right;
}

.model-thresholds {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 14px 26px;
}

.model-thresholds span {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--surface-soft);
}

.clinical-disclaimer {
  margin: 0;
  border-left: 3px solid var(--line);
  padding: 8px 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

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

.segmentation-grid figure {
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.segmentation-grid figure.wide {
  grid-column: 1 / -1;
}

.segmentation-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 1;
  object-fit: contain;
  background: #050706;
}

.image-zoom-trigger {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: #050706;
  cursor: zoom-in;
}

.image-zoom-trigger:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: -3px;
}

.image-zoom-badge {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  color: #fff;
  background: rgba(17, 24, 21, 0.8);
}

.image-lightbox {
  width: min(96vw, 1440px);
  max-width: none;
  max-height: 94vh;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.image-lightbox::backdrop {
  background: rgba(3, 5, 4, 0.88);
}

.image-lightbox-shell {
  position: relative;
  display: grid;
  max-height: 94vh;
  place-items: center;
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: #050706;
}

.image-lightbox img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 92vh;
  object-fit: contain;
}

.image-lightbox-close {
  position: absolute;
  z-index: 2;
  top: 10px;
  right: 10px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 6px;
  color: #fff;
  background: rgba(17, 24, 21, 0.86);
}

.result-actions {
  display: flex;
  justify-content: flex-end;
}

.segmentation-grid figcaption {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.table {
  --bs-table-bg: transparent;
}

.lucide {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.synthetic-attestation {
  align-items: flex-start;
  background: color-mix(in srgb, var(--bs-primary) 7%, transparent);
  border: 1px solid color-mix(in srgb, var(--bs-primary) 22%, transparent);
  border-radius: 10px;
  gap: 10px;
  padding: 12px;
}

.ai-run-status {
  background: color-mix(in srgb, var(--bs-info) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--bs-info) 24%, transparent);
  border-radius: 12px;
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 14px;
}

.ai-run-status[hidden] {
  display: none;
}

.ai-run-status-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ai-run-status progress {
  accent-color: var(--bs-primary);
  height: 8px;
  width: 100%;
}

.recent-ai-runs {
  border-top: 1px solid var(--bs-border-color);
  display: grid;
  gap: 6px;
  margin-top: 18px;
  padding-top: 14px;
}

.recent-ai-run {
  align-items: center;
  color: inherit;
  display: flex;
  justify-content: space-between;
  text-decoration: none;
}

.recent-ai-run:hover {
  color: var(--bs-primary);
}

@media (max-width: 980px) {
  :root {
    --sidebar-width: 0px;
  }

  .app-sidebar {
    position: static;
    width: 100%;
    min-height: auto;
  }

  .app-main {
    margin-left: 0;
  }

  .content-wrap {
    width: min(100% - 24px, 1280px);
  }

  .dashboard-grid,
  .two-column,
  .three-column,
  .stats-grid,
  .module-grid,
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    min-height: 360px;
  }
}

@media (max-width: 640px) {
  .topbar,
  .patient-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .demo-grid {
    grid-template-columns: 1fr;
  }

  .task-list article,
  .role-check-grid,
  .search-form,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .search-form {
    width: 100%;
    flex-direction: column;
  }

  .login-box,
  .auth-visual,
  .topbar {
    padding: 22px;
  }

  .model-detail-list div {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .model-detail-list span {
    text-align: left;
  }

  .segmentation-grid {
    grid-template-columns: 1fr;
  }
}
