:root {
  --forest: #1d6a50;
  --forest-deep: #174b3b;
  --forest-light: #eaf4ee;
  --cream: #f5f4ed;
  --paper: #fff;
  --ink: #1d2d27;
  --muted: #678078;
  --line: #dce5df;
  --amber: #d89b43;
  --clay: #b76b4b;
  --sky: #639c91;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--cream);
  color: var(--ink);
  margin: 0;
}

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

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.loading-screen,
.login-page {
  align-items: center;
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

.loading-screen {
  flex-direction: column;
  gap: 12px;
}

.brand-mark {
  align-items: center;
  background: var(--forest);
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 18px 6px 18px 6px;
  box-shadow: 0 10px 30px rgba(23, 75, 59, 0.2);
  color: white;
  display: flex;
  font-family: Georgia, serif;
  font-size: 28px;
  height: 52px;
  justify-content: center;
  width: 52px;
}

.login-page {
  background:
    radial-gradient(circle at 15% 15%, rgba(216, 155, 67, 0.2), transparent 32%),
    radial-gradient(circle at 85% 82%, rgba(29, 106, 80, 0.18), transparent 34%),
    #edf2ec;
  padding: 24px;
}

.login-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 28px;
  box-shadow: 0 24px 70px rgba(29, 50, 42, 0.14);
  max-width: 440px;
  padding: 38px;
  width: 100%;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
}

.brand strong {
  display: block;
  font-family: Georgia, serif;
  font-size: 22px;
}

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

.login-card .brand {
  margin-bottom: 34px;
}

.eyebrow {
  color: var(--forest);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2 {
  font-family: Georgia, serif;
  font-weight: 550;
}

.login-card h1 {
  font-size: 34px;
  margin: 9px 0 10px;
}

.login-card > p {
  color: var(--muted);
  line-height: 1.6;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field > span {
  color: #3e5c51;
  font-size: 11px;
  font-weight: 750;
}

.field input,
.field select,
.field textarea,
.search,
.caption-input {
  background: #fbfcf9;
  border: 1px solid #d5e0d8;
  border-radius: 11px;
  min-height: 44px;
  outline: none;
  padding: 10px 12px;
  width: 100%;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search:focus,
.caption-input:focus {
  border-color: var(--forest);
  box-shadow: 0 0 0 3px rgba(29, 106, 80, 0.11);
}

.login-form {
  display: grid;
  gap: 17px;
  margin-top: 24px;
}

.button {
  align-items: center;
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  display: inline-flex;
  font-weight: 750;
  gap: 7px;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  text-decoration: none;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-primary {
  background: var(--forest);
  color: white;
}

.button-secondary {
  background: var(--forest-light);
  color: var(--forest-deep);
}

.button-ghost {
  background: transparent;
  color: var(--forest);
}

.login-error,
.alert {
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
  padding: 11px 13px;
}

.login-error,
.alert-error {
  background: #fff0eb;
  color: #8a3f2d;
}

.alert-success {
  background: var(--forest-light);
  color: var(--forest-deep);
}

.app-shell {
  display: grid;
  grid-template-columns: 225px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--forest-deep);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 25px 17px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand small {
  color: #b9d1c7;
}

.sidebar .brand-mark {
  box-shadow: none;
}

.nav {
  display: grid;
  gap: 7px;
  margin-top: 42px;
}

.nav button {
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: #d7e6df;
  cursor: pointer;
  font-weight: 650;
  padding: 12px;
  text-align: left;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.12);
  color: white;
}

.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  display: grid;
  gap: 5px;
  margin-top: auto;
  padding-top: 16px;
}

.sidebar-foot span {
  color: #b9d1c7;
  font-size: 10px;
}

.sidebar-foot button {
  justify-self: start;
  margin-top: 7px;
}

.main {
  min-width: 0;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 30px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar strong {
  display: block;
  font-family: Georgia, serif;
}

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

.user-avatar,
.animal-avatar {
  align-items: center;
  background: var(--forest-light);
  border-radius: 50%;
  color: var(--forest-deep);
  display: flex;
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 850;
  height: 38px;
  justify-content: center;
  width: 38px;
}

.animal-avatar {
  background: #edf3ee;
  height: 36px;
  width: 36px;
}

.content {
  margin: 0 auto;
  max-width: 1180px;
  padding: 30px;
}

.hero {
  background:
    linear-gradient(110deg, rgba(29, 106, 80, 0.98), rgba(23, 75, 59, 0.91)),
    white;
  border-radius: 22px;
  color: white;
  overflow: hidden;
  padding: 33px;
  position: relative;
}

.hero::after {
  border: 34px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
  content: "";
  height: 180px;
  position: absolute;
  right: -35px;
  top: -45px;
  width: 180px;
}

.hero h1 {
  font-size: 32px;
  margin: 8px 0 9px;
}

.hero p {
  color: #d8e8e1;
  line-height: 1.6;
  max-width: 670px;
}

.hero .button {
  background: white;
  color: var(--forest-deep);
}

.metrics {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 20px 0;
}

.metric,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 8px 24px rgba(35, 61, 51, 0.04);
}

.metric {
  min-height: 135px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
}

.metric strong {
  display: block;
  font-family: Georgia, serif;
  font-size: 34px;
  margin: 13px 0 2px;
}

.metric small {
  color: var(--muted);
  font-size: 9px;
}

.grid-2 {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.25fr 0.75fr;
}

.panel {
  padding: 20px;
}

.panel-heading,
.title-row,
.filters,
.animal-row,
.drawer-hero,
.file-upload {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.panel-heading {
  margin-bottom: 17px;
}

.panel-heading h2 {
  font-size: 20px;
  margin: 0;
}

.panel-heading p,
.title-row p {
  color: var(--muted);
  font-size: 11px;
  margin: 4px 0 0;
}

.animal-list {
  display: grid;
}

.animal-row {
  background: transparent;
  border: 0;
  border-top: 1px solid #edf1ed;
  color: inherit;
  cursor: pointer;
  min-height: 68px;
  padding: 10px 3px;
  text-align: left;
  width: 100%;
}

.animal-row:first-child {
  border-top: 0;
}

.animal-row .identity {
  flex: 1;
  min-width: 0;
}

.identity strong,
.identity span {
  display: block;
}

.identity span {
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}

.status {
  background: var(--forest-light);
  border-radius: 999px;
  color: var(--forest);
  font-size: 9px;
  font-weight: 750;
  padding: 6px 9px;
}

.status.final {
  background: #f2e7e2;
  color: var(--clay);
}

.bars {
  display: grid;
  gap: 13px;
}

.bar-label {
  display: flex;
  font-size: 10px;
  justify-content: space-between;
  margin-bottom: 5px;
}

.bar-track {
  background: #edf1ed;
  border-radius: 99px;
  height: 7px;
  overflow: hidden;
}

.bar-fill {
  background: var(--forest);
  border-radius: inherit;
  height: 100%;
}

.title-row {
  align-items: end;
  margin-bottom: 22px;
}

.title-row h1 {
  font-size: 30px;
  margin: 5px 0 0;
}

.title-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  justify-content: flex-end;
}

.filters {
  align-items: stretch;
  margin-bottom: 15px;
}

.filters > * {
  flex: 1;
}

.filters select {
  flex: 0 0 180px;
}

.empty {
  color: var(--muted);
  padding: 35px 15px;
  text-align: center;
}

.form-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  margin-bottom: 17px;
  padding: 24px;
}

.form-card h2 {
  font-size: 21px;
  margin-bottom: 18px;
}

.custom-species {
  display: none;
}

.custom-species.visible {
  background: #f7f9f6;
  border: 1px dashed var(--line);
  border-radius: 12px;
  display: block;
  padding: 15px;
}

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

.wide {
  grid-column: 1 / -1;
}

.photo-field {
  align-items: center;
  background: var(--forest-light);
  border: 1px dashed #9dbcae;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  gap: 4px 12px;
  grid-template-columns: auto 1fr;
  padding: 13px;
}

.photo-field > b {
  align-items: center;
  background: var(--forest);
  border-radius: 50%;
  color: white;
  display: flex;
  grid-row: 1 / 3;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.photo-field span {
  color: var(--forest-deep);
  font-size: 11px;
  font-weight: 750;
}

.photo-field small {
  color: var(--muted);
  font-size: 9px;
}

.photo-field input {
  grid-column: 2;
  width: 100%;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.compact-actions {
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
  padding: 16px 0 20px;
}

.event-form {
  background: #f6f8f5;
  border-radius: 12px;
  margin-bottom: 20px;
  padding: 17px;
}

.drawer-backdrop {
  background: rgba(13, 30, 23, 0.38);
  inset: 0;
  position: fixed;
  z-index: 20;
}

.drawer {
  background: var(--cream);
  box-shadow: -18px 0 50px rgba(12, 35, 27, 0.16);
  height: 100vh;
  margin-left: auto;
  max-width: 760px;
  overflow-y: auto;
  padding: 24px;
  width: 92%;
}

.drawer-close {
  background: white;
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
  float: right;
  font-size: 20px;
  height: 38px;
  width: 38px;
}

.drawer-hero {
  align-items: flex-start;
  padding: 35px 5px 20px;
}

.drawer-hero h2 {
  font-size: 28px;
  margin: 5px 0;
}

.drawer-code {
  color: var(--forest);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.drawer-section {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  margin-top: 15px;
  padding: 20px;
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, 1fr);
}

.detail-grid div {
  background: #f6f8f5;
  border-radius: 10px;
  padding: 11px;
}

.detail-grid dt {
  color: var(--muted);
  font-size: 9px;
}

.detail-grid dd {
  font-size: 11px;
  font-weight: 700;
  margin: 5px 0 0;
}

.history-note {
  background: #f6f8f5;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.55;
  margin: 13px 0 0;
  padding: 12px;
}

.timeline {
  display: grid;
  gap: 14px;
}

.event-card {
  border-left: 3px solid var(--forest);
  padding: 3px 0 4px 14px;
}

.event-card h3 {
  font-size: 14px;
  margin: 3px 0 7px;
}

.event-card p {
  font-size: 11px;
  line-height: 1.55;
}

.event-card small {
  color: var(--muted);
  display: block;
  font-size: 9px;
  margin-top: 7px;
}

.files-grid {
  display: grid;
  gap: 11px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.file-card {
  background: #f3f6f2;
  border-radius: 10px;
  color: inherit;
  overflow: hidden;
  text-decoration: none;
}

.file-card img,
.pdf-tile {
  height: 115px;
  object-fit: cover;
  width: 100%;
}

.pdf-tile {
  align-items: center;
  background: #efe9e4;
  color: var(--clay);
  display: flex;
  font-weight: 800;
  justify-content: center;
}

.file-copy {
  padding: 9px;
}

.file-copy strong,
.file-copy small {
  display: block;
}

.file-copy strong {
  font-size: 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-copy small {
  color: var(--muted);
  font-size: 8px;
  margin-top: 4px;
}

.file-upload {
  align-items: end;
}

.file-upload .photo-field {
  flex: 1.2;
}

.file-upload .caption-input {
  flex: 1;
}

.stat-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.alert {
  margin-bottom: 15px;
}

.permission-panel {
  margin: 50px auto;
  max-width: 650px;
  padding: 34px;
  text-align: center;
}

.permission-panel h1 {
  margin: 9px 0 12px;
}

.permission-panel p {
  color: var(--muted);
  line-height: 1.6;
}

.credential-notice {
  align-items: center;
  background: #eaf4ee;
  border: 1px solid #a9c9bb;
  border-radius: 16px;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 18px;
  padding: 20px;
}

.credential-notice h2 {
  font-size: 20px;
  margin: 5px 0 9px;
}

.credential-notice p {
  line-height: 1.65;
  margin: 0;
}

.credential-notice code {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 5px;
  font-size: 11px;
  padding: 3px 6px;
  user-select: all;
}

.credential-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.user-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 0.78fr) minmax(460px, 1.22fr);
}

.user-create {
  align-self: start;
  margin: 0;
  position: sticky;
  top: 90px;
}

.user-create .form-grid {
  grid-template-columns: 1fr;
}

.user-form-actions {
  flex-wrap: wrap;
  margin-top: 18px;
}

.users-list {
  display: grid;
  gap: 11px;
}

.user-card {
  align-items: center;
  background: #f8faf7;
  border: 1px solid var(--line);
  border-radius: 12px;
  display: grid;
  gap: 13px;
  grid-template-columns: minmax(190px, 1fr) minmax(300px, auto);
  padding: 14px;
}

.user-card.inactive {
  background: #f2efed;
  opacity: 0.78;
}

.user-identity {
  align-items: center;
  display: flex;
  gap: 11px;
  min-width: 0;
}

.user-identity > div:last-child {
  min-width: 0;
}

.user-identity strong,
.user-identity span,
.user-identity small {
  display: block;
}

.user-identity span {
  color: var(--muted);
  font-size: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-identity small,
.self-note {
  color: var(--muted);
  font-size: 8px;
  margin-top: 4px;
}

.user-controls {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.user-controls .button {
  font-size: 9px;
  min-height: 34px;
  padding: 7px 10px;
}

.compact-field {
  min-width: 145px;
}

.compact-field select {
  min-height: 34px;
  padding: 6px 8px;
}

.password-reset {
  align-items: end;
  background: white;
  border-radius: 10px;
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
  padding: 12px;
}

.password-reset .field {
  flex: 1;
}

.password-reset .button {
  flex: 0 0 auto;
}

.mobile-nav {
  display: none;
}

@media (max-width: 860px) {
  .app-shell {
    display: block;
    padding-bottom: 70px;
  }

  .sidebar {
    display: none;
  }

  .topbar {
    padding: 12px 17px;
  }

  .content {
    padding: 18px 14px;
  }

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

  .grid-2,
  .stat-layout,
  .user-layout {
    grid-template-columns: 1fr;
  }

  .user-create {
    position: static;
  }

  .mobile-nav {
    background: white;
    border-top: 1px solid var(--line);
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    left: 0;
    padding: 7px 5px calc(7px + env(safe-area-inset-bottom));
    position: fixed;
    right: 0;
    z-index: 10;
  }

  .mobile-nav.admin {
    grid-template-columns: repeat(5, 1fr);
  }

  .mobile-nav.viewer {
    grid-template-columns: repeat(3, 1fr);
  }

  .mobile-nav button {
    background: transparent;
    border: 0;
    color: var(--muted);
    font-size: 9px;
    padding: 8px 3px;
  }

  .mobile-nav button.active {
    color: var(--forest);
    font-weight: 800;
  }
}

@media (max-width: 620px) {
  .login-card {
    padding: 30px 24px;
  }

  .hero {
    padding: 27px 22px;
  }

  .hero h1,
  .title-row h1 {
    font-size: 27px;
  }

  .form-grid,
  .detail-grid,
  .files-grid {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: auto;
  }

  .filters,
  .file-upload,
  .title-row,
  .title-actions,
  .credential-notice,
  .password-reset {
    align-items: stretch;
    flex-direction: column;
  }

  .filters select {
    flex-basis: auto;
  }

  .drawer {
    padding: 15px 12px 80px;
    width: 100%;
  }

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

  .user-controls {
    align-items: stretch;
    justify-content: flex-start;
  }

  .user-controls > * {
    flex: 1 1 130px;
  }
}
