:root {
  --brand-navy: #0d2d52;
  --brand-blue: #1f69a6;
  --brand-light: #f3f7fb;
  --brand-gold: #f7c35f;
  --text-primary: #1a2a3a;
  --text-secondary: #4c5a6a;
  --white: #ffffff;
  --shadow: 0 30px 80px -40px rgba(12, 32, 66, 0.45);
  --radius-lg: 32px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --transition: 200ms ease;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: linear-gradient(
    180deg,
    rgba(243, 247, 251, 1) 0%,
    rgba(250, 252, 255, 0.95) 100%
  );
  color: var(--text-primary);
  min-height: 100vh;
  padding: 0;
}

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

.app-header {
  background: var(--white);
  border-bottom: 1px solid rgba(13, 45, 82, 0.08);
  box-shadow: 0 1px 3px rgba(13, 45, 82, 0.1);
  padding: 1rem 0;
}

.app-header__content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}

.app-header__title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--brand-navy);
}

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

.user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.user-info__name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.user-info__email {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.logout-btn {
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(213, 78, 78, 0.1);
  color: #741919;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--transition), color var(--transition);
}

.logout-btn:hover {
  background: rgba(213, 78, 78, 0.2);
  color: #5a1414;
}

.card {
  position: relative;
  margin: clamp(3rem, 8vw, 6rem) auto 4rem;
  width: min(90%, 980px);
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: clamp(2rem, 6vw, 4rem);
  box-shadow: var(--shadow);
}

.note__eyebrow {
  margin: 0;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.28rem;
  color: rgba(13, 45, 82, 0.55);
  font-weight: 600;
}

.note__header h3 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--brand-navy);
}

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

.note-card {
  background: var(--white);
  border-radius: var(--radius-md);
  border: 1px solid rgba(13, 45, 82, 0.08);
  box-shadow: 0 24px 48px -32px rgba(13, 45, 82, 0.25);
  display: flex;
  flex-direction: column;
  width: 100%;
}

.note-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.3rem 0.45rem;
  gap: 1rem;
}

.note-card__header h4 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--brand-navy);
}

.note-card__body {
  padding: 0 1.3rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.note-meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.4rem 1.5rem;
}

.note-meta dt {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12rem;
  color: rgba(26, 42, 58, 0.55);
}

.note-meta dd {
  margin: 0 0 0.55rem;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
}

.note-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.note-list li {
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(13, 45, 82, 0.05);
  color: var(--text-primary);
  font-weight: 500;
}

.copyable-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(13, 45, 82, 0.05);
}

.copyable-row__label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12rem;
  color: rgba(26, 42, 58, 0.55);
  min-width: 140px;
}

.copyable-row__value {
  flex: 1;
  font-weight: 500;
  color: var(--text-primary);
}

.copyable-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.group-label {
  margin: 0 0 0.25rem 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12rem;
  color: rgba(26, 42, 58, 0.6);
  font-weight: 600;
}

.condition-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(31, 105, 166, 0.08);
  transition: background 0.3s ease;
}

.condition-item--customized {
  background: rgba(255, 192, 203, 0.25) !important;
  border: 1px solid rgba(255, 105, 180, 0.4) !important;
  box-shadow: 0 2px 8px rgba(255, 105, 180, 0.1);
}

.care-plan-changes {
  background: rgba(173, 216, 230, 0.2);
  border: 1px solid rgba(135, 206, 235, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.75rem 0.85rem;
  margin-top: 0.75rem;
}

.care-plan-changes__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.care-plan-changes__title {
  margin: 0;
  font-weight: 600;
  color: #1e40af;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.care-plan-changes__content {
  color: #1e3a8a;
  font-size: 0.9rem;
  line-height: 1.5;
}

.condition-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.condition-item__name {
  margin: 0;
  font-weight: 600;
  color: var(--brand-navy);
  flex: 1;
}

.condition-item__plan-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.condition-item__plan {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  flex: 1;
  line-height: 1.5;
}

.condition-item__plan strong {
  color: var(--text-primary);
  font-weight: 600;
}

.condition-item__plan em {
  font-style: italic;
  color: var(--brand-navy);
}

.condition-item__plan ul,
.condition-item__plan ol {
  margin: 0.5rem 0;
  padding-left: 1.2rem;
}

.condition-item__plan li {
  margin-bottom: 0.25rem;
}

.condition-item__plan p {
  margin: 0.5rem 0;
}

.condition-item__plan p:first-child {
  margin-top: 0;
}

.condition-item__plan p:last-child {
  margin-bottom: 0;
}

.barrier-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(247, 195, 95, 0.14);
}

.barrier-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.barrier-item__title {
  margin: 0;
  font-weight: 600;
  color: #7a4a0c;
  flex: 1;
}

.barrier-item__intervention-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.barrier-item__intervention {
  margin: 0;
  color: #4f3623;
  font-size: 0.95rem;
  flex: 1;
  line-height: 1.5;
}

.rating-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(31, 105, 166, 0.12);
  color: var(--brand-navy);
  font-weight: 600;
  font-size: 0.85rem;
  flex: 1;
}

.note-pre {
  margin: 0;
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, "Liberation Mono",
    Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #253342;
  background: rgba(13, 45, 82, 0.05);
  padding: 1rem;
  border-radius: var(--radius-sm);
}

.note-timeline {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.timeline-item {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(13, 45, 82, 0.12);
  background: rgba(255, 255, 255, 0.8);
}

.timeline-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.timeline-item__header h5 {
  margin: 0;
  font-size: 1rem;
  color: var(--text-primary);
}

.timeline-item p {
  margin: 0;
  color: var(--text-secondary);
}

.copy-btn {
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  font-weight: 600;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  border: none;
  background: var(--brand-blue);
  color: var(--white);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition),
    background var(--transition);
}

.copy-btn:hover,
.copy-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px -12px rgba(31, 105, 166, 0.5);
}

.card::after {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(13, 45, 82, 0.06);
  pointer-events: none;
}

.card h2 {
  margin-top: 0;
  font-size: 1.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card__intro {
  margin-bottom: 2rem;
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.form label {
  font-weight: 600;
  color: var(--text-primary);
}

.form__row {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}

.form input {
  flex: 1 1 220px;
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(26, 42, 58, 0.15);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form input:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 4px rgba(31, 105, 166, 0.15);
}

.form button {
  padding: 0.95rem 1.8rem;
  border-radius: var(--radius-sm);
  border: none;
  background: linear-gradient(135deg, var(--brand-gold) 0%, #f59e0b 100%);
  color: #1f2933;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition),
    filter var(--transition);
}

.form button:hover,
.form button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 20px -12px rgba(247, 195, 95, 0.7);
}

.form button:disabled {
  cursor: wait;
  filter: grayscale(0.4);
  transform: none;
  box-shadow: none;
}

.help-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.banner {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
  border: 1px solid transparent;
  display: block;
}

.banner--hidden {
  display: none;
}

.banner--info {
  background: rgba(31, 105, 166, 0.08);
  border-color: rgba(31, 105, 166, 0.25);
  color: var(--brand-navy);
}

.banner--success {
  background: rgba(32, 163, 106, 0.1);
  border-color: rgba(32, 163, 106, 0.3);
  color: #1b5945;
}

.banner--warning {
  background: rgba(235, 173, 51, 0.12);
  border-color: rgba(235, 173, 51, 0.3);
  color: #805306;
}

.banner--error {
  background: rgba(213, 78, 78, 0.12);
  border-color: rgba(213, 78, 78, 0.35);
  color: #741919;
}

.loading {
  display: none;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 0;
}

.loading--visible {
  display: flex;
}

.loading__text {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(31, 105, 166, 0.2);
  border-top-color: var(--brand-blue);
  animation: spin 0.75s linear infinite;
}

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

.note {
  background: var(--brand-light);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  border: 1px solid rgba(31, 105, 166, 0.15);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.note__header {
  margin-bottom: 1rem;
}

.note__header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 2rem;
  flex-wrap: wrap;
}

.note__header h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--brand-navy);
}

.care-template-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  transition: color 0.2s ease;
}

.toggle-option {
  white-space: nowrap;
  transition: color 0.2s ease;
  font-weight: 500;
}

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

.toggle-label:hover .toggle-option {
  color: var(--brand-navy);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 80px;
  height: 36px;
  background: rgba(13, 45, 82, 0.1);
  border-radius: 36px;
  border: 2px solid rgba(13, 45, 82, 0.15);
  overflow: hidden;
  transition: all 0.3s ease;
}

.toggle-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, rgba(76, 90, 106, 0.8) 0%, rgba(76, 90, 106, 0.8) 50%, var(--brand-blue) 50%, var(--brand-blue) 100%);
  transition: all 0.3s ease;
  border-radius: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  font-size: 0.7rem;
  font-weight: 600;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 28px;
  width: 36px;
  left: 2px;
  top: 2px;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 28px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15), 0 2px 4px rgba(0,0,0,0.1);
  z-index: 2;
}

.toggle-slider:after {
  content: "STD";
  position: absolute;
  left: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  z-index: 1;
  transition: opacity 0.2s ease;
}

.toggle-input:checked + .toggle-slider:after {
  content: "CUST";
  left: auto;
  right: 6px;
}

.toggle-input:checked + .toggle-slider {
  background: linear-gradient(90deg, rgba(76, 90, 106, 0.4) 0%, rgba(76, 90, 106, 0.4) 50%, var(--brand-blue) 50%, var(--brand-blue) 100%);
}

.toggle-input:focus + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(31, 105, 166, 0.2);
}

.toggle-input:checked + .toggle-slider:before {
  transform: translateX(40px);
}

.toggle-switch:hover .toggle-slider {
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.toggle-switch:hover .toggle-slider:before {
  box-shadow: 0 6px 16px rgba(0,0,0,0.2), 0 2px 4px rgba(0,0,0,0.1);
}

.copy-btn--success {
  background: #20a36a;
}

.copy-btn--inline {
  padding: 0.45rem 0.9rem;
  font-size: 0.8rem;
}

.copy-btn--tiny {
  padding: 0.35rem 0.7rem;
  font-size: 0.7rem;
  letter-spacing: 0.05rem;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .app-header__content {
    padding: 0 1rem;
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }

  .app-header__user {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .user-info {
    align-items: center;
  }

  .card {
    margin-top: 2rem;
    padding: 2.2rem;
  }

  .form__row {
    flex-direction: column;
    align-items: stretch;
  }

  .form button {
    width: 100%;
  }

  .note {
    padding: 1.25rem;
  }

  .note__header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .care-template-toggle {
    align-self: stretch;
    justify-content: center;
  }

  .toggle-label {
    gap: 0.5rem;
    font-size: 0.85rem;
  }

  .toggle-switch {
    width: 70px;
    height: 32px;
  }

  .toggle-slider:before {
    width: 32px;
    height: 24px;
  }

  .toggle-input:checked + .toggle-slider:before {
    transform: translateX(34px);
  }
}

.card__warning {
  background: rgba(255, 243, 205, 0.4);
  border: 1px solid rgba(255, 193, 7, 0.4);
  color: #664d03;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  margin-bottom: 1.5rem;
}

/* Login Page Styles */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 3rem;
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-header {
  margin-bottom: 2rem;
}

.login-title {
  margin: 0 0 0.5rem 0;
  font-size: 2rem;
  font-weight: 600;
  color: var(--brand-navy);
}

.login-subtitle {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.login-content {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.microsoft-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border: 2px solid #0078d4;
  border-radius: var(--radius-sm);
  background: #0078d4;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  width: 100%;
}

.microsoft-login-btn:hover {
  background: #106ebe;
  border-color: #106ebe;
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(0, 120, 212, 0.3);
}

.microsoft-icon {
  flex-shrink: 0;
}

.login-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.login-status.hidden {
  display: none;
}

.login-status .spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(31, 105, 166, 0.2);
  border-top-color: var(--brand-blue);
  animation: spin 0.75s linear infinite;
}

@media (max-width: 480px) {
  .login-container {
    padding: 1rem;
  }

  .login-card {
    padding: 2rem;
  }

  .login-title {
    font-size: 1.75rem;
  }
}
