:root {
  color-scheme: light;

  --ink: #17211b;
  --muted: #647068;
  --line: #d9e0db;
  --paper: #f5f7f5;
  --card: #fff;

  --green: #1d6b4b;
  --green-soft: #e7f3ed;

  --amber: #8a5a08;
  --amber-soft: #fff3d8;

  --red: #9b2f2f;
  --red-soft: #fdeaea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 7px;
  background: var(--green);
  color: white;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.5rem 0.65rem;
  background: white;
}


/* =========================================================
   TOP NAVIGATION
   ========================================================= */

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.75rem max(1rem, calc((100vw - 1200px) / 2));
  background: #10271d;
  color: white;
}

.topbar a {
  color: white;
  text-decoration: none;
}

.brand {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.topbar nav {
  display: flex;
  gap: 1rem;
}

.global-search {
  display: flex;
  flex: 1;
  max-width: 440px;
  margin-left: auto;
}

.global-search input {
  min-width: 0;
  flex: 1;
  border-radius: 7px 0 0 7px;
}

.global-search button {
  border-radius: 0 7px 7px 0;
  background: #dcebe3;
  color: #173d2b;
}

.identity {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-size: 0.88rem;
}

.identity form {
  margin: 0;
}

.link-button {
  padding: 0.3rem;
  min-height: 36px;
  background: transparent;
  text-decoration: underline;
}


/* =========================================================
   PAGE STRUCTURE
   ========================================================= */

.container {
  width: min(1200px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.heading-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.button-link {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  padding: 0.55rem 0.9rem;
  background: var(--green);
  color: white;
  text-decoration: none;
}

.secondary-button {
  border: 1px solid var(--line);
  background: white;
  color: var(--green);
}

.edit-mouse-panel {
  max-width: 850px;
}

.read-only-context {
  display: grid;
  gap: 0.15rem;
  margin-bottom: 1rem;
  border-left: 4px solid var(--green);
  padding: 0.65rem 0.8rem;
  background: var(--green-soft);
}

.read-only-context span,
.read-only-context small {
  color: var(--muted);
}

.field-error {
  margin: 0.2rem 0 0;
  color: var(--red);
  font-size: 0.78rem;
}

.edit-mouse-form .form-actions {
  justify-content: flex-end;
}

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

h1 {
  margin-bottom: 0.2rem;
  font-size: clamp(1.8rem, 4vw, 2.5rem);
}

h2 {
  margin-bottom: 0.7rem;
  font-size: 1.1rem;
}

h3 {
  margin-bottom: 0.5rem;
}

.eyebrow {
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.subtle {
  color: var(--muted);
  font-size: 0.84rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}


/* =========================================================
   GENERIC CARDS / PANELS
   ========================================================= */

.metric,
.panel,
.cage-card,
.result,
.empty-state,
.alert,
.success,
.warning {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  padding: 1rem;
  box-shadow: 0 2px 8px rgb(20 45 32 / 5%);
}

.panel {
  margin-top: 0.85rem;
}

.compact-panel {
  padding: 0.9rem 1rem;
}

.notice {
  color: var(--muted);
  border-left: 3px solid var(--line);
  padding-left: 0.8rem;
  margin-bottom: 0;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.section-heading p {
  margin-bottom: 0;
}

.compact-heading {
  margin-bottom: 0.65rem;
}

.compact-heading h2 {
  margin-bottom: 0.15rem;
}


/* =========================================================
   DASHBOARD METRICS
   ========================================================= */

.metric-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.metric {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--ink);
}

.metric strong {
  font-size: 2rem;
}

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

.metric.warning {
  background: var(--amber-soft);
  border-color: #ebcf92;
}

.dashboard-section + .dashboard-section,
.system-status-panel {
  margin-top: 0.9rem;
}

.dashboard-section-heading h2 {
  margin-bottom: 0.45rem;
  color: #3f5147;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dashboard-section .metric-grid:not(.task-metric-grid) .metric {
  min-height: 108px;
  justify-content: center;
}

.dashboard-section .metric[href] {
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.dashboard-section .metric[href]:hover,
.dashboard-section .metric[href]:focus-visible {
  border-color: #afc7ba;
  box-shadow: 0 4px 12px rgb(20 45 32 / 9%);
}

.task-metric-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  width: min(100%, 640px);
}

.task-metric {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: baseline;
  gap: 0.65rem;
  min-height: 0;
  padding: 0.65rem 0.8rem;
}

.task-metric strong {
  font-size: 1.45rem;
  line-height: 1;
}

.task-metric span {
  font-size: 0.86rem;
  font-weight: 650;
}

.system-status-panel {
  padding: 0.75rem 0.9rem 0.7rem;
}

.system-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.35rem 1.15rem;
  margin: 0;
}

.system-status-grid > div {
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.34rem 0;
  border-bottom: 1px solid #e8ede9;
}

.system-status-grid dt {
  min-width: 0;
  font-size: 0.75rem;
}

.system-status-grid dd {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.system-status-grid .status-warning {
  color: var(--amber);
}

.system-status-footnote {
  display: flex;
  align-items: baseline;
  gap: 0.45rem;
  margin: 0.48rem 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.system-status-footnote strong {
  color: #536159;
  font-size: inherit;
}

.system-status-panel .notice {
  margin-top: 0.6rem;
  font-size: 0.8rem;
}


/* =========================================================
   GENERIC DETAILS / SYNC
   ========================================================= */

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

.sync-grid div {
  display: flex;
  flex-direction: column;
}

.sync-grid span,
dt {
  color: var(--muted);
  font-size: 0.78rem;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.details div {
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--line);
}

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


/* =========================================================
   FILTERS
   ========================================================= */

.filters {
  display: flex;
  align-items: end;
  gap: 0.7rem;
  flex-wrap: wrap;
  padding: 1rem;
  margin-bottom: 1rem;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.filters a {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0.5rem;
}


/* =========================================================
   TABLES
   ========================================================= */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

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

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

th {
  background: #edf2ee;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td small {
  display: block;
  color: var(--muted);
}

.empty-cell {
  text-align: center;
  padding: 2rem;
  color: var(--muted);
}


/* =========================================================
   STATUS / BADGES
   ========================================================= */

.badge,
.status,
.exact {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: #edf2ee;
  color: #34473c;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.status-synced {
  background: var(--green-soft);
  color: var(--green);
}

.status-conflict,
.status-error,
.status-missing_remote {
  background: var(--red-soft);
  color: var(--red);
}

.status-stale {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-superseded {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-voided {
  background: var(--red-soft);
  color: var(--red);
}


/* =========================================================
   CAGE CARDS
   ========================================================= */

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

.cage-card {
  color: var(--ink);
  text-decoration: none;
}

.cage-card > div {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.cage-card > div > strong {
  font-size: 1.15rem;
}

.cage-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0;
}


/* =========================================================
   SEARCH RESULTS
   ========================================================= */

.result-list {
  display: grid;
  gap: 0.65rem;
}

.result {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.75rem;
  color: var(--ink);
  text-decoration: none;
}

.result > span:not(.badge):not(.exact),
.result small {
  color: var(--muted);
}

.result .exact {
  position: absolute;
  right: 1rem;
  top: 1rem;
  color: var(--green);
  background: var(--green-soft);
}

.result small {
  grid-column: 2;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  min-height: 44px;
}


/* =========================================================
   ALERTS
   ========================================================= */

.alert {
  background: var(--red-soft);
  border-color: #efb9b9;
  margin-bottom: 1rem;
}

.success {
  background: var(--green-soft);
  border-color: #b7ddc9;
  margin-bottom: 1rem;
}

.warning {
  background: var(--amber-soft);
  border-color: #ebcf92;
  margin-bottom: 1rem;
}

.alert p:last-child,
.success p:last-child,
.warning p:last-child {
  margin-bottom: 0;
}


/* =========================================================
   MOUSE DETAIL — COMPACT OVERVIEW
   ========================================================= */

.mouse-overview-panel {
  padding: 0.9rem 1rem;
}

.mouse-overview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.info-item {
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
}

.info-item dt {
  margin-bottom: 0.12rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.info-item dd {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 650;
  line-height: 1.3;
}

.info-item-wide {
  grid-column: span 2;
}


/* =========================================================
   MOUSE DETAIL — SUMMARY ROW
   ========================================================= */

.mouse-summary-grid {
  display: grid;
  grid-template-columns:
    minmax(180px, 0.85fr)
    minmax(340px, 1.65fr)
    minmax(220px, 1fr);
  gap: 0.85rem;
  align-items: stretch;
  margin-top: 0.85rem;
}

.mouse-summary-grid > .panel {
  margin-top: 0;
}

.quick-info-panel,
.weight-panel,
.pedigree-panel {
  min-width: 0;
}

.quick-info-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.quick-info-list > div {
  display: grid;
  grid-template-columns: minmax(90px, 0.9fr) minmax(0, 1.1fr);
  gap: 0.6rem;
  align-items: baseline;
  padding: 0.43rem 0;
  border-bottom: 1px solid #edf1ee;
}

.quick-info-list > div:last-child {
  border-bottom: 0;
}

.quick-info-list dt {
  font-size: 0.76rem;
}

.quick-info-list dd {
  text-align: right;
  font-weight: 650;
}

.latest-weight {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.latest-weight strong {
  color: var(--green);
  font-size: 1.5rem;
  line-height: 1.05;
}

.latest-weight span {
  color: var(--muted);
  font-size: 0.74rem;
  margin-top: 0.18rem;
}

.weight-chart {
  height: 300px;
  margin: 1rem 0;
}

.compact-weight-chart {
  height: 230px;
  margin: 0.45rem 0 0;
}


/* =========================================================
   EVENT HISTORY
   ========================================================= */

.timeline-panel {
  padding-bottom: 0.7rem;
}

.timeline-panel .section-heading {
  margin-bottom: 0.25rem;
}

.timeline-panel .section-heading p {
  margin-bottom: 0;
}

.timeline {
  position: relative;
  list-style: none;
  padding: 0;
  margin: 0;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 0.7rem;
  bottom: 0.7rem;
  left: 9.7rem;
  width: 2px;
  background: var(--line);
}

.timeline-event {
  position: relative;
  display: grid;
  grid-template-columns: 9rem minmax(0, 1fr);
  gap: 1.5rem;
  padding: 0.62rem 0;
}

.timeline-event::before {
  content: "";
  position: absolute;
  top: 0.9rem;
  left: 9.35rem;
  width: 0.65rem;
  height: 0.65rem;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 1px var(--line);
}

.timeline-event + .timeline-event {
  border-top: 1px solid #edf1ee;
}

.timeline-when {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
  padding-top: 0.06rem;
  text-align: right;
}

.timeline-content {
  min-width: 0;
  overflow-wrap: anywhere;
}

.timeline-content h3 {
  margin: 0.2rem 0 0.08rem;
  font-size: 0.95rem;
}

.timeline-content p {
  margin: 0;
}

.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.timeline-summary {
  color: #36453d;
  font-size: 0.86rem;
  line-height: 1.38;
}

.timeline-actor {
  color: var(--muted);
  font-size: 0.76rem;
  margin-top: 0.18rem !important;
}

.timeline-incident::before {
  background: var(--red);
}

.timeline-weight::before {
  background: #386a9a;
}

.timeline-lifecycle::before {
  background: var(--amber);
}


/* =========================================================
   WEIGHT ENTRY / WORKFLOW FORMS
   ========================================================= */

.workflow-section {
  margin-top: 0.9rem;
}

.workflow-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem;
  align-items: end;
}

.workflow-form label,
.stacked label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.workflow-form .wide,
.workflow-form button {
  grid-column: 1 / -1;
}

.compact-workflow-form {
  grid-template-columns:
    minmax(130px, 0.7fr)
    minmax(210px, 1fr)
    minmax(220px, 1.5fr)
    auto;
  gap: 0.7rem;
}

.compact-workflow-form .wide,
.compact-workflow-form button {
  grid-column: auto;
}

.compact-workflow-form button {
  align-self: end;
  white-space: nowrap;
}

.record-weight-panel {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}

.record-weight-panel h2 {
  margin-bottom: 0.5rem;
}

.stacked {
  display: grid;
  gap: 0.8rem;
}

.compact {
  min-width: 240px;
  padding: 0.65rem 0;
}


/* =========================================================
   HOUSING
   ========================================================= */

.housing-panel > p {
  margin-bottom: 0.35rem;
}

.compact-details {
  margin-top: 0.55rem;
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
}

.compact-details summary {
  width: max-content;
  max-width: 100%;
  color: var(--green);
  font-weight: 700;
  cursor: pointer;
}

.compact-details ul {
  margin: 0.55rem 0 0;
  padding-left: 1.3rem;
}

.compact-details li {
  padding: 0.2rem 0;
}


/* =========================================================
   MOVEMENT / INCIDENT WORKFLOW SUPPORT
   ========================================================= */

.mock-banner,
.disabled-banner {
  color: var(--amber);
  background: var(--amber-soft);
  border-left: 3px solid #d29a2e;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.7rem;
}

.checkbox {
  display: inline-flex !important;
  width: max-content;
  max-width: 100%;
  grid-template-columns: auto 1fr;
  align-items: center;
  margin-right: 1rem;
  color: var(--ink) !important;
}

.checkbox input {
  width: auto;
  min-height: auto;
}

.workflow-form fieldset {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.8rem;
}

.workflow-form .form-fields {
  border: 0;
  padding: 0;
  margin: 0;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.wrap {
  min-width: 220px;
  white-space: normal;
  overflow-wrap: anywhere;
}


/* =========================================================
   CAGE DETAIL — DENSE OPERATIONAL OVERVIEW
   ========================================================= */

.cage-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.cage-identity,
.cage-sync,
.cage-quick-actions,
.cage-quick-actions > div,
.occupant-list {
  display: flex;
  align-items: center;
}

.cage-identity {
  min-width: 0;
  gap: 0.7rem;
}

.cage-identity h1 {
  margin: 0;
}

.cage-status {
  background: var(--green-soft);
  color: var(--green);
}

.cage-sync {
  flex: 0 0 auto;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.cage-sync strong {
  color: currentColor;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.cage-sync-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: currentColor;
}

.cage-sync.status-synced {
  color: var(--green);
}

.cage-sync.status-conflict,
.cage-sync.status-error,
.cage-sync.status-missing_remote {
  color: var(--red);
}

.cage-sync.status-stale {
  color: var(--amber);
}

.cage-overview {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  box-shadow: 0 2px 8px rgb(20 45 32 / 4%);
}

.cage-info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.cage-info-grid > div {
  min-width: 0;
  padding: 0.58rem 0.8rem;
  border-right: 1px solid var(--line);
  background: #fbfcfb;
}

.cage-info-grid > div:last-child {
  border-right: 0;
}

.cage-info-grid dt,
.cage-notes h2 {
  margin-bottom: 0.12rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cage-info-grid dd {
  font-size: 0.9rem;
  font-weight: 650;
}

.cage-notes {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: baseline;
  padding: 0.5rem 0.8rem;
  border-top: 1px solid var(--line);
}

.cage-notes h2,
.cage-notes p {
  margin: 0;
}

.cage-notes p {
  color: #46534b;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.cage-occupancy,
.cage-operation {
  padding: 0.85rem 0.95rem;
}

.cage-occupancy {
  border-color: #b9cdc1;
}

.cage-occupancy .compact-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.cage-occupancy .compact-heading strong {
  color: var(--ink);
}

.occupant-list {
  flex-wrap: wrap;
  gap: 0.45rem;
  min-height: 2rem;
}

.occupant-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 34px;
  padding: 0.38rem 0.62rem;
  border: 1px solid #bfd2c6;
  border-radius: 7px;
  background: var(--green-soft);
  color: #174f39;
  text-decoration: none;
}

.occupant-chip:hover,
.occupant-chip:focus-visible {
  border-color: var(--green);
}

.occupant-chip span {
  color: var(--muted);
  font-size: 0.73rem;
}

.cage-context-strips {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.65rem;
}

.context-strip {
  margin: 0;
  padding: 0.38rem 0.55rem;
  border-left: 3px solid #c9d2cc;
  background: #f5f7f5;
  color: var(--muted);
  font-size: 0.74rem;
}

.context-strip-alert {
  grid-column: 1 / -1;
  border-color: #d87878;
  background: var(--red-soft);
  color: var(--red);
}

.context-strip-warning {
  border-color: #d7a64a;
  background: #fff9eb;
  color: #70531a;
}

.cage-occupancy > .context-strip {
  margin-top: 0.6rem;
}

.cage-quick-actions {
  gap: 0.8rem;
  margin-top: 0.65rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef3ef;
}

.cage-quick-actions > strong {
  flex: 0 0 auto;
  color: #4b5d52;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.cage-quick-actions > div {
  flex-wrap: wrap;
  gap: 0.4rem;
}

.cage-quick-actions a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.3rem 0.6rem;
  border: 1px solid #bdd0c4;
  border-radius: 6px;
  background: white;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
}

.cage-operation:focus,
.incident-entry:focus {
  outline: 2px solid #8ab29c;
  outline-offset: 2px;
}

.cage-operation h2 {
  margin-bottom: 0.55rem;
}

.cage-move-fields {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem 0.65rem;
}

.cage-move-fields .checkbox-group {
  grid-column: 1 / -1;
}

.cage-move-fields button {
  grid-column: 1 / -1;
  width: max-content;
}

.cage-weight-form {
  gap: 0.6rem;
}

.weight-time-field {
  width: min(100%, 320px);
}

.cage-weight-table th,
.cage-weight-table td,
.incident-history th,
.incident-history td {
  padding: 0.48rem 0.6rem;
}

.cage-weight-table th:first-child {
  width: 20%;
}

.cage-weight-table th:nth-child(2) {
  width: 25%;
}

.cage-weight-table td:first-child a {
  font-weight: 750;
}

.cage-weight-table input {
  min-height: 36px;
  padding-block: 0.35rem;
}

.cage-weight-form button {
  width: max-content;
}

.incident-entry {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
}

.incident-entry h3 {
  margin-bottom: 0.6rem;
  font-size: 0.95rem;
}

.cage-incident-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.7rem;
}

.cage-incident-form textarea {
  min-height: 76px;
}

.cage-incident-form button {
  width: max-content;
}


/* =========================================================
   LOGIN
   ========================================================= */

.login-shell {
  max-width: 460px;
  padding-top: 8vh;
}

.login-shell form {
  display: grid;
  gap: 1rem;
}

.login-shell form label {
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
}

.login-shell form button {
  width: 100%;
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 850px) {

  .topbar {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .global-search {
    order: 3;
    max-width: none;
    flex-basis: 100%;
  }

  .identity {
    margin-left: auto;
  }

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

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

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

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

  .info-item-wide {
    grid-column: span 2;
  }

  .mouse-summary-grid {
    grid-template-columns: minmax(180px, 0.8fr) minmax(0, 1.8fr);
  }

  .pedigree-panel {
    grid-column: 1 / -1;
  }

  .pedigree-panel .quick-info-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
  }

  .pedigree-panel .quick-info-list > div {
    display: block;
    border-bottom: 0;
    padding: 0;
  }

  .pedigree-panel .quick-info-list dd {
    text-align: left;
    margin-top: 0.15rem;
  }

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

  .compact-workflow-form .wide,
  .compact-workflow-form button {
    grid-column: auto;
  }

  .compact-workflow-form .wide {
    grid-column: 1 / -1;
  }

  .compact-workflow-form button {
    grid-column: 1 / -1;
  }

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

  .cage-info-grid > div:nth-child(2) {
    border-right: 0;
  }

  .cage-info-grid > div:last-child {
    grid-column: 1 / -1;
    border-top: 1px solid var(--line);
  }

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


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 560px) {

  body {
    font-size: 14px;
  }

  .topbar nav {
    order: 2;
    width: 100%;
    justify-content: space-between;
  }

  .identity {
    position: absolute;
    right: 1rem;
    top: 0.65rem;
    flex-direction: column;
    align-items: end;
    gap: 0;
  }

  .identity span {
    max-width: 145px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .container {
    width: min(100% - 0.8rem, 1200px);
    padding-top: 1rem;
  }

  .page-heading {
    margin-bottom: 0.7rem;
  }

  .panel,
  .metric,
  .cage-card,
  .result,
  .empty-state,
  .alert,
  .success,
  .warning {
    padding: 0.8rem;
  }

  .metric-grid,
  .card-grid,
  .sync-grid,
  .details,
  .workflow-form {
    grid-template-columns: 1fr;
  }

  .system-status-grid {
    grid-template-columns: 1fr;
  }

  .details .wide,
  .workflow-form .wide,
  .workflow-form button {
    grid-column: auto;
  }

  .filters {
    align-items: stretch;
  }

  .filters label {
    flex: 1 1 45%;
  }

  .page-heading,
  .section-heading {
    align-items: flex-start;
  }

  .section-heading {
    flex-direction: column;
    gap: 0.35rem;
  }

  .latest-weight {
    align-items: flex-start;
  }

  .cage-card {
    min-height: 150px;
  }

  .result .exact {
    position: static;
    width: max-content;
    grid-column: 2;
  }

  .pagination {
    gap: 1rem;
  }


  /* Mouse overview remains compact on mobile */

  .mouse-overview-panel {
    padding: 0.7rem;
  }

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

  .info-item {
    padding: 0.55rem 0.6rem;
  }

  .info-item dt {
    font-size: 0.67rem;
  }

  .info-item dd {
    font-size: 0.85rem;
  }

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


  /* Main mouse cards stack */

  .mouse-summary-grid {
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .pedigree-panel {
    grid-column: auto;
  }

  .pedigree-panel .quick-info-list {
    grid-template-columns: 1fr;
  }

  .quick-info-list > div,
  .pedigree-panel .quick-info-list > div {
    display: grid;
    grid-template-columns: minmax(90px, 0.9fr) minmax(0, 1.1fr);
    gap: 0.5rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid #edf1ee;
  }

  .quick-info-list dd,
  .pedigree-panel .quick-info-list dd {
    text-align: right;
    margin-top: 0;
  }

  .cage-detail-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .cage-identity {
    flex-wrap: wrap;
  }

  .cage-sync {
    flex-wrap: wrap;
  }

  .cage-info-grid,
  .cage-context-strips,
  .cage-move-fields,
  .cage-incident-form {
    grid-template-columns: 1fr;
  }

  .cage-info-grid > div,
  .cage-info-grid > div:nth-child(2),
  .cage-info-grid > div:last-child {
    grid-column: auto;
    border-top: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .cage-notes {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  .context-strip-alert,
  .cage-move-fields .checkbox-group,
  .cage-incident-form .wide,
  .cage-incident-form button {
    grid-column: auto;
  }

  .cage-quick-actions {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.4rem;
  }

  .cage-quick-actions > div {
    width: 100%;
  }

  .cage-quick-actions a {
    flex: 1 1 auto;
    justify-content: center;
  }

  .cage-weight-table {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .cage-weight-table table,
  .cage-weight-table tbody,
  .cage-weight-table tr,
  .cage-weight-table td {
    display: block;
    width: 100%;
  }

  .cage-weight-table thead {
    display: none;
  }

  .cage-weight-table tr {
    margin-bottom: 0.55rem;
    padding: 0.55rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
  }

  .cage-weight-table td {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, 1fr);
    gap: 0.5rem;
    align-items: center;
    padding: 0.25rem 0;
    border: 0;
    white-space: normal;
  }

  .cage-weight-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
  }

  .cage-weight-table td:first-child a {
    font-size: 0.9rem;
  }

  .cage-weight-form button,
  .cage-move-fields button,
  .cage-incident-form button {
    width: 100%;
  }

  .compact-weight-chart {
    height: 220px;
  }


  /* Timeline becomes a compact single-column stream */

  .timeline::before {
    left: 0.3rem;
  }

  .timeline-event {
    grid-template-columns: 1fr;
    gap: 0.12rem;
    padding: 0.7rem 0 0.7rem 1.35rem;
  }

  .timeline-event::before {
    left: 0;
    top: 0.85rem;
  }

  .timeline-when {
    text-align: left;
    font-size: 0.72rem;
  }

  .timeline-content h3 {
    margin-top: 0.25rem;
  }

  .timeline-summary {
    font-size: 0.82rem;
  }


  /* Record weight */

  .compact-workflow-form {
    grid-template-columns: 1fr;
  }

  .compact-workflow-form .wide,
  .compact-workflow-form button {
    grid-column: auto;
  }


  /* Inputs stay finger-friendly */

  button,
  input,
  select,
  textarea {
    min-height: 42px;
  }
}
