:root {
  color-scheme: light;

  /* Surfaces */
  --bg: #f4f7f8;
  --bg-2: #eaf4f3;
  --panel: #ffffff;
  --panel-alt: #f6f9f9;
  --panel-strong: #ffffff;

  /* Ink */
  --text: #1c2430;
  --text-2: #3d4757;
  --muted: #6b7484;
  --muted-2: #a0a7b4;

  /* Brand — aqua healthcare palette */
  --primary: #14a39a;
  --primary-strong: #0e857e;
  --primary-bright: #61c8c5;
  --primary-soft: rgba(20, 163, 154, 0.1);
  --primary-line: rgba(20, 163, 154, 0.32);
  --gradient-brand: linear-gradient(135deg, #1fb5aa 0%, #0e857e 100%);

  /* Status */
  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.1);
  --warning: #b45309;
  --warning-soft: rgba(180, 83, 9, 0.1);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.08);

  --brand-ink: #0f1a24;
  --border: rgba(28, 36, 48, 0.12);
  --border-soft: rgba(28, 36, 48, 0.07);

  --shadow-xs: 0 1px 2px rgba(15, 26, 36, 0.05);
  --shadow-soft: 0 1px 2px rgba(15, 26, 36, 0.04), 0 4px 16px -4px rgba(15, 26, 36, 0.08);
  --shadow-hover: 0 2px 4px rgba(15, 26, 36, 0.05), 0 12px 28px -8px rgba(15, 26, 36, 0.14);
  --shadow-strong: 0 8px 20px rgba(15, 26, 36, 0.08), 0 32px 64px -16px rgba(15, 26, 36, 0.22);
  --shadow-primary: 0 1px 2px rgba(14, 133, 126, 0.2), 0 6px 16px -4px rgba(14, 133, 126, 0.4);

  --font-display: "Plus Jakarta Sans", "Inter", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 15px;
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(97, 200, 197, 0.14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(97, 200, 197, 0.08), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body.auth-pending .app-shell,
body.auth-pending > .toast,
body.auth-pending > .modal {
  visibility: hidden;
}

body.auth-pending::before {
  content: "Checking your session…";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 500;
  animation: pulse-text 1.4s ease-in-out infinite;
}

@keyframes pulse-text {
  50% {
    opacity: 0.45;
  }
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

a {
  color: inherit;
}

::selection {
  background: rgba(97, 200, 197, 0.3);
  color: var(--brand-ink);
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease), color 0.18s var(--ease),
    box-shadow 0.18s var(--ease), transform 0.18s var(--ease);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

.hidden {
  display: none !important;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-strong);
  margin: 0 0 10px;
}

/* ============ Page transitions ============ */

/* Smooth cross-page navigation (Chromium/Safari); other browsers just load normally. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

::view-transition-group(root) {
  animation-duration: 0.28s;
  animation-timing-function: var(--ease);
}

/* Sidebar stays put; only the highlighted nav item glides to its new spot. */
.sidebar {
  view-transition-name: sidebar;
}

::view-transition-old(sidebar) {
  display: none;
}

::view-transition-new(sidebar) {
  animation: none;
}

.nav-btn.active {
  view-transition-name: nav-active;
}

::view-transition-group(nav-active) {
  animation-duration: 0.38s;
  animation-timing-function: cubic-bezier(0.3, 1.3, 0.5, 1);
}

/* ============ Auth / landing ============ */

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.landing-layout {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  align-items: stretch;
  border-radius: 28px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow-strong);
  border: 1px solid var(--border-soft);
  animation: rise-in 0.5s var(--ease) both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.hero-panel {
  position: relative;
  margin: 10px;
  padding: clamp(32px, 5vw, 56px);
  border-radius: 20px;
  background:
    radial-gradient(600px 400px at 110% -10%, rgba(97, 200, 197, 0.55), transparent 60%),
    radial-gradient(500px 360px at -20% 120%, rgba(20, 163, 154, 0.45), transparent 60%),
    linear-gradient(160deg, #0f2a33 0%, #0b1a22 100%);
  color: #eef6f5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

/* ECG trace across the hero */
.hero-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 180' preserveAspectRatio='none'%3E%3Cpath d='M0 140 L110 140 L130 60 L150 160 L170 20 L190 140 L230 140 L250 100 L270 140 L600 140' fill='none' stroke='%2361c8c5' stroke-width='1.5' opacity='0.16'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 88%;
  background-size: 130% auto;
  pointer-events: none;
}

/* Subtle grid texture */
.hero-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
  pointer-events: none;
}

.hero-panel > * {
  position: relative;
  z-index: 1;
}

.hero-panel .eyebrow {
  color: #8fe0dc;
}

.hero-panel h1 {
  margin: 0 0 18px;
  font-size: clamp(2.3rem, 3.6vw, 3.25rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
  max-width: 14ch;
  font-weight: 800;
  color: #ffffff;
}

.hero-copy {
  max-width: 44ch;
  color: rgba(238, 246, 245, 0.72);
  font-size: 1.02rem;
  line-height: 1.65;
  margin-bottom: 28px;
}

.portal-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  color: #eef6f5;
  font-size: 0.86rem;
  font-weight: 500;
  width: fit-content;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
  flex: none;
  animation: ping 2s ease-out infinite;
}

@keyframes ping {
  0% {
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55);
  }
  80%,
  100% {
    box-shadow: 0 0 0 8px rgba(74, 222, 128, 0);
  }
}

.portal-list {
  list-style: none;
  padding: 0;
  margin: 32px 0 0;
  display: grid;
  gap: 12px;
  max-width: 420px;
}

.portal-list li {
  position: relative;
  padding-left: 32px;
  color: rgba(238, 246, 245, 0.85);
  font-size: 0.95rem;
}

.portal-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 1px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(97, 200, 197, 0.2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238fe0dc' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")
    center / 12px no-repeat;
}

.auth-card {
  width: 100%;
  background: var(--panel);
  padding: clamp(32px, 4.5vw, 60px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-card .brand {
  margin-bottom: 36px;
}

.signin-title {
  margin-bottom: 10px;
  font-size: clamp(1.5rem, 2.2vw, 1.85rem);
  line-height: 1.2;
  letter-spacing: -0.025em;
  font-weight: 700;
  max-width: 22ch;
}

.auth-copy,
.session-copy {
  color: var(--muted);
  line-height: 1.6;
}

.auth-copy {
  margin-bottom: 28px;
  max-width: 40ch;
}

.auth-card button[type="submit"] {
  margin-top: 6px;
  padding: 13px 18px;
}

/* ============ App shell ============ */

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  position: fixed;
  inset: 12px auto 12px 12px;
  width: 236px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  color: var(--text);
  padding: 20px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  overflow-y: auto;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar .brand {
  padding: 0 6px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow-xs), inset 0 0 0 1px var(--border-soft);
  padding: 4px;
  flex: none;
  object-fit: contain;
}

.brand h2 {
  display: flex;
  gap: 1px;
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.brand-guada {
  color: var(--primary);
}

.brand-health {
  color: var(--brand-ink);
}

.brand h2,
.brand p {
  margin: 0;
}

.brand p {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 1px;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-links-vertical {
  flex-direction: column;
  flex: 1;
}

.nav-links-vertical::before {
  content: "Menu";
  padding: 0 12px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-2);
}

.nav-links-top {
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.nav-btn,
.ghost-btn,
.secondary-btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: transparent;
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: none;
}

.nav-btn {
  width: 100%;
  min-width: 0;
  justify-content: flex-start;
  gap: 11px;
  padding: 10px 12px;
  color: var(--text-2);
  font-size: 0.93rem;
  transition: background-color 0.18s var(--ease), color 0.18s var(--ease), transform 0.12s var(--ease);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--muted);
  transition: color 0.18s var(--ease);
}

.nav-btn:hover:not(.active) {
  background: rgba(28, 36, 48, 0.045);
  color: var(--text);
}

.nav-btn:hover .nav-icon {
  color: var(--text);
}

.nav-btn.active {
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-weight: 600;
}

.nav-btn.active .nav-icon {
  color: var(--primary);
}

.nav-btn:active {
  transform: scale(0.97);
}

.nav-btn:hover .nav-icon,
.nav-btn:focus-visible .nav-icon {
  transform: translateX(1px) scale(1.08);
}

.nav-icon {
  transition: color 0.18s var(--ease), transform 0.2s var(--ease);
}

.sidebar-card,
.card,
.hero-card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.sidebar-card {
  padding: 6px;
  margin-top: auto;
  background: var(--panel-alt);
  box-shadow: none;
  border-radius: var(--radius-md);
}

.sidebar-card p {
  color: var(--muted);
  margin: 4px 0 10px;
  font-size: 0.86rem;
}

.sidebar .ghost-btn {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  border-color: transparent;
  color: var(--text-2);
  box-shadow: none;
  padding: 9px 10px;
}

.sidebar .ghost-btn:hover:not(:disabled) {
  background: var(--danger-soft);
  border-color: transparent;
  color: var(--danger);
}

.main-panel {
  grid-column: 2;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  padding: clamp(20px, 2.6vw, 36px) clamp(20px, 3vw, 44px);
}

.main-panel > * {
  max-width: 1120px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.topbar .eyebrow {
  margin: 0;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 12px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--text-2);
  font-size: 0.84rem;
  font-weight: 500;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-xs);
}

.status-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  flex: none;
}

.content {
  display: grid;
  gap: 20px;
  animation: rise-in 0.4s var(--ease) both;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-card {
  position: relative;
  padding: 30px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  overflow: hidden;
  background:
    radial-gradient(500px 260px at 100% 0%, rgba(97, 200, 197, 0.16), transparent 70%),
    var(--panel);
}

.hero-card h2 {
  font-size: clamp(1.5rem, 2vw, 1.9rem);
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-weight: 800;
}

.hero-card p {
  color: var(--muted);
  margin-top: 8px;
  max-width: 56ch;
}

.hero-card p.eyebrow {
  color: var(--primary-strong);
  margin: 0 0 10px;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(110px, 1fr));
  gap: 10px;
}

.metric-card {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--gradient-brand);
}

.metric-card:nth-child(2)::before {
  background: linear-gradient(90deg, #38bdf8, #0284c7);
}

.metric-card:nth-child(3)::before {
  background: linear-gradient(90deg, #a78bfa, #7c3aed);
}

.metric-card span {
  font-family: var(--font-display);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.metric-card small {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

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

.card {
  padding: 26px 28px;
  transition: box-shadow 0.25s var(--ease);
}

.grid-2 .card {
  animation: rise-in 0.45s var(--ease) both;
}

.grid-2 .card:nth-child(2) {
  animation-delay: 0.08s;
}

.metric-card {
  animation: rise-in 0.45s var(--ease) both;
}

.metric-card:nth-child(1) {
  animation-delay: 0.1s;
}

.metric-card:nth-child(2) {
  animation-delay: 0.16s;
}

.metric-card:nth-child(3) {
  animation-delay: 0.22s;
}

.grid-2 .card:hover {
  box-shadow: var(--shadow-hover);
}

.card-header {
  margin-bottom: 20px;
}

.card-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.card-header p {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.55;
  font-size: 0.93rem;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.file-preview {
  min-height: 240px;
  border: 1.5px dashed var(--primary-line);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 50% 40%, rgba(97, 200, 197, 0.08), transparent 70%),
    var(--panel-alt);
  padding: 16px;
  overflow: hidden;
  display: grid;
  place-items: center;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.file-preview-placeholder {
  display: grid;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  font-weight: 500;
  text-align: center;
  font-size: 0.92rem;
}

.file-preview-placeholder::before {
  content: "";
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--panel)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314a39a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='3' width='18' height='18' rx='3'/%3E%3Ccircle cx='9' cy='9' r='2'/%3E%3Cpath d='m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21'/%3E%3C/svg%3E")
    center / 24px no-repeat;
  box-shadow: var(--shadow-soft);
}

.file-preview img {
  width: 100%;
  height: 100%;
  max-height: 420px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.file-preview img[hidden],
.file-preview-placeholder[hidden] {
  display: none;
}

.file-preview.has-image {
  padding: 10px;
  border-style: solid;
  border-color: var(--border-soft);
  background: var(--panel-alt);
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--text-2);
  font-size: 0.86rem;
  font-weight: 600;
}

input,
select,
textarea,
button {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--panel);
  color: var(--text);
  font-weight: 400;
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

input:hover:not(:focus):not(:disabled),
select:hover:not(:focus):not(:disabled),
textarea:hover:not(:focus):not(:disabled) {
  border-color: rgba(28, 36, 48, 0.2);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input:disabled,
textarea:disabled {
  background: var(--panel-alt);
  cursor: not-allowed;
}

textarea {
  line-height: 1.6;
  resize: vertical;
}

#transcription-output {
  min-height: 200px;
  font-family: var(--font-mono);
  font-size: 0.88rem;
}

input[type="search"] {
  padding-left: 40px;
  background: var(--panel)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7484' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E")
    14px center / 17px no-repeat;
}

input[type="file"] {
  padding: 6px;
  color: var(--muted);
  font-size: 0.88rem;
}

input[type="file"]::file-selector-button {
  margin-right: 12px;
  padding: 7px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.18s var(--ease);
}

input[type="file"]::file-selector-button:hover {
  background: rgba(20, 163, 154, 0.18);
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  background: var(--gradient-brand);
  color: #ffffff;
  font-weight: 600;
  font-size: 0.92rem;
  border: 1px solid transparent;
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

button:hover:not(:disabled) {
  background: linear-gradient(135deg, #17a99f 0%, #0b746e 100%);
  box-shadow: 0 2px 4px rgba(14, 133, 126, 0.25), 0 10px 22px -6px rgba(14, 133, 126, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.secondary-btn {
  background: var(--primary-soft);
  color: var(--primary-strong);
  border-color: transparent;
  box-shadow: none;
}

.secondary-btn:hover:not(:disabled) {
  background: rgba(20, 163, 154, 0.16);
  color: var(--primary-strong);
  box-shadow: none;
}

#scan-button,
#export-records-button {
  background: var(--brand-ink);
  color: #ffffff;
  border-color: var(--brand-ink);
  box-shadow: 0 1px 2px rgba(15, 26, 36, 0.2), 0 6px 16px -6px rgba(15, 26, 36, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

#scan-button:hover:not(:disabled),
#export-records-button:hover:not(:disabled) {
  background: #1f2c38;
  border-color: #1f2c38;
}

#scan-button::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.9 2.6 8.5 6.8a2 2 0 0 1-1.3 1.3L3 9.5l4.2 1.4a2 2 0 0 1 1.3 1.3l1.4 4.2 1.4-4.2a2 2 0 0 1 1.3-1.3l4.2-1.4-4.2-1.4a2 2 0 0 1-1.3-1.3z'/%3E%3Cpath d='M19 14v6M16 17h6'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9.9 2.6 8.5 6.8a2 2 0 0 1-1.3 1.3L3 9.5l4.2 1.4a2 2 0 0 1 1.3 1.3l1.4 4.2 1.4-4.2a2 2 0 0 1 1.3-1.3l4.2-1.4-4.2-1.4a2 2 0 0 1-1.3-1.3z'/%3E%3Cpath d='M19 14v6M16 17h6'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

#export-records-button::before {
  content: "";
  width: 16px;
  height: 16px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 10l5 5 5-5M5 21h14'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v12M7 10l5 5 5-5M5 21h14'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

/* The scan button and its progress bar share one slot; the bar replaces the button while running. */
.scan-slot {
  display: grid;
}

.scan-slot > * {
  grid-area: 1 / 1;
}

.scan-slot:has(.transcription-progress:not([hidden])) #scan-button {
  visibility: hidden;
}

.transcription-progress {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 100%;
  padding: 0 18px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--brand-ink);
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 26, 36, 0.2), 0 6px 16px -6px rgba(15, 26, 36, 0.45);
  animation: slot-pop 0.32s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}

.transcription-progress[hidden] {
  display: none;
}

@keyframes slot-pop {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
}

/* Fill sweeps behind the text */
.progress {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--gradient-brand);
  overflow: hidden;
  transition: width 0.35s var(--ease);
}

/* Moving sheen while work is in flight */
.progress::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.28), transparent);
  transform: translateX(-100%);
  animation: progress-sheen 1.4s ease-in-out infinite;
}

@keyframes progress-sheen {
  to {
    transform: translateX(100%);
  }
}

.progress-label,
.progress-value {
  position: relative;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.progress-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.progress-label::before {
  content: "";
  width: 14px;
  height: 14px;
  flex: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}

.progress-value {
  flex: none;
  font-family: var(--font-display);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

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

.transcription-progress.is-complete .progress {
  background: linear-gradient(90deg, #22c55e, #15803d);
}

.transcription-progress.is-error {
  background: var(--danger);
}

.transcription-progress.is-error .progress,
.transcription-progress.is-error .progress-value {
  display: none;
}

.transcription-progress.is-complete .progress::after,
.transcription-progress.is-error .progress::after {
  animation: none;
}

.transcription-progress.is-complete .progress-label::before,
.transcription-progress.is-error .progress-label::before {
  border: none;
  animation: pop 0.35s var(--ease);
  background: center / contain no-repeat;
}

.transcription-progress.is-complete .progress-label::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

.transcription-progress.is-error .progress-label::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E");
}

@keyframes pop {
  50% {
    transform: scale(1.35);
  }
}

/* Brief highlight when OCR text lands in the output box */
#transcription-output.just-filled {
  animation: filled-flash 1.2s var(--ease);
}

@keyframes filled-flash {
  0% {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(97, 200, 197, 0.35);
    background-color: rgba(97, 200, 197, 0.08);
  }
}

.ghost-btn {
  background: var(--panel);
  color: var(--text-2);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}

.ghost-btn:hover:not(:disabled) {
  background: var(--panel-alt);
  border-color: rgba(28, 36, 48, 0.2);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

.button-row {
  display: flex;
  gap: 10px;
  padding-top: 4px;
}

.timeline {
  list-style: none;
  counter-reset: step;
  padding: 0;
  color: var(--text-2);
  display: grid;
  gap: 0;
  margin: 0;
  font-size: 0.93rem;
}

.timeline li {
  counter-increment: step;
  position: relative;
  padding: 3px 0 16px 42px;
}

.timeline li:last-child {
  padding-bottom: 0;
}

.timeline li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.78rem;
  font-weight: 700;
}

.timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 13.5px;
  top: 32px;
  bottom: 4px;
  width: 1px;
  background: var(--primary-line);
}

.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.toolbar #search-input {
  flex: 1;
}

.toolbar select {
  width: auto;
  min-width: 180px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

td {
  color: var(--text-2);
  font-size: 0.92rem;
}

td:first-child {
  color: var(--text);
  font-weight: 600;
}

tbody tr:last-child td {
  border-bottom: none;
}

th {
  background: var(--panel-alt);
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding-top: 11px;
  padding-bottom: 11px;
}

tbody tr {
  transition: background-color 0.15s var(--ease);
  animation: row-in 0.35s var(--ease) both;
}

tbody tr:nth-child(2) { animation-delay: 0.03s; }
tbody tr:nth-child(3) { animation-delay: 0.06s; }
tbody tr:nth-child(4) { animation-delay: 0.09s; }
tbody tr:nth-child(5) { animation-delay: 0.12s; }
tbody tr:nth-child(6) { animation-delay: 0.15s; }
tbody tr:nth-child(7) { animation-delay: 0.18s; }
tbody tr:nth-child(n + 8) { animation-delay: 0.21s; }

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

tbody tr:hover {
  background: rgba(97, 200, 197, 0.06);
}

td[colspan] {
  padding: 48px 18px;
  text-align: center !important;
  color: var(--muted);
  font-weight: 500;
}

td:last-child,
th:last-child {
  text-align: right;
}

.edit-record-btn {
  padding: 7px 12px;
  font-size: 0.84rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex: none;
}

.badge.reviewed {
  background: var(--success-soft);
  color: var(--success);
}

.badge.reviewed::before {
  background: var(--success);
}

.badge.pending {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.pending::before {
  background: var(--warning);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px 12px 14px;
  background: rgba(15, 26, 36, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: #f1f6f8;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  box-shadow: var(--shadow-strong);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  transform: translateY(10px) scale(0.98);
  font-size: 0.9rem;
  font-weight: 500;
}

.toast::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary-bright);
  box-shadow: 0 0 0 3px rgba(97, 200, 197, 0.25);
  flex: none;
}

.toast.show {
  opacity: 1;
  transform: none;
}

/* ============ Modal ============ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal.hidden {
  display: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 26, 36, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.2s var(--ease) both;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: 24px;
  box-shadow: var(--shadow-strong);
  padding: 28px;
  animation: modal-in 0.28s var(--ease) both;
}

@media (min-width: 981px) {
  .modal-panel {
    width: min(1120px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px 24px;
  }

  .modal-header,
  .modal-meta,
  .modal-actions {
    grid-column: 1 / -1;
  }

  .record-image-section,
  .modal-field {
    margin-bottom: 0;
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-header .eyebrow {
  margin-bottom: 6px;
}

.modal-header h2 {
  margin: 0;
  font-size: clamp(1.3rem, 1.8vw, 1.55rem);
  font-weight: 700;
}

.modal-close-btn {
  flex: 0 0 auto;
}

.modal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.modal-meta > div {
  background: var(--panel-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.modal-meta strong {
  font-weight: 600;
  color: var(--text);
}

.modal-label {
  display: block;
  color: var(--muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  font-weight: 600;
}

.record-image-section {
  margin-bottom: 18px;
}

.record-image-preview {
  min-height: 180px;
  max-height: 380px;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--panel-alt);
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
}

.record-image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 356px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: #ffffff;
}

.record-image-preview img[hidden],
.record-image-preview span[hidden] {
  display: none;
}

.modal-field {
  margin-bottom: 18px;
}

.modal-field textarea {
  min-height: 220px;
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.65;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 18px;
  border-top: 1px solid var(--border-soft);
}

/* ============ Responsive ============ */

@media (max-width: 980px) {
  .landing-layout {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    padding: 36px 28px;
  }

  .hero-panel h1,
  .hero-copy,
  .portal-list,
  .portal-status {
    max-width: none;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    overflow: visible;
  }

  .sidebar {
    position: sticky;
    inset: auto;
    top: 0;
    width: auto;
    margin: 0;
    flex-direction: row;
    align-items: center;
    padding: 10px 16px;
    gap: 16px;
    overflow: visible;
    border-radius: 0;
    border-width: 0 0 1px;
    box-shadow: none;
  }

  .main-panel {
    grid-column: auto;
    height: auto;
    overflow: visible;
  }

  .sidebar .brand {
    flex: 1;
    padding: 0;
  }

  .nav-links-vertical {
    flex-direction: row;
    flex: none;
  }

  .nav-links-vertical::before {
    display: none;
  }

  .nav-btn {
    justify-content: center;
    width: auto;
  }

  .sidebar-card {
    display: none;
  }

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

  .hero-metrics {
    min-width: 0;
  }

  .modal-meta {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 740px) {
  .auth-screen {
    padding: 16px;
  }

  .main-panel {
    padding: 16px;
  }

  .card,
  .hero-card {
    padding: 20px;
  }

  .grid-2,
  .form-row {
    grid-template-columns: 1fr;
  }

  .hero-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-card {
    padding: 14px 12px 12px;
  }

  .metric-card span {
    font-size: 1.5rem;
  }

  .toolbar,
  .button-row {
    flex-direction: column;
  }

  .toolbar select {
    width: 100%;
  }

  .sidebar {
    flex-wrap: wrap;
  }

  .nav-links-vertical {
    width: 100%;
    order: 3;
  }

  .nav-btn {
    flex: 1;
    min-width: 0;
    padding: 9px 8px;
  }

  .topbar .eyebrow {
    display: none;
  }

  .topbar {
    justify-content: flex-end;
  }

  .modal {
    padding: 10px;
  }

  .modal-panel {
    padding: 18px;
    max-height: calc(100vh - 20px);
  }

  .modal-header,
  .modal-actions {
    flex-direction: column;
  }

  .modal-actions button,
  .modal-close-btn {
    width: 100%;
  }
}

/* Extracted-field verification */
.extracted-fields {
  margin-bottom: 18px;
}

.extracted-fields-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.items-table {
  margin-bottom: 10px;
}

.items-table th,
.items-table td {
  padding: 8px 10px;
}

.items-table input {
  width: 100%;
}

/* Dashboard: prescriptions waiting for verification */
.review-list {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.review-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
}

.review-list a:hover {
  border-color: var(--primary-line);
  background: var(--primary-soft);
}

.review-list span,
.review-list-empty {
  color: var(--muted);
  font-size: 0.88rem;
}

.review-list-all {
  color: var(--primary-strong);
  font-weight: 600;
  font-size: 0.9rem;
}
