* {
  box-sizing: border-box;
}

:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  --radius: 18px;
  --blue: #2563eb;
  --green: #16a34a;
  --amber: #f59e0b;
  --dark: #0f172a;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(37,99,235,0.08), transparent 280px),
    radial-gradient(circle at top right, rgba(22,163,74,0.06), transparent 260px),
    var(--bg);
  color: var(--text);
}

a {
  text-decoration: none;
  color: inherit;
}

.container {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
}

.page {
  padding: 1.5rem 0 2.5rem;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(10px);
  background: rgba(255,255,255,0.88);
  border-bottom: 1px solid rgba(226,232,240,0.9);
}

.nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

.brand a {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.nav a {
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  color: var(--muted);
}

.nav a:hover {
  background: var(--panel-soft);
  color: var(--text);
}

.center-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.card {
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(226,232,240,0.9);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.hero-card,
.chart-card,
.stat-card,
.animal-card {
  overflow: hidden;
}

.narrow {
  width: min(460px, 100%);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
  color: #ffffff;
  padding: 0.85rem 1.05rem;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  margin-top: 0.5rem;
  font-weight: 700;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.button:hover {
  transform: translateY(-1px);
  opacity: 0.96;
}

.button.secondary {
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
}

.small-button {
  padding: 0.65rem 0.9rem;
  font-size: 0.92rem;
}

.alert {
  padding: 0.85rem 1rem;
  border-radius: 14px;
  margin: 0.85rem 0;
  border: 1px solid transparent;
}

.alert.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.alert.success {
  background: #ecfdf5;
  color: #166534;
  border-color: #bbf7d0;
}

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

.small-text {
  font-size: 0.92rem;
}

.eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--blue);
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

.page-title {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.page-subtitle {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 1rem;
}

.layout-two {
  display: grid;
  grid-template-columns: 370px 1fr;
  gap: 1rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.form {
  display: grid;
  gap: 0.65rem;
}

.form label {
  font-size: 0.94rem;
  font-weight: 700;
}

.form input,
.form select,
.form textarea,
.form button {
  width: 100%;
}

input,
select,
textarea {
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  color: var(--text);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37,99,235,0.6);
  box-shadow: 0 0 0 4px rgba(37,99,235,0.10);
}

textarea {
  resize: vertical;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.stat-big {
  font-size: 2.2rem;
  font-weight: 800;
  margin-top: 0.4rem;
  letter-spacing: -0.04em;
}

.stat-label {
  margin-top: 0.55rem;
  font-weight: 700;
}

.animal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 1rem;
}

.animal-card h2,
.card h2 {
  margin-top: 0;
  margin-bottom: 0.35rem;
}

.animal-top,
.source-row,
.entry-row,
.section-head,
.hero-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.metric-block {
  margin-top: 1rem;
  padding: 0.95rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(248,250,252,1) 0%, rgba(241,245,249,1) 100%);
  border: 1px solid var(--border);
}

.metric-label {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
}

.metric-value {
  margin-top: 0.3rem;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.hero-notes,
.animal-notes,
.entry-note {
  margin-top: 0.75rem;
  line-height: 1.5;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: var(--dark);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
}

.pill.soft {
  background: var(--panel-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.legend-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 1rem;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.92rem;
  color: var(--muted);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  display: inline-block;
}

.legend-dot.blue {
  background: var(--blue);
}

.legend-dot.green {
  background: var(--green);
}

.legend-dot.amber {
  background: var(--amber);
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 390px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 0.9rem 0.55rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

thead th {
  color: var(--muted);
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.entry-list {
  display: grid;
  gap: 0.8rem;
}

.entry-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.95rem;
  background: linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(248,250,252,1) 100%);
}

.source-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: capitalize;
}

.source-badge.vet {
  background: rgba(37,99,235,0.12);
  color: var(--blue);
}

.source-badge.home {
  background: rgba(22,163,74,0.12);
  color: var(--green);
}

.source-badge.predicted {
  background: rgba(245,158,11,0.14);
  color: #b45309;
}

.source-badge.- {
  background: var(--panel-soft);
  color: var(--muted);
}

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

  .stat-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 800px) {
  .nav-wrap {
    align-items: flex-start;
    flex-direction: column;
  }

  .chart-wrap {
    height: 300px;
  }

  .container {
    width: min(100% - 1rem, 1180px);
  }

  .page {
    padding-top: 1rem;
  }

  .card {
    padding: 1rem;
  }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr;
  gap: 1rem;
}

.inner-card {
  box-shadow: none;
  background: linear-gradient(180deg, rgba(255,255,255,1) 0%, rgba(248,250,252,1) 100%);
}

.layout-two-wide {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 1rem;
}

@media (max-width: 1100px) {
  .dashboard-grid,
  .layout-two-wide {
    grid-template-columns: 1fr;
  }
}

.action-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.print-page {
  background: #e5e7eb;
}

.print-container {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.print-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.print-sheet {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.print-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1rem;
}

.print-meta {
  color: var(--muted);
  font-size: 0.95rem;
  display: grid;
  gap: 0.35rem;
}

.print-block {
  margin-top: 1.25rem;
}

.print-highlight {
  display: grid;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
}

@media print {
  body {
    background: #ffffff;
  }

  .no-print,
  .site-header {
    display: none !important;
  }

  .print-container {
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .print-sheet {
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
  }

  .print-block,
  table,
  tr,
  td,
  th {
    page-break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}

.profile-facts {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.status-green { background: #dcfce7; padding:10px; border-radius:8px; }
.status-amber { background: #fef3c7; padding:10px; border-radius:8px; }
.status-red { background: #fee2e2; padding:10px; border-radius:8px; }

.profile-photo-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}

.profile-photo-large {
  width: 100%;
  max-width: 420px;
  height: 320px;
  object-fit: cover;
  object-position: center;
  border-radius: 18px;
  display: block;
  background: #f8fafc;
  border: 1px solid var(--border);
}

@media (max-width: 800px) {
  .profile-photo-large {
    max-width: 100%;
    height: 240px;
  }

  .profile-photo-panel {
    min-height: 240px;
  }
}

.profile-head-large {
  display: grid;
  grid-template-columns: minmax(260px, 420px) 1fr;
  gap: 1rem;
  align-items: start;
}

.profile-photo-shell {
  width: 100%;
  max-width: 420px;
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #f8fafc;
}

.profile-photo-large {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}

.profile-photo-fallback-shell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-photo-fallback-shell .animal-avatar.large {
  width: 120px;
  height: 120px;
}

@media (max-width: 900px) {
  .profile-head-large {
    grid-template-columns: 1fr;
  }

  .profile-photo-shell {
    max-width: 100%;
  }
}

.animal-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  border: 2px solid rgba(226,232,240,0.95);
  background: #ffffff;
  flex-shrink: 0;
}

.animal-avatar.large {
  width: 120px;
  height: 120px;
}

.print-header-left .animal-avatar.large {
  width: 84px;
  height: 84px;
}

.print-sheet img {
  max-width: 100%;
  height: auto;
}

@media print {
  .print-header-left .animal-avatar.large {
    width: 72px;
    height: 72px;
  }

  .print-sheet img {
    max-width: 72px !important;
    max-height: 72px !important;
    width: 72px !important;
    height: 72px !important;
    object-fit: cover !important;
    object-position: center !important;
    border-radius: 50% !important;
  }
}

.print-header-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.print-header-left .animal-avatar.large,
.print-header-left .animal-avatar-fallback.large {
  width: 84px;
  height: 84px;
}

.print-header-left {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}

.print-header-left .animal-avatar.large,
.print-header-left .animal-avatar-fallback.large {
  width: 84px;
  height: 84px;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-search-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.header-search-input {
  min-width: 280px;
  max-width: 420px;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  color: var(--text);
}

.search-summary {
  margin-bottom: 1rem;
}

.search-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

@media (max-width: 900px) {
  .header-tools {
    width: 100%;
    align-items: stretch;
    justify-content: flex-start;
  }

  .header-search-form {
    width: 100%;
  }

  .header-search-input {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-search-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.header-search-input {
  min-width: 280px;
  max-width: 420px;
  padding: 0.8rem 0.95rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #ffffff;
  color: var(--text);
}

@media (max-width: 900px) {
  .header-tools {
    width: 100%;
    align-items: stretch;
    justify-content: flex-start;
  }

  .header-search-form {
    width: 100%;
  }

  .header-search-input {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }
}

.dashboard-hero {
  display: grid;
  grid-template-columns: 1.35fr 0.9fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dashboard-hero-copy,
.dashboard-hero-side {
  min-height: 100%;
}

.dashboard-hero-copy {
  padding: 1.4rem 1.2rem;
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(37,99,235,0.10), rgba(22,163,74,0.06)),
    rgba(255,255,255,0.92);
  border: 1px solid rgba(226,232,240,0.9);
  box-shadow: var(--shadow);
}

.dashboard-hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.dashboard-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.mini-stat {
  padding: 1rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(248,250,252,1) 0%, rgba(241,245,249,1) 100%);
  border: 1px solid var(--border);
}

.mini-stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.mini-stat-value {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.55rem;
  line-height: 1;
  letter-spacing: -0.03em;
}

.dashboard-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.dashboard-stat-card {
  min-height: 160px;
}

.dashboard-stat-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dashboard-stat-title {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 700;
}

.dashboard-stat-value {
  margin-top: 0.75rem;
  font-size: clamp(2rem, 4vw, 2.6rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 800;
}

.dashboard-main-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.82fr;
  gap: 1rem;
}

.dashboard-section-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

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

.dashboard-animal-card {
  padding: 1rem;
}

.dashboard-animal-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.dashboard-animal-identity h3 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}

.dashboard-animal-identity p {
  margin: 0.12rem 0;
}

.dashboard-animal-metrics {
  display: grid;
  gap: 0.85rem;
}

.dashboard-metric-box {
  padding: 0.95rem;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(248,250,252,1) 0%, rgba(241,245,249,1) 100%);
  border: 1px solid var(--border);
}

.dashboard-metric-label {
  display: block;
  font-size: 0.86rem;
  color: var(--muted);
}

.dashboard-metric-value {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.dashboard-metric-stack {
  display: grid;
  gap: 0.6rem;
}

.dashboard-inline-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.dashboard-small-strong {
  font-size: 0.95rem;
}

.dashboard-side-card {
  position: relative;
}

@media (max-width: 1180px) {
  .dashboard-hero,
  .dashboard-main-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .dashboard-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-animal-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .dashboard-stats-grid,
  .dashboard-mini-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-hero-copy {
    padding: 1.1rem 1rem;
  }

  .dashboard-animal-top {
    flex-direction: column;
    align-items: stretch;
  }
}

.sms-stats-grid {
  margin-bottom: 1rem;
}

.sms-message-cell {
  max-width: 460px;
  white-space: pre-wrap;
  word-break: break-word;
}

.sms-provider-id {
  font-family: monospace;
  font-size: 0.85rem;
  word-break: break-all;
}

.source-badge.delivered {
  background: rgba(22,163,74,0.12);
  color: #15803d;
}

.source-badge.queued,
.source-badge.accepted,
.source-badge.buffered {
  background: rgba(37,99,235,0.12);
  color: #1d4ed8;
}

.source-badge.failed,
.source-badge.rejected,
.source-badge.expired,
.source-badge.unknown {
  background: rgba(239,68,68,0.12);
  color: #b91c1c;
}

.clinical-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1rem;
  max-width: 1500px;
  margin: 0 auto;
  padding: 1rem;
}

.clinical-sidebar {
  position: sticky;
  top: 92px;
  align-self: start;
}

.clinical-photo-card {
  background: #ffffff;
  border: 1px solid rgba(148,163,184,0.2);
  border-radius: 24px;
  padding: 1rem;
  box-shadow: 0 18px 40px rgba(15,23,42,0.08);
}

.clinical-photo {
  width: 100%;
  height: 260px;
  object-fit: cover;
  border-radius: 20px;
  border: 1px solid rgba(148,163,184,0.16);
}

.clinical-photo-fallback {
  width: 100%;
  height: 260px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: rgba(37,99,235,0.1);
  color: #1d4ed8;
  font-size: 5rem;
  font-weight: 800;
}

.clinical-side-facts {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.clinical-side-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid rgba(148,163,184,0.16);
}

.clinical-side-facts span {
  color: #64748b;
}

.clinical-actions {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.clinical-main {
  min-width: 0;
}

.clinical-topbar {
  background:
    linear-gradient(135deg, rgba(37,99,235,0.12), rgba(16,185,129,0.06)),
    #ffffff;
  border: 1px solid rgba(148,163,184,0.16);
  border-radius: 24px;
  padding: 1.2rem;
  margin-bottom: 0.8rem;
  box-shadow: 0 18px 40px rgba(15,23,42,0.06);
}

.clinical-topbar h2 {
  margin: 0.3rem 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  letter-spacing: -0.05em;
}

.clinical-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.6rem;
  border-radius: 18px;
  background: #ffffff;
  border: 1px solid rgba(148,163,184,0.16);
  margin-bottom: 1rem;
  position: sticky;
  top: 82px;
  z-index: 20;
}

.clinical-tabs a {
  white-space: nowrap;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  text-decoration: none;
  color: #64748b;
  font-weight: 700;
}

.clinical-tabs a.active {
  background: #2563eb;
  color: #ffffff;
}

.clinical-panel {
  display: none;
}

.clinical-grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

.weight-entry-card {
  display: grid;
  gap: 0.7rem;
}

.weight-entry-side {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.weight-delta-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.32rem 0.72rem;
  border-radius: 999px;
  font-size: 0.83rem;
  font-weight: 700;
}

.weight-delta-badge.up {
  background: rgba(22,163,74,0.12);
  color: #15803d;
}

.weight-delta-badge.down {
  background: rgba(239,68,68,0.12);
  color: #b91c1c;
}

.weight-delta-badge.neutral {
  background: rgba(148,163,184,0.12);
  color: #475569;
}

@media (max-width: 1100px) {
  .clinical-shell {
    grid-template-columns: 1fr;
  }

  .clinical-sidebar {
    position: static;
  }

  .clinical-photo {
    height: 220px;
  }

  .clinical-grid-2 {
    grid-template-columns: 1fr;
  }
}


body {
  background:
    radial-gradient(circle at top left, rgba(37,99,235,0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(20,184,166,0.15), transparent 24%),
    linear-gradient(135deg, #eef6ff 0%, #f8fafc 45%, #ecfdf5 100%);
}

.enhanced-clinical {
  grid-template-columns: 320px minmax(0, 1fr);
  grid-template-areas:
    "tabs tabs"
    "side main";
}

.patient-tabs-wrap {
  grid-area: tabs;
  position: sticky;
  top: 78px;
  z-index: 30;
  padding: 0.35rem 0;
}

.patient-tabs {
  display: flex;
  gap: 0.65rem;
  overflow-x: auto;
  padding: 0.75rem;
  border-radius: 22px;
  background: rgba(255,255,255,0.84);
  border: 1px solid rgba(148,163,184,0.22);
  box-shadow: 0 18px 40px rgba(15,23,42,0.08);
  backdrop-filter: blur(18px);
}

.patient-tab {
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: 18px;
  text-decoration: none;
  color: #0f172a;
  border: 1px solid rgba(148,163,184,0.16);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.patient-tab.active {
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb 0%, #0f766e 100%);
  border-color: transparent;
}

.patient-tab img,
.patient-tab-fallback {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: rgba(37,99,235,0.12);
  color: #1d4ed8;
  font-weight: 800;
}

.patient-tab.active .patient-tab-fallback {
  background: rgba(255,255,255,0.18);
  color: #ffffff;
}

.patient-tab span {
  display: grid;
}

.patient-tab small {
  opacity: 0.78;
  text-transform: capitalize;
}

.clinical-sidebar {
  grid-area: side;
}

.clinical-main {
  grid-area: main;
}

.colour-card {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.96) 0%, rgba(248,250,252,0.94) 100%);
  border: 1px solid rgba(148,163,184,0.18);
  box-shadow: 0 20px 42px rgba(15,23,42,0.08);
}

.colour-hero {
  background:
    linear-gradient(135deg, rgba(37,99,235,0.18), rgba(20,184,166,0.10)),
    linear-gradient(180deg, rgba(255,255,255,0.96), rgba(248,250,252,0.96));
  border: 1px solid rgba(148,163,184,0.18);
}

.clinical-tabs {
  background: rgba(15,23,42,0.88);
  border-color: rgba(255,255,255,0.10);
}

.clinical-tabs a {
  color: rgba(255,255,255,0.72);
}

.clinical-tabs a.active {
  background: linear-gradient(135deg, #2563eb 0%, #14b8a6 100%);
  color: #ffffff;
}

.chart-wrap {
  height: 340px;
  background: #ffffff;
}

.compact-table {
  max-height: 420px;
  overflow: auto;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 0.35rem;
}

.legend-dot.blue {
  background: #2563eb;
}

.legend-dot.green {
  background: #16a34a;
}

.legend-dot.amber {
  background: #f59e0b;
}

@media (max-width: 1100px) {
  .enhanced-clinical {
    grid-template-columns: 1fr;
    grid-template-areas:
      "tabs"
      "side"
      "main";
  }

  .patient-tabs-wrap {
    top: 72px;
  }
}

@media (max-width: 700px) {
  .patient-tab {
    min-width: 150px;
  }

  .chart-wrap {
    height: 280px;
  }
}


/* Windows XP inspired clinical theme */
body {
  background:
    linear-gradient(180deg, #5ba7ff 0%, #8fc8ff 34%, #d7ecff 70%, #f4fbff 100%);
  color: #111827;
}

.site-header {
  background: linear-gradient(180deg, #2f7df6 0%, #1557c9 100%);
  border-bottom: 3px solid #0b3f9f;
  box-shadow: 0 4px 14px rgba(0,0,0,0.18);
}

.brand a,
.nav a {
  color: #ffffff;
}

.nav a {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
}

.nav a:hover {
  background: rgba(255,255,255,0.25);
}

.card,
.colour-card,
.clinical-photo-card,
.clinical-topbar {
  background: linear-gradient(180deg, #ffffff 0%, #f0f6ff 100%);
  border: 2px solid #7aa7e8;
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.9),
    0 6px 18px rgba(20, 60, 120, 0.18);
}

.card h2,
.clinical-topbar h2 {
  color: #0b3f9f;
}

.clinical-tabs {
  background: linear-gradient(180deg, #2f7df6 0%, #1557c9 100%);
  border: 2px solid #0b3f9f;
  border-radius: 12px;
}

.clinical-tabs a {
  background: linear-gradient(180deg, #eef6ff 0%, #c8ddff 100%);
  color: #0b3f9f;
  border: 1px solid #7aa7e8;
  box-shadow: inset 0 1px 0 #ffffff;
}

.clinical-tabs a.active {
  background: linear-gradient(180deg, #fff7c2 0%, #ffbf3f 100%);
  color: #3b2600;
  border-color: #d97706;
}

.patient-tabs {
  background: linear-gradient(180deg, #d9ecff 0%, #9dc7ff 100%);
  border: 2px solid #3b82f6;
  border-radius: 12px;
}

.patient-tab {
  background: linear-gradient(180deg, #ffffff 0%, #dbeafe 100%);
  border: 2px solid #7aa7e8;
  border-radius: 10px;
}

.patient-tab.active {
  background: linear-gradient(180deg, #3b82f6 0%, #1557c9 100%);
  color: #ffffff;
  border-color: #08378f;
}

.button {
  background: linear-gradient(180deg, #5ee35e 0%, #159215 100%);
  border: 2px solid #087408;
  border-radius: 10px;
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.7),
    0 3px 8px rgba(0,0,0,0.18);
}

.button.secondary {
  background: linear-gradient(180deg, #ffffff 0%, #dbeafe 100%);
  color: #0b3f9f;
  border: 2px solid #7aa7e8;
}

input,
select,
textarea {
  background: #ffffff;
  border: 2px solid #7aa7e8;
  border-radius: 8px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245,158,11,0.25);
}

.status-green {
  background: linear-gradient(180deg, #dcfce7 0%, #86efac 100%);
  border: 2px solid #16a34a;
}

.status-amber {
  background: linear-gradient(180deg, #fef9c3 0%, #facc15 100%);
  border: 2px solid #ca8a04;
}

.status-red {
  background: linear-gradient(180deg, #fee2e2 0%, #fca5a5 100%);
  border: 2px solid #dc2626;
}

.entry-card {
  background: linear-gradient(180deg, #ffffff 0%, #eef6ff 100%);
  border: 1px solid #9dbff2;
  border-radius: 10px;
}

.table-wrap {
  border: 2px solid #7aa7e8;
  border-radius: 10px;
}

thead th {
  background: linear-gradient(180deg, #2f7df6 0%, #1557c9 100%);
  color: #ffffff;
}

tr:nth-child(even) td {
  background: #eef6ff;
}

.pill,
.source-badge,
.weight-delta-badge {
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.12);
}


/* Cleaner patient tabs and sticky layout fix */
.patient-tabs-wrap {
  top: 78px;
  padding: 0.45rem 0 0.35rem;
  background: linear-gradient(180deg, rgba(91,167,255,0.96), rgba(143,200,255,0.88));
  border-radius: 0 0 14px 14px;
}

.patient-tabs {
  scrollbar-width: thin;
  scrollbar-color: #2f7df6 #dbeafe;
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

.patient-tabs::-webkit-scrollbar {
  height: 8px;
}

.patient-tabs::-webkit-scrollbar-track {
  background: #dbeafe;
  border-radius: 999px;
}

.patient-tabs::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, #2f7df6, #1557c9);
  border-radius: 999px;
}

.patient-tab {
  flex: 0 0 auto;
}

.clinical-tabs {
  position: sticky;
  top: 175px;
  z-index: 25;
}

.clinical-sidebar {
  top: 175px;
}

.cage-mate-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin: 0.75rem 0;
  padding: 0.7rem;
  border-radius: 10px;
  background: linear-gradient(180deg, #fff7c2 0%, #ffdf75 100%);
  border: 2px solid #d97706;
  color: #3b2600;
}

.cage-mate-box a {
  display: inline-flex;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  background: #ffffff;
  color: #0b3f9f;
  border: 1px solid #7aa7e8;
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 1100px) {
  .clinical-tabs {
    top: 155px;
  }

  .clinical-sidebar {
    top: auto;
  }
}

@media (max-width: 700px) {
  .patient-tabs-wrap {
    top: 70px;
  }

  .clinical-tabs {
    top: 150px;
  }
}


.animal-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.75rem 0;
}

.xp-flag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.3rem 0.65rem;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 800;
  border: 1px solid rgba(0,0,0,0.2);
}

.xp-flag.green {
  background: linear-gradient(180deg, #dcfce7, #86efac);
  color: #14532d;
}

.xp-flag.blue {
  background: linear-gradient(180deg, #dbeafe, #93c5fd);
  color: #0b3f9f;
}

.xp-flag.purple {
  background: linear-gradient(180deg, #ede9fe, #c4b5fd);
  color: #4c1d95;
}

.xp-flag.amber {
  background: linear-gradient(180deg, #fef9c3, #fde68a);
  color: #78350f;
}

.mini-form {
  margin-top: 0.8rem;
  padding: 0.75rem;
  border-radius: 10px;
  background: rgba(219,234,254,0.6);
  border: 1px solid #7aa7e8;
}

/* Mobile and tablet clinical layout fixes */
@media (max-width: 900px) {
  .clinical-shell.enhanced-clinical {
    display: block;
    padding: 0.5rem;
  }

  .patient-tabs-wrap {
    position: sticky;
    top: 64px;
    z-index: 50;
    margin-bottom: 0.5rem;
  }

  .patient-tabs {
    padding: 0.45rem;
    gap: 0.45rem;
  }

  .patient-tab {
    min-width: 135px;
    padding: 0.45rem;
  }

  .patient-tab img,
  .patient-tab-fallback {
    width: 38px;
    height: 38px;
  }

  .patient-tab strong {
    font-size: 0.9rem;
  }

  .patient-tab small {
    font-size: 0.75rem;
  }

  .clinical-sidebar {
    position: static;
    margin-bottom: 0.75rem;
  }

  .clinical-photo-card {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 0.75rem;
    align-items: start;
  }

  .clinical-photo,
  .clinical-photo-fallback {
    width: 110px;
    height: 110px;
    font-size: 2.4rem;
  }

  .clinical-photo-card h1 {
    margin-top: 0;
    font-size: 1.55rem;
  }

  .clinical-side-facts,
  .clinical-actions,
  .animal-flags,
  .cage-mate-box {
    grid-column: 1 / -1;
  }

  .clinical-topbar {
    padding: 0.9rem;
  }

  .clinical-topbar h2 {
    font-size: 1.7rem;
  }

  .clinical-tabs {
    position: sticky;
    top: 132px;
    z-index: 45;
    overflow-x: auto;
    padding: 0.45rem;
    gap: 0.4rem;
  }

  .clinical-tabs a {
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
  }

  .clinical-grid-2 {
    grid-template-columns: 1fr !important;
  }

  .chart-wrap {
    height: 260px;
  }

  .entry-row {
    align-items: flex-start;
  }

  .weight-entry-side {
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  .clinical-photo-card {
    grid-template-columns: 82px minmax(0, 1fr);
  }

  .clinical-photo,
  .clinical-photo-fallback {
    width: 82px;
    height: 82px;
    border-radius: 14px;
  }

  .clinical-side-facts > div {
    display: grid;
    gap: 0.2rem;
  }

  .clinical-actions .button,
  .clinical-actions .button.secondary {
    width: 100%;
  }

  .patient-tab {
    min-width: 118px;
  }

  .patient-tab small {
    display: none;
  }

  .clinical-tabs {
    top: 120px;
  }

  .table-wrap {
    font-size: 0.85rem;
  }

  th,
  td {
    padding: 0.55rem;
  }
}


.reports-page .report-filter-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 0.9rem;
}

.report-section-card {
  margin-top: 1rem;
}

.report-section-card h2 {
  color: #0b3f9f;
}

@media (max-width: 800px) {
  .reports-page .report-filter-form {
    grid-template-columns: 1fr;
  }
}


.report-export-actions {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.report-export-actions .button {
  width: auto;
}

@media (max-width: 700px) {
  .report-export-actions .button {
    width: 100%;
  }
}


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

.chart-panel {
  background: linear-gradient(180deg, #ffffff 0%, #eef6ff 100%);
  border: 2px solid #7aa7e8;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 8px 18px rgba(20, 60, 120, 0.12);
}

.chart-panel h3 {
  margin-top: 0;
  color: #0b3f9f;
}

.report-chart-wrap {
  height: 320px;
}

@media (max-width: 900px) {
  .reports-chart-grid {
    grid-template-columns: 1fr;
  }

  .report-chart-wrap {
    height: 280px;
  }
}


.animal-browser-tabs {
  position: sticky;
  top: 78px;
  z-index: 35;
  padding: 0.35rem 0.75rem;
  background: linear-gradient(180deg, #1d4ed8 0%, #2563eb 100%);
  border-bottom: 2px solid #0b3f9f;
  box-shadow: 0 5px 14px rgba(0,0,0,0.18);
}

.animal-browser-tabs-inner {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  max-width: 1500px;
  margin: 0 auto;
}

.animal-browser-tab-list {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  flex: 1;
  padding-bottom: 0.1rem;
}

.animal-browser-tab {
  display: flex;
  align-items: center;
  min-width: 160px;
  max-width: 230px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, #eaf4ff 0%, #bcd7ff 100%);
  border: 2px solid #7aa7e8;
  border-bottom-color: #0b3f9f;
  box-shadow: inset 0 1px 0 #ffffff;
}

.animal-browser-tab.active {
  background: linear-gradient(180deg, #fff7c2 0%, #ffbf3f 100%);
  border-color: #d97706;
}

.animal-browser-tab a {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.42rem 0.55rem;
  text-decoration: none;
  color: #0b3f9f;
}

.animal-browser-tab img,
.animal-browser-tab span {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 7px;
  object-fit: cover;
  display: grid;
  place-items: center;
  background: #ffffff;
  color: #0b3f9f;
  font-weight: 800;
}

.animal-browser-tab strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.9rem;
}

.animal-browser-tab button {
  width: 28px;
  height: 28px;
  margin-right: 0.25rem;
  border: 1px solid #9b1c1c;
  border-radius: 7px;
  background: linear-gradient(180deg, #fecaca 0%, #ef4444 100%);
  color: #ffffff;
  font-weight: 900;
  cursor: pointer;
}

.animal-browser-clear {
  flex: 0 0 auto;
  border: 2px solid #7aa7e8;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff 0%, #dbeafe 100%);
  color: #0b3f9f;
  font-weight: 800;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}

@media (max-width: 800px) {
  .animal-browser-tabs {
    top: 64px;
    padding: 0.3rem;
  }

  .animal-browser-tab {
    min-width: 135px;
  }

  .animal-browser-clear {
    display: none;
  }
}

