* {
  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;
}
