:root {
  --ink: #0f2f6e;
  --indigo: #25458c;
  --sky: #80a6da;
  --cream: #fcf6ed;
  --peach: #f2d2bc;
  --sage: #547669;
  --rose: #875d74;
  --white: #ffffff;
  --shadow: 0 16px 32px rgba(15, 47, 110, 0.14);
  --shadow-soft: 0 8px 20px rgba(15, 47, 110, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: "Outfit", "Avenir Next", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #ecf1fb 0%, #f9f0e6 50%, #fff8f0 100%);
}

body {
  position: relative;
}

.bg-glow {
  position: fixed;
  width: 48vw;
  height: 48vw;
  border-radius: 50%;
  filter: blur(16px);
  opacity: 0.28;
  z-index: 0;
  pointer-events: none;
}

.bg-glow-left {
  top: -16vw;
  left: -14vw;
  background: radial-gradient(circle, #6f7fc8 0%, #e4aeb3 70%, transparent 100%);
}

.bg-glow-right {
  bottom: 10vh;
  right: -18vw;
  background: radial-gradient(circle, #6ab1c8 0%, #9eccbc 70%, transparent 100%);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.app-header {
  background: linear-gradient(140deg, rgba(15, 47, 110, 0.96), rgba(47, 79, 155, 0.94));
  color: var(--white);
  border-radius: 1.25rem;
  padding: 1rem;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 0.9rem;
  box-shadow: var(--shadow);
}

.logo {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.7);
}

.header-copy h1 {
  margin: 0.2rem 0 0;
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: 1.35rem;
  line-height: 1.1;
}

.header-copy p {
  margin: 0;
}

.eyebrow {
  letter-spacing: 0.09em;
  text-transform: uppercase;
  font-size: 0.7rem;
  color: rgba(253, 240, 230, 0.92);
}

.subhead {
  margin-top: 0.45rem;
  font-size: 0.86rem;
  color: rgba(255, 250, 244, 0.93);
}

.section {
  margin-top: 1rem;
  background: rgba(255, 255, 255, 0.93);
  border-radius: 1.1rem;
  padding: 1rem;
  box-shadow: var(--shadow-soft);
}

.section h2 {
  margin: 0;
  font-family: "Fraunces", Georgia, serif;
  font-size: 1.2rem;
}

.section h3 {
  margin: 0;
  font-size: 1rem;
}

.section-intro {
  margin: 0.5rem 0 0;
  color: #476283;
  font-size: 0.9rem;
}

.quick-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  background: linear-gradient(145deg, #fdf6ee 0%, #f4e1d1 100%);
}

.quick-card {
  background: rgba(255, 255, 255, 0.78);
  border-radius: 0.85rem;
  padding: 0.65rem 0.55rem;
}

.quick-label {
  margin: 0;
  color: #50698d;
  font-size: 0.74rem;
}

.quick-value {
  margin: 0.35rem 0 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--indigo);
}

.small-value {
  font-size: 0.9rem;
  line-height: 1.2;
}

.supply-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.supply-item {
  background: #f4f7fd;
  border-radius: 0.85rem;
  padding: 0.65rem;
  border: 1px solid rgba(37, 69, 140, 0.1);
}

.supply-item p {
  margin: 0;
}

.supply-name {
  font-size: 0.8rem;
  color: #546b8a;
}

.supply-value {
  margin-top: 0.3rem;
  font-size: 1rem;
  font-weight: 700;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
}

.button-inline {
  display: inline-flex;
  gap: 0.45rem;
  align-items: center;
}

.section-head input[type="search"] {
  max-width: 58%;
}

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

label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.83rem;
  color: #3f5d80;
}

input,
select,
textarea {
  border: 1px solid rgba(37, 69, 140, 0.24);
  border-radius: 0.72rem;
  font-size: 1rem;
  padding: 0.64rem 0.68rem;
  color: var(--ink);
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(128, 166, 218, 0.62);
  border-color: rgba(37, 69, 140, 0.35);
}

button {
  border: 0;
  border-radius: 0.75rem;
  padding: 0.62rem 0.72rem;
  cursor: pointer;
}

.primary-btn {
  background: linear-gradient(120deg, var(--indigo), #4166af);
  color: var(--white);
  font-weight: 600;
}

.ghost-btn {
  background: #eef3fd;
  color: var(--indigo);
  font-weight: 600;
}

.small-btn {
  background: #edf3fc;
  color: var(--indigo);
  font-size: 0.78rem;
  padding: 0.46rem 0.38rem;
}

.danger-btn {
  background: #fbe7ea;
  color: var(--rose);
}

.pet-list,
.stack-list {
  display: grid;
  gap: 0.75rem;
}

.pet-card,
.stack-item {
  border: 1px solid rgba(37, 69, 140, 0.13);
  border-radius: 1rem;
  overflow: hidden;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.99), rgba(246, 250, 255, 0.95));
}

.pet-photo {
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  background: #dce7f7;
}

.pet-body,
.stack-item {
  padding: 0.75rem;
}

.pet-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pet-name {
  margin: 0;
  font-size: 1.05rem;
}

.pet-status-tag {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.22rem 0.45rem;
  border-radius: 999px;
  background: #eaf2ff;
  color: var(--indigo);
}

.pet-meta,
.pet-health,
.pet-stage,
.small {
  margin: 0.45rem 0 0;
  font-size: 0.84rem;
  color: #4f6786;
}

.pet-actions {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.pet-form,
.settings-form,
.auth-actions {
  display: grid;
  gap: 0.85rem;
}

#pet-save-btn {
  position: sticky;
  bottom: calc(0.55rem + env(safe-area-inset-bottom));
  z-index: 2;
  min-height: 3.1rem;
  box-shadow: 0 10px 20px rgba(15, 47, 110, 0.18);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.span-2 {
  grid-column: 1 / -1;
}

.photo-area {
  display: grid;
  gap: 0.5rem;
}

.photo-preview {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 0.9rem;
  max-height: 320px;
  object-fit: cover;
  background: #dce7f7;
}

.vaccine-block {
  padding: 0.8rem;
  border-radius: 0.95rem;
  background: linear-gradient(180deg, #f5f9ff 0%, #edf4fb 100%);
}

.vaccine-rows,
.inventory-list {
  display: grid;
  gap: 0.65rem;
}

.vaccine-row,
.inventory-item {
  background: var(--white);
  border: 1px solid rgba(37, 69, 140, 0.12);
  border-radius: 0.8rem;
  padding: 0.65rem;
  display: grid;
  gap: 0.55rem;
}

.vaccine-row-grid,
.inventory-grid,
.button-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.55rem;
}

.top-nav {
  position: sticky;
  top: 0.5rem;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
  padding: 0.55rem 0.65rem;
  margin-top: 0.8rem;
  border-radius: 0.9rem;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(247, 240, 233, 0.98));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(37, 69, 140, 0.15);
}

.nav-btn {
  background: #f2f6fd;
  color: #4a6180;
  font-weight: 600;
  font-size: 0.82rem;
  min-height: 2.9rem;
  white-space: nowrap;
  width: 100%;
}

.nav-btn.active {
  color: var(--white);
  background: linear-gradient(120deg, var(--indigo), #3d66ad);
}

.empty-state {
  margin: 0;
  text-align: center;
  color: #536f8f;
  background: #f5f8fd;
  border-radius: 0.9rem;
  padding: 1rem;
}

.qr-canvas {
  margin-top: 0.5rem;
  border-radius: 0.8rem;
  background: #fff;
  border: 1px solid rgba(37, 69, 140, 0.12);
  width: 220px;
  max-width: 100%;
}

.tag-note {
  margin: 0;
  font-size: 0.8rem;
  color: #50698d;
  background: #edf3fd;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
}

.top-gap {
  margin-top: 0.95rem;
}

.mono {
  font-family: "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.crop-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(7, 23, 54, 0.56);
  display: grid;
  place-items: center;
  padding: 1rem;
}

.crop-panel {
  width: min(520px, 96vw);
  max-height: min(90dvh, 90vh);
  overflow-y: auto;
  background: #ffffff;
  border-radius: 1rem;
  padding: 1rem 1rem calc(0.8rem + env(safe-area-inset-bottom));
  box-shadow: 0 16px 40px rgba(10, 30, 66, 0.3);
  overscroll-behavior: contain;
}

.crop-canvas {
  width: 100%;
  max-width: 100%;
  border-radius: 0.85rem;
  border: 1px solid rgba(37, 69, 140, 0.18);
  background: #dce7f7;
  margin: 0.7rem 0;
}

#crop-modal .button-grid {
  position: sticky;
  bottom: calc(env(safe-area-inset-bottom) * -1);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), #ffffff 36%);
  padding: 0.65rem 0 calc(0.65rem + env(safe-area-inset-bottom));
}

#crop-apply-btn,
#crop-cancel-btn,
#crop-apply-top-btn {
  min-height: 3rem;
  font-size: 0.96rem;
}

@media (min-width: 700px) {
  .quick-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

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

  .vaccine-row-grid {
    grid-template-columns: 1.4fr 1fr 1fr 1fr auto;
    align-items: end;
  }

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

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

  .top-nav {
    grid-template-columns: repeat(9, minmax(0, 1fr));
  }

  .pet-card {
    display: grid;
    grid-template-columns: 210px 1fr;
  }

  .pet-photo {
    height: auto;
  }
}
