/* ========================================================================
   MediScribe AI — Design system
   Tokens: emerald-600 primary, slate-900 ink, slate-50 canvas
   Typography: -apple-system stack, Inter on the web
   ======================================================================== */

:root {
  --brand:      #047857;
  --brand-2:    #10b981;
  --brand-soft: #ecfdf5;
  --ink:        #0f172a;
  --ink-2:      #334155;
  --muted:      #64748b;
  --line:       #e2e8f0;
  --canvas:     #f8fafc;
  --danger:     #b91c1c;
  --warn:       #b45309;
  --info:       #1d4ed8;
  --shadow-1:   0 1px 2px rgba(15,23,42,.04), 0 1px 1px rgba(15,23,42,.02);
  --shadow-2:   0 8px 24px -8px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.05);
  --shadow-pop: 0 12px 40px -12px rgba(4,120,87,.35);
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  20px;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter var', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: 'cv11','ss01','ss03';
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* Brand mark */
.brand-mark {
  background: linear-gradient(135deg, #047857 0%, #10b981 100%);
  box-shadow: 0 4px 14px -4px rgba(4,120,87,.5);
}

/* Polished card surface used everywhere */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-2);
}

/* Primary button */
.btn-primary {
  background: linear-gradient(180deg, #059669 0%, #047857 100%);
  color: #fff;
  font-weight: 600;
  border-radius: 10px;
  padding: 10px 18px;
  transition: transform .12s, box-shadow .2s, opacity .2s;
  box-shadow: 0 6px 18px -6px rgba(4,120,87,.55), inset 0 1px 0 rgba(255,255,255,.18);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -8px rgba(4,120,87,.6); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-ghost {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  font-weight: 500;
  color: var(--ink-2);
  transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: #f1f5f9; border-color: #cbd5e1; }

/* Inputs */
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=file], select, textarea {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}

/* ============================================================
   App page — recording panel
   ============================================================ */

.recorder-shell {
  background: radial-gradient(circle at 50% 0%, #ecfdf5 0%, #f8fafc 60%);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
}

.mic-btn {
  width: 96px; height: 96px;
  border-radius: 999px;
  background: linear-gradient(180deg, #10b981, #047857);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-pop);
  transition: transform .12s ease, box-shadow .2s ease;
  cursor: pointer;
}
@media (max-width: 640px) {
  .mic-btn { width: 76px; height: 76px; }
  .mic-btn svg { width: 32px !important; height: 32px !important; }
}
.mic-btn:hover { transform: scale(1.04); }
.mic-btn:active { transform: scale(.98); }

@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.7), 0 8px 28px -6px rgba(220,38,38,.45); }
  50%      { box-shadow: 0 0 0 18px rgba(220, 38, 38, 0), 0 8px 28px -6px rgba(220,38,38,.45); }
}
.mic-btn.recording {
  background: linear-gradient(180deg, #ef4444, #b91c1c) !important;
  animation: pulse-rec 1.6s infinite;
}

/* VU meter */
.vu-meter { background: #e2e8f0; }
.vu-meter > div { background: linear-gradient(90deg, #10b981, #047857); transition: width .12s linear; }

/* ============================================================
   SOAP output
   ============================================================ */

#soap-output section {
  margin: 0 0 1rem 0;
  padding: 1rem 1.1rem;
  border-left: 3px solid var(--brand-2);
  background: linear-gradient(0deg, var(--canvas), #fff);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  box-shadow: var(--shadow-1);
}
#soap-output h3 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--brand);
  margin: 0 0 0.5rem 0;
}
#soap-output p {
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  margin: 0;
  color: var(--ink);
}
#soap-output .cc {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  padding: 0.7rem 1rem;
  background: var(--brand-soft);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-md);
}
#soap-output aside {
  margin-top: 1rem;
  padding: 0.85rem 1.05rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  box-shadow: var(--shadow-1);
}
#soap-output aside.red {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}
#soap-output aside.dx { background: #eff6ff; border: 1px solid #bfdbfe; }
#soap-output aside.icd {
  background: #fefce8; border: 1px solid #fde68a;
}
#soap-output aside.icd table {
  width: 100%; margin-top: 0.5rem;
  border-collapse: collapse; font-size: 0.8rem;
}
#soap-output aside.icd td {
  padding: 0.3rem 0.5rem;
  border-top: 1px solid #fde68a;
}
#soap-output aside.icd code {
  font-weight: 600;
  background: #fff;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  color: var(--ink);
}
#soap-output aside h4 {
  margin: 0 0 0.4rem 0;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-2);
}
#soap-output ul { margin: 0.25rem 0 0 1.25rem; padding: 0; }
#soap-output aside.followup {
  background: #f0fdf4; border: 1px solid #bbf7d0;
}

/* Prescriptions panel — emphasized like a real Rx pad */
#soap-output aside.rx {
  background: linear-gradient(180deg, #fff, #fafdf7);
  border: 1px solid #86efac;
  border-left: 4px solid #047857;
}
#soap-output aside.rx h4 {
  color: #047857;
  font-size: 0.8rem;
}
#soap-output .rx-row {
  background: #fff;
  border: 1px solid #d1fae5;
  border-radius: 8px;
  padding: 10px 12px;
  margin-top: 8px;
}
#soap-output .rx-row b {
  color: #064e3b;
}
#soap-output .rx-line2 {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--ink-2);
  font-family: 'SF Mono', Menlo, monospace;
  letter-spacing: 0.01em;
}
#soap-output .rx-ind {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}
#soap-output .rx-cautions {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #d1fae5;
  font-size: 0.78rem;
  color: #92400e;
}
#soap-output .rx-cautions > div { margin: 2px 0; }
#soap-output .rx-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
#soap-output .rx-verified      { background: #d1fae5; color: #065f46; }
#soap-output .rx-needs-review  { background: #fef3c7; color: #92400e; }
#soap-output .rx-disclaimer {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: normal;
  text-transform: none;
}
#soap-output .rx-row-warn { border-color: #fcd34d; background: #fffbeb; }
#soap-output .rx-row-pending { border-left-width: 4px; border-left-color: #f59e0b; }
#soap-output .rx-quote {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: #eff6ff;
  font-size: 0.78rem;
  color: #1e40af;
  font-style: italic;
}
#soap-output .rx-verify-notes {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #fde68a;
  font-size: 0.75rem;
  color: #78350f;
}
#soap-output .muted { color: var(--muted); font-weight: 400; }

/* Investigations panel */
#soap-output aside.inv {
  background: #f0f9ff; border: 1px solid #bae6fd;
}
#soap-output aside.inv h4 { color: #0369a1; }

/* Vitals captured */
#soap-output aside.vitals {
  background: #f0f9ff; border: 1px solid #bae6fd; border-left: 4px solid #0369a1;
}
#soap-output aside.vitals h4 { color: #075985; }
#soap-output .vitals-list {
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.85rem;
  color: #0c4a6e;
  letter-spacing: 0.01em;
  margin-top: 4px;
}

/* Billing codes */
#soap-output aside.billing {
  background: #fefce8; border: 1px solid #fde68a; border-left: 4px solid #ca8a04;
}
#soap-output aside.billing h4 { color: #854d0e; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#soap-output aside.billing table { width: 100%; margin-top: 6px; font-size: 0.82rem; border-collapse: collapse; }
#soap-output aside.billing td { padding: 6px 8px; border-top: 1px solid #fde68a; vertical-align: top; }
#soap-output aside.billing code { background: #fff; padding: 2px 7px; border-radius: 6px; font-weight: 600; color: #854d0e; }

/* Follow-up radar (inline) */
#soap-output aside.followup-radar {
  background: linear-gradient(180deg, #ecfdf5, #fff);
  border: 1px solid #6ee7b7;
  border-left: 4px solid #047857;
  font-size: 0.9rem;
  color: #065f46;
}

/* Front-desk task queue */
#soap-output aside.frontdesk {
  background: linear-gradient(180deg, #faf5ff, #fff);
  border: 1px solid #d8b4fe;
  border-left: 4px solid #7c3aed;
}
#soap-output aside.frontdesk h4 { color: #5b21b6; display:flex; gap:6px; flex-wrap:wrap; align-items:center; }
#soap-output .fd-task {
  display: flex; gap: 10px; padding: 8px 10px; margin-top: 6px;
  background: #fff; border: 1px solid #ede9fe; border-radius: 8px;
}
#soap-output .fd-em { font-size: 1.05rem; }
#soap-output .fd-title { font-weight: 600; color: var(--ink); font-size: 0.9rem; }
#soap-output .fd-meta  { font-size: 0.78rem; color: #6b7280; margin-top: 2px; font-family: 'SF Mono', Menlo, monospace; }
#soap-output .fd-notes { font-size: 0.78rem; color: var(--muted); font-style: italic; margin-top: 2px; }

/* Agenda tab buttons */
.agenda-tab { font-size: .7rem; }
.agenda-tab.active {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand-2);
}
.appt-act {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  transition: background-color .15s, transform .12s;
}
.appt-act:hover { background-color: #f1f5f9; transform: scale(1.1); }
.appt-act:active { transform: scale(0.92); }

/* Data Destruction Certificate animation */
#dd-cert:not(.hidden) {
  animation: dd-pulse .6s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes dd-pulse {
  from { opacity: 0; transform: translateY(6px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Patient instructions */
#soap-output aside.inst {
  background: #faf5ff; border: 1px solid #e9d5ff;
}
#soap-output aside.inst h4 { color: #6b21a8; }
#soap-output aside.inst p {
  font-size: 0.9rem; line-height: 1.5; margin: 4px 0 0 0;
  white-space: pre-wrap;
}

/* ============================================================
   Loading & status
   ============================================================ */

.skeleton {
  background: linear-gradient(90deg, #e2e8f0 0%, #f1f5f9 50%, #e2e8f0 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   Landing page polish
   ============================================================ */

.hero-bg {
  background:
    radial-gradient(1000px 500px at 50% -10%, #d1fae5 0%, transparent 60%),
    radial-gradient(800px 400px at 100% 0%, #dbeafe 0%, transparent 50%),
    #f8fafc;
}
.feature-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: transform .15s, box-shadow .25s, border-color .15s;
}
.feature-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  border-color: #cbd5e1;
}
.price-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 2rem;
}
.price-card.featured {
  border: 2px solid var(--brand);
  box-shadow: 0 30px 60px -30px rgba(4,120,87,.45);
  position: relative;
}
.price-card.featured::after {
  content: 'Most popular';
  position: absolute;
  top: -12px; left: 50%; transform: translateX(-50%);
  background: var(--brand);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 4px 14px;
  border-radius: 999px;
}

/* Subtle dividers */
.section-divider {
  border-top: 1px solid var(--line);
}

/* Header sticky polish */
.app-header {
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}

/* Toast / alert */
.alert {
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  font-size: 0.875rem;
  border: 1px solid transparent;
}
.alert-info  { background: #eff6ff; border-color: #bfdbfe; color: var(--info); }
.alert-warn  { background: #fffbeb; border-color: #fde68a; color: var(--warn); }
.alert-error { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.alert-ok    { background: var(--brand-soft); border-color: #bbf7d0; color: var(--brand); }

/* Spinner */
.spinner {
  width: 44px; height: 44px;
  border: 4px solid #d1fae5;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.footer {
  background: linear-gradient(0deg, #f1f5f9, #fff);
  border-top: 1px solid var(--line);
}

/* ============================================================
   New components: chips, kbd, steps, waveform, responsive
   ============================================================ */

/* Pill-shaped template chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s ease;
  white-space: nowrap;
}
.chip:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.chip.chip-active {
  background: var(--brand-soft);
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: inset 0 0 0 1px var(--brand);
}

/* Keyboard key visual */
.kbd {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-bottom-width: 2px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  line-height: 1.2;
}

/* Loading-step list */
.step {
  transition: opacity .35s ease, color .35s ease;
}
.step.active {
  opacity: 1;
  color: var(--brand);
  font-weight: 600;
}
.step.done {
  opacity: 1;
  color: var(--ink-2);
}
.step.done::before {
  content: '✓ ';
  color: var(--brand);
  margin-right: 2px;
}

/* Live waveform */
#waveform {
  background: rgba(255,255,255,.6);
  border-radius: 6px;
}

/* SOAP output: smoother enter animation */
@keyframes soap-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#soap-output:not(.hidden) section,
#soap-output:not(.hidden) aside {
  animation: soap-in .32s ease both;
}
#soap-output:not(.hidden) section:nth-child(2) { animation-delay: .04s; }
#soap-output:not(.hidden) section:nth-child(3) { animation-delay: .08s; }
#soap-output:not(.hidden) section:nth-child(4) { animation-delay: .12s; }
#soap-output:not(.hidden) section:nth-child(5) { animation-delay: .16s; }
#soap-output:not(.hidden) aside { animation-delay: .2s; }

/* Mobile-only sticky generate bar */
@media (max-width: 1023px) {
  body.audio-ready #mobile-bar { display: block !important; }
  body.audio-ready { padding-bottom: 76px; }
}

/* Smaller cards on phone */
@media (max-width: 640px) {
  .card { border-radius: 14px; }
  .mic-btn { width: 86px; height: 86px; }
  .recorder-shell { border-radius: 12px; }
  #soap-output section { padding: 0.75rem 0.85rem; }
  #soap-output p { font-size: 0.9rem; }
  .price-card { padding: 1.5rem; }
}

/* Print styles — let doctors print/save SOAP as PDF */
@media print {
  header, footer, .card.p-5.sm\:p-7, .card.p-4.sm\:p-5,
  #welcome, #mobile-bar, #shortcuts-modal, #warnings, #meta,
  .alert { display: none !important; }
  body { background: #fff; padding: 0; }
  main { display: block !important; max-width: 100% !important; }
  .card { box-shadow: none !important; border: none !important; padding: 0 !important; }
  #soap-output section { box-shadow: none !important; border-left: 2px solid #047857 !important; }
}

/* User menu fade */
#user-menu, #shortcuts-modal {
  animation: menu-in .15s ease both;
}
@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Clinical Decision Support cards (advisory side-cards)
   ============================================================ */
#soap-output aside.cds {
  background: linear-gradient(180deg, #fefce8, #fffefa);
  border: 1px solid #fde68a;
  border-left: 4px solid #ca8a04;
}
#soap-output aside.cds h4 {
  color: #854d0e;
  font-size: .8rem;
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
}
#soap-output .cds-disclaimer {
  font-size: .7rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: normal;
  text-transform: none;
}
#soap-output .cds-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}
@media (min-width: 640px) {
  #soap-output .cds-grid { grid-template-columns: 1fr 1fr; }
}
#soap-output .cds-card {
  background: #fff;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 12px 14px;
  transition: opacity .25s, transform .25s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 6px;
}
#soap-output .cds-card:hover { box-shadow: 0 6px 18px -8px rgba(202,138,4,.3); }
#soap-output .cds-head { font-size: .65rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #92400e; }
#soap-output .cds-cat { background: #fef3c7; padding: 2px 7px; border-radius: 999px; }
#soap-output .cds-title { font-size: .92rem; font-weight: 600; color: var(--ink); line-height: 1.4; }
#soap-output .cds-rationale { font-size: .8rem; color: var(--ink-2); line-height: 1.5; }
#soap-output .cds-evidence { font-size: .72rem; color: var(--muted); font-style: italic; }
#soap-output .cds-actions { display: flex; gap: 6px; margin-top: 4px; }
#soap-output .cds-actions button {
  flex: 1;
  font-size: .75rem; font-weight: 600;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid;
  cursor: pointer;
  transition: background .12s;
}
#soap-output .cds-approve { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
#soap-output .cds-approve:hover { background: #a7f3d0; }
#soap-output .cds-discard { background: #fff; color: var(--muted); border-color: var(--line); }
#soap-output .cds-discard:hover { background: #f1f5f9; color: #b91c1c; border-color: #fca5a5; }
#soap-output .cds-discarded { opacity: 0; transform: translateY(-6px); }
#soap-output .cds-approved { background: #ecfdf5; border-color: #6ee7b7; }
#soap-output .cds-added {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .75rem; font-weight: 600; color: #047857;
  background: #d1fae5; padding: 6px 12px; border-radius: 8px;
}

/* ============================================================
   v6 Visual polish layer — calm, premium, medical
   ============================================================ */

/* Background canvas with subtle ambient gradient */
body {
  background:
    radial-gradient(80% 40% at 50% -10%, rgba(16,185,129,.08), transparent 70%),
    radial-gradient(50% 30% at 100% 100%, rgba(59,130,246,.05), transparent 70%),
    var(--canvas);
  min-height: 100vh;
}

/* Card refinement */
.card {
  border-color: rgba(15,23,42,.06);
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
}
.card:hover { box-shadow: 0 12px 32px -12px rgba(15,23,42,.12), 0 2px 8px rgba(15,23,42,.05); }

/* Header refinement */
.app-header {
  background: rgba(255,255,255,.78);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid rgba(15,23,42,.06);
}

/* Brand mark — softer halo */
.brand-mark { box-shadow: 0 6px 20px -6px rgba(4,120,87,.4), inset 0 1px 0 rgba(255,255,255,.2); }

/* Refined hero on landing — lift typography */
.hero-headline {
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-weight: 800;
}
.hero-sub {
  font-size: clamp(1rem, 2vw, 1.18rem);
  color: var(--muted);
  line-height: 1.55;
}

/* Buttons — subtle inner highlight + shine effect */
.btn-primary {
  position: relative;
  overflow: hidden;
  letter-spacing: -0.005em;
  background-image: linear-gradient(180deg, #10b981 0%, #047857 100%);
  box-shadow:
    0 6px 18px -6px rgba(4,120,87,.55),
    0 0 0 0 rgba(16,185,129,.4),
    inset 0 1px 0 rgba(255,255,255,.18);
  transition: all .3s cubic-bezier(.2,.8,.2,1);
}
.btn-primary::after {
  content: ""; position: absolute; top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(110deg, transparent, rgba(255,255,255,.35), transparent);
  animation: btn-shine 5s ease-in-out infinite;
  pointer-events: none;
}
@keyframes btn-shine {
  0%, 80% { left: -100%; }
  100%    { left: 200%; }
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow:
    0 12px 28px -6px rgba(4,120,87,.6),
    0 0 24px rgba(16,185,129,.4),
    inset 0 1px 0 rgba(255,255,255,.22);
}
.btn-primary:focus-visible {
  outline: 3px solid rgba(16,185,129,.35); outline-offset: 2px;
}
.btn-ghost {
  color: var(--ink);
  transition: all .25s cubic-bezier(.2,.8,.2,1);
}
.btn-ghost:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15,23,42,.08);
}

/* Chip refinement */
.chip {
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px);
  border-color: rgba(15,23,42,.08);
}
.chip:hover { transform: translateY(-1px); box-shadow: 0 4px 12px -4px rgba(15,23,42,.1); }
.chip.chip-active {
  background: linear-gradient(180deg, #ecfdf5, #d1fae5);
  box-shadow: inset 0 0 0 1px var(--brand), 0 4px 12px -4px rgba(4,120,87,.25);
}

/* Mic button — premium glow + breathing pulse + ripple on record */
.mic-btn {
  position: relative;
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  box-shadow:
    0 12px 32px -8px rgba(4,120,87,.4),
    inset 0 1px 0 rgba(255,255,255,.2),
    inset 0 -2px 0 rgba(0,0,0,.05);
  transition: all .25s cubic-bezier(.2,.8,.2,1);
}
.mic-btn::before {
  content: ""; position: absolute; inset: -8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16,185,129,.25) 0%, transparent 70%);
  z-index: -1;
  animation: mic-halo 3s ease-in-out infinite;
}
@keyframes mic-halo {
  0%, 100% { transform: scale(.85); opacity: .5; }
  50%      { transform: scale(1.15); opacity: 1; }
}
.mic-btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow:
    0 20px 48px -8px rgba(4,120,87,.55),
    inset 0 1px 0 rgba(255,255,255,.25);
}
.mic-btn:active { transform: translateY(0) scale(.96); }
/* Recording: ripple effect */
.mic-btn.recording::before { animation: none; }
.mic-btn.recording::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid rgba(220,38,38,.6);
  animation: mic-ripple 1.4s cubic-bezier(.2,.8,.2,1) infinite;
}
@keyframes mic-ripple {
  0%   { transform: scale(1);    opacity: 1; }
  100% { transform: scale(1.8);  opacity: 0; }
}

/* Recorder shell — soft warm gradient + ring on activity */
.recorder-shell {
  background:
    radial-gradient(circle at 50% 30%, rgba(16,185,129,.08), transparent 60%),
    linear-gradient(180deg, #fff, #f8fafc);
  border: 1px solid rgba(15,23,42,.06);
  border-radius: 18px;
  position: relative;
  overflow: hidden;
}
body.audio-ready .recorder-shell::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 18px;
  box-shadow: inset 0 0 0 2px rgba(16,185,129,.4);
  animation: ready-pulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes ready-pulse {
  0%,100% { opacity: .6; }
  50%     { opacity: 1; }
}

/* SOAP output — better surfaces */
#soap-output section {
  background: linear-gradient(180deg, #fff, #f8fafc);
  border-left: 3px solid var(--brand-2);
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
#soap-output section h3 {
  font-size: .68rem; letter-spacing: .12em;
}

/* Pricing cards on landing */
.price-card {
  border-radius: 20px;
  border: 1px solid rgba(15,23,42,.06);
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(10px);
  transition: transform .2s, box-shadow .2s;
}
.price-card:hover { transform: translateY(-3px); box-shadow: 0 16px 36px -16px rgba(15,23,42,.14); }
.price-card.featured {
  border: 2px solid var(--brand-2);
  box-shadow: 0 16px 40px -12px rgba(4,120,87,.3);
}

/* Section dividers */
.section-divider { border-top: 1px solid rgba(15,23,42,.05); }

/* Better feature cards */
.feature-card {
  padding: 1.5rem;
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(15,23,42,.06);
  border-radius: 16px;
  backdrop-filter: blur(6px);
}

/* Spinner — refined */
.spinner {
  width: 44px; height: 44px;
  border: 3px solid rgba(16,185,129,.18);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Scrollbar (chrome/safari) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid var(--canvas); }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Selection */
::selection { background: rgba(16,185,129,.25); color: var(--ink); }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ============================================================
   v8 — animations + micro-interactions for premium feel
   ============================================================ */

/* Page-level entrance: cards stagger in (Linear-style fade-in-up) */
@keyframes card-rise {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: fade-in-up .55s cubic-bezier(.2,.8,.2,1) both; }
/* Stagger via :nth-child for any container with .stagger-children */
.stagger-children > * { animation: fade-in-up .55s cubic-bezier(.2,.8,.2,1) both; }
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 80ms; }
.stagger-children > *:nth-child(3) { animation-delay: 160ms; }
.stagger-children > *:nth-child(4) { animation-delay: 240ms; }
.stagger-children > *:nth-child(5) { animation-delay: 320ms; }
.stagger-children > *:nth-child(6) { animation-delay: 400ms; }
.stagger-children > *:nth-child(n+7) { animation-delay: 480ms; }
main > section, main > div, .card {
  animation: card-rise .35s cubic-bezier(.2,.8,.2,1) both;
}
main > section:nth-child(1), main > div:nth-child(1), .card:nth-child(1) { animation-delay: 0ms; }
main > section:nth-child(2), main > div:nth-child(2), .card:nth-child(2) { animation-delay: 50ms; }
main > section:nth-child(3), main > div:nth-child(3), .card:nth-child(3) { animation-delay: 100ms; }
main > section:nth-child(4), main > div:nth-child(4), .card:nth-child(4) { animation-delay: 150ms; }
main > section:nth-child(5), main > div:nth-child(5), .card:nth-child(5) { animation-delay: 200ms; }

/* Buttons: tactile press */
button, .btn-primary, .btn-ghost, .chip {
  transition: transform .12s cubic-bezier(.2,.8,.2,1), box-shadow .18s, background .15s, border-color .15s;
}
button:not(:disabled):active, .btn-primary:not(:disabled):active, .btn-ghost:active, .chip:active {
  transform: translateY(1px) scale(.98);
}

/* Table row hover with smooth bg shift + arrow slide */
tbody tr {
  transition: background-color .2s ease, transform .2s ease;
}
tbody tr:hover {
  background-color: #ecfdf5 !important;
}
/* Action arrow inside row — slides on hover */
tbody tr a[href*="dossier"],
tbody tr a[href*="patient.html"] {
  transition: transform .25s cubic-bezier(.2,.8,.2,1), color .2s;
  display: inline-block;
}
tbody tr:hover a[href*="dossier"],
tbody tr:hover a[href*="patient.html"] {
  transform: translateX(4px);
  color: #047857;
}

/* Page-level fade-in-up for main content (overrides Tailwind animate-fade-in-up if user adds class) */
.animate-fade-in-up {
  animation: fade-in-up .55s cubic-bezier(.2,.8,.2,1) both;
}
.ws-pane-body { animation: fade-in-up .45s cubic-bezier(.2,.8,.2,1) both; }

/* Action icons in patient history — bigger hit area, smooth color */
.hist-act {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  margin: 0 1px;
  border-radius: 8px;
  transition: background-color .15s, transform .15s, color .15s;
  cursor: pointer;
}
.hist-act:hover { transform: scale(1.15); }
.hist-act:active { transform: scale(0.92); }

/* Skeleton shimmer for loading states */
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%);
  background-size: 800px 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: 6px;
  display: inline-block;
}

/* Input focus glow — softer */
input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 4px rgba(16,185,129,.18);
}
.ring-2.ring-red-400 { animation: shake .35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-4px); }
  75%      { transform: translateX(4px); }
}

/* Mic button — breathing rest state to invite tap */
@keyframes mic-breath {
  0%, 100% { box-shadow: 0 12px 32px -8px rgba(4,120,87,.4), inset 0 1px 0 rgba(255,255,255,.2); }
  50%      { box-shadow: 0 18px 40px -8px rgba(4,120,87,.55), inset 0 1px 0 rgba(255,255,255,.2); }
}
#btn-record:not(.recording) { animation: mic-breath 3s ease-in-out infinite; }

/* SOAP sections in: stagger nicely */
#soap-output:not(.hidden) > * {
  animation: card-rise .4s cubic-bezier(.2,.8,.2,1) both;
}
#soap-output:not(.hidden) > *:nth-child(1) { animation-delay: 20ms; }
#soap-output:not(.hidden) > *:nth-child(2) { animation-delay: 60ms; }
#soap-output:not(.hidden) > *:nth-child(3) { animation-delay: 100ms; }
#soap-output:not(.hidden) > *:nth-child(4) { animation-delay: 140ms; }
#soap-output:not(.hidden) > *:nth-child(5) { animation-delay: 180ms; }
#soap-output:not(.hidden) > *:nth-child(6) { animation-delay: 220ms; }
#soap-output:not(.hidden) > *:nth-child(n+7) { animation-delay: 260ms; }

/* CDS card hover lift */
#soap-output .cds-card {
  transition: transform .18s cubic-bezier(.2,.8,.2,1), box-shadow .18s;
}
#soap-output .cds-card:hover { transform: translateY(-2px); }

/* Status pills update animation */
#serial-pill:not(.hidden), #usage-pill:not(:empty) {
  animation: pop-in .35s cubic-bezier(.2,1.5,.3,1) both;
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(.7); }
  to   { opacity: 1; transform: scale(1); }
}

/* Table row entrance when re-rendered */
#hist-body tr {
  animation: card-rise .25s cubic-bezier(.2,.8,.2,1) both;
}

/* Quota bar fill animation */
#quota-bar { transition: width .8s cubic-bezier(.2,.8,.2,1); }

/* Smooth menu open/close (keep existing menu-in but extend) */
#user-menu, #shortcuts-modal {
  animation: menu-in .18s cubic-bezier(.2,.8,.2,1) both;
}

/* Header link hover underline grow */
.app-header nav a, .app-header div a {
  position: relative;
  padding-bottom: 2px;
}
.app-header nav a::after, .app-header > div a::after {
  content: "";
  position: absolute; left: 0; bottom: -2px;
  width: 0; height: 2px;
  background: var(--brand);
  transition: width .25s cubic-bezier(.2,.8,.2,1);
}
.app-header nav a:hover::after, .app-header > div a:hover::after { width: 100%; }

/* Patient timeline slide-over */
#timeline-panel:not(.hidden) {
  animation: slide-in-right .28s cubic-bezier(.2,.8,.2,1) both;
}
#timeline-overlay:not(.hidden) {
  animation: fade-in .25s ease both;
}
@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ============================================================
   v14 — Polish: padding, breathing room, visual hierarchy
   ============================================================ */

/* All cards get consistent breathing room */
.card { padding: 1.5rem; }
@media (min-width: 640px) { .card { padding: 2rem; } }

/* Sections separation on long pages */
main > section + section, main > div + div { margin-top: 1.25rem; }

/* Headings: clean weight + size hierarchy */
h1.tracking-tight { font-weight: 800; letter-spacing: -0.025em; }
h2.tracking-tight { font-weight: 700; letter-spacing: -0.015em; }

/* Better KPI tile look */
.card .uppercase.tracking-wider {
  letter-spacing: 0.08em;
  font-weight: 600;
  color: #64748b;
  font-size: 0.7rem;
}

/* Tables with breathing room */
table { border-spacing: 0; }
table thead th { padding: 12px 10px; background: #f8fafc; font-weight: 600; }
table tbody td { padding: 12px 10px; }
table tbody tr { border-bottom: 1px solid rgba(15,23,42,.05); }

/* Form inputs uniform radius */
input, select, textarea { border-radius: 10px !important; }

/* Section divider line in landing */
.section-divider { padding-top: 1px; }

/* Owner badge highlight */
.bg-amber-100 { font-weight: 700; }

/* Make alerts breathe */
.alert {
  padding: 14px 16px;
  border-radius: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.alert.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert.alert-warn  { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert.alert-ok    { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

/* Header internal spacing — never cramped */
.app-header > div { gap: 0.75rem; }

/* ============================================================
   v16 — Numbered step cards + Share buttons
   ============================================================ */
.step-card {
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(15,23,42,.06);
  border-radius: 16px;
  box-shadow:
    0 1px 2px rgba(15,23,42,.04),
    0 8px 24px -10px rgba(15,23,42,.08);
  padding: 1.5rem 1.65rem 1.65rem;
  transition: all .3s cubic-bezier(.2,.8,.2,1);
}
.step-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 4px 12px rgba(15,23,42,.06),
    0 16px 40px -12px rgba(15,23,42,.15);
  border-color: rgba(16,185,129,.2);
}
.step-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.step-num {
  display: inline-grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, #047857, #10b981);
  color: #fff;
  font-weight: 700; font-size: 13px;
  box-shadow: 0 4px 10px -3px rgba(4,120,87,.4);
}
.step-title {
  font-size: 14px; font-weight: 600; color: var(--ink);
  letter-spacing: -0.005em;
}
.step-required {
  font-size: 10px; font-weight: 700;
  background: #fef3c7; color: #92400e;
  padding: 2px 7px; border-radius: 999px;
  letter-spacing: 0.04em; text-transform: uppercase;
}

/* Portal share buttons */
.share-btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px; font-weight: 600;
  color: #fff;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, opacity .15s;
}
.share-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px -3px rgba(0,0,0,.15); }
.share-btn:active { transform: translateY(0); }
.share-wa    { background: #25D366; }
.share-sms   { background: #3b82f6; }
.share-email { background: #6b7280; }
.share-qr    { background: #1f2937; }

/* Toast notifications (in-app, no alerts) */
#toast-container {
  position: fixed; right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 100; max-width: 360px;
}
.toast {
  background: #fff;
  border: 1px solid rgba(15,23,42,.08);
  border-left: 4px solid var(--brand);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,.10);
  display: flex; gap: 10px; align-items: flex-start;
  animation: toast-in .3s cubic-bezier(.2,.8,.2,1) both;
  max-width: 100%;
}
.toast.toast-error { border-left-color: #b91c1c; }
.toast.toast-warn  { border-left-color: #b45309; }
.toast.toast-ok    { border-left-color: #047857; }
.toast .toast-icon { font-size: 18px; flex-shrink: 0; }
.toast .toast-body { flex: 1; }
.toast .toast-title { font-weight: 600; font-size: 13px; color: var(--ink); }
.toast .toast-msg   { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.toast.toast-out { animation: toast-out .25s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(20px); } }

/* ============================================================
   v15 — Section grouping (clearer organization on dashboard)
   ============================================================ */
.section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  margin: 1.75rem 0 0.5rem 0;
  padding-bottom: 0.35rem;
  border-bottom: 2px solid #d1fae5;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.section-title:first-of-type { margin-top: 0.5rem; }

/* Inbox slide-over */
#inbox-panel:not(.hidden) {
  animation: slide-in-right .28s cubic-bezier(.2,.8,.2,1) both;
}
#inbox-overlay:not(.hidden) {
  animation: fade-in .25s ease both;
}
.inbox-item {
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, border-color .15s;
}
.inbox-item:hover { transform: translateY(-1px); }
.inbox-item:active { transform: translateY(0); }
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Welcome banner subtle pulse on first load */
#welcome:not(.hidden) {
  animation: card-rise .5s cubic-bezier(.2,.8,.2,1) both, glow-soft 4s ease-in-out 1s;
}
@keyframes glow-soft {
  0%, 100% { box-shadow: 0 8px 24px -8px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.05); }
  50%      { box-shadow: 0 16px 32px -8px rgba(4,120,87,.18), 0 2px 6px rgba(15,23,42,.05); }
}

/* ============================================================
   v18 — Clinical Workspace (3-pane layout)
   Left: collapsible icon nav · Middle: input · Right: output
   ============================================================ */

/* ════════════════════════════════════════════════════════════════════
   v18d — TOP NAVBAR (يحل محل الـ sidebar الجانبي)
   ════════════════════════════════════════════════════════════════════ */

.ds-topnav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.ds-topnav-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 64px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
@media (min-width: 1024px) {
  .ds-topnav-inner { padding: 0 28px; }
}

/* LEFT cluster: brand + nav */
.ds-topnav-left {
  display: flex; align-items: center; gap: 28px;
  flex-shrink: 0;
}
.ds-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.015em;
}
.ds-brand-text { display: none; }
@media (min-width: 768px) { .ds-brand-text { display: inline; } }

/* Nav links */
.ds-nav {
  display: none;
  align-items: center;
  gap: 4px;
}
@media (min-width: 1024px) { .ds-nav { display: flex; } }
.ds-nav-link {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px;
  border-radius: 10px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: all .25s cubic-bezier(.2,.8,.2,1);
  position: relative;
}
.ds-nav-link:hover {
  background: #f1f5f9;
  color: var(--ink);
  transform: translateY(-1px);
}
.ds-nav-link.is-active {
  background: linear-gradient(135deg, rgba(16,185,129,.13), rgba(4,120,87,.08));
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 2px 8px -2px rgba(4,120,87,.18), inset 0 0 0 1px rgba(16,185,129,.2);
}
.ds-nav-icon { font-size: 15px; line-height: 1; }
.ds-nav-label { white-space: nowrap; }
.ds-nav-badge {
  display: inline-grid; place-items: center;
  background: #ef4444; color: #fff;
  border-radius: 999px;
  padding: 1px 6px;
  font-size: 10px; font-weight: 700;
  margin-left: 2px;
  min-width: 18px;
  line-height: 1.4;
}

/* CENTER: Global search */
.ds-topnav-search {
  flex: 1 1 auto;
  max-width: 380px;
  position: relative;
  align-items: center;
  background: #f1f5f9;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 12px;
  height: 38px;
  transition: all .2s;
}
.ds-topnav-search:focus-within {
  background: #fff;
  border-color: var(--brand-2);
  box-shadow: 0 0 0 3px rgba(16,185,129,.15);
}
.ds-search-icon { font-size: 13px; opacity: .55; flex-shrink: 0; }
.ds-search-input {
  flex: 1; border: 0; background: transparent;
  font-size: 13px; color: var(--ink);
  padding: 0 8px;
  outline: none !important;
}
.ds-search-input::placeholder { color: var(--muted); }
.ds-search-kbd {
  font-size: 10px;
  font-family: 'SF Mono', Menlo, monospace;
  padding: 2px 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  flex-shrink: 0;
}
.ds-search-dropdown {
  position: absolute;
  top: calc(100% + 6px); left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 36px -12px rgba(15,23,42,.18);
  overflow: hidden;
  max-height: 360px;
  overflow-y: auto;
  z-index: 50;
}
.ds-search-item {
  display: grid;
  grid-template-columns: 78px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  transition: background .15s;
}
.ds-search-item:last-child { border-bottom: 0; }
.ds-search-item:hover { background: var(--brand-soft); }
.ds-search-chartid { font-family: 'SF Mono', Menlo, monospace; font-size: 11px; color: var(--brand); font-weight: 700; }
.ds-search-name { font-weight: 500; }
.ds-search-visits { font-size: 11px; color: var(--muted); }
.ds-search-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* RIGHT cluster */
.ds-topnav-right {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}
.ds-cta-mic {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 16px;
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
  color: #fff;
  font-size: 13px; font-weight: 600;
  border-radius: 10px;
  text-decoration: none;
  box-shadow: 0 4px 12px -4px rgba(4,120,87,.5), inset 0 1px 0 rgba(255,255,255,.18);
  transition: all .25s cubic-bezier(.2,.8,.2,1);
  position: relative;
  overflow: hidden;
}
.ds-cta-mic::after {
  content: ""; position: absolute; top: 0; left: -100%;
  width: 50%; height: 100%;
  background: linear-gradient(110deg, transparent, rgba(255,255,255,.35), transparent);
  animation: btn-shine 5s ease-in-out infinite;
}
.ds-cta-mic:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -4px rgba(4,120,87,.6), 0 0 18px rgba(16,185,129,.4);
}
.ds-cta-icon { font-size: 14px; }
.ds-cta-label { white-space: nowrap; }

.ds-icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink-2);
  font-size: 16px;
  cursor: pointer;
  transition: all .2s;
}
.ds-icon-btn:hover {
  background: #f1f5f9;
  border-color: var(--line);
  transform: translateY(-1px);
}

.ds-user-wrap { position: relative; }
.ds-user-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .2s;
  font-size: 13px;
  color: var(--ink-2);
}
.ds-user-btn:hover { background: #f1f5f9; border-color: var(--line); }
.ds-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  display: grid; place-items: center;
  letter-spacing: -0.01em;
}
.ds-user-name { font-weight: 500; }
.ds-user-caret { font-size: 10px; opacity: .55; }

.ds-dropdown {
  position: absolute;
  top: calc(100% + 6px); right: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 36px -12px rgba(15,23,42,.18);
  padding: 6px;
  z-index: 50;
  animation: menu-in .15s cubic-bezier(.2,.8,.2,1);
}
.ds-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 13px;
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background .15s;
}
.ds-menu-item:hover { background: var(--brand-soft); color: var(--brand); }
.ds-menu-item > span:first-child { font-size: 14px; opacity: .75; width: 18px; }
.ds-menu-sep { height: 1px; background: var(--line); margin: 4px 0; }
.ds-menu-danger { color: #dc2626; }
.ds-menu-danger:hover { background: #fef2f2; color: #dc2626; }

/* ─── Bell notifications dropdown ─── */
.ds-bell-wrap { position: relative; }
.ds-bell-btn { position: relative; }
.ds-bell-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 18px; height: 18px;
  background: #ef4444;
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid #fff;
  padding: 0 4px;
}
.ds-bell-dropdown {
  width: 380px;
  max-width: 92vw;
  padding: 0;
  max-height: 540px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.ds-bell-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.ds-bell-list {
  overflow-y: auto;
  flex: 1;
  max-height: 460px;
}
.ds-bell-item {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  transition: background .15s;
}
.ds-bell-item:hover { background: var(--brand-soft); }
.ds-bell-item.is-unread { background: rgba(16,185,129,.06); }
.ds-bell-item.is-unread::before {
  content: ""; position: absolute;
  width: 6px; height: 6px;
  background: #10b981; border-radius: 50%;
  margin-left: -10px; margin-top: 6px;
}
.ds-bell-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: #f1f5f9;
  display: grid; place-items: center;
  font-size: 15px;
  flex-shrink: 0;
}
.ds-bell-item:hover .ds-bell-icon { background: rgba(16,185,129,.15); }
.ds-bell-body { min-width: 0; flex: 1; }
.ds-bell-title { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.ds-bell-chart {
  display: inline-block;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 10px;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: 1px;
}
.ds-bell-name { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.ds-bell-preview {
  font-size: 11.5px; color: var(--ink-2);
  margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ds-bell-time {
  font-size: 10.5px; color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Mobile slide-down */
.ds-mobile-panel {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 8px 12px 12px;
}
.ds-mobile-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: 0;
  width: 100%; text-align: left;
  cursor: pointer;
}
.ds-mobile-link:hover { background: #f1f5f9; }
.ds-mobile-link.is-active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ════════════════════════════════════════════════════════════════════
   App Shell — true viewport lock (no body scroll)
   • body: h-screen overflow-hidden
   • topnav: fixed/sticky height 64px
   • ws-middle: takes the rest, scrolls internally
   • ws-right (only on app.html): same height, scrolls internally
   ════════════════════════════════════════════════════════════════════ */
.ws-body {
  background: var(--canvas);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
@media (min-width: 1024px) {
  /* Desktop: lock viewport, internal scroll only */
  .ws-body {
    height: 100vh;
    height: 100dvh;        /* dvh respects mobile / Windows taskbar */
    overflow: hidden;
  }
  /* Single-pane (dashboard, patients, agenda, inbox, settings) */
  .ws-body > section.ws-middle {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    overflow-y: auto;
    overflow-x: hidden;
  }
  /* 3-pane app.html: shell wraps middle+right */
  .ws-body > .ws-app-shell {
    flex: 1; display: flex; min-height: 0;
  }
  .ws-body > .ws-app-shell > .ws-middle,
  .ws-body > .ws-app-shell > .ws-right {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
  }
}
.ws-body > section.ws-middle,
.ws-body > .ws-app-shell > .ws-middle,
.ws-body > .ws-app-shell > .ws-right {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

/* Generous padding-bottom على آخر pane — لا يلتصق بحافة الشاشة */
.ws-pane-body {
  padding: 28px 24px 80px;
}
@media (min-width: 640px) { .ws-pane-body { padding: 32px 32px 96px; } }
@media (min-width: 1024px) { .ws-pane-body { padding: 36px 40px 120px; } }

/* ════════════════════════════════════════════════════════════════════
   v18c.5 — Spatial UI/UX overhaul (Linear / Apple aesthetic)
   ════════════════════════════════════════════════════════════════════ */

/* LEFT — sidebar */
.ws-sidebar {
  width: 248px;
  background: rgba(255,255,255,.95);
  backdrop-filter: saturate(180%) blur(8px);
  border-right: 1px solid rgba(15,23,42,.06);
  box-shadow: 1px 0 2px rgba(15,23,42,.02);
  flex-shrink: 0;
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
}
.ws-sidebar .ws-label { opacity: 1; transform: none; }
@media (min-width: 1024px) and (max-width: 1199px) {
  .ws-sidebar { width: 220px; }
}

.ws-brand {
  height: 68px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid rgba(15,23,42,.06);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.015em;
  color: var(--ink);
  text-decoration: none;
}
.ws-sidebar nav { padding: 16px 12px; gap: 8px; display: flex; flex-direction: column; }

.ws-label {
  opacity: 1;
  white-space: nowrap;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.ws-nav-item {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  color: var(--ink-2);
  text-decoration: none;
  transition: all .25s cubic-bezier(.2,.8,.2,1);
  position: relative;
  font-size: 13.5px;
  font-weight: 500;
}
.ws-nav-item:hover {
  background: #f1f5f9;
  color: var(--ink);
  transform: translateX(2px);
}
.ws-nav-item.ws-nav-active {
  background: linear-gradient(135deg, rgba(16,185,129,.12), rgba(4,120,87,.08));
  color: var(--brand);
  font-weight: 600;
  box-shadow: 0 2px 8px -2px rgba(4,120,87,.12);
}
.ws-nav-item.ws-nav-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #10b981, #047857);
  box-shadow: 0 0 8px rgba(16,185,129,.5);
}
.ws-icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  font-size: 17px;
  flex-shrink: 0;
}

/* MIDDLE pane — في app.html (3-pane workspace) عرض ثابت 480px،
   في dashboard/patients/agenda/inbox/settings (single-pane) يأخذ كل المتبقي */
.ws-middle {
  background: #fff;
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}
@media (min-width: 1024px) {
  .ws-middle {
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid rgba(15,23,42,.06);
  }
  /* فقط في app.html (مع right pane) عرض ثابت */
  .ws-body:has(.ws-right) .ws-middle {
    width: 480px;
    flex: 0 0 480px;
  }
}

/* RIGHT pane */
.ws-right {
  background: var(--canvas);
  display: flex;
  flex-direction: column;
}
@media (min-width: 1024px) {
  .ws-right {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    min-width: 0;
  }
}

.ws-pane-header {
  position: sticky; top: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(10px);
  -webkit-backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid rgba(15,23,42,.06);
  padding: 18px 32px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px;
  z-index: 10;
  flex-shrink: 0;
  flex-wrap: nowrap;
  min-width: 0;
}
.ws-pane-header > div:first-child { min-width: 0; flex: 1 1 auto; overflow: hidden; }
.ws-pane-header > div:first-child h1,
.ws-pane-header > div:first-child p {
  white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
}
.ws-pane-header h1 { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; }
.ws-pane-header > a, .ws-pane-header > button,
.ws-pane-header > div:not(:first-child) { flex-shrink: 0; }
@media (max-width: 640px) { .ws-pane-header { padding: 14px 18px; gap: 12px; } }

/* (legacy ws-pane-body — overridden by App Shell rules above) */

/* Override: cards inside ws-pane-body — consistent breathing room */
.ws-middle .step-card { padding: 1.25rem 1.25rem 1.4rem; margin: 0; }
.ws-middle .card { padding: 1.15rem 1.25rem; margin: 0; }
.ws-middle .ws-pane-body > * + * { margin-top: 1rem; }
.ws-middle .step-head { margin-bottom: 1rem; }
/* Recorder shell — tighter on narrow pane */
.ws-middle .recorder-shell { padding: 1.5rem 1rem; }
.ws-middle .mic-btn { width: 78px; height: 78px; }
.ws-middle #rec-status { margin-top: 1rem; font-size: .9rem; }
.ws-middle #rec-timer { margin-top: .5rem; font-size: 1.5rem; }
/* Generate row buttons */
.ws-middle .step-card .grid.grid-cols-2 { margin-top: 1rem; }

/* Cancel previous main+section staggered animation when inside workspace
   (those rules animate every section; with sticky panes this causes flicker) */
.ws-body section, .ws-body div, .ws-body .card { animation: none; }
.ws-body .step-card, .ws-body .card { animation: card-rise .35s cubic-bezier(.2,.8,.2,1) both; }

/* Mobile top bar (visible <lg) */
.ws-mobile-bar {
  display: flex;
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid rgba(15,23,42,.06);
  padding: 10px 14px;
  align-items: center; justify-content: space-between; gap: 10px;
}
@media (min-width: 1024px) { .ws-mobile-bar { display: none; } }

/* On mobile the right pane sits naturally below middle (stacks via flex-col on body) */
@media (max-width: 1023px) {
  .ws-body { display: block; }
  .ws-middle, .ws-right { width: 100%; max-width: 100%; }
  .ws-pane-header { display: none; }
}

/* User-menu popout positioning when sidebar collapsed */
.ws-user-menu {
  position: absolute;
  left: 56px; bottom: 12px;
  width: 220px;
  background: #fff;
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 12px;
  box-shadow: 0 12px 32px -8px rgba(15,23,42,.18);
  padding: 4px;
  z-index: 40;
}
.ws-user-menu a, .ws-user-menu button {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px; border-radius: 8px;
  font-size: 13px; color: var(--ink-2);
}
.ws-user-menu a:hover, .ws-user-menu button:hover { background: #f1f5f9; color: var(--ink); }
.ws-user-menu .ws-menu-divider { border-top: 1px solid rgba(15,23,42,.06); margin: 4px 0; }
.ws-user-menu .ws-menu-danger { color: var(--danger); }
.ws-user-menu .ws-menu-danger:hover { background: #fef2f2; color: var(--danger); }

/* ============================================================
   v18c — Dark Mode (data-theme="dark" on <html>)
   ============================================================ */
html[data-theme="dark"] {
  color-scheme: dark;
}
html[data-theme="dark"] body {
  background:
    radial-gradient(80% 40% at 50% -10%, rgba(16,185,129,.06), transparent 70%),
    #0b1220;
  color: #e2e8f0;
}
html[data-theme="dark"] .card {
  background: rgba(30,41,59,.85);
  border-color: rgba(255,255,255,.06);
  color: #e2e8f0;
}
html[data-theme="dark"] .step-card {
  background: rgba(30,41,59,.92);
  border-color: rgba(255,255,255,.08);
  color: #e2e8f0;
}
html[data-theme="dark"] .step-title { color: #f1f5f9; }
html[data-theme="dark"] .text-slate-900,
html[data-theme="dark"] .text-slate-700,
html[data-theme="dark"] .text-slate-600 { color: #e2e8f0 !important; }
html[data-theme="dark"] .text-slate-500,
html[data-theme="dark"] .text-slate-400 { color: #94a3b8 !important; }
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .bg-slate-100 { background-color: #1e293b !important; }
html[data-theme="dark"] .border,
html[data-theme="dark"] .border-slate-200,
html[data-theme="dark"] .border-slate-100 { border-color: #334155 !important; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background-color: #1e293b !important;
  color: #e2e8f0 !important;
  border-color: #334155 !important;
}
html[data-theme="dark"] .ws-sidebar {
  background: #0f172a;
  border-right-color: rgba(255,255,255,.06);
}
html[data-theme="dark"] .ws-brand { color: #e2e8f0; border-bottom-color: rgba(255,255,255,.06); }
html[data-theme="dark"] .ws-nav-item { color: #94a3b8; }
html[data-theme="dark"] .ws-nav-item:hover { background: #1e293b; color: #e2e8f0; }
html[data-theme="dark"] .ws-nav-item.ws-nav-active {
  background: rgba(16,185,129,.12);
  color: #6ee7b7;
}
html[data-theme="dark"] .ws-middle { background: #0f172a; border-right-color: rgba(255,255,255,.06); }
html[data-theme="dark"] .ws-right  { background: #0b1220; }
html[data-theme="dark"] .ws-pane-header,
html[data-theme="dark"] .app-header,
html[data-theme="dark"] .ws-mobile-bar {
  background: rgba(15,23,42,.92);
  border-bottom-color: rgba(255,255,255,.06);
}
html[data-theme="dark"] table thead th { background: #1e293b; color: #cbd5e1; }
html[data-theme="dark"] tbody tr:hover { background-color: rgba(16,185,129,.08) !important; }
html[data-theme="dark"] .recorder-shell {
  background: linear-gradient(180deg, #1e293b, #0f172a);
  border-color: rgba(255,255,255,.06);
}
html[data-theme="dark"] .footer { background: #0b1220; border-top-color: rgba(255,255,255,.06); color: #64748b; }
html[data-theme="dark"] .ws-user-menu {
  background: #1e293b;
  border-color: rgba(255,255,255,.08);
  color: #e2e8f0;
}
html[data-theme="dark"] .ws-user-menu a,
html[data-theme="dark"] .ws-user-menu button { color: #cbd5e1; }
html[data-theme="dark"] .ws-user-menu a:hover,
html[data-theme="dark"] .ws-user-menu button:hover { background: #334155; color: #f1f5f9; }
html[data-theme="dark"] .alert.alert-ok    { background: rgba(16,185,129,.10); color: #6ee7b7; border-color: rgba(16,185,129,.25); }
html[data-theme="dark"] .alert.alert-warn  { background: rgba(245,158,11,.10); color: #fcd34d; border-color: rgba(245,158,11,.25); }
html[data-theme="dark"] .alert.alert-error { background: rgba(239,68,68,.10); color: #fca5a5; border-color: rgba(239,68,68,.25); }
html[data-theme="dark"] #soap-output section { background: linear-gradient(180deg,#1e293b,#0f172a); }
html[data-theme="dark"] #soap-output p { color: #e2e8f0; }
html[data-theme="dark"] .chip { background: #1e293b; color: #cbd5e1; border-color: rgba(255,255,255,.08); }
html[data-theme="dark"] .chip:hover { background: #334155; }
html[data-theme="dark"] .chip.chip-active {
  background: rgba(16,185,129,.18);
  border-color: #10b981;
  color: #6ee7b7;
}

/* ─── Dark mode للصفحة الرئيسية والـ landing pages ─── */
html[data-theme="dark"] .hero-bg {
  background:
    radial-gradient(1000px 500px at 50% -10%, rgba(16,185,129,.12) 0%, transparent 60%),
    radial-gradient(800px 400px at 100% 0%, rgba(59,130,246,.06) 0%, transparent 50%),
    #0b1220;
}
html[data-theme="dark"] .feature-card {
  background: rgba(30,41,59,.85);
  border-color: rgba(255,255,255,.06);
  color: #e2e8f0;
}
html[data-theme="dark"] .price-card {
  background: rgba(30,41,59,.92);
  border-color: rgba(255,255,255,.08);
  color: #e2e8f0;
}
html[data-theme="dark"] .price-card.featured {
  border-color: #10b981;
}
html[data-theme="dark"] .v18-feature {
  background: rgba(30,41,59,.85);
  border-color: rgba(255,255,255,.08);
  color: #e2e8f0;
}
html[data-theme="dark"] .v18-feature h3 { color: #f1f5f9 !important; }
html[data-theme="dark"] .testimonial {
  background: #1e293b;
  border-color: rgba(255,255,255,.08);
  color: #e2e8f0;
}
html[data-theme="dark"] .ws-mock {
  background: #1e293b;
  border-color: rgba(255,255,255,.08);
  box-shadow: 0 30px 60px -20px rgba(0,0,0,.5);
}
html[data-theme="dark"] .ws-mock-bar { background: linear-gradient(180deg,#0f172a,#0b1220); }
html[data-theme="dark"] .ws-mock-sidebar { background: #0f172a; }
html[data-theme="dark"] .ws-mock-mid { background: #1e293b; }
html[data-theme="dark"] .ws-mock-right { background: #0f172a; }
html[data-theme="dark"] .ws-mock-step { background: #0f172a; border-color: rgba(255,255,255,.08); }
html[data-theme="dark"] .ws-mock-soap { background: #0f172a; border-color: rgba(255,255,255,.08); }
html[data-theme="dark"] .ws-mock-title { color: #f1f5f9; }
html[data-theme="dark"] .ws-mock-input { background: #0b1220; border-color: rgba(255,255,255,.08); color: #cbd5e1; }
html[data-theme="dark"] .ws-mock-chip { background: #0f172a; border-color: rgba(255,255,255,.08); color: #cbd5e1; }
html[data-theme="dark"] .hero-stat-num { color: #6ee7b7; }
html[data-theme="dark"] .price-card .price-amount { color: #f1f5f9; }

/* Tailwind overrides لخلفيات صريحة */
html[data-theme="dark"] .bg-gradient-to-b.from-white,
html[data-theme="dark"] .bg-gradient-to-b.from-slate-50,
html[data-theme="dark"] .bg-gradient-to-b.to-slate-50,
html[data-theme="dark"] .bg-gradient-to-b.to-white { background: #0b1220 !important; }

/* Header الـ landing */
html[data-theme="dark"] .app-header {
  background: rgba(11,18,32,.85) !important;
  border-bottom-color: rgba(255,255,255,.06) !important;
}

/* Trust badge على intake/handout */
html[data-theme="dark"] .trust-badge {
  background: linear-gradient(180deg,#1e293b,#0f172a);
  border-color: rgba(16,185,129,.2);
  color: #cbd5e1;
}

/* Testimonial avatar/stars stay vibrant */
html[data-theme="dark"] .testimonial-stars { color: #fbbf24; }
html[data-theme="dark"] .testimonial p { color: #cbd5e1 !important; }
html[data-theme="dark"] .testimonial .font-semibold { color: #f1f5f9 !important; }

/* Footer (landing) */
html[data-theme="dark"] footer.bg-slate-900 { background: #050810 !important; }

/* Login hero panel */
html[data-theme="dark"] aside.card.p-7,
html[data-theme="dark"] .card.w-full.max-w-md { background: #1e293b !important; color: #e2e8f0; }

/* Inputs everywhere — better dark contrast */
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color: #64748b !important; }
html[data-theme="dark"] kbd.kbd { background: #0b1220; border-color: #334155; color: #cbd5e1; }

/* Select dropdown text */
html[data-theme="dark"] select option { background: #1e293b; color: #e2e8f0; }

/* CTA emerald → keep visible in dark */
html[data-theme="dark"] .from-emerald-700 { --tw-gradient-from: #047857 !important; }
html[data-theme="dark"] .to-emerald-900 { --tw-gradient-to: #022c22 !important; }

/* ─── Landing hero pill (PIPEDA badge) في dark mode ─── */
html[data-theme="dark"] .bg-white.border-emerald-200,
html[data-theme="dark"] .bg-white.border.border-emerald-200 {
  background-color: rgba(16,185,129,.10) !important;
  border-color: rgba(16,185,129,.35) !important;
  color: #6ee7b7 !important;
}
html[data-theme="dark"] .text-emerald-800 { color: #6ee7b7 !important; }
html[data-theme="dark"] .text-emerald-700 { color: #34d399 !important; }

/* Hero text — keep gradient + ensure subhead readable */
html[data-theme="dark"] .hero-headline { color: #f8fafc; }
html[data-theme="dark"] .hero-sub { color: #94a3b8; }

/* Pricing card bg overrides */
html[data-theme="dark"] .bg-emerald-50 {
  background-color: rgba(16,185,129,.10) !important;
  color: #6ee7b7 !important;
}
html[data-theme="dark"] .border-emerald-200 { border-color: rgba(16,185,129,.30) !important; }

/* Theme button (landing) — dark mode */
html[data-theme="dark"] #theme-btn {
  background: #1e293b !important;
  border-color: rgba(255,255,255,.12) !important;
  color: #fbbf24;
}
html[data-theme="dark"] #theme-btn:hover { border-color: #10b981 !important; }

/* Section bg gradients (landing) */
html[data-theme="dark"] .bg-gradient-to-b.from-white,
html[data-theme="dark"] .bg-gradient-to-b.to-slate-50,
html[data-theme="dark"] .bg-gradient-to-b.to-white,
html[data-theme="dark"] .bg-gradient-to-b.from-slate-50 {
  background: #0b1220 !important;
}
html[data-theme="dark"] section.bg-white,
html[data-theme="dark"] section.bg-slate-50 { background: #0b1220 !important; }

/* Mobile sidebar panel in dark */
html[data-theme="dark"] #ws-mobile-panel { background: #0f172a !important; color: #e2e8f0; }

/* Theme button in workspace sidebar — emoji color in dark */
html[data-theme="dark"] #ws-theme-icon { color: #fbbf24; }


/* ════════════════════════════════════════════════════════════════════
   v18e — Workspace Record card animations
   ════════════════════════════════════════════════════════════════════ */
.rec-emoji-wrap {
  position: relative;
  margin-left: auto;
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
}
.rec-emoji {
  font-size: 22px;
  display: inline-block;
  animation: emoji-bounce 2.5s ease-in-out infinite;
  filter: drop-shadow(0 4px 8px rgba(4,120,87,.25));
}
.rec-emoji-orbit {
  position: absolute;
  font-size: 11px;
  animation: emoji-orbit 3.5s linear infinite;
}
@keyframes emoji-bounce {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%      { transform: translateY(-4px) rotate(5deg); }
}
@keyframes emoji-orbit {
  0%   { transform: rotate(0)   translateX(18px) rotate(0);   opacity: 1; }
  50%  { opacity: .4; }
  100% { transform: rotate(360deg) translateX(18px) rotate(-360deg); opacity: 1; }
}

.rec-emoji-inline {
  display: inline-block;
  animation: emoji-tap 1.6s ease-in-out infinite;
  margin-right: 4px;
}
@keyframes emoji-tap {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

/* Mic stage with sound waves */
.mic-stage {
  position: relative;
  width: 130px; height: 130px;
  margin: 0 auto;
  display: grid; place-items: center;
}
.mic-wave {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(16,185,129,.4);
  border-radius: 50%;
  animation: mic-wave-out 2.4s cubic-bezier(.2,.8,.2,1) infinite;
  pointer-events: none;
  opacity: 0;
}
.mic-wave-2 { animation-delay: .8s; }
.mic-wave-3 { animation-delay: 1.6s; }
@keyframes mic-wave-out {
  0%   { transform: scale(.8);  opacity: 0; }
  20%  { opacity: .6; }
  100% { transform: scale(1.5); opacity: 0; border-width: 1px; }
}
/* recording state — أكثر intensity */
body.recording .mic-wave {
  border-color: rgba(220,38,38,.5);
  animation-duration: 1.4s;
}

@media (max-width: 640px) {
  .mic-stage { width: 110px; height: 110px; }
}

/* v18c.4 — Patient avatar (initials circle) */
.p-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 13px; font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}
/* Hash-based color (deterministic per patient name) */
.p-av-1 { background: linear-gradient(135deg,#7c3aed,#3b82f6); }
.p-av-2 { background: linear-gradient(135deg,#10b981,#047857); }
.p-av-3 { background: linear-gradient(135deg,#f59e0b,#dc2626); }
.p-av-4 { background: linear-gradient(135deg,#ec4899,#a855f7); }
.p-av-5 { background: linear-gradient(135deg,#0891b2,#0e7490); }
.p-av-6 { background: linear-gradient(135deg,#84cc16,#16a34a); }

/* v18 — Smart UI Indicator (Patient Data Ready) */
#intake-ready-badge:not(.hidden) {
  display: inline-flex;
  animation:
    fade-in .3s cubic-bezier(.2,.8,.2,1) both,
    intake-pulse 1.4s cubic-bezier(.4,0,.2,1) 2;
}
@keyframes intake-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
  50%      { box-shadow: 0 0 0 8px rgba(16,185,129,0); }
}

/* ════════════════════════════════════════════════════════════════════
   v18h — Universal Upgrade Modal
   ════════════════════════════════════════════════════════════════════ */
.ds-upgrade-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(15,23,42,.6);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  padding: 24px;
  opacity: 0; transition: opacity .25s;
}
.ds-upgrade-overlay.is-open { opacity: 1; }
.ds-upgrade-card {
  background: #fff;
  border-radius: 24px;
  max-width: 480px; width: 100%;
  padding: 40px 36px 32px;
  box-shadow: 0 32px 80px -20px rgba(15,23,42,.4);
  position: relative;
  text-align: center;
  transform: scale(.92) translateY(20px);
  transition: transform .3s cubic-bezier(.2,.8,.2,1);
}
.ds-upgrade-overlay.is-open .ds-upgrade-card { transform: scale(1) translateY(0); }
.ds-upgrade-close {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px; border-radius: 50%;
  background: #f1f5f9; border: 0;
  color: #64748b; font-size: 20px; line-height: 1;
  cursor: pointer; display: grid; place-items: center;
}
.ds-upgrade-close:hover { background: #e2e8f0; color: #0f172a; }
.ds-upgrade-icon {
  font-size: 56px;
  filter: drop-shadow(0 8px 16px rgba(245,158,11,.4));
  margin-bottom: 12px;
  animation: upgrade-bounce .8s cubic-bezier(.36,0,.4,1.4);
}
@keyframes upgrade-bounce { from { transform: scale(.5); opacity: 0; } }
.ds-upgrade-title {
  font-size: 22px; font-weight: 800; letter-spacing: -.02em;
  color: #0f172a; margin: 0 0 8px;
}
.ds-upgrade-sub {
  font-size: 14px; color: #64748b; margin: 0 0 20px;
  line-height: 1.6;
}
.ds-upgrade-list {
  list-style: none; padding: 0; margin: 0 0 24px;
  text-align: left;
  background: #f8fafc;
  border-radius: 16px; padding: 16px 20px;
}
.ds-upgrade-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; font-size: 13.5px; color: #334155;
}
.ds-upgrade-list li > span {
  width: 22px; height: 22px; border-radius: 50%;
  background: #ecfdf5; color: #047857;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.ds-upgrade-price {
  font-size: 18px; color: #64748b; margin: 16px 0 4px;
}
.ds-upgrade-amount {
  font-size: 44px; font-weight: 800; letter-spacing: -.03em;
  color: #047857; line-height: 1;
}
.ds-upgrade-mo { font-size: 16px; color: #64748b; font-weight: 500; }
.ds-upgrade-fineprint { font-size: 11px; color: #94a3b8; margin: 0 0 24px; }
.ds-upgrade-actions { display: flex; gap: 10px; justify-content: center; }
.ds-upgrade-cancel {
  padding: 12px 22px; border-radius: 12px;
  background: #fff; border: 1px solid #e2e8f0; color: #475569;
  font-weight: 500; font-size: 14px; cursor: pointer;
}
.ds-upgrade-cancel:hover { background: #f8fafc; }
.ds-upgrade-cta {
  padding: 12px 24px; border-radius: 12px;
  background: linear-gradient(135deg, #10b981, #047857);
  color: #fff; font-weight: 700; font-size: 14px;
  text-decoration: none;
  box-shadow: 0 8px 20px -6px rgba(4,120,87,.55);
  transition: all .2s;
}
.ds-upgrade-cta:hover { transform: translateY(-1px); box-shadow: 0 12px 28px -6px rgba(4,120,87,.65); }

html[data-theme="dark"] .ds-upgrade-card { background: #1e293b; color: #e2e8f0; }
html[data-theme="dark"] .ds-upgrade-title { color: #f1f5f9; }
html[data-theme="dark"] .ds-upgrade-sub { color: #94a3b8; }
html[data-theme="dark"] .ds-upgrade-list { background: #0f172a; }
html[data-theme="dark"] .ds-upgrade-list li { color: #cbd5e1; }
html[data-theme="dark"] .ds-upgrade-amount { color: #34d399; }
html[data-theme="dark"] .ds-upgrade-cancel { background: #0f172a; border-color: #334155; color: #cbd5e1; }
html[data-theme="dark"] .ds-upgrade-close { background: #334155; color: #94a3b8; }

/* Badge pulse on new message arrival */
.badge-pulse {
  animation: badge-bounce 1s cubic-bezier(.36,0,.4,1) 2;
}
@keyframes badge-bounce {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.5); box-shadow: 0 0 16px rgba(239,68,68,.7); }
}

/* Inbox badge dot when sidebar collapsed */
.ws-inbox-dot {
  position: absolute;
  top: 8px; left: 30px;
  background: #ef4444; color: #fff;
  font-size: 10px; font-weight: 700;
  border-radius: 999px;
  padding: 1px 5px;
  min-width: 16px; text-align: center;
  border: 2px solid #fff;
}
