:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #667085;
  --primary: #1250e6;
  --primary-dark: #0d46d0;
  --border: #e8eaf2;
  --shadow-soft: 0 6px 18px rgba(41, 47, 76, 0.06);
  --error-bg: #fef2f2;
  --error-text: #b42318;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  min-height: 100vh;
}

a,
button {
  color: inherit;
  font: inherit;
}

a {
  text-decoration: none;
}

.assign-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 24;
  padding: 18px 16px 14px;
  background:
    radial-gradient(circle at top right, rgba(18, 80, 230, 0.16), transparent 32%),
    linear-gradient(180deg, #ffffff 0%, #f7f8fd 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: grid;
  gap: 14px;
}

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

.topbar__nav .back-link {
  justify-self: start;
}

.topbar__nav .support-link {
  justify-self: end;
}

.brand--centered {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.brand__logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(18, 80, 230, 0.18);
  flex-shrink: 0;
}

.brand__name {
  font-size: 18px;
  font-weight: 800;
  white-space: nowrap;
}

.title-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #eceff3;
  border: 1px solid #dde3eb;
}

.title-strip h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  min-width: 0;
}

.assign-main {
  padding: 18px 16px 124px;
  display: grid;
  gap: 18px;
}

.patients-panel {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow-soft);
  padding: 18px;
}

.compact-panel {
  padding-top: 16px;
}

.section-header h2 {
  margin: 0 0 6px;
  font-size: 28px;
}

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

.section-header__action {
  border: none;
  border-radius: 14px;
  padding: 12px 22px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(18, 80, 230, 0.2);
  flex-shrink: 0;
}

.screen-message {
  border-radius: 16px;
  padding: 14px 16px;
  font-size: 14px;
  font-weight: 700;
}

.screen-message--error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid rgba(180, 35, 24, 0.12);
}

.empty-state {
  margin-top: 18px;
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed #d5dbe5;
  color: var(--muted);
  text-align: center;
}

.patients-grid {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.patient-select-button {
  appearance: none;
  border: 1px solid rgba(37, 211, 102, 0.24);
  border-radius: 20px;
  min-height: 74px;
  padding: 18px 56px 18px 22px;
  background:
    linear-gradient(180deg, rgba(37, 211, 102, 0.14), rgba(37, 211, 102, 0.09));
  color: #166534;
  font-weight: 700;
  font-size: 21px;
  line-height: 1.15;
  text-align: left;
  box-shadow:
    0 10px 24px rgba(22, 101, 52, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
  cursor: pointer;
  position: relative;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background 0.18s ease,
    color 0.18s ease;
}

.patient-select-button::after {
  content: "›";
  position: absolute;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(22, 101, 52, 0.8);
  font-size: 28px;
  font-weight: 500;
}

.patient-select-button:hover,
.patient-select-button:focus-visible {
  border-color: rgba(37, 211, 102, 0.36);
  background:
    linear-gradient(135deg, rgba(37, 211, 102, 0.18), rgba(37, 211, 102, 0.11)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(240, 253, 244, 0.9));
  color: #14532d;
  box-shadow:
    0 16px 36px rgba(22, 101, 52, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  transform: translateY(-1px);
}

.patient-select-button:focus-visible {
  outline: none;
}

.patient-select-button:hover::after,
.patient-select-button:focus-visible::after {
  color: #14532d;
}

.patient-select-button:active {
  transform: scale(0.992);
}

.compact-patients-list {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.compact-patient-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: #fbfcff;
  display: grid;
  gap: 4px;
}

.compact-patient-item__name {
  font-size: 16px;
  font-weight: 800;
  color: #1f2430;
}

.compact-patient-item__meta {
  font-size: 14px;
  color: #667085;
  line-height: 1.45;
  word-break: break-word;
}

.task-choice-modal[hidden] {
  display: none !important;
}

.task-choice-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
}

.task-choice-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(6px);
}

.task-choice-modal__card {
  position: relative;
  z-index: 1;
  width: min(calc(100vw - 24px), 560px);
  margin: 12vh auto 0;
  padding: 12px 20px 20px;
  border-radius: 24px;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
  display: grid;
  gap: 18px;
}

.task-choice-modal__header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: -4px;
}

.task-choice-modal__label {
  margin: 0 0 6px;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.task-choice-modal__header h3 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.15;
}

.task-choice-modal__subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.patient-edit-form {
  display: grid;
  gap: 14px;
}

.patient-edit-section {
  display: grid;
  gap: 14px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.patient-edit-section__title {
  margin: 0;
  color: #1f2430;
  font-size: 16px;
  font-weight: 800;
}

.patient-edit-field {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: none;
  min-width: 0;
}

.patient-edit-field--top {
  margin-top: -2px;
}

.patient-edit-field--inline {
  grid-template-columns: minmax(150px, 190px) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.patient-edit-field__label {
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.patient-edit-field__value {
  color: #344054;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  word-break: break-word;
}

.patient-edit-field__input {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 14px;
  padding: 14px 16px;
  background: #ffffff;
  color: #1f2430;
  outline: none;
}

.patient-edit-field__input--select {
  height: 54px;
  min-height: 54px;
  padding-top: 14px;
  padding-bottom: 14px;
  line-height: 1.35;
}

.patient-edit-field__input--status {
  color: #1f2430;
}

.patient-edit-field__textarea {
  resize: vertical;
  min-height: 112px;
}

.patient-edit-field__input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(18, 80, 230, 0.12);
}

.task-choice-modal__close {
  border: none;
  background: #f2f4f7;
  color: #344054;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  flex-shrink: 0;
}

.task-choice-modal__actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.task-choice-cancel {
  border: 1px solid #d0d5dd;
  border-radius: 14px;
  padding: 12px 28px;
  background: #ffffff;
  color: #344054;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
}

.task-choice-save {
  border: none;
  border-radius: 14px;
  padding: 12px 28px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(18, 80, 230, 0.28);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  transform: none;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px 24px 0 0;
  background: rgba(35, 48, 70, 0.96);
  backdrop-filter: blur(14px);
  box-shadow: 0 -10px 28px rgba(20, 24, 38, 0.18);
  z-index: 30;
}

.bottom-nav__item {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  min-height: 58px;
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
  position: relative;
}

.bottom-nav__item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.bottom-nav__icon {
  width: 22px;
  height: 22px;
  display: inline-flex;
}

.bottom-nav__icon svg {
  width: 100%;
  height: 100%;
  display: block;
}

.bottom-nav__label {
  font-size: 11px;
  line-height: 1;
}

.bottom-nav__menu-wrap {
  position: relative;
  display: flex;
  width: 100%;
}

.bottom-nav__menu-wrap .bottom-nav__item {
  width: 100%;
}

.bottom-nav__menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  min-width: 180px;
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  background: rgba(35, 48, 70, 0.98);
  box-shadow: 0 18px 38px rgba(20, 24, 38, 0.22);
  backdrop-filter: blur(16px);
}

.bottom-nav__menu[hidden] {
  display: none !important;
}

.bottom-nav__menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.bottom-nav__menu-item {
  appearance: none;
  display: block;
  border: none;
  width: 100%;
  text-align: left;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  padding: 14px 14px;
  font-weight: 700;
  cursor: pointer;
}

.bottom-nav__menu-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.bottom-nav__menu-item--current {
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
  cursor: default;
}

.bottom-nav__menu-item--danger {
  color: #fecaca;
}

.bottom-nav__menu-item--danger:hover {
  background: rgba(185, 28, 28, 0.16);
}

@media (min-width: 768px) {
  .topbar,
  .assign-main {
    max-width: 980px;
    margin: 0 auto;
  }

  .assign-main {
    padding-top: 24px;
  }

}

@media (max-width: 640px) {
  .topbar__nav {
    grid-template-columns: auto 1fr auto;
  }

  .brand__name {
    font-size: 16px;
  }

  .title-strip h1 {
    font-size: 18px;
  }

  .section-header h2 {
    font-size: 22px;
  }

  .section-header {
    align-items: flex-start;
  }

  .section-header__action {
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 12px;
  }

  .patient-select-button {
    width: 100%;
    font-size: 20px;
  }

  .task-choice-modal__card {
    margin-top: 10vh;
    padding: 10px 18px 18px;
  }

  .task-choice-modal__header h3 {
    font-size: 21px;
  }

  .patient-edit-field--inline {
    grid-template-columns: minmax(118px, 132px) minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  .patient-edit-field__label {
    font-size: 11px;
    line-height: 1.2;
  }

  .patient-edit-field__input {
    padding: 12px 14px;
  }

  .patient-edit-field__input--select {
    height: 56px;
    min-height: 56px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

}
