/* Pawnda — clinical UI (see portal.css for design system) */

:root {
  --purple-700: #5b4dc7;
  --purple-600: #6c5ce7;
  --purple-500: #7c6df0;
  --purple-400: #a594f9;
  --purple-100: #ede9fe;
  --purple-50: #f5f3ff;

  --bg-page: #f7f6fb;
  --bg-surface: #ffffff;
  --bg-muted: #f0eef8;

  --text-primary: #1e1b2e;
  --text-secondary: #6b6780;
  --text-muted: #9490a8;
  --border: #e8e5f2;

  --mint: #10b981;
  --amber: #f59e0b;
  --rose: #f43f5e;

  --radius-xl: 20px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 3px rgba(91, 77, 199, 0.06);
  --shadow-md: 0 8px 24px rgba(91, 77, 199, 0.1);
  --shadow-lg: 0 16px 48px rgba(91, 77, 199, 0.14);

  --font: "DM Sans", ui-sans-serif, system-ui, sans-serif;
  --nav-h: 64px;
}

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

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.app-frame {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-nav {
  height: var(--nav-h);
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 1.5rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 120px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon.lg {
  width: 48px;
  height: 48px;
  font-size: 1.25rem;
  border-radius: var(--radius-lg);
}

.brand-name {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--purple-700);
  letter-spacing: -0.02em;
}

.nav-tabs {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-tab {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.nav-tab:hover:not(.disabled) {
  color: var(--purple-600);
  background: var(--purple-50);
}

.nav-tab.active {
  color: var(--purple-700);
  background: var(--purple-100);
  font-weight: 600;
}

.nav-tab.disabled { opacity: 0.35; cursor: not-allowed; }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.signed-in-vet { font-size: 0.78rem; color: var(--text-muted); }

.btn-text {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
}

.btn-text:hover { color: var(--purple-600); background: var(--purple-50); }

.app-body {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.75rem 1.5rem 2.5rem;
}

.legal-foot {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 1rem;
  margin: 0;
}

.view-panel.hidden { display: none; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.view-header h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

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

.banner-error {
  background: #fef2f2;
  color: #b91c1c;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  margin-bottom: 1rem;
}

.patient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.patient-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  width: 100%;
  text-align: left;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.patient-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--purple-400);
}

.patient-card-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 3px solid var(--purple-100);
  background: var(--purple-50);
}

.patient-card-avatar-fallback {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  background: var(--purple-100);
}

.patient-card-body { flex: 1; min-width: 0; }

.patient-card-body h3 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.patient-card-body p {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pill {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
}

.pill.visit { background: var(--purple-100); color: var(--purple-700); }
.pill.species { background: var(--bg-muted); color: var(--text-secondary); }
.pill.species.canine { background: #dbeafe; color: #1d4ed8; }
.pill.species.feline { background: #fae8ff; color: #7e22ce; }

.patient-card-meta { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.empty-msg, .empty-state, .checklist-empty {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
  padding: 1rem;
  text-align: center;
}

.case-topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-back {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
}

.btn-back:hover {
  border-color: var(--purple-400);
  color: var(--purple-700);
  background: var(--purple-50);
}

.case-topbar-patient {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 180px;
}

.avatar-ring {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--purple-100);
  background: var(--purple-50);
  flex-shrink: 0;
}

.patient-avatar { width: 100%; height: 100%; object-fit: cover; }

.avatar-fallback, .patient-avatar-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 600;
  background: var(--purple-100);
  color: var(--purple-600);
}

.case-name-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.case-topbar h1 { margin: 0; font-size: 1.25rem; font-weight: 700; }

.case-sub, .case-detail-line {
  margin: 0.15rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.case-topbar-visit { margin-left: auto; }

.select-clean, .appt-controls select {
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  color: var(--text-primary);
}

.hint-bar, .lead-muted {
  margin: -0.5rem 0 1rem;
  padding: 0.5rem 1rem;
  background: #fffbeb;
  color: #92400e;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
}

.case-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 1rem;
  padding: 0.25rem;
  background: var(--bg-muted);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
}

.case-tab {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  cursor: pointer;
}

.case-tab.active {
  background: var(--bg-surface);
  color: var(--purple-700);
  box-shadow: var(--shadow-sm);
}

.case-panel.hidden { display: none; }

.case-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 1.25rem;
}

@media (max-width: 960px) {
  .case-layout { grid-template-columns: 1fr; }
  .nav-tabs { display: none; }
}

.case-col-main { display: flex; flex-direction: column; gap: 1rem; }

.case-col-main .surface {
  overflow: visible;
}

.surface, .panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.surface-head, .panel-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.surface-head h2, .panel-head span:first-child {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  flex: 1;
}

.insights-body, .scroll-panel {
  max-height: 280px;
  overflow-y: auto;
  padding: 0.85rem 1.15rem 1.15rem;
}

.case-col-main .insights-body {
  max-height: none;
  overflow: visible;
}

.highlights-grid, .timeline-body, .labs-body {
  padding: 1rem 1.15rem 1.15rem;
}

#highlights-mount.surface-body,
#timeline-mount.surface-body,
#labs-mount.surface-body {
  padding: 0;
}

.case-panel {
  padding-bottom: 1.5rem;
}

.highlights-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.summary-block {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-page);
  border: 1px solid var(--border);
}

.summary-block.client {
  background: var(--purple-50);
  border-color: #e9d5ff;
}

.summary-block h3, .takeaways-block h3 {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.summary-block p, .takeaway-list li {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.takeaways-block {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
}

.takeaway-list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.ai-disclaimer {
  margin: 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.timeline-care-gaps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.care-gap-chip {
  margin: 0;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.75rem;
}

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

.timeline-item {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.65rem;
  align-items: start;
}

.timeline-marker {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--purple-50);
  display: grid;
  place-items: center;
  font-size: 0.95rem;
}

.timeline-card {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-page);
  padding: 0.65rem;
  cursor: pointer;
  font-family: inherit;
}

.timeline-card:hover { border-color: var(--purple-300); }

.timeline-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
}

.timeline-thumb-icon {
  display: grid;
  place-items: center;
  background: var(--bg-muted);
  font-size: 1.25rem;
}

.timeline-card-body { min-width: 0; flex: 1; }

.timeline-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.timeline-card-head strong {
  font-size: 0.86rem;
  color: var(--text-primary);
}

.timeline-card-head time {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.timeline-card p {
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.timeline-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}

.timeline-flag {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: #fff5f5;
  color: #b91c1c;
}

.labs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.85rem;
}

.lab-chart-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-page);
  padding: 0.85rem;
}

.lab-chart-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: start;
  margin-bottom: 0.5rem;
}

.lab-chart-head h3 {
  margin: 0;
  font-size: 0.88rem;
}

.lab-latest {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.lab-trend-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.25rem 0.45rem;
  border-radius: 999px;
  white-space: nowrap;
}

.lab-trend-badge.trend-up { background: #fff5f5; color: #b91c1c; }
.lab-trend-badge.trend-down { background: #eff6ff; color: #1d4ed8; }
.lab-trend-badge.trend-stable { background: #f0fdf4; color: #15803d; }
.lab-trend-badge.trend-unknown { background: var(--bg-muted); color: var(--text-muted); }

.lab-chart-svg {
  width: 100%;
  height: auto;
  min-height: 88px;
  display: block;
  cursor: pointer;
}

.lab-ref-band { fill: rgba(34, 197, 94, 0.12); }
.lab-line { stroke: var(--purple-600); stroke-width: 2; }
.lab-dot {
  fill: var(--purple-600);
  cursor: pointer;
  stroke: #fff;
  stroke-width: 1.5;
}
.lab-dot.abnormal { fill: #dc2626; }
.lab-dot:focus { outline: 2px solid var(--purple-400); outline-offset: 2px; }

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

.lab-history-row {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  font-family: inherit;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
}

.lab-history-row:hover {
  background: var(--purple-50);
  color: var(--text-primary);
}

.lab-chart-card.is-clickable { cursor: pointer; }
.lab-chart-card.is-clickable:hover { border-color: var(--purple-300); }

.lab-chart-hint {
  margin: 0.35rem 0 0;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.insights-list-cards { display: flex; flex-direction: column; gap: 0.6rem; }

.insight-card {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-page);
  border-left: 3px solid var(--purple-400);
}

.insight-card.priority-high { border-left-color: var(--rose); background: #fff5f5; }
.insight-card.priority-medium { border-left-color: var(--amber); background: #fffbeb; }
.insight-card.priority-vet { border-left-color: var(--purple-600); background: var(--purple-50); }

.insight-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.insight-card-head h4 { margin: 0; font-size: 0.82rem; font-weight: 600; }

.insight-tag {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
}

.insight-card p { margin: 0; font-size: 0.88rem; line-height: 1.45; color: var(--text-secondary); }

.chat-surface { display: flex; flex-direction: column; min-height: 400px; }

.segmented, .chat-mode-tabs {
  display: flex;
  background: var(--bg-muted);
  border-radius: 999px;
  padding: 3px;
}

.segmented button, .chat-mode-tabs button {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}

.segmented button[aria-selected="true"],
.segmented button.active,
.chat-mode-tabs button.active {
  background: var(--bg-surface);
  color: var(--purple-700);
  box-shadow: var(--shadow-sm);
}

.chat-thread, .chat-messages {
  flex: 1;
  min-height: 220px;
  max-height: 340px;
  overflow-y: auto;
  padding: 1rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.chat-bubble {
  max-width: 88%;
  padding: 0.65rem 0.9rem;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.chat-bubble.user {
  align-self: flex-end;
  background: var(--purple-600);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--bg-muted);
  border-bottom-left-radius: 4px;
}

.chat-citations { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.35rem; }

.chat-compose, .chat-form {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid var(--border);
}

.chat-compose textarea, .chat-form textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.9rem;
  font-family: inherit;
  font-size: 0.88rem;
  background: var(--bg-page);
}

.chat-compose textarea:focus, .chat-form textarea:focus {
  outline: none;
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.btn-send, .btn-primary.btn-sm {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--purple-600);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  border: none;
  background: var(--purple-600);
  color: #fff;
  font-family: inherit;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.btn-primary.full { width: 100%; }
.btn-primary:hover, .btn-send:hover { background: var(--purple-700); }

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--purple-700);
  font-family: inherit;
  font-weight: 600;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--purple-400);
  background: var(--purple-50);
}

.existing-docs-picker {
  margin-bottom: 0.5rem;
}

.existing-docs-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 240px;
  overflow-y: auto;
}

.existing-doc-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  cursor: pointer;
}

.existing-doc-row:has(input:checked) {
  border-color: var(--purple-500);
  background: var(--purple-50);
}

.existing-doc-row input {
  flex-shrink: 0;
}

.existing-doc-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.existing-doc-thumb-icon {
  display: grid;
  place-items: center;
  background: var(--bg-muted);
  font-size: 1rem;
}

.existing-doc-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.existing-doc-body strong {
  font-size: 0.84rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pending-uploads-list {
  list-style: none;
  margin: 0.35rem 0 0.85rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.pending-upload-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-sm);
  background: var(--bg-muted);
  font-size: 0.82rem;
}

.pending-upload-remove {
  padding: 0.15rem 0.35rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--purple-600);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.docs-list, .docs-gallery {
  max-height: min(520px, 60vh);
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.doc-tile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: inherit;
}

.doc-tile:hover { background: var(--purple-50); }

.doc-thumb-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-thumb-wrap img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb-icon { font-size: 1.25rem; }
.doc-tile-body { min-width: 0; flex: 1; }
.doc-tile-name { margin: 0; font-size: 0.82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-tile-meta { margin: 0.1rem 0 0; font-size: 0.72rem; color: var(--text-muted); }

.upload-drop, .upload-zone.friendly {
  margin: 0.5rem;
  padding: 1.25rem;
  border: 2px dashed var(--purple-400);
  border-radius: var(--radius-lg);
  background: var(--purple-50);
  text-align: center;
  cursor: pointer;
}

.upload-drop.hidden { display: none; }
.upload-drop p { margin: 0; font-size: 0.85rem; color: var(--purple-700); font-weight: 500; }

.upload-progress-track {
  height: 4px;
  margin: 0 0.75rem 0.75rem;
  background: var(--bg-muted);
  border-radius: 999px;
  overflow: hidden;
}

.upload-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--purple-600);
  transition: width 0.1s linear;
}

.modal, .doc-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.modal-scrim, .doc-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(30, 27, 46, 0.35);
  backdrop-filter: blur(4px);
}

.modal-sheet, .doc-modal-card {
  position: relative;
  width: min(720px, 100%);
  max-height: 85vh;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head, .doc-modal-head {
  display: flex;
  justify-content: space-between;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border);
}

.modal-head h3, .doc-modal-head h3 { margin: 0; font-size: 1rem; }
.modal-sub, .lead-muted { font-size: 0.78rem; color: var(--text-muted); margin: 0.2rem 0 0; }
.modal-body, .doc-modal-body { padding: 1rem 1.15rem; overflow: auto; }

.doc-viewer-image {
  width: 100%;
  max-height: 55vh;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
}

.doc-viewer-text {
  white-space: pre-wrap;
  font-family: ui-monospace, monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
}

.doc-image-strip { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.75rem; }
.doc-image-strip button { border: 2px solid transparent; border-radius: var(--radius-sm); padding: 0; cursor: pointer; background: none; }
.doc-image-strip button.active { border-color: var(--purple-600); }
.doc-image-strip img { width: 64px; height: 64px; object-fit: cover; display: block; }

.loading-inline { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.82rem; color: var(--text-muted); }

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--purple-600);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
}

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

.login-foot code {
  font-size: 0.78rem;
  background: var(--bg-muted);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.owner-nav-tabs .nav-tab.active {
  color: var(--purple-700);
  background: var(--purple-100);
}

.owner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.owner-form-body {
  padding: 1rem 1.15rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.owner-form-body textarea,
.owner-form-body .input,
.owner-form-body .select-clean {
  width: 100%;
}

.owner-form-body textarea {
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  resize: vertical;
}

.hint-inline {
  margin: 0;
  font-size: 0.78rem;
  color: var(--mint);
}

.owner-status-wrap {
  margin-left: auto;
}

.pill.owner-status.status-shared {
  background: #ecfdf5;
  color: #047857;
}

.pill.owner-status.status-pending {
  background: #fffbeb;
  color: #92400e;
}

.pill.owner-queue {
  background: #eff6ff;
  color: #1d4ed8;
}

.owner-history-body {
  padding: 1rem 1.15rem 1.15rem;
}

.owner-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.owner-history-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem;
  background: var(--bg-page);
}

.owner-history-item header {
  margin-bottom: 0.45rem;
  font-size: 0.82rem;
}

.owner-history-item p {
  margin: 0.35rem 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

.owner-history-photo {
  width: 100%;
  max-width: 220px;
  border-radius: var(--radius-md);
  display: block;
  margin-bottom: 0.35rem;
}

.owner-photo-preview img {
  width: 100%;
  max-width: 240px;
  border-radius: var(--radius-lg);
  display: block;
  margin-bottom: 0.5rem;
}

.shared-docs-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.shared-doc-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  font-size: 0.85rem;
}

.muted { color: var(--text-muted); }

.owner-panel.hidden { display: none; }

.owner-dashboard-layout {
  display: grid;
  grid-template-columns: 1fr min(300px, 32%);
  gap: 1.25rem;
  align-items: start;
}

.share-wizard {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.share-step-label {
  margin: 0 0 0.15rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--purple-600);
}

.share-step.hidden { display: none; }

.vet-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
}

.vet-picker-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-page);
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.vet-picker-card:hover {
  border-color: var(--purple-300);
  box-shadow: var(--shadow-sm);
}

.vet-picker-card.selected {
  border-color: var(--purple-600);
  background: var(--purple-50);
  box-shadow: var(--shadow-sm);
}

.vet-picker-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--bg-surface);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.vet-picker-body strong {
  display: block;
  font-size: 0.95rem;
}

.vet-picker-specialty {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.vet-picker-email {
  margin: 0.15rem 0 0;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.vet-picker-cta {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--purple-700);
  white-space: nowrap;
}

.selected-vet-banner {
  margin: 0 0 0.85rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--purple-50);
  border: 1px solid #ddd6fe;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.share-action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.share-action-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-page);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.share-action-card:hover {
  border-color: var(--purple-400);
  background: var(--purple-50);
}

.share-action-icon {
  font-size: 1.35rem;
}

.share-action-card strong {
  font-size: 0.92rem;
}

.share-action-card span:last-child {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

@media (max-width: 900px) {
  .owner-dashboard-layout { grid-template-columns: 1fr; }
}

.owner-vet-body {
  padding: 0.85rem 1rem 1rem;
}

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

.vet-team-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-lg);
  background: var(--bg-page);
  border: 1px solid var(--border);
}

.vet-team-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--purple-50);
  display: grid;
  place-items: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.vet-team-card strong {
  display: block;
  font-size: 0.88rem;
}

.vet-team-card p {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.owner-vet-banner {
  margin-bottom: 1rem;
}

.login-wrap-wide { width: min(520px, 100%); }

.demo-accounts {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.demo-accounts-title {
  margin: 0 0 0.75rem;
  font-size: 0.82rem;
  font-weight: 600;
}

.demo-accounts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.demo-accounts-col h3 {
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.demo-account-btn {
  display: block;
  width: 100%;
  text-align: left;
  margin-bottom: 0.35rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-page);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.demo-account-btn:hover {
  border-color: var(--purple-400);
  background: var(--purple-50);
}

@media (max-width: 540px) {
  .demo-accounts-grid { grid-template-columns: 1fr; }
}

.vet-profile-bar {
  margin-bottom: 1rem;
}

.vet-profile-card {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--purple-50);
  border: 1px solid #ddd6fe;
}

.vet-profile-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--bg-surface);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.vet-profile-card strong {
  display: block;
  font-size: 0.95rem;
}

.vet-profile-card p {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.surface-subtitle {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}

.records-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.owner-records-body {
  padding: 0.85rem 1rem 1rem;
}

.owner-records-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.owner-record-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-page);
}

.owner-record-thumb {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
}

.owner-record-thumb-icon {
  display: grid;
  place-items: center;
  background: var(--bg-muted);
  font-size: 1.25rem;
}

.owner-record-body {
  min-width: 0;
}

.owner-record-body strong {
  display: block;
  font-size: 0.84rem;
}

.owner-record-body p {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.owner-pet-card-meta-line {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.vet-finder-context {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--bg-muted);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.error-text { color: var(--rose); font-size: 0.85rem; }

body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% -10%, rgba(108, 92, 231, 0.12), transparent), var(--bg-page);
  padding: 2rem 1rem;
}

.login-wrap { width: min(400px, 100%); }

.login-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: 2rem;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.login-brand { text-align: center; margin-bottom: 1.75rem; }
.login-brand h1 { margin: 0.75rem 0 0.35rem; font-size: 1.45rem; font-weight: 700; }
.login-brand p { margin: 0; color: var(--text-secondary); font-size: 0.9rem; }

.login-form { display: flex; flex-direction: column; gap: 0.35rem; }
.field-label { font-size: 0.78rem; font-weight: 600; color: var(--text-secondary); margin-top: 0.5rem; }

.input, .login-card input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg-page);
}

.input:focus, .login-card input:focus {
  outline: none;
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.12);
}

.login-form .btn-primary { margin-top: 1rem; }

.auth-tabs {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 0.25rem;
  background: var(--surface-2, rgba(0, 0, 0, 0.04));
  border-radius: var(--radius-md, 10px);
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius-sm, 8px);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
}
.auth-tab.active {
  background: var(--surface, #fff);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.role-fieldset {
  border: none;
  margin: 0.75rem 0 0;
  padding: 0;
}
.role-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
  font-size: 0.92rem;
  color: var(--text-secondary);
}
.auth-hint {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.field-success {
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--success, #0d7a4f);
}
.btn-ghost {
  margin-top: 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm, 8px);
  padding: 0.65rem 1rem;
  cursor: pointer;
}

.onboarding-page .onboarding-card {
  text-align: left;
}
.onboarding-steps {
  margin: 0 0 1.25rem 1.1rem;
  padding: 0;
  color: var(--text-secondary);
  font-size: 0.92rem;
  line-height: 1.55;
}
.onboarding-steps li + li {
  margin-top: 0.65rem;
}
.auth-hint a {
  color: var(--purple-500, #6c5ce7);
  text-decoration: none;
}
.auth-hint a:hover {
  text-decoration: underline;
}

.auth-switch {
  margin: 1rem 0 0;
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-secondary);
}
.auth-switch a {
  color: var(--purple-500, #6c5ce7);
  font-weight: 600;
  text-decoration: none;
}
.auth-switch a:hover {
  text-decoration: underline;
}

.password-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.password-row .field-label {
  margin-top: 0;
}
.link-button {
  border: none;
  background: none;
  padding: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--purple-500, #6c5ce7);
  cursor: pointer;
  text-decoration: none;
}
.link-button:hover {
  text-decoration: underline;
}

.signup-choice {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.signup-path-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-page);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.signup-path-card:hover {
  border-color: var(--purple-400);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}
.signup-path-icon {
  font-size: 1.35rem;
  line-height: 1;
}
.signup-path-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.signup-path-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.field-error, .error { color: var(--rose); font-size: 0.82rem; }
.login-foot { text-align: center; font-size: 0.72rem; color: var(--text-muted); margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.landing-page .landing-card {
  padding: 2rem 1.75rem 1.75rem;
}
.landing-tagline {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 28rem;
}
.landing-section-label {
  margin: 1.5rem 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.landing-signin {
  margin-top: 1.25rem;
  text-align: center;
}

.species-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-muted);
  color: var(--text-secondary);
}

.species-badge.canine { background: #dbeafe; color: #1d4ed8; }
.species-badge.feline { background: #fae8ff; color: #7e22ce; }
