:root {
  --bg: #f3f6f8;
  --surface: #ffffff;
  --ink: #1b2a33;
  --muted: #5a6a73;
  --accent: #d96f27;
  --accent-soft: #fff3e8;
  --navy-2: #173d4b;
  --line: #d6e0e6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
}

.app-shell {
  max-width: 980px;
  margin: 0 auto;
  background: var(--bg);
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #12303b;
  color: #fff;
}

.appbar {
  z-index: 20;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset;
}

.app-menu {
  background: #173d4b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 12px;
}

.app-menu-item {
  display: block;
  color: #e7f2f7;
  text-decoration: none;
  padding: 10px 8px;
  border-radius: 8px;
  font-weight: 600;
}

.app-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.menu-btn {
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.06);
  color: #e7f2f7;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.appbar-spacer {
  width: 34px;
  height: 34px;
}

.topbar a {
  color: #e7f2f7;
  margin-left: 12px;
  text-decoration: none;
}

.title {
  font-weight: 700;
  font-size: 1.26rem;
  letter-spacing: 0.01em;
}

.title-link {
  color: #ffffff;
  text-decoration: none;
}
.top-links {
  display: flex;
  align-items: center;
}

.container {
  padding: 10px;
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: 78px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 8px;
  box-shadow: 0 1px 0 rgba(12, 24, 32, 0.03);
}

h1 { margin: 0 0 2px; font-size: 1.28rem; line-height: 1.15; }
.muted { color: var(--muted); font-size: 0.98rem; }
.strong { font-weight: 700; }
.list { margin-top: 8px; }

.animal-page > .card:first-child {
  padding-top: 8px;
  padding-bottom: 8px;
}

.animal-page > .card:first-child h1 {
  margin-bottom: 0;
  line-height: 1.05;
}

.animal-page > .card:first-child .muted {
  margin: 4px 0 0;
}
.rowlink {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background-color 0.14s ease, transform 0.08s ease;
}

.rowlink:active {
  transform: scale(0.995);
  border-color: #dfb494;
  box-shadow: 0 0 0 2px rgba(217, 111, 39, 0.18);
  background: #fff8f2;
}

.rowlink.rowlink-selected {
  border-color: #d96f27;
  box-shadow: 0 0 0 2px rgba(217, 111, 39, 0.34);
  background: #fff7f0;
}

.chip {
  background: #f7fafc;
  color: #435966;
  border: 1px solid #ccd9e2;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.82rem;
  font-weight: 700;
}

.chip-death {
  background: #fbe9e9;
  color: #9f1f1f;
  border-color: #e4a3a3;
}

.chip-zero {
  background: #f1f4f6;
  color: #5a6a73;
  border-color: #cbd6dd;
  font-weight: 600;
}

.date-cell {
  white-space: nowrap;
}

.death-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid #b83838;
  background: #fbe9e9;
  color: #b52121;
  font-size: 0.68rem;
  line-height: 1;
  font-weight: 700;
  vertical-align: middle;
}

.timeline {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.event-flow-card {
  padding: 8px 10px;
}

.event-flow {
  position: relative;
  display: block;
  overflow-x: auto;
  padding: 6px 2px 2px;
}

.event-flow::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: #d6e0e6;
  transform: translateY(-50%);
  z-index: 0;
}

.event-flow-dot {
  position: relative;
  z-index: 1;
  min-width: 23px;
  height: 23px;
  border-radius: 999px;
  border: 1px solid #b8c7d0;
  background: #ffffff;
  color: #5a6a73;
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.event-flow-track {
  display: inline-flex;
  align-items: flex-start;
  gap: 14px;
  min-width: 100%;
  padding-right: 6px;
}

.event-flow-node {
  position: relative;
  z-index: 1;
  min-width: 36px;
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.event-flow-code {
  font-size: 0.64rem;
  font-weight: 800;
  color: #4b616d;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
}

.event-flow-dot-death {
  border-color: #b83838;
  background: #fbe9e9;
  color: #b52121;
}

.timeline-item {
  margin-bottom: 0;
  border-left: 4px solid #c4d2db;
  padding-left: 10px;
  scroll-margin-top: 74px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.timeline-item-death {
  border-left-color: #d67b7b;
  background: #fffcfc;
}

.timeline-item:target {
  border-left-color: #d96f27;
  box-shadow: 0 0 0 2px rgba(217, 111, 39, 0.32);
  background: #fff7f0;
}

.timeline-item:target .timeline-seq {
  border-color: #d96f27;
  color: #8b3d07;
  background: #fff2e8;
}

.timeline-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.timeline-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-seq {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid #b8c7d0;
  color: #5a6a73;
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.timeline-date {
  font-weight: 700;
  font-size: 1.15rem;
}

.timeline-badge {
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 2px 8px;
  border: 1px solid #e4a3a3;
  background: #fbe9e9;
  color: #9f1f1f;
}

.timeline-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 10px;
  font-size: 0.97rem;
}

.timeline-details .label {
  font-weight: 700;
  color: var(--muted);
}

@media (max-width: 767px) {
  .timeline-details {
    grid-template-columns: 1fr;
  }
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #12303b;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px 6px max(8px, env(safe-area-inset-bottom));
  z-index: 30;
}

.nav-item {
  text-decoration: none;
  color: #f2f7fa;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 4px 0;
  border-radius: 8px;
}

.nav-item.active {
  color: #ff9f57;
  background: rgba(255, 159, 87, 0.14);
}

.nav-icon {
  font-size: 1rem;
  line-height: 1;
  display: inline-block;
  font-weight: 700;
}

.nav-item.active .nav-icon {
  color: #ff9f57;
}

.rowlink-main {
  min-width: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 8px;
  margin-top: 5px;
}

.metric-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  background: #f7fafc;
  border: 1px solid #dce5eb;
  border-radius: 9px;
  padding: 5px 7px;
  font-size: 0.9rem;
}

.metric-k {
  color: #526874;
  font-weight: 700;
}

.metric-v {
  color: #1f2f39;
  font-weight: 700;
}

.metric-sub {
  font-size: 0.82rem;
  color: #5a6a73;
  font-weight: 600;
}

.view-switch {
  display: inline-flex;
  gap: 8px;
}

.switch-pill {
  text-decoration: none;
  border: 1px solid #cbd6dd;
  border-radius: 999px;
  padding: 5px 11px;
  color: #4b5d68;
  font-weight: 700;
  font-size: 0.9rem;
  background: #f5f8fa;
}

.switch-pill.active {
  border-color: #e6a172;
  background: var(--accent-soft);
  color: #8b3d07;
}

.pen-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 8px;
  margin-top: 5px;
}

.pen-overview-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 7px;
  border: 1px solid #d5e1e8;
  border-radius: 9px;
  background: #f7fafc;
}

.pen-overview-k {
  color: #5a6a73;
  font-weight: 700;
  font-size: 0.88rem;
}

.pen-overview-v {
  color: #1f2f39;
  font-weight: 700;
  font-size: 0.92rem;
}

.section-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 2px solid #e6edf2;
}

.section-bar-compact {
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.section-icon {
  min-width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid #c8d6e0;
  background: #eef4f8;
  color: #2b4654;
  font-size: 0.76rem;
  font-weight: 800;
}

.section-label {
  font-weight: 700;
  color: #4f6572;
  text-transform: uppercase;
  font-size: 0.74rem;
  letter-spacing: 0.05em;
}

.section-inline-card {
  padding-top: 8px;
  padding-bottom: 7px;
}

.trend-row {
  margin-top: 6px;
}

.trend-spark {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  letter-spacing: 1px;
  color: #2f4754;
}

@media (min-width: 1024px) {
  .bottom-nav {
    left: 50%;
    transform: translateX(-50%);
    max-width: 980px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
    border-right: 1px solid rgba(255, 255, 255, 0.12);
  }
}

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

input, select, button {
  font-size: 1rem;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 700;
}

@media (max-width: 520px) {
  body {
    font-size: 19px;
  }

  h1 {
    font-size: 1.42rem;
  }

  .timeline-details {
    font-size: 1.06rem;
  }

  .card {
    border-radius: 14px;
  }

  .section-icon {
    min-width: 24px;
    height: 24px;
  }

  .filters { grid-template-columns: 1fr; }
  .top-links {
    display: none;
  }

  .animal-page .card {
    padding: 10px;
    margin-bottom: 7px;
  }

  .animal-page h1 {
    font-size: 1.24rem;
  }

  .animal-page .muted {
    font-size: 0.93rem;
  }

  .animal-page > .card:first-child {
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .animal-page > .card:first-child .muted {
    margin-top: 3px;
  }

  .animal-page .event-flow-track {
    gap: 10px;
  }

  .animal-page .event-flow-node {
    min-width: 31px;
  }

  .animal-page .event-flow-code {
    font-size: 0.56rem;
  }

  .animal-page .timeline-item {
    padding-left: 8px;
    border-left-width: 3px;
  }

  .animal-page .timeline-head {
    margin-bottom: 5px;
  }

  .animal-page .timeline-date {
    font-size: 1.08rem;
  }

  .animal-page .timeline-details {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 3px 9px;
    font-size: 0.84rem;
    line-height: 1.24;
  }

  .animal-page .timeline-badge {
    font-size: 0.7rem;
    padding: 2px 7px;
  }
}

.table-wrap {
  overflow-x: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.history-table th,
.history-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.history-table th {
  color: var(--muted);
  font-weight: 700;
}

@media (max-width: 767px) {
  .history-table thead {
    display: none;
  }

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

  .history-table tr {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px;
    margin-bottom: 10px;
  }

  .history-table td {
    border: none;
    padding: 4px 0;
    white-space: normal;
  }

  .history-table td::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--muted);
  }
}
