/* Internal Assistant — standalone module (medical teal theme, ChatGPT-style layout) */

:root {
  --ia-navy: #12363f;
  --ia-navy-mid: #0e252f;
  --ia-teal: #22b8c7;
  --ia-teal-dark: #1699a6;
  --ia-teal-light: #e7f7fa;
  --ia-bg: #f0f4f7;
  --ia-border: #d9e2e8;
  --ia-muted: #5c7b82;
  --ia-slate: #33565e;
  --ia-radius: 12px;
  --ia-font: "Source Sans 3", system-ui, -apple-system, sans-serif;
  --ia-shadow: 0 4px 24px rgba(18, 54, 63, 0.08);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.ia-body {
  margin: 0;
  font-family: var(--ia-font);
  color: var(--ia-navy);
  background: var(--ia-bg);
  line-height: 1.55;
  min-height: 100dvh;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ia-skip-link {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--ia-teal);
  color: #fff;
  font-weight: 600;
  border-radius: 8px;
  z-index: 300;
  transform: translateY(-140%);
  transition: transform 0.2s ease;
}

.ia-skip-link:focus {
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.ia-app {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Sidebar */
.ia-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--ia-navy-mid) 0%, #153f48 100%);
  color: #e8f4f7;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 200;
}

.ia-sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem 1rem 1rem;
}

.ia-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.ia-brand-mark {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 10px;
  background: var(--ia-teal);
  color: #fff;
  font-weight: 700;
  font-size: 1.35rem;
  display: grid;
  place-items: center;
}

.ia-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.ia-brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
}

.ia-brand-sub {
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #9ec9cf;
}

.ia-sidebar-close {
  display: none;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.ia-sidebar-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.ia-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0 0.75rem;
}

.ia-nav-link {
  display: block;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  color: #d3eaee;
  font-weight: 600;
  font-size: 0.9375rem;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

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

.ia-nav-link--active {
  background: rgba(34, 184, 199, 0.25);
  color: #fff;
  border: 1px solid rgba(34, 184, 199, 0.35);
}

.ia-sidebar-section {
  padding: 1rem 1rem 0;
}

.ia-sidebar-section--tools {
  padding-top: 0.25rem;
}

.ia-sidebar-label {
  margin: 0 0 0.5rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #7aa7ae;
}

.ia-sidebar-btn {
  width: 100%;
  font: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.55rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: #e8f4f7;
  cursor: pointer;
  transition: background 0.15s ease;
}

.ia-sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.ia-sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ia-sidebar-meta {
  font-size: 0.72rem;
  color: #8aa9af;
}

.ia-sidebar-meta code {
  font-size: 0.68rem;
  color: #c5e8ec;
}

/* Main workspace */
.ia-workspace {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
}

.ia-topbar {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ia-border);
  background: linear-gradient(180deg, #fff 0%, var(--ia-teal-light) 100%);
}

.ia-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--ia-border);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.ia-menu-btn span {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: var(--ia-navy);
  border-radius: 1px;
}

.ia-topbar-title {
  flex: 1;
  min-width: 0;
}

.ia-page-title {
  margin: 0;
  font-size: clamp(1.15rem, 2.5vw, 1.35rem);
  font-weight: 700;
  color: var(--ia-navy);
  letter-spacing: -0.02em;
}

/* Chat area */
.ia-chat-shell {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ia-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ia-msg {
  display: flex;
  justify-content: flex-start;
}

.ia-msg--user {
  justify-content: flex-end;
}

.ia-msg-inner {
  max-width: min(720px, 92%);
  border-radius: 14px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--ia-border);
  background: #fff;
  box-shadow: 0 1px 3px rgba(10, 22, 40, 0.06);
}

.ia-msg--user .ia-msg-inner {
  background: linear-gradient(135deg, #e7f7fa 0%, #dff5f8 100%);
  border-color: rgba(34, 184, 199, 0.35);
}

.ia-msg-label {
  display: block;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ia-teal-dark);
  margin-bottom: 0.35rem;
}

.ia-msg--user .ia-msg-label {
  color: var(--ia-navy);
}

.ia-msg-body {
  font-size: 0.9375rem;
  color: var(--ia-navy);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Composer */
.ia-composer-wrap {
  padding: 0.85rem 1.25rem 1.25rem;
  border-top: 1px solid var(--ia-border);
  background: linear-gradient(180deg, #fafcfd 0%, #fff 40%);
}

.ia-composer {
  max-width: 900px;
  margin: 0 auto;
}

.ia-composer-row {
  display: flex;
  align-items: stretch;
  gap: 0.65rem;
}

.ia-stt-status {
  max-width: 900px;
  margin: 0 auto 0.45rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ia-teal-dark);
  text-align: center;
}

.ia-mic-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 14px;
  border: 2px solid var(--ia-border);
  background: #fff;
  color: var(--ia-teal-dark);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.ia-mic-btn:hover:not(:disabled) {
  border-color: var(--ia-teal);
  background: var(--ia-teal-light);
}

.ia-mic-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ia-mic-btn--recording {
  border-color: #ef4444;
  color: #dc2626;
  background: #fef2f2;
  animation: ia-mic-pulse 1.1s ease-in-out infinite;
}

.ia-mic-btn--transcribing {
  opacity: 0.75;
}

@keyframes ia-mic-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(239, 68, 68, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ia-mic-btn--recording {
    animation: none;
  }
}

.ia-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  font: inherit;
  font-size: 1rem;
  padding: 0 1rem;
  border-radius: 14px;
  border: 2px solid var(--ia-border);
  background: #fff;
  color: var(--ia-navy);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ia-input:focus {
  outline: none;
  border-color: var(--ia-teal);
  box-shadow: 0 0 0 3px rgba(34, 184, 199, 0.2);
}

.ia-send-btn {
  font: inherit;
  font-weight: 700;
  font-size: 0.9375rem;
  padding: 0.55rem 1.35rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: var(--ia-teal);
  color: #fff;
  box-shadow: 0 4px 14px rgba(34, 184, 199, 0.35);
  transition: background 0.15s ease, transform 0.12s ease, opacity 0.15s ease;
}

.ia-send-btn:hover:not(:disabled) {
  background: var(--ia-teal-dark);
}

.ia-send-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.ia-send-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.ia-send-btn--busy {
  letter-spacing: 0.1em;
}

/* Mobile drawer */
.ia-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 22, 40, 0.45);
  z-index: 150;
}

@media (max-width: 900px) {
  .ia-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-102%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }

  .ia-sidebar--open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.2);
  }

  .ia-sidebar-close {
    display: grid;
    place-items: center;
  }

  .ia-menu-btn {
    display: flex;
  }

  .ia-backdrop {
    display: block;
  }

  .ia-backdrop[hidden] {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ia-sidebar {
    transition: none;
  }
}

/* Sidebar tools stack */
.ia-sidebar-tools {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

/* -------- Prescription modal (workflow moved from admin.html) -------- */
.ia-rx-modal {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.ia-rx-modal[hidden] {
  display: none !important;
}

body.ia-rx-modal-open {
  overflow: hidden;
}

.ia-rx-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 22, 40, 0.55);
  cursor: pointer;
}

.ia-rx-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(92vh, 920px);
  background: #fff;
  color: var(--ia-navy);
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(18, 54, 63, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ia-rx-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem 0.85rem;
  border-bottom: 1px solid var(--ia-border);
  background: linear-gradient(180deg, #f7fbfc 0%, #fff 100%);
}

.ia-rx-modal__title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--ia-navy);
}

.ia-rx-modal__hint {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--ia-muted);
}

.ia-rx-modal__close {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 10px;
  background: rgba(18, 54, 63, 0.08);
  color: var(--ia-navy);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.ia-rx-modal__close:hover {
  background: rgba(18, 54, 63, 0.14);
}

.ia-rx-modal__scroll {
  overflow-y: auto;
  padding: 1rem 1.1rem 1.25rem;
  -webkit-overflow-scrolling: touch;
}

.ia-rx-form {
  display: grid;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

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

.ia-rx-field {
  display: grid;
  gap: 0.35rem;
}

.ia-rx-field span {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--ia-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ia-rx-field input,
.ia-rx-field select,
.ia-rx-field textarea {
  width: 100%;
  font: inherit;
  border: 1px solid var(--ia-border);
  border-radius: 10px;
  padding: 0.55rem 0.72rem;
  background: #fff;
  color: var(--ia-navy);
}

.ia-rx-field textarea {
  resize: vertical;
  min-height: 84px;
}

.ia-rx-field input:focus,
.ia-rx-field select:focus,
.ia-rx-field textarea:focus {
  outline: none;
  border-color: var(--ia-teal);
  box-shadow: 0 0 0 3px rgba(34, 184, 199, 0.22);
}

.ia-rx-field--full {
  grid-column: 1 / -1;
}

.ia-rx-subtitle {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ia-navy);
}

.ia-rx-meds-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.ia-rx-medicine-list {
  display: grid;
  gap: 0.65rem;
}

/* Medicine rows (shared class names from legacy admin) */
.ia-rx-modal .rx-med-row {
  display: grid;
  grid-template-columns: minmax(160px, 2fr) 1fr 1fr auto;
  gap: 0.5rem;
  align-items: start;
}

.ia-rx-modal .rx-med-autocomplete {
  position: relative;
}

.ia-rx-modal .rx-med-name,
.ia-rx-modal .rx-med-dosage,
.ia-rx-modal .rx-med-duration {
  width: 100%;
  font: inherit;
  border: 1px solid var(--ia-border);
  border-radius: 10px;
  padding: 0.55rem 0.72rem;
  background: #fff;
}

.ia-rx-modal .rx-med-name:focus,
.ia-rx-modal .rx-med-dosage:focus,
.ia-rx-modal .rx-med-duration:focus {
  outline: none;
  border-color: var(--ia-teal);
  box-shadow: 0 0 0 3px rgba(34, 184, 199, 0.2);
}

.ia-rx-modal .rx-med-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  z-index: 20;
  border: 1px solid var(--ia-border);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--ia-shadow);
  overflow: hidden;
}

.ia-rx-modal .rx-suggestion-item {
  width: 100%;
  border: 0;
  background: #fff;
  color: var(--ia-navy);
  text-align: left;
  padding: 0.52rem 0.65rem;
  font: inherit;
  font-size: 0.87rem;
  cursor: pointer;
}

.ia-rx-modal .rx-suggestion-item:hover {
  background: var(--ia-teal-light);
}

.ia-rx-modal .rx-remove-med {
  border: 1px solid #fecaca;
  background: #fff5f5;
  color: #b91c1c;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  width: 2.25rem;
  height: 2.25rem;
  cursor: pointer;
}

.ia-rx-modal .rx-remove-med:hover {
  background: #fee2e2;
}

.ia-rx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.ia-rx-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.58rem 1.1rem;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
}

.ia-rx-btn--primary {
  background: var(--ia-teal);
  color: #fff;
  border-color: var(--ia-teal-dark);
}

.ia-rx-btn--primary:hover:not(:disabled) {
  background: var(--ia-teal-dark);
}

.ia-rx-btn--primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.ia-rx-btn--blue {
  background: #0ea5e9;
  color: #fff;
  border-color: #0284c7;
}

.ia-rx-btn--blue:hover {
  filter: brightness(1.05);
}

.ia-rx-btn--outline {
  background: transparent;
  color: var(--ia-teal-dark);
  border-color: rgba(34, 184, 199, 0.45);
}

.ia-rx-btn--outline:hover {
  background: var(--ia-teal-light);
}

.ia-rx-feedback {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.78rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.ia-rx-feedback--ok {
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: #ecfdf3;
  color: #166534;
}

.ia-rx-feedback--err {
  border: 1px solid rgba(239, 68, 68, 0.38);
  background: #fef2f2;
  color: #991b1b;
}

/* Prescription upload modal */
.ia-upload-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.ia-upload-modal[hidden] {
  display: none !important;
}

body.ia-upload-modal-open {
  overflow: hidden;
}

.ia-upload-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 24, 32, 0.52);
  backdrop-filter: blur(6px);
}

.ia-upload-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: min(92vh, 920px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid rgba(178, 200, 209, 0.55);
  background: linear-gradient(180deg, #ffffff 0%, #f7fcfd 100%);
  box-shadow: 0 28px 80px rgba(7, 25, 35, 0.22);
}

.ia-upload-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid rgba(178, 200, 209, 0.45);
  background: linear-gradient(135deg, rgba(232, 252, 255, 0.95), rgba(255, 255, 255, 0.88));
}

.ia-upload-modal__title {
  margin: 0;
  font-size: 1.18rem;
  color: var(--ia-navy);
  letter-spacing: -0.025em;
}

.ia-upload-modal__subtitle {
  margin: 0.28rem 0 0;
  color: var(--ia-muted);
  font-size: 0.88rem;
}

.ia-upload-modal__close {
  border: 0;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ia-muted);
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 12px;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.ia-upload-modal__close:hover {
  background: #eef8fa;
  color: var(--ia-navy);
}

.ia-upload-modal__body {
  padding: 1rem 1.2rem 1.2rem;
  overflow: auto;
}

.ia-upload-warning {
  margin-bottom: 1rem;
  padding: 0.72rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  background: #fffbeb;
  color: #92400e;
  font-size: 0.9rem;
  font-weight: 600;
}

.ia-upload-processing {
  display: grid;
  justify-items: center;
  gap: 0.85rem;
  padding: 2rem 1rem;
  text-align: center;
}

.ia-upload-processing__pulse {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, #5eead4, #21c3d6 55%, #0f766e);
  box-shadow: 0 0 0 0 rgba(33, 195, 214, 0.35);
  animation: ia-upload-pulse 1.4s ease-in-out infinite;
}

.ia-upload-processing p {
  margin: 0;
  color: var(--ia-muted);
  font-weight: 600;
}

.ia-upload-form {
  display: grid;
  gap: 0.85rem;
}

.ia-upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.ia-upload-field {
  display: grid;
  gap: 0.35rem;
}

.ia-upload-field span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #628089;
}

.ia-upload-field input,
.ia-upload-field textarea,
.ia-upload-field select {
  width: 100%;
  font: inherit;
  border: 1px solid var(--ia-border);
  border-radius: 12px;
  padding: 0.62rem 0.78rem;
  background: #fff;
  color: var(--ia-navy);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.ia-upload-field input:focus,
.ia-upload-field textarea:focus,
.ia-upload-field select:focus {
  outline: none;
  border-color: var(--ia-teal);
  box-shadow: 0 0 0 3px rgba(34, 184, 199, 0.18);
}

.ia-upload-field input[readonly],
.ia-upload-field textarea[readonly] {
  background: #f8fbfc;
}

.ia-upload-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.35rem;
}

.ia-upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.62rem 1.15rem;
  border-radius: 12px;
  font: inherit;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  border: 1px solid transparent;
}

.ia-upload-btn--ghost {
  background: #fff;
  color: var(--ia-teal-dark);
  border-color: rgba(34, 184, 199, 0.35);
}

.ia-upload-btn--ghost:hover {
  background: var(--ia-teal-light);
}

.ia-upload-btn--primary {
  background: linear-gradient(135deg, #21c3d6, #0f97a8);
  color: #fff;
  box-shadow: 0 10px 24px rgba(33, 195, 214, 0.24);
}

.ia-upload-btn--primary:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.ia-upload-btn--primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.ia-upload-feedback {
  margin-top: 0.85rem;
  padding: 0.65rem 0.78rem;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
}

.ia-upload-feedback--ok {
  border: 1px solid rgba(34, 197, 94, 0.35);
  background: #ecfdf3;
  color: #166534;
}

.ia-upload-feedback--err {
  border: 1px solid rgba(239, 68, 68, 0.38);
  background: #fef2f2;
  color: #991b1b;
}

@keyframes ia-upload-pulse {
  0%,
  100% {
    transform: scale(0.96);
    box-shadow: 0 0 0 0 rgba(33, 195, 214, 0.28);
  }
  50% {
    transform: scale(1);
    box-shadow: 0 0 0 12px rgba(33, 195, 214, 0);
  }
}

.ia-rx-history-wrap {
  border-top: 1px solid var(--ia-border);
  margin-top: 1rem;
  padding-top: 1rem;
}

.ia-rx-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--ia-border);
  border-radius: 10px;
}

.ia-rx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.ia-rx-table th,
.ia-rx-table td {
  padding: 0.55rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid #e8eef2;
}

.ia-rx-table th {
  background: #f4f9fa;
  font-weight: 700;
  color: var(--ia-slate);
}

.ia-rx-table tbody tr:last-child td {
  border-bottom: 0;
}

.ia-rx-empty-cell {
  text-align: center;
  color: var(--ia-muted);
  padding: 1rem !important;
}

.ia-rx-link {
  color: var(--ia-teal-dark);
  font-weight: 600;
  text-decoration: none;
}

.ia-rx-link:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  .ia-rx-grid {
    grid-template-columns: 1fr;
  }

  .ia-rx-modal .rx-med-row {
    grid-template-columns: 1fr;
  }

  .ia-rx-modal .rx-remove-med {
    width: 100%;
    height: 2.1rem;
  }
}

/* Premium Nexa copilot refresh */
:root {
  --ia-navy: #071923;
  --ia-navy-mid: #0b2530;
  --ia-teal: #21c3d6;
  --ia-teal-dark: #0f97a8;
  --ia-teal-light: #e9fbfd;
  --ia-bg: #eef5f7;
  --ia-border: rgba(178, 200, 209, 0.52);
  --ia-muted: #647a86;
  --ia-slate: #294752;
  --ia-radius: 18px;
  --ia-shadow: 0 20px 60px rgba(7, 25, 35, 0.12);
  --ia-glass: rgba(255, 255, 255, 0.72);
}

body.ia-body {
  background:
    radial-gradient(circle at 18% 8%, rgba(33, 195, 214, 0.22), transparent 28%),
    radial-gradient(circle at 88% 4%, rgba(84, 112, 255, 0.12), transparent 24%),
    linear-gradient(135deg, #eef7f9 0%, #f8fbfd 46%, #eaf3f6 100%);
  color: var(--ia-navy);
  letter-spacing: -0.006em;
}

.ia-sidebar {
  width: 304px;
  background:
    radial-gradient(circle at 18% 0%, rgba(33, 195, 214, 0.34), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(111, 144, 255, 0.18), transparent 34%),
    linear-gradient(180deg, #071923 0%, #0b2530 48%, #06141d 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

.ia-sidebar-head {
  padding: 1.35rem 1.1rem 1.1rem;
}

.ia-brand {
  align-items: center;
  gap: 0.8rem;
}

.ia-brand-mark {
  position: relative;
  width: 2.9rem;
  height: 2.9rem;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.06)),
    linear-gradient(135deg, #21c3d6, #5eead4);
  box-shadow:
    0 18px 32px rgba(33, 195, 214, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.ia-brand-mark-core {
  position: relative;
  z-index: 1;
  color: #06202a;
  font-weight: 900;
  font-size: 1.08rem;
}

.ia-brand-pulse {
  position: absolute;
  inset: -5px;
  border-radius: 22px;
  border: 1px solid rgba(94, 234, 212, 0.48);
  animation: ia-ai-pulse 2.6s ease-out infinite;
}

.ia-brand-name {
  font-size: 1.08rem;
  letter-spacing: -0.025em;
}

.ia-brand-sub {
  margin-top: 0.15rem;
  color: rgba(207, 250, 254, 0.76);
}

.ia-sidebar-label {
  color: rgba(207, 250, 254, 0.52);
}

.ia-sidebar-btn {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border-radius: 14px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.ia-sidebar-btn::before {
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 10px;
  background: rgba(33, 195, 214, 0.15);
  color: #9ff7ff;
}

#ia-clear-chat::before {
  content: "↺";
}

#ia-open-prescription::before {
  content: "Rx";
  font-size: 0.72rem;
  font-weight: 900;
}

#ia-open-upload-prescription::before {
  content: none;
  display: none;
}

.ia-sidebar-btn--upload {
  background: linear-gradient(135deg, rgba(33, 195, 214, 0.18), rgba(255, 255, 255, 0.08));
  border-color: rgba(94, 234, 212, 0.28);
}

.ia-sidebar-btn--upload:hover {
  border-color: rgba(94, 234, 212, 0.52);
  box-shadow: 0 8px 22px rgba(33, 195, 214, 0.16);
}

.ia-sidebar-btn-icon {
  display: grid;
  place-items: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 10px;
  background: rgba(33, 195, 214, 0.18);
  font-size: 0.95rem;
  line-height: 1;
}

.ia-sidebar-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(94, 234, 212, 0.36);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.16);
}

.ia-sidebar-footer {
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.04));
}

.ia-workspace {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(248, 252, 253, 0.84)),
    radial-gradient(circle at 84% 0%, rgba(33, 195, 214, 0.12), transparent 32%);
}

.ia-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  align-items: center;
  padding: 1rem 1.35rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(239, 252, 254, 0.74));
  border-bottom: 1px solid rgba(178, 200, 209, 0.46);
  backdrop-filter: blur(18px);
  box-shadow: 0 10px 28px rgba(7, 25, 35, 0.06);
}

.ia-page-title {
  font-size: clamp(1.18rem, 2vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.ia-page-kicker {
  margin: 0.14rem 0 0;
  color: var(--ia-muted);
  font-size: 0.88rem;
}

.ia-chat-shell {
  background:
    radial-gradient(circle at 50% 0%, rgba(33, 195, 214, 0.08), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(244, 249, 251, 0.72));
}

.ia-messages {
  width: min(100%, 1040px);
  margin: 0 auto;
  padding: 1.35rem 1.6rem 1.8rem;
  gap: 1.05rem;
}

.ia-msg {
  animation: ia-message-in 0.24s ease both;
}

.ia-msg-inner {
  max-width: min(820px, 94%);
  border-radius: 22px;
  padding: 1rem 1.08rem;
  border: 1px solid rgba(178, 200, 209, 0.58);
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    0 16px 40px rgba(7, 25, 35, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.ia-msg--assistant .ia-msg-inner {
  border-top-left-radius: 8px;
}

.ia-msg--user .ia-msg-inner {
  color: #06202a;
  border-color: rgba(33, 195, 214, 0.36);
  background:
    linear-gradient(135deg, rgba(225, 250, 253, 0.96), rgba(255, 255, 255, 0.88));
  border-top-right-radius: 8px;
  box-shadow: 0 16px 36px rgba(15, 151, 168, 0.12);
}

.ia-msg-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.48rem;
  color: var(--ia-teal-dark);
  font-size: 0.7rem;
}

.ia-msg-label::before {
  content: "";
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 999px;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(33, 195, 214, 0.12);
}

.ia-msg-body {
  font-size: 1rem;
  line-height: 1.72;
  color: #15313b;
}

.ia-msg--streaming .ia-msg-inner {
  border-color: rgba(33, 195, 214, 0.42);
}

.ia-loading-state {
  display: inline-flex;
  align-items: baseline;
  gap: 0.08rem;
  animation: ia-loading-fade-in 0.35s ease-out;
}

.ia-loading-shimmer {
  display: inline-block;
  background: linear-gradient(
    90deg,
    rgba(107, 127, 136, 0.72) 0%,
    rgba(15, 151, 168, 0.95) 48%,
    rgba(107, 127, 136, 0.72) 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: ia-shimmer 2.4s ease-in-out infinite;
}

.ia-stream-cursor {
  display: inline-block;
  width: 0.48rem;
  height: 1.05em;
  margin-left: 0.1rem;
  vertical-align: -0.16em;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(33, 195, 214, 0.92), rgba(94, 234, 212, 0.78));
  box-shadow: 0 0 0 0 rgba(33, 195, 214, 0.28);
  animation: ia-cursor-pulse 1.15s ease-in-out infinite;
}

.ia-patient-card {
  min-width: min(640px, 100%);
  overflow: hidden;
  border: 1px solid rgba(33, 195, 214, 0.22);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 253, 254, 0.94)),
    radial-gradient(circle at 0% 0%, rgba(33, 195, 214, 0.16), transparent 28%);
  box-shadow:
    0 18px 44px rgba(7, 25, 35, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.96);
}

.ia-patient-card__header {
  display: flex;
  align-items: center;
  gap: 0.78rem;
  padding: 1rem 1.05rem;
  border-bottom: 1px solid rgba(178, 200, 209, 0.5);
  background: linear-gradient(135deg, rgba(232, 252, 255, 0.9), rgba(255, 255, 255, 0.72));
}

.ia-patient-card__avatar {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 15px;
  background: linear-gradient(135deg, #21c3d6, #5eead4);
  color: #05202a;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(33, 195, 214, 0.24);
}

.ia-patient-card h3 {
  margin: 0;
  color: var(--ia-navy);
  font-size: 1.05rem;
  line-height: 1.2;
  letter-spacing: -0.025em;
}

.ia-patient-card p {
  margin: 0.16rem 0 0;
  color: var(--ia-muted);
  font-size: 0.78rem;
}

.ia-patient-card__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: 0.2rem 1.05rem 1rem;
}

.ia-patient-card__row {
  padding: 0.78rem 0.8rem 0.68rem 0;
  border-bottom: 1px solid rgba(178, 200, 209, 0.42);
}

.ia-patient-card__row:nth-last-child(-n + 2) {
  border-bottom: 0;
}

.ia-patient-card__label {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--ia-muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ia-patient-card__value {
  display: block;
  color: #102b35;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.42;
}

.ia-composer-wrap {
  padding: 0.9rem 1.35rem 1.2rem;
  border-top: 1px solid rgba(178, 200, 209, 0.44);
  background: rgba(255, 255, 255, 0.74);
  backdrop-filter: blur(18px);
  box-shadow: 0 -14px 40px rgba(7, 25, 35, 0.06);
}

.ia-composer {
  max-width: 980px;
}

.ia-composer-row {
  padding: 0.34rem;
  border: 1px solid rgba(178, 200, 209, 0.6);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow:
    0 16px 42px rgba(7, 25, 35, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.ia-input {
  height: 52px;
  border: 0;
  background: transparent;
  padding: 0 0.8rem;
}

.ia-input:focus {
  box-shadow: none;
}

.ia-mic-btn,
.ia-send-btn {
  height: 52px;
  border-radius: 17px;
}

.ia-mic-btn {
  border: 1px solid rgba(178, 200, 209, 0.58);
  background: linear-gradient(180deg, #fff, #f3fbfc);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.ia-send-btn {
  padding-inline: 1.45rem;
  background: linear-gradient(135deg, #16a3b5 0%, #21c3d6 48%, #5eead4 100%);
  color: #05202a;
  box-shadow: 0 12px 28px rgba(33, 195, 214, 0.28);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.ia-send-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #16a3b5 0%, #21c3d6 48%, #5eead4 100%);
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(33, 195, 214, 0.34);
}

.ia-send-btn--busy {
  animation: ia-busy-glow 1.4s ease-in-out infinite;
}

@keyframes ia-ai-pulse {
  0% {
    transform: scale(0.9);
    opacity: 0.8;
  }
  80%,
  100% {
    transform: scale(1.24);
    opacity: 0;
  }
}

@keyframes ia-message-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes ia-loading-fade-in {
  from {
    opacity: 0;
    transform: translateY(2px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ia-cursor-pulse {
  0%,
  100% {
    opacity: 0.45;
    transform: scaleY(0.92);
    box-shadow: 0 0 0 0 rgba(33, 195, 214, 0.12);
  }
  50% {
    opacity: 1;
    transform: scaleY(1);
    box-shadow: 0 0 10px 1px rgba(33, 195, 214, 0.18);
  }
}

@keyframes ia-shimmer {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@keyframes ia-busy-glow {
  0%,
  100% {
    filter: saturate(1);
  }
  50% {
    filter: saturate(1.25) brightness(1.03);
  }
}

@media (max-width: 900px) {
  .ia-sidebar {
    width: min(320px, 88vw);
  }
}

@media (max-width: 640px) {
  .ia-topbar {
    padding: 0.85rem 1rem;
  }

  .ia-page-kicker {
    display: none;
  }

  .ia-messages {
    padding: 1rem 0.85rem 1.3rem;
  }

  .ia-msg-inner {
    max-width: 96%;
    border-radius: 18px;
    padding: 0.86rem 0.92rem;
  }

  .ia-patient-card {
    min-width: 0;
  }

  .ia-patient-card__grid {
    grid-template-columns: 1fr;
  }

  .ia-patient-card__row:nth-last-child(-n + 2) {
    border-bottom: 1px solid rgba(178, 200, 209, 0.42);
  }

  .ia-patient-card__row:last-child {
    border-bottom: 0;
  }

  .ia-composer-wrap {
    padding: 0.75rem;
  }

  .ia-send-btn {
    padding-inline: 1rem;
  }

  .ia-upload-grid {
    grid-template-columns: 1fr;
  }

  .ia-upload-modal__dialog {
    width: min(100%, calc(100vw - 1.25rem));
    max-height: calc(100vh - 1.25rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ia-brand-pulse,
  .ia-msg,
  .ia-loading-state,
  .ia-loading-shimmer,
  .ia-stream-cursor,
  .ia-send-btn--busy,
  .ia-upload-processing__pulse {
    animation: none;
  }

  .ia-stream-cursor {
    opacity: 0.85;
  }
}
