:root {
  --bg: #0b1020;
  --bg-soft: #151b2f;
  --bg-elevated: #1c2540;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f2f5ff;
  --muted: #97a4c3;
  --accent: #5cc8ff;
  --accent-strong: #ff4d7d;
  --success: #2dd4bf;
  --danger: #ff738c;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

html,
body {
  height: 100%;
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(92, 200, 255, 0.12), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 77, 125, 0.1), transparent 20%),
    linear-gradient(180deg, #0a0f1d 0%, #090d18 100%);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

a {
  color: inherit;
}

.app-body {
  height: 100%;
  overflow: hidden;
}

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

.app-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 2rem;
  overflow: auto;
  padding: 2rem 1.5rem;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(18, 24, 43, 0.96), rgba(10, 14, 28, 0.98));
}

.app-brand {
  display: grid;
  gap: 0.35rem;
}

.app-brand strong {
  font-size: 1.9rem;
  letter-spacing: 0.04em;
}

.app-brand__eyebrow,
.app-topbar__eyebrow,
.content-card__eyebrow,
.metric-card__label,
.app-sidebar__label {
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--muted);
}

.app-brand__subcopy,
.app-sidebar__role,
.app-topbar__user,
.content-card p,
.metric-card__hint,
.text-secondary {
  color: var(--muted) !important;
}

.app-nav {
  display: grid;
  gap: 0.75rem;
}

.app-nav__link {
  display: block;
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.02);
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.app-nav__link:hover,
.app-nav__link--active {
  transform: translateX(4px);
  border-color: rgba(92, 200, 255, 0.35);
  background: linear-gradient(120deg, rgba(92, 200, 255, 0.14), rgba(255, 77, 125, 0.16));
}

.app-sidebar__footer {
  margin-top: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.03);
}

.app-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

.app-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 15, 29, 0.88);
  backdrop-filter: blur(18px);
}

.app-topbar__title {
  margin: 0.2rem 0 0;
  font-size: 2rem;
}

.app-topbar__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.app-content {
  min-height: 0;
  padding: 2rem;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.panel-grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.panel-grid--cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.metric-card,
.content-card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(27, 35, 58, 0.96), rgba(16, 21, 37, 0.98));
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 0.65rem;
  padding: 1.5rem;
}

.metric-card strong {
  font-size: 2.3rem;
  line-height: 1;
}

.content-card {
  padding: 1.5rem;
}

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

.content-card__header h2 {
  margin: 0.25rem 0 0;
}

.status-list,
.feature-list {
  display: grid;
  gap: 0.85rem;
  margin: 0;
  padding: 0;
}

.feature-list {
  list-style: none;
}

.feature-list li,
.status-row {
  padding: 0.95rem 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.study-search,
.upload-form {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.worklist-form,
.worklist-filter-grid {
  display: grid;
  gap: 1rem;
}

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

.worklist-form-grid__span-2 {
  grid-column: span 2;
}

.worklist-filter-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
}

.worklist-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.worklist-checkbox {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-height: 48px;
  padding-top: 1.85rem;
}

.worklist-checkbox .form-check-input {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  border-color: rgba(255, 255, 255, 0.16);
  background-color: rgba(255, 255, 255, 0.04);
}

.worklist-checkbox .form-check-label {
  margin: 0;
  color: var(--text);
}

.table-shell {
  overflow: auto;
  border-radius: 22px;
  border: 1px solid var(--line);
}

.orthanc-inbox-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.detail-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-grid--study {
  align-items: stretch;
}

.detail-tile {
  display: grid;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.detail-tile strong {
  font-size: 1.05rem;
}

.status-pill {
  display: grid;
  gap: 0.35rem;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.03);
}

.status-pill strong {
  font-size: 1.25rem;
}

.table-primary {
  font-weight: 600;
}

.table-secondary {
  color: var(--muted);
  font-size: 0.85rem;
}

.orthanc-id {
  font-family: "Consolas", "Courier New", monospace;
  word-break: break-all;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.table-actions form {
  margin: 0;
}

.table {
  margin-bottom: 0;
}

.table-dark {
  --bs-table-bg: transparent;
  --bs-table-border-color: rgba(255, 255, 255, 0.06);
  --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
  --bs-table-hover-bg: rgba(92, 200, 255, 0.08);
}

.badge {
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
}

.upload-dropzone {
  flex: 1 1 420px;
  display: grid;
  gap: 0.3rem;
  padding: 1.5rem;
  border-radius: 22px;
  border: 1px dashed rgba(92, 200, 255, 0.4);
  background: rgba(92, 200, 255, 0.05);
  cursor: pointer;
}

.upload-dropzone input {
  margin-top: 0.5rem;
  color: var(--muted);
}

.form-control,
.btn {
  border-radius: 14px;
}

.form-label {
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.form-control {
  min-height: 48px;
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.form-control:focus {
  border-color: rgba(92, 200, 255, 0.55);
  box-shadow: 0 0 0 0.2rem rgba(92, 200, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.btn-primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
}

.btn-outline-light {
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--text);
}

.btn-outline-info {
  border-color: rgba(92, 200, 255, 0.35);
  color: var(--accent);
}

.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-shell {
  width: min(100%, 960px);
}

.login-card {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 2rem;
  padding: 2rem;
  border-radius: 34px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(26, 34, 58, 0.98), rgba(12, 17, 31, 0.99));
  box-shadow: var(--shadow);
}

.login-card__brand h1 {
  margin-top: 0.4rem;
  font-size: 2.8rem;
}

.login-card__brand p {
  max-width: 30rem;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 1rem;
  align-content: center;
}

.login-card__footer {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
}

.alert {
  border-radius: 16px;
}

@media (max-width: 1200px) {
  .panel-grid--cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-body {
    height: auto;
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .app-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow: visible;
  }

  .app-main {
    min-height: auto;
    overflow: visible;
  }

  .login-card {
    grid-template-columns: 1fr;
  }

  .app-content {
    min-height: auto;
    overflow: visible;
    scrollbar-gutter: auto;
  }

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

@media (max-width: 720px) {
  .app-content,
  .app-topbar,
  .app-sidebar {
    padding: 1.25rem;
  }

  .panel-grid,
  .panel-grid--cards {
    grid-template-columns: 1fr;
  }

  .orthanc-inbox-summary {
    grid-template-columns: 1fr;
  }

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

  .worklist-form-grid,
  .worklist-filter-grid {
    grid-template-columns: 1fr;
  }

  .worklist-form-grid__span-2 {
    grid-column: auto;
  }
}
