/* Cases — shared page, button, form, list, and empty-state components.
   Used by patient (RX) cases, IPR cases, and user management. */

:root {
  /* Legacy aliases onto the foundation tokens (read by feature stylesheets). */
  --case-bg: var(--ah-bg);
  --case-surface: var(--ah-surface);
  --case-surface-2: var(--ah-surface-2);
  --case-border: var(--ah-border);
  --case-border-strong: var(--ah-border-strong);
  --case-text: var(--ah-ink);
  --case-text-soft: var(--ah-ink-2);
  --case-text-muted: var(--ah-ink-3);
  --case-mint: var(--ah-accent);
  --case-mint-strong: var(--ah-accent);
  --case-mint-soft: var(--ah-accent-soft);
  --case-radius: var(--ah-radius-lg);
  --case-radius-md: var(--ah-radius-md);
  --case-radius-sm: var(--ah-radius-sm);
  --case-shadow-sm: var(--ah-shadow-xs);
  --case-shadow: var(--ah-shadow-pop);
  --case-glow: var(--ah-focus-ring);
  --case-font: var(--ah-font);
}

/* ── Page frame ──────────────────────────────────────────── */

.case-page {
  width: 100%;
  max-width: 88rem;
  margin: 0 auto;
  padding: 2.25rem var(--ah-gutter) 5rem;
  box-sizing: border-box;
}

/* Page blocks rise into place once per navigation. */
.case-page > * {
  animation: ah-rise var(--ah-dur-4) var(--ah-ease-spring) both;
}

.case-page > *:nth-child(2) { animation-delay: 60ms; }
.case-page > *:nth-child(3) { animation-delay: 120ms; }
.case-page > *:nth-child(4) { animation-delay: 170ms; }
.case-page > *:nth-child(n+5) { animation-delay: 210ms; }

.case-page--form {
  max-width: 56rem;
}

.case-page--ipr-form {
  max-width: 88rem;
}

.case-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ah-space-4);
  min-height: 2.5rem;
  margin-bottom: 1.75rem;
}

.case-page__header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--ah-space-2);
  flex-shrink: 0;
}

.case-page__header-actions form {
  margin: 0;
}

.case-page__title {
  margin: 0;
  font-size: var(--ah-text-display);
  font-weight: var(--ah-weight-semibold);
  line-height: 1.15;
  letter-spacing: -0.032em;
  color: var(--ah-ink);
}

.case-page__case-number {
  margin-left: 0.375rem;
  font-family: var(--ah-mono);
  font-size: var(--ah-text-base);
  font-weight: var(--ah-weight-regular);
  letter-spacing: -0.01em;
  color: var(--ah-ink-3);
  -webkit-text-fill-color: currentColor;
}

.case-page__brand {
  margin: 0 0 1.5rem;
  font-size: var(--ah-text-xl);
  font-weight: var(--ah-weight-semibold);
  color: var(--ah-ink);
  text-align: center;
  letter-spacing: -0.02em;
}

.case-page--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 4rem;
}

/* ── Search ──────────────────────────────────────────────── */

.case-search {
  margin: 0 0 var(--ah-space-3);
  width: 100%;
}

.case-search--above-table {
  margin-bottom: var(--ah-space-4);
}

.case-search__shell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 26rem;
  height: 2.5rem;
  padding: 0 0.75rem;
  border: 1px solid var(--ah-border);
  border-radius: var(--ah-radius-md);
  background: var(--ah-surface);
  box-shadow: var(--ah-shadow-xs), var(--ah-inner-highlight);
  box-sizing: border-box;
  transition: border-color var(--ah-dur-1), box-shadow var(--ah-dur-2);
}

.case-search__shell:hover {
  border-color: var(--ah-border-strong);
}

.case-search__shell:focus-within {
  border-color: var(--ah-accent);
  box-shadow: var(--ah-focus-ring);
}

.case-search__icon {
  display: inline-flex;
  color: var(--ah-ink-4);
  flex-shrink: 0;
}

.case-search__icon svg {
  width: 15px;
  height: 15px;
}

.case-search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ah-ink);
  font-size: var(--ah-text-base);
  padding: 0;
}

.case-search__input:focus-visible {
  outline: none;
}

.case-search__input::-webkit-search-cancel-button {
  display: none;
}

.case-search__clear {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--ah-radius-xs);
  color: var(--ah-ink-4);
  text-decoration: none;
  flex-shrink: 0;
  transition: background var(--ah-dur-1), color var(--ah-dur-1);
}

.case-search__clear:hover {
  color: var(--ah-ink);
  background: var(--ah-surface-3);
  text-decoration: none;
}

/* ── Buttons ─────────────────────────────────────────────── */

.case-btn,
.case-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.375rem;
  padding: 0 1rem;
  border: 1px solid transparent;
  border-radius: var(--ah-radius-md);
  font-family: inherit;
  font-size: var(--ah-text-sm);
  font-weight: var(--ah-weight-medium);
  line-height: 1;
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  transition:
    background var(--ah-dur-1),
    border-color var(--ah-dur-1),
    color var(--ah-dur-1),
    box-shadow var(--ah-dur-2),
    filter var(--ah-dur-2),
    transform var(--ah-dur-2) var(--ah-ease-spring);
  -webkit-user-select: none;
  user-select: none;
}

.case-btn svg,
.case-back svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  transition: transform var(--ah-dur-3) var(--ah-ease-spring);
}

/* Trailing arrows lean forward; leading back-chevrons lean back. */
.case-btn:hover svg:last-child:not(:first-child) {
  transform: translateX(2px);
}

.case-back:hover svg {
  transform: translateX(-2px);
}

.case-btn:hover,
.case-back:hover {
  text-decoration: none;
}

.case-btn:active:not(:disabled),
.case-back:active {
  transform: scale(0.97);
}

.case-btn:focus-visible,
.case-back:focus-visible {
  outline: none;
  box-shadow: var(--ah-focus-ring);
}

/* Primary — solid accent. "next" is the same role (wizard advance, create). */
.case-btn--primary,
.case-btn--next {
  background: var(--ah-accent-grad);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 0 0 1px rgba(8, 90, 82, 0.9),
    0 6px 16px -6px rgba(13, 122, 112, 0.55);
}

.case-btn--primary:hover,
.case-btn--next:hover {
  background: var(--ah-accent-grad-hover);
  color: #fff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 0 0 1px rgba(8, 90, 82, 0.9),
    0 10px 24px -8px rgba(13, 122, 112, 0.6);
}

.case-btn--primary:active,
.case-btn--next:active {
  filter: brightness(0.95);
}

.case-btn--primary:focus-visible,
.case-btn--next:focus-visible {
  box-shadow: 0 0 0 1px var(--ah-surface), 0 0 0 3px var(--ah-accent);
}

.case-btn--primary svg,
.case-btn--next svg {
  color: rgba(255, 255, 255, 0.9);
}

/* Secondary — surface with hairline. Back links share it. */
.case-btn--ghost,
.case-back {
  background: var(--ah-surface);
  border-color: var(--ah-border);
  color: var(--ah-ink);
  box-shadow: 0 1px 2px rgba(10, 26, 28, 0.06), var(--ah-inner-highlight);
}

.case-btn--ghost svg,
.case-back svg {
  color: var(--ah-ink-3);
}

.case-btn--ghost:hover,
.case-back:hover {
  border-color: var(--ah-border-strong);
  background: var(--ah-surface);
  color: var(--ah-ink);
  box-shadow: 0 4px 12px -4px rgba(10, 26, 28, 0.14), var(--ah-inner-highlight);
}

.case-btn--ghost:active,
.case-back:active {
  background: var(--ah-surface-2);
}

.case-back {
  flex-shrink: 0;
  padding: 0 0.75rem 0 0.5625rem;
}

/* Danger — quiet until it matters. */
.case-btn--danger {
  background: var(--ah-surface);
  border-color: var(--ah-border);
  color: var(--ah-danger);
  box-shadow: 0 1px 2px rgba(10, 26, 28, 0.06), var(--ah-inner-highlight);
}

.case-btn--danger:hover:not(:disabled) {
  background: var(--ah-danger-soft);
  border-color: var(--ah-danger-border);
  color: var(--ah-danger-ink);
}

.case-btn:disabled,
.case-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* ── Forms ───────────────────────────────────────────────── */

.case-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.case-form__errors {
  border: 1px solid var(--ah-danger-border);
  background: var(--ah-danger-soft);
  color: var(--ah-danger-ink);
  border-radius: var(--ah-radius-md);
  padding: 0.75rem 1rem;
  font-size: var(--ah-text-sm);
  line-height: 1.5;
}

.case-form__errors ul {
  margin: 0.375rem 0 0;
  padding-left: 1.125rem;
}

.case-form__section + .case-form__section {
  margin-top: 1.5rem;
}

.case-form__section + .case-form__actions {
  margin-top: 1.25rem;
}

.case-form__title {
  margin: 0 0 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--ah-border);
  font-size: var(--ah-text-md);
  font-weight: var(--ah-weight-semibold);
  letter-spacing: -0.01em;
  color: var(--ah-ink);
}

.case-form__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.125rem 1.25rem;
}

.case-form__field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

.case-form__field label {
  font-size: var(--ah-text-sm);
  font-weight: var(--ah-weight-medium);
  letter-spacing: 0;
  text-transform: none;
  color: var(--ah-ink-2);
}

.case-form__field input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
.case-form__field select,
.case-form__field textarea {
  width: 100%;
  min-height: 2.5rem;
  box-sizing: border-box;
  border: 1px solid var(--ah-border);
  border-radius: var(--ah-radius-md);
  padding: 0.5625rem 0.8125rem;
  font-size: var(--ah-text-base);
  font-weight: var(--ah-weight-regular);
  font-family: inherit;
  line-height: 1.4;
  color: var(--ah-ink);
  background-color: var(--ah-surface);
  box-shadow: var(--ah-shadow-xs);
  transition: border-color var(--ah-dur-1), box-shadow var(--ah-dur-1), background-color var(--ah-dur-1);
}

.case-form__field input::placeholder,
.case-form__field textarea::placeholder {
  color: var(--ah-placeholder);
  font-weight: var(--ah-weight-regular);
}

.case-form__field select {
  appearance: none;
  padding-right: 2.25rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%235b6769' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 6.5 8 9.5l3-3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 1rem 1rem;
}

/* Keep the "Select type" prompt reading as a placeholder, not a real value. */
.case-form__field select:has(option[value=""]:checked) {
  color: var(--ah-placeholder);
}

.case-form__field select option {
  color: var(--ah-ink);
}

.case-form__field input:not([type="checkbox"]):not([type="radio"]):hover,
.case-form__field select:hover,
.case-form__field textarea:hover {
  border-color: var(--ah-border-strong);
}

.case-form__field input:not([type="checkbox"]):not([type="radio"]):focus,
.case-form__field select:focus,
.case-form__field textarea:focus {
  outline: none;
  border-color: var(--ah-accent);
  box-shadow: var(--ah-focus-ring);
}

/* Matches the specificity of the base field selector above so it wins. */
.case-form__field input.case-form__input--readonly:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]),
.case-form__field input.case-form__input--readonly:not([type="checkbox"]):not([type="radio"]):hover,
.case-form__field input.case-form__input--readonly:not([type="checkbox"]):not([type="radio"]):focus {
  background: var(--ah-surface-2);
  border-color: var(--ah-border);
  color: var(--ah-ink-2);
  font-family: var(--ah-mono);
  font-size: var(--ah-text-sm);
  cursor: default;
  box-shadow: none;
}

.case-form__hint {
  font-size: var(--ah-text-xs);
  color: var(--ah-ink-3);
}

.case-form__stage-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  padding: 0.875rem 1rem;
  border: 1px solid var(--ah-border);
  border-radius: var(--ah-radius-md);
  background: var(--ah-surface-2);
  box-sizing: border-box;
}

.case-form__field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.case-form__field--checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  padding: 0;
  cursor: pointer;
}

.case-form__field--checkbox label {
  margin: 0;
  font-size: var(--ah-text-base);
  font-weight: var(--ah-weight-medium);
  color: var(--ah-ink);
  cursor: pointer;
}

.case-form__actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--ah-space-2);
}

.case-form__actions--split {
  justify-content: space-between;
  padding-top: 0.25rem;
}

/* ── Show (IPR case detail) ──────────────────────────────── */

.case-show {
  background: var(--ah-surface);
  border: 0;
  border-radius: var(--ah-radius-lg);
  padding: 0;
  overflow: hidden;
  margin: 6px;
  box-shadow: 0 0 0 5px var(--ah-shell-bg), 0 0 0 6px rgba(10, 26, 28, 0.06), var(--ah-shadow-card);
}

.case-show__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 0;
}

.case-show__item {
  display: grid;
  grid-template-columns: minmax(7rem, 11rem) 1fr;
  align-items: baseline;
  gap: var(--ah-space-4);
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--ah-border);
}

.case-show__item:nth-child(odd) {
  border-right: 1px solid var(--ah-border);
}

.case-show__item dt {
  margin: 0;
  font-size: var(--ah-text-sm);
  font-weight: var(--ah-weight-regular);
  color: var(--ah-ink-3);
}

.case-show__item dd {
  margin: 0;
  font-size: var(--ah-text-base);
  font-weight: var(--ah-weight-medium);
  color: var(--ah-ink);
  min-width: 0;
  overflow-wrap: anywhere;
}

.case-show__stages {
  white-space: pre-line;
  line-height: 1.5;
}

.case-show__link {
  color: var(--ah-accent);
  font-weight: var(--ah-weight-medium);
  text-decoration: none;
}

.case-show__link:hover {
  text-decoration: underline;
}

.case-show__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--ah-space-2);
  padding: 0.875rem 1.25rem;
  background: var(--ah-surface-2);
  border-top: 0;
}

/* ── Case list (table) ───────────────────────────────────── */

.case-list {
  display: grid;
  grid-template-columns:
    minmax(8rem, 1.15fr)
    minmax(6rem, 1fr)
    minmax(6rem, 1fr)
    minmax(5rem, 0.85fr)
    minmax(8rem, 1fr)
    minmax(6rem, 0.8fr)
    max-content;
  column-gap: 1rem;
  background: var(--ah-surface);
  border: 0;
  border-radius: var(--ah-radius-lg);
  overflow: hidden;
  /* Double bezel drawn with rings: a hairline tray around a white core. */
  margin: 6px;
  box-shadow:
    0 0 0 5px var(--ah-shell-bg),
    0 0 0 6px rgba(10, 26, 28, 0.06),
    var(--ah-shadow-card);
}

.case-list__head,
.case-list__row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: subgrid;
  align-items: center;
  padding: 0 1rem;
}

.case-list__head {
  min-height: 2.5rem;
  background: linear-gradient(180deg, #fafbfb, var(--ah-surface-2));
  border-bottom: 1px solid var(--ah-border);
  font-size: var(--ah-text-xs);
  font-weight: var(--ah-weight-medium);
  text-transform: none;
  letter-spacing: 0;
  color: var(--ah-ink-3);
}

.case-list__sort {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-left: -0.375rem;
  padding: 0.25rem 0.375rem;
  border-radius: var(--ah-radius-xs);
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--ah-dur-1), color var(--ah-dur-1);
}

.case-list__sort:hover {
  background: var(--ah-surface-3);
  color: var(--ah-ink);
  text-decoration: none;
}

.case-list__sort-icon {
  display: inline-flex;
  color: var(--ah-ink-4);
}

.case-list__sort--asc .case-list__sort-icon path:first-child,
.case-list__sort--desc .case-list__sort-icon path:last-child {
  opacity: 0.3;
}

.case-list__sort--asc .case-list__sort-icon path:last-child,
.case-list__sort--desc .case-list__sort-icon path:first-child {
  color: var(--ah-ink);
  opacity: 1;
}

.case-list__row {
  position: relative;
  min-height: 3.25rem;
  font-size: var(--ah-text-base);
  color: var(--ah-ink);
  border-bottom: 1px solid var(--ah-border);
  transition: background var(--ah-dur-2) var(--ah-ease-out), box-shadow var(--ah-dur-2) var(--ah-ease-out);
  animation: ah-rise 460ms var(--ah-ease-spring) both;
  animation-delay: 140ms;
}

.case-list__row:nth-child(3) { animation-delay: 170ms; }
.case-list__row:nth-child(4) { animation-delay: 200ms; }
.case-list__row:nth-child(5) { animation-delay: 230ms; }
.case-list__row:nth-child(6) { animation-delay: 260ms; }
.case-list__row:nth-child(7) { animation-delay: 290ms; }
.case-list__row:nth-child(n+8) { animation-delay: 320ms; }

.case-list__row > * {
  min-width: 0;
}

.case-list__row:last-child {
  border-bottom: none;
}

.case-list__row:hover {
  background: linear-gradient(90deg, rgba(20, 162, 145, 0.06), rgba(20, 162, 145, 0.015) 40%, transparent);
  box-shadow: inset 3px 0 0 var(--ah-accent);
}

.case-list__case-number,
a.case-list__case-number {
  font-family: var(--ah-mono);
  font-size: var(--ah-text-sm);
  font-weight: var(--ah-weight-medium);
  letter-spacing: -0.01em;
  color: var(--ah-ink);
  text-decoration: none;
  white-space: nowrap;
}

a.case-list__case-number:hover {
  color: var(--ah-accent);
  text-decoration: underline;
}

.case-list__stages {
  white-space: pre-line;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}

.case-list__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: nowrap;
  gap: 0.125rem;
  white-space: nowrap;
}

.case-list__actions form {
  display: inline-flex;
  margin: 0;
}

/* Row actions — quiet icon buttons; colour only on intent. */
.case-action {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 0;
  border-radius: var(--ah-radius-sm);
  background: transparent;
  color: var(--ah-ink-3);
  text-decoration: none;
  cursor: pointer;
  appearance: none;
  transition: background var(--ah-dur-1), color var(--ah-dur-1), transform var(--ah-dur-1) var(--ah-ease-out);
}

.case-action svg {
  width: 16px;
  height: 16px;
}

.case-action:hover {
  background: var(--ah-surface-3);
  color: var(--ah-ink);
  text-decoration: none;
}

.case-action:active:not(:disabled) {
  transform: scale(0.92);
}

.case-action:focus-visible {
  outline: none;
  box-shadow: var(--ah-focus-ring);
}

.case-action--show,
.case-action--edit,
.case-action--treatment {
  color: var(--ah-ink-3);
}

.case-action--next,
.case-action--next:hover {
  color: var(--ah-accent);
}

.case-action--next:hover {
  background: var(--ah-accent-soft);
}

.case-action--prev {
  color: var(--ah-ink-3);
}

.case-action--prev:hover {
  background: var(--ah-warning-soft);
  color: var(--ah-warning);
}

.case-action--remove {
  color: var(--ah-ink-4);
}

.case-action--remove:hover {
  background: var(--ah-danger-soft);
  color: var(--ah-danger);
}

.case-action:disabled,
.case-action--next-disabled,
.case-action--prev-disabled,
.case-action--next-disabled:hover,
.case-action--prev-disabled:hover {
  opacity: 0.35;
  color: var(--ah-ink-4);
  background: transparent;
  cursor: not-allowed;
}

/* ── Hold switch ─────────────────────────────────────────── */

.rx-hold-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4375rem;
  margin: 0;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.rx-hold-switch__text {
  font-size: var(--ah-text-xs);
  font-weight: var(--ah-weight-medium);
  letter-spacing: 0;
  text-transform: none;
  color: var(--ah-ink-3);
}

.rx-hold-switch__input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.rx-hold-switch__track {
  position: relative;
  flex: 0 0 auto;
  width: 1.875rem;
  height: 1.125rem;
  border-radius: 999px;
  background: var(--ah-border-strong);
  transition: background var(--ah-dur-2) var(--ah-ease-out);
}

.rx-hold-switch__thumb {
  position: absolute;
  top: 0.125rem;
  left: 0.125rem;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 25, 0.24);
  transform-origin: left center;
  transition: transform var(--ah-dur-2) var(--ah-ease-out), scale var(--ah-dur-1) var(--ah-ease-out);
}

/* A pressed thumb squashes toward its travel direction. */
.rx-hold-switch:active .rx-hold-switch__thumb {
  scale: 1.2 1;
}

.rx-hold-switch:active .rx-hold-switch__input:checked + .rx-hold-switch__track .rx-hold-switch__thumb {
  transform-origin: right center;
}

.rx-hold-switch__input:checked + .rx-hold-switch__track {
  background: var(--ah-warning);
}

.rx-hold-switch__input:checked + .rx-hold-switch__track .rx-hold-switch__thumb {
  transform: translateX(0.75rem);
}


.rx-hold-switch__input:focus-visible + .rx-hold-switch__track {
  outline: 2px solid var(--ah-accent);
  outline-offset: 2px;
}

.rx-hold-switch:has(.rx-hold-switch__input:checked) .rx-hold-switch__text {
  color: var(--ah-warning);
}

.rx-hold-switch__input:disabled + .rx-hold-switch__track {
  opacity: 0.6;
  cursor: progress;
}

/* ── Empty state ─────────────────────────────────────────── */

.case-empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  max-width: 26rem;
  margin: 0;
  padding: 3rem 2rem;
  background:
    radial-gradient(18rem 10rem at 50% 0%, rgba(20, 162, 145, 0.08), transparent 70%),
    var(--ah-surface);
  border: 0;
  border-radius: var(--ah-radius-lg);
  box-sizing: border-box;
  margin: 6px;
  box-shadow: 0 0 0 5px var(--ah-shell-bg), 0 0 0 6px rgba(10, 26, 28, 0.06), var(--ah-shadow-card);
}

/* Search "no matches" card: match the list width. */
.case-empty-card.case-empty-card--inline {
  max-width: none;
  margin-top: 0.5rem;
}

.case-empty-card.case-empty-card--inline .case-empty-card__text {
  max-width: 28rem;
}

.case-empty-card__icon {
  display: inline-grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  margin-bottom: 1.125rem;
  border-radius: 14px;
  background: linear-gradient(160deg, #ffffff, var(--ah-accent-soft));
  box-shadow: 0 0 0 1px rgba(13, 122, 112, 0.14), 0 8px 20px -10px rgba(13, 122, 112, 0.5), var(--ah-inner-highlight);
  color: var(--ah-accent);
}

.case-empty-card__icon svg {
  width: 20px;
  height: 20px;
}

.case-empty-card__title {
  margin: 0 0 0.375rem;
  font-size: var(--ah-text-md);
  font-weight: var(--ah-weight-semibold);
  letter-spacing: -0.01em;
  color: var(--ah-ink);
}

.case-empty-card__text {
  margin: 0 0 1.25rem;
  font-size: var(--ah-text-base);
  line-height: 1.55;
  color: var(--ah-ink-3);
  max-width: 22rem;
}

.case-empty-card__text:last-child {
  margin-bottom: 0;
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 900px) {
  .case-list {
    display: block;
  }

  .case-list__head {
    display: none;
  }

  .case-list__row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem 1rem;
    padding: 1rem;
  }

  .case-list__row > span::before {
    display: block;
    margin-bottom: 0.125rem;
    font-size: var(--ah-text-xs);
    font-weight: var(--ah-weight-regular);
    color: var(--ah-ink-3);
  }

  .case-list__row > span:nth-child(1)::before { content: "Case number"; }
  .case-list__row > span:nth-child(2)::before { content: "Patient"; }
  .case-list__row > span:nth-child(3)::before { content: "Doctor"; }
  .case-list__row > span:nth-child(4)::before { content: "Type"; }
  .case-list__row > span:nth-child(5)::before { content: "Stage"; }
  .case-list__row > span:nth-child(6)::before { content: "Stages"; }

  .case-list__actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    gap: 0.25rem;
    margin: 0 -0.375rem -0.375rem;
  }

  .case-action {
    width: 2.75rem;
    height: 2.75rem;
  }
}

@media (max-width: 640px) {
  .case-page {
    padding-top: 1.25rem;
  }

  .case-page__header {
    flex-wrap: wrap;
  }

  .case-page__header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .case-page__header-actions > .case-btn,
  .case-page__header-actions > form,
  .case-page__header-actions > a {
    flex: 1 1 auto;
  }

  .case-btn,
  .case-back {
    height: 2.75rem;
  }

  .case-search__shell {
    max-width: none;
    height: 2.75rem;
  }

  .case-form__grid,
  .case-show__grid {
    grid-template-columns: 1fr;
  }

  .case-show__item {
    grid-template-columns: 1fr;
    gap: 0.125rem;
  }

  .case-show__item:nth-child(odd) {
    border-right: 0;
  }

  .case-show__actions > * {
    flex: 1;
  }
}
