:root {
  --border: #e5e7eb;
  --muted: #6b7280;
  --bg: #f4f7f4;
  --surface: #ffffff;
  --accent: #2F5D3A;
  --accent-weak: rgba(47, 93, 58, 0.14);
  --shadow: 0 1px 2px rgba(17, 24, 39, 0.06);
  --shadow-lg: 0 14px 36px rgba(17, 24, 39, 0.14);
  --text: #111827;
  --mobile-main-bottom: 92px;
  --mobile-keyboard-offset: 0px;
}

/* Ensure the HTML [hidden] attribute always hides elements.
   This is important because some components (e.g., bottom sheets)
   define their own display styles which would otherwise override
   the browser default hidden behavior. */
[hidden] { display: none !important; }

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: #111827;
}

.container {
  max-width: 1100px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 16px;
}

.topbar .container {
  max-width: 1320px;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
  position: sticky;
  top: 0;
  z-index: 800;
}

.topbar .container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-toggle {
  display: none;
  border: 1px solid var(--border);
  background: #fff;
  color: #111827;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.brand a {
  text-decoration: none;
  color: #111827;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  min-width: 0;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.05;
}

.brand {
  min-width: 0;
  flex: 0 0 auto;
  max-width: 240px;
}

.brand-logo {
  display: block;
  height: 34px;
  width: auto;
  max-width: 220px;
}

.topbar-right {
  display: none;
}

.user-mobile {
  display: none;
}

.user-desktop {
  color: var(--muted);
  font-size: 14px;
  flex: 0 0 auto;
  min-width: 0;
  max-width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.nav {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.nav a {
  text-decoration: none;
  color: #374151;
  padding: 6px 10px;
  border-radius: 6px;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
}

.nav a:hover {
  background: #f3f4f6;
}

/* Subtle active nav state (desktop) */
@media (min-width: 821px) {
  /* Desktop header only: put the brand/user on the first row and give
     the navigation its own second row so long emails cannot overlap links. */
  .topbar .container {
    display: grid;
    grid-template-columns: minmax(0, auto) 1fr auto;
    grid-template-areas:
      "brand spacer user"
      "nav nav nav";
    align-items: center;
    column-gap: 16px;
    row-gap: 10px;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .brand {
    grid-area: brand;
    max-width: none;
  }

  .nav {
    grid-area: nav;
    flex: none;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
  }

  .user-desktop {
    grid-area: user;
    justify-self: end;
    align-self: start;
    max-width: 340px;
    line-height: 1.15;
  }

  .nav a.active {
    border-bottom-color: var(--accent);
    font-weight: 700;
    color: #111827;
  }

  /* Style a couple links as actions without changing routes/structure */
  .nav a.nav-action {
    background: #fff;
    box-shadow: inset 0 0 0 1px var(--border);
    color: #111827;
  }

  .nav a.nav-action:hover {
    box-shadow: inset 0 0 0 1px var(--accent);
  }

  /* With the two-row desktop layout, logout no longer needs to be pushed away. */
  .nav a.nav-logout {
    margin-left: 0;
  }
}

.user {
  color: var(--muted);
  font-size: 14px;
}

a.link-muted {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

a.link-muted:hover {
  text-decoration: underline;
}

h1 {
  margin: 8px 0 16px 0;
  font-size: 24px;
}

.card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-clickable {
  cursor: pointer;
}

.card-clickable:active {
  transform: scale(0.99);
}

.card-clickable:focus {
  outline: 2px solid #111827;
  outline-offset: 2px;
}

.report-card {
  text-decoration: none;
  color: inherit;
  display: block;
}

.report-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}

.report-card-desc {
  color: var(--muted);
  margin-top: 8px;
}

.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.row > * {
  flex: 1;
  min-width: 240px;
}

label {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"],
input[type="number"],
input[type="email"],
input[type="search"],
input[type="tel"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-sizing: border-box;
  font-size: 16px;
  line-height: 1.35;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent-weak);
  outline-offset: 1px;
  border-color: rgba(47, 93, 58, 0.45);
}

/* Tom Select: match our input styles */
.ts-control {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  line-height: 1.35;
}

.ts-wrapper.single .ts-control {
  background: #fff;
}

.ts-control input,
.ts-dropdown .option,
.ts-dropdown .optgroup-header {
  font-size: 16px !important;
}

textarea {
  min-height: 90px;
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

button, .btn {
  display: inline-block;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
}

button:hover, .btn:hover {
  filter: brightness(0.96);
}

.label-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: #111827;
  font-size: 13px;
  line-height: 1;
}

.help-btn:active {
  transform: scale(0.98);
}

/* Inline “View” buttons used in Activity Log cells */
.help-btn-inline {
  width: auto;
  height: auto;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 999px;
  font-size: 12px;
}

.hint {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  display: none;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
}

.help-dialog {
  position: relative;
  margin: 10vh auto;
  width: calc(100% - 24px);
  max-width: 520px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
}

.help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.help-body {
  padding: 12px 14px;
  white-space: pre-wrap;
}

.list-body {
  padding: 12px 14px;
  white-space: normal;
  max-height: 70vh;
  overflow: auto;
}

.animal-mini-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.animal-mini-item a {
  display: flex;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: #111827;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.animal-mini-item a:active {
  transform: scale(0.99);
}

.animal-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  object-fit: cover;
  background: #f3f4f6;
}

.animal-avatar-placeholder {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #111827;
}

.animal-mini-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.animal-mini-meta small {
  color: var(--muted);
}

.image-dialog {
  max-width: 900px;
}

.image-body {
  padding: 12px 14px;
}

.image-body img {
  width: 100%;
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.image-caption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.photo-tile {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
}

.photo-tile img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f3f4f6;
}

.photo-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.photo-actions form {
  margin: 0;
}

.photo-upload-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.photo-upload-picked {
  margin-top: 8px;
  font-size: 13px;
}

.upload-submit[disabled],
button[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
}

.upload-status {
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: #f8fafc;
}

.upload-status-title {
  font-weight: 800;
  margin-bottom: 8px;
}

.upload-progress {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #dbe5dc;
  overflow: hidden;
}

.upload-progress-bar {
  position: absolute;
  inset: 0 auto 0 0;
  width: 38%;
  border-radius: 999px;
  background: var(--accent);
  animation: upload-progress-indeterminate 1.15s ease-in-out infinite;
}

.upload-status-text {
  margin-top: 8px;
  font-size: 13px;
}

.photo-upload-form.is-uploading input[type="file"],
.photo-upload-form.is-uploading input[type="text"],
.photo-upload-form.is-uploading input[type="checkbox"] {
  pointer-events: none;
}

@keyframes upload-progress-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.btn-small {
  padding: 7px 10px;
  font-size: 13px;
}

.profile-photo {
  width: 100%;
  max-width: 520px;
  border-radius: 12px;
  border: 1px solid var(--border);
  display: block;
}

.profile-photo-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

.help-close {
  border: 1px solid var(--border);
  background: #fff;
  color: #111827;
  padding: 8px 10px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

body.modal-open {
  overflow: hidden;
}

.bottom-nav {
  display: none;
}

/* Mobile first adjustments */
@media (max-width: 820px) {
  .container {
    padding: 14px;
  }

  h1 {
    font-size: 22px;
  }

  button, .btn {
    padding: 12px 14px;
    font-size: 16px;
  }

  .topbar .container {
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 10px;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .nav {
    width: 100%;
    flex-basis: 100%;
    display: none;
    flex-direction: column;
    gap: 0;
    margin-top: 8px;
    border-top: 1px solid var(--border);
  }

  body.nav-open .nav {
    display: flex;
  }

  .nav a {
    padding: 12px 10px;
    border-radius: 0;
    border-bottom: none;
    border-left: 4px solid transparent;
  }

  /* Active page indicator in the collapsed mobile menu */
  .nav a.active {
    border-left-color: var(--accent);
    font-weight: 700;
    background: #f3f4f6;
  }

  .user-desktop {
    display: none;
  }

  .topbar-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    margin-left: auto;
    min-width: 0;
  }

  .user-mobile {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.1;
    text-align: right;
    min-width: 0;
  }

  .user-mobile-name {
    display: block;
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    font-size: 12px;
  }

  .row > * {
    min-width: 100%;
  }

  .hint {
    display: block;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    z-index: 900;
  }

  .bottom-nav a {
    flex: 1;
    text-align: center;
    padding: 12px 6px;
    text-decoration: none;
    color: #111827;
    font-size: 13px;
    border-top: 3px solid transparent;
  }

  .bottom-nav a.active {
    border-top-color: var(--accent);
    font-weight: 700;
  }

  main.container {
    padding-bottom: 74px;
  }

  .help-dialog {
    margin: auto;
    top: auto;
    bottom: 0;
    border-radius: 14px 14px 0 0;
    max-width: 100%;
  }

  .dataTables_filter {
    text-align: left;
  }

  .dataTables_filter input {
    width: 100% !important;
    margin-left: 0 !important;
    box-sizing: border-box;
  }

  .image-dialog {
    max-width: 100%;
  }

  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .brand-logo {
    height: 30px;
    max-width: 156px;
  }
}

/* DataTables small tweaks */
table.dataTable thead th {
  color: var(--muted);
}

.btn-secondary {
  background: #fff;
  color: #111827;
  border-color: var(--border);
}

.btn-secondary:hover {
  border-color: var(--accent);
  filter: none;
}

.btn-danger {
  background: #b91c1c;
  border-color: #b91c1c;
}

.flash {
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 8px;
  margin: 12px 0;
}

.flash-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.flash-error {
  border-color: #fecaca;
  background: #fef2f2;
}

.flash-info {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* On phones, keep DataTables cells on one line so tables become horizontally swipeable */
@media (max-width: 820px) {
  table.display th,
  table.display td {
    white-space: nowrap;
  }

  /* Better momentum scrolling for DataTables scrollX on iOS */
  div.dataTables_scrollBody {
    -webkit-overflow-scrolling: touch;
  }
}

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

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

table th {
  font-size: 13px;
  color: var(--muted);
}

.footer {
  margin-top: 30px;
  border-top: 1px solid var(--border);
  background: #ffffff;
}

/* Auth (login) layout */
.page-login {
  background: radial-gradient(circle at top, #eef5ef 0%, var(--bg) 55%, var(--bg) 100%);
}

.page-login .topbar,
.page-login .footer,
.page-login .bottom-nav {
  display: none;
}

.page-login main.container {
  max-width: 560px;
  padding: 28px 16px;
}

.page-login .flash {
  max-width: 520px;
  margin-left: auto;
  margin-right: auto;
}

.auth-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.auth-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.auth-logo {
  display: block;
  height: 100px;
  width: auto;
  max-width: 520px;
}

.auth-title {
  font-weight: 800;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  color: var(--muted);
  font-size: 14px;
}

.auth-card {
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
}

.auth-public-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 12px;
}

.auth-public-links a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.auth-public-links a:hover {
  text-decoration: underline;
}

.terms-consent {
  display: grid;
  gap: 8px;
}

@media (max-width: 820px) {
  .auth-logo {
    height: 78px;
    max-width: 340px;
  }
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: #111827;
  background: #f9fafb;
}

.badge-dead {
  background: #fee2e2;
  border-color: #fecaca;
}

.badge-open {
  background: #ffedd5;
  border-color: #fed7aa;
}

.badge-calved {
  background: #dcfce7;
  border-color: #bbf7d0;
}

.badge-sold {
  background: #ede9fe;
  border-color: #ddd6fe;
}

.badge-none {
  background: #f3f4f6;
  border-color: var(--border);
}

/* ------------------------------------------------------------
   Mobile focused UI (Home/Herd/Animal)
   Safe additions only (does not change routing or backend)
------------------------------------------------------------ */

.only-mobile { display: none; }
.only-desktop { display: block; }

.mobile-title-row { margin: 10px 0 12px; }
.mobile-title {
  font-size: 44px;
  line-height: 1.05;
  font-weight: 800;
  margin: 0;
}

.section-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.section-row-title { font-size: 22px; font-weight: 800; }
.section-row-link { color: var(--accent); font-weight: 700; text-decoration: none; }

.searchbar {
  position: relative;
}
.searchbar-icon {
  display: none;
}
.searchbar-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #ffffff;
  font-size: 16px;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.summary-card {
  position: relative;
  display: block;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #ffffff;
  text-decoration: none;
  color: var(--text);
}
.summary-title { font-weight: 800; font-size: 18px; }
.summary-value { font-size: 34px; font-weight: 900; margin-top: 4px; }
.summary-sub { color: var(--muted); margin-top: 2px; }
.summary-chev {
  position: absolute;
  right: 12px;
  top: 12px;
  color: var(--muted);
  font-size: 22px;
}

.chip-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.chip-active {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: var(--accent);
}

.muted-row { color: var(--muted); margin-top: 8px; }

.list-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.list-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #ffffff;
  text-decoration: none;
  color: var(--text);
}
.list-card-title {
  font-size: 26px;
  font-weight: 900;
  line-height: 1.05;
}
.list-card-sub {
  color: var(--muted);
  margin-top: 2px;
}
.list-card-meta {
  color: #94a3b8;
  margin-top: 2px;
  font-size: 14px;
}
.list-card-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.chev { color: #94a3b8; font-size: 26px; line-height: 1; }

/* Bottom navigation (mobile) */
.bottom-nav {
  display: none;
}

.bottom-nav .bn-item {
  appearance: none;
  background: transparent;
  border: 0;
  text-decoration: none;
  color: var(--muted);
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  border-radius: 14px;
  font-weight: 700;
}

.bottom-nav .bn-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav .bn-label {
  font-size: 12px;
}

.bottom-nav .bn-item.active {
  color: var(--accent);
}

.bottom-nav .bn-item.active::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 3px;
  background: var(--accent);
  border-radius: 999px;
}

.bottom-nav .bn-add .bn-icon {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.bottom-nav .bn-add {
  transform: translateY(-6px);
}

.bottom-nav .bn-add.active .bn-icon {
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.28);
}

.bottom-nav .bn-add.active::before {
  display: none;
}

/* Sheets */
.sheet-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.45);
}

.sheet {
  position: relative;
  width: 100%;
  max-width: 520px;
  background: #ffffff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -14px 40px rgba(0,0,0,0.18);
  padding: 10px 14px 18px;
}

.sheet-handle {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: #cbd5e1;
  margin: 6px auto 10px;
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 0 4px 10px;
}

.sheet-title {
  font-size: 34px;
  line-height: 1.05;
  font-weight: 900;
}

.sheet-sub {
  color: var(--muted);
  margin-top: 4px;
}

.sheet-close {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sheet-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sheet-item {
  position: relative;
  display: block;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #ffffff;
  text-decoration: none;
  color: var(--text);
}

.sheet-item-active {
  background: rgba(16, 185, 129, 0.10);
  border-color: rgba(16, 185, 129, 0.35);
}

.sheet-item-active .sheet-item-title {
  color: var(--accent);
}

.sheet-item-title { font-weight: 900; font-size: 24px; }
.sheet-item-sub { color: var(--muted); margin-top: 2px; }
.sheet-item-chev {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 28px;
}

.sheet-foot {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  padding: 0 4px;
}

/* Topbar action button (mobile) */
.topbar-action {
  display: none;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
  font-size: 14px;
  color: var(--text);
}

/* Animal page */
.animal-page { display: flex; flex-direction: column; gap: 12px; }

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

.animal-header-main { min-width: 0; }
.animal-header-title { font-size: 40px; line-height: 1.0; font-weight: 900; }
.animal-header-sub { color: var(--muted); margin-top: 2px; }
.animal-header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text);
  font-size: 24px;
  flex-shrink: 0;
}

.btn-small { padding: 8px 10px; font-size: 14px; }

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

.animal-summary-photo { flex: 0 0 112px; }
.animal-photo {
  width: 112px;
  height: 112px;
  border-radius: 16px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.animal-photo-placeholder {
  width: 112px;
  height: 112px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #94a3b8;
}

.animal-photo-placeholder-icon {
  width: 32px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid #cbd5e1;
}

.animal-photo-placeholder-text { font-weight: 800; }

.animal-summary-tag { font-size: 28px; font-weight: 900; line-height: 1.1; }
.animal-summary-coat { color: var(--muted); margin-top: 2px; }
.animal-summary-born { margin-top: 8px; }
.animal-summary-family { color: var(--muted); margin-top: 8px; display: flex; flex-wrap: wrap; gap: 10px; }

.section-title { font-size: 20px; font-weight: 900; }

.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #ffffff;
  text-decoration: none;
  color: var(--text);
}

.quick-action-disabled {
  opacity: 0.5;
}

.qa-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
}

.qa-label { font-weight: 900; }
.qa-chev { margin-left: auto; color: #94a3b8; font-size: 22px; }

.detail-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; }
.detail-k { color: var(--muted); font-weight: 700; }
.detail-v { font-weight: 900; text-align: right; }

.link-rows { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.link-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 10px; border-top: 1px solid rgba(226,232,240,0.7); }
.link-row:first-child { border-top: 0; padding-top: 0; }
.link-k { color: var(--muted); font-weight: 800; }
.link-v a { color: var(--accent); font-weight: 900; text-decoration: none; }

.photo-tile { display: flex; flex-direction: column; }
.photo-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }

.note-item {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: #ffffff;
}

.note-list { display: flex; flex-direction: column; gap: 10px; }
.note-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.note-text { margin-top: 8px; }
.note-actions { margin-top: 10px; }

.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-item { display: flex; gap: 10px; }
.timeline-dot { width: 10px; height: 10px; border-radius: 999px; background: rgba(16,185,129,0.25); margin-top: 6px; flex: 0 0 10px; }
.timeline-when { font-size: 12px; color: var(--muted); }
.timeline-text { font-weight: 800; }

@media (max-width: 820px) {
  .only-mobile { display: block; }
  .only-desktop { display: none; }

  .footer { display: none; }

  .topbar-action { display: inline-flex; }
  .nav-toggle { display: none; }
  .nav { display: none !important; }
  .user-display { display: none; }

  .page-animal .topbar { display: none; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) * -1);
    left: 0;
    right: 0;
    padding: 0 8px env(safe-area-inset-bottom);
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -1px 2px rgba(17, 24, 39, 0.04);
    z-index: 100;
  }

  .bottom-nav .bn-item {
    position: relative;
    min-height: 68px;
    padding: 8px 0 8px;
  }

  .main {
    padding-bottom: var(--mobile-main-bottom);
  }
}



/* Mobile shell hardening: stable bottom nav, safe-area spacing, keyboard handling */
@media (max-width: 820px) {
  html,
  body {
    height: 100%;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: none;
  }

  body {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  body > .topbar {
    flex: 0 0 auto;
    padding-top: env(safe-area-inset-top);
  }

  body.page-animal {
    padding-top: env(safe-area-inset-top);
  }

  body.page-animal > .topbar {
    padding-top: 0;
  }

  main.container {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: none;
    padding-bottom: var(--mobile-main-bottom);
    scroll-padding-top: 16px;
    scroll-padding-bottom: var(--mobile-main-bottom);
  }

  body.modal-open main.container {
    overflow: hidden;
    touch-action: none;
  }

  .page-login main.container {
    overflow-y: auto;
  }

  .page-login .auth-wrap,
  .page-contact .auth-wrap {
    min-height: calc(100dvh - 56px - env(safe-area-inset-top));
  }

  .bottom-nav {
    box-sizing: border-box;
    transition: box-shadow 180ms ease, opacity 180ms ease;
  }

  .bottom-nav .bn-item {
    gap: 6px;
  }

  body.keyboard-open .bottom-nav {
    box-shadow: 0 -10px 24px rgba(17, 24, 39, 0.12);
  }

  body.keyboard-open .bottom-nav .bn-item {
    gap: 4px;
  }

  body.keyboard-open .bottom-nav .bn-label {
    font-size: 11px;
  }

  body.keyboard-open .bottom-nav .bn-add {
    transform: translateY(-2px);
  }

  body.keyboard-open .bottom-nav .bn-add .bn-icon {
    width: 40px;
    height: 40px;
    font-size: 26px;
  }

  .dataTables_filter input,
  .searchbar-input,
  input,
  select,
  textarea,
  .ts-control,
  .ts-control input {
    font-size: 16px !important;
  }
}


.release-log-list {
  display: grid;
  gap: 10px;
}

.release-log-item {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  padding: 10px 12px;
}

.release-log-item summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.release-log-item summary::-webkit-details-marker {
  display: none;
}

.release-log-bullets {
  margin: 10px 0 0;
  padding-left: 18px;
}

.release-log-bullets li + li {
  margin-top: 6px;
}

.release-log-pre {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}

.backup-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
}

.backup-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fff;
  padding: 14px;
}

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