:root {
  --primary-color: #40734b;
  --secondary-color: #d8b9a3;
  --accent-color: #483433;
  --contrast-color: #ffffff;
  --ink: #241e1b;
  --muted: #6f625b;
  --surface: #fffaf6;
  --panel: #ffffff;
  --line: #e9ddd4;
  --success: #2f7d4f;
  --warning: #a86918;
  --danger: #a33c32;
  --shadow: 0 18px 45px rgba(72, 52, 51, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(120deg, rgba(216, 185, 163, 0.28), transparent 36%),
    linear-gradient(180deg, #fffdf9 0%, #f7efe7 100%);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.5;
}

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

a {
  color: var(--primary-color);
}

img {
  display: block;
  max-width: 100%;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem clamp(1rem, 4vw, 3rem);
  background: rgba(255, 250, 246, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  color: var(--accent-color);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--primary-color);
  color: var(--contrast-color);
  font-weight: 700;
}

.brand small {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
}

.site-nav a,
.footer-links a {
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  color: var(--accent-color);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a.active,
.footer-links a:hover {
  background: rgba(64, 115, 75, 0.12);
}

.nav-toggle {
  display: none;
}

.auth-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

.button,
button {
  min-height: 42px;
  padding: 0.7rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--primary-color);
  color: var(--contrast-color);
  cursor: pointer;
  text-decoration: none;
}

.button.secondary,
button.secondary {
  background: var(--secondary-color);
  color: var(--accent-color);
}

.button.ghost,
button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--accent-color);
}

.button.danger,
button.danger {
  background: var(--danger);
}

main {
  min-height: 72vh;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(300px, 0.9fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: center;
  min-height: 68vh;
  padding: clamp(2rem, 7vw, 5rem) clamp(1rem, 5vw, 5rem);
  border-bottom: 1px solid var(--line);
}

.hero h1 {
  max-width: 820px;
  margin: 0;
  color: var(--accent-color);
  font-size: clamp(2.4rem, 7vw, 6rem);
  line-height: 0.98;
}

.hero p {
  max-width: 650px;
  color: var(--muted);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
}

.hero-actions,
.toolbar-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.hero-photo {
  min-height: 430px;
  border-radius: 8px;
  background:
    linear-gradient(rgba(36, 30, 27, 0.06), rgba(36, 30, 27, 0.2)),
    var(--hero-image, url("https://images.unsplash.com/photo-1548199973-03cce0bbc87b?auto=format&fit=crop&w=1200&q=80")) center/cover;
  box-shadow: var(--shadow);
}

.section,
.dashboard,
.page {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3rem) 0;
}

.section-header,
.page-header {
  display: flex;
  gap: 1rem;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.section-header h2,
.page-header h1 {
  margin: 0;
  color: var(--accent-color);
  font-size: clamp(1.7rem, 4vw, 3rem);
}

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

.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field label {
  color: var(--accent-color);
  font-size: 0.85rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.pet-grid,
.org-grid,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.pet-list {
  display: grid;
  gap: 0.85rem;
}

.pet-card,
.org-card,
.panel,
.stat-card {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(72, 52, 51, 0.08);
}

.pet-card.list {
  display: grid;
  grid-template-columns: 180px 1fr auto;
  align-items: stretch;
}

.pet-photo,
.org-banner,
.detail-photo {
  background: #eadfd6 center/cover;
}

.pet-photo {
  aspect-ratio: 4 / 3;
}

.pet-card.list .pet-photo {
  aspect-ratio: auto;
  min-height: 160px;
}

.pet-body,
.org-body,
.panel-body,
.stat-card {
  padding: 1rem;
}

.pet-body h3,
.org-body h3,
.panel h2,
.panel h3 {
  margin-top: 0;
  color: var(--accent-color);
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(64, 115, 75, 0.12);
  color: var(--primary-color);
  font-size: 0.82rem;
  font-weight: 700;
}

.badge.warning {
  background: rgba(168, 105, 24, 0.12);
  color: var(--warning);
}

.badge.danger {
  background: rgba(163, 60, 50, 0.12);
  color: var(--danger);
}

.empty-state {
  padding: 2rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.detail-layout,
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 1rem;
}

.detail-photo {
  min-height: 420px;
  border-radius: 8px;
}

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

.fact {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 250, 246, 0.7);
}

.fact strong {
  display: block;
  color: var(--accent-color);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tabs button.active {
  background: var(--accent-color);
}

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

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

th,
td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--accent-color);
}

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

.field.full,
.form-actions,
.panel.full {
  grid-column: 1 / -1;
}

.site-footer {
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 2rem clamp(1rem, 5vw, 5rem);
  background: var(--accent-color);
  color: var(--contrast-color);
}

.site-footer a {
  color: var(--contrast-color);
}

.site-footer p {
  margin: 0.25rem 0 0;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.loading {
  padding: 4rem 1rem;
  text-align: center;
}

@media (max-width: 920px) {
  .site-header {
    grid-template-columns: 1fr auto;
  }

  .nav-toggle {
    display: inline-flex;
    justify-content: center;
  }

  .site-nav,
  .auth-actions {
    display: none;
    grid-column: 1 / -1;
    justify-content: start;
  }

  .site-nav.open,
  .auth-actions.open {
    display: flex;
  }

  .hero,
  .detail-layout,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pet-card.list {
    grid-template-columns: 130px 1fr;
  }
}

@media (max-width: 620px) {
  .filters,
  .form-grid,
  .facts {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
  }

  .hero-photo {
    min-height: 300px;
  }

  .section-header,
  .page-header,
  .site-footer {
    align-items: start;
    flex-direction: column;
  }

  .pet-card.list {
    grid-template-columns: 1fr;
  }
}
