:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0a0d12;
  color: #eef2f7;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top, #182131 0, #0a0d12 52rem); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.app-shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 52px 0 80px; }
.hero { display: flex; align-items: start; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { display: block; margin: 0 0 8px; font-size: .72rem; font-weight: 800; letter-spacing: .16em; color: #8fb7ff; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 12px; font-size: clamp(2.1rem, 6vw, 4rem); line-height: 1; }
h2 { margin-bottom: 6px; }
h3 { margin-bottom: 8px; }
.subtitle, .muted { color: #aeb8c7; }
.subtitle { max-width: 620px; font-size: 1.1rem; }

.card { padding: 24px; border: 1px solid #2b3442; border-radius: 18px; background: rgba(18, 24, 34, .95); box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.auth-card { max-width: 520px; }
.toolbar, .ranch-header, .section-heading { display: flex; justify-content: space-between; align-items: start; gap: 18px; }
.toolbar, .ranch-header { margin-bottom: 18px; }
.form-card { margin-bottom: 18px; }

.tabs { display: flex; gap: 8px; margin-bottom: 24px; }
.tab, .secondary, .icon-button, .text-button { border: 1px solid #39465a; border-radius: 10px; padding: 10px 14px; background: #151c27; cursor: pointer; }
.tab.active { border-color: #6ea1ff; color: white; background: #223454; }
.text-button { border: 0; padding: 0; background: transparent; color: #9fc1ff; }
.icon-button { padding: 3px 10px; font-size: 1.4rem; line-height: 1; }

form { display: grid; gap: 12px; }
label { display: block; margin: 6px 0 7px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #39465a; border-radius: 10px; padding: 12px 14px; background: #0d131d; color: white; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #6ea1ff; outline-offset: 2px; }

.primary { margin-top: 8px; border: 0; border-radius: 10px; padding: 13px 16px; background: #4f86ed; color: white; font-weight: 800; cursor: pointer; }
.primary.compact { margin-top: 0; padding: 10px 14px; }
button:disabled { opacity: .55; cursor: wait; }

.message { min-height: 1.4rem; margin: 10px 0 0; color: #ffbd74; }
.message.error { color: #ff8787; }
.hidden { display: none !important; }

.form-grid { display: grid; gap: 14px; }
.two-column { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three-column { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-full { grid-column: 1 / -1; }

.ranch-grid, .animal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 16px; }
.ranch-card { text-align: left; cursor: pointer; color: inherit; }
.ranch-card:hover { border-color: #6ea1ff; transform: translateY(-1px); }
.ranch-card strong { display: block; margin-bottom: 8px; font-size: 1.2rem; }
.ranch-card span:last-child { color: #aeb8c7; }

.stats-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; text-align: center; }
.stats-row div { display: grid; gap: 4px; }
.stats-row strong { font-size: 1.7rem; }
.stats-row span { color: #aeb8c7; font-size: .88rem; }

.animal-card h3 { font-size: 1.3rem; }
.sex-badge { padding: 5px 9px; border-radius: 999px; background: #222d3d; color: #cbd5e1; text-transform: capitalize; font-size: .82rem; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0; }
.stat-grid div { padding: 10px; border-radius: 10px; background: #0d131d; }
.stat-grid dt { color: #8f9bad; font-size: .78rem; }
.stat-grid dd { margin: 3px 0 0; font-weight: 800; }
.notes { color: #c3ccd8; white-space: pre-wrap; }
.danger { color: #ff8d8d; }
.empty-state { text-align: center; color: #aeb8c7; }

@media (max-width: 760px) {
  .app-shell { padding-top: 32px; }
  .hero, .toolbar, .ranch-header { flex-direction: column; align-items: stretch; }
  .two-column, .three-column { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .card { padding: 18px; }
  .app-shell { width: min(100% - 20px, 1120px); }
}