:root {
  --paper: #fff3ec;
  --surface: #fffdf9;
  --ink: #392b28;
  --muted: #776764;
  --line: #ead8cf;
  --teal: #168179;
  --teal-dark: #0f5d57;
  --blue: #3f6fb6;
  --red: #c94f63;
  --rose: #e66f83;
  --coral: #de7052;
  --sun: #e5aa43;
  --image-two-cream: #fff7f0;
  --image-two-blush: #ffe3df;
  --image-two-cocoa: #8a7069;
  --amber: #af6f24;
  --green: #3a7b53;
  --shadow: 0 18px 55px rgba(98, 50, 36, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 239, 230, 0.88)),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: rgba(255, 246, 240, 0.93);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

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

.brand-logo {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: cover;
  object-position: center;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(98, 50, 36, 0.12);
}

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

.brand span {
  color: var(--muted);
  font-size: 13px;
}

.view-nav {
  display: flex;
  gap: 8px;
  padding: 4px;
  background: #f5dfd5;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.view-nav button {
  min-width: 88px;
  padding: 10px 12px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.view-nav button.is-active {
  background: #fffaf6;
  color: var(--ink);
  box-shadow: 0 4px 18px rgba(166, 77, 60, 0.16);
}

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

.offline-status {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf6;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.offline-status.is-offline {
  color: var(--amber);
}

.install-button {
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--rose), var(--coral));
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}

.install-button:disabled {
  cursor: default;
  opacity: 0.72;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 280px) 1fr;
  gap: 22px;
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.filter-panel,
.panel,
.pet-detail,
.application-drawer {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filter-panel {
  position: sticky;
  top: 92px;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px;
}

.section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.section-title p {
  margin: 0 0 4px;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.section-title h1,
.section-title h2 {
  margin: 0;
}

.section-title span,
.save-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fffaf6;
  color: var(--ink);
  padding: 12px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(230, 111, 131, 0.26);
  outline-offset: 2px;
}

.adopt-view {
  display: grid;
  grid-template-columns: minmax(280px, 410px) minmax(0, 1fr);
  gap: 22px;
}

.home-hero {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 360px);
  gap: 22px;
  overflow: hidden;
  min-height: 250px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(120deg, rgba(255, 247, 240, 0.96), rgba(255, 227, 223, 0.92)),
    var(--image-two-cream);
  box-shadow: var(--shadow);
}

.home-hero-copy {
  display: grid;
  align-content: center;
  gap: 14px;
}

.home-hero-copy p {
  margin: 0;
  color: var(--coral);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.home-hero-copy h2 {
  max-width: 760px;
  margin: 0;
  color: var(--ink);
  font-size: clamp(42px, 7vw, 86px);
  line-height: 0.98;
}

.home-hero-copy span {
  max-width: 680px;
  color: var(--image-two-cocoa);
  font-size: 17px;
  line-height: 1.65;
}

.hero-stat-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.hero-stat-row strong {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.72);
  color: var(--ink);
  font-size: 13px;
}

.home-hero-photo {
  position: relative;
  min-height: 220px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--image-two-blush);
}

.home-hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.home-hero-photo span {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 253, 249, 0.82);
  color: var(--coral);
  font-size: 12px;
  font-weight: 900;
}

.pet-list {
  display: grid;
  gap: 14px;
  align-content: start;
}

.pet-card {
  position: relative;
  display: grid;
  grid-template-columns: 128px 1fr;
  min-height: 150px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 32px rgba(98, 50, 36, 0.1);
}

.pet-card.is-selected {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(230, 111, 131, 0.18), var(--shadow);
}

.pet-card img,
.detail-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #ddd7cb;
}

.pet-card-body {
  display: grid;
  gap: 8px;
  padding: 14px;
}

.pet-card h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

.pet-card p,
.story,
.apply-panel p,
.insight-grid p,
.insight-grid small {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.card-topline,
.score-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score-row strong {
  color: var(--coral);
}

.country,
.freshness,
.tag-row span,
.summary-strip span {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 800;
}

.country.sg {
  background: rgba(63, 111, 182, 0.13);
  color: var(--blue);
}

.country.my {
  background: rgba(201, 79, 99, 0.14);
  color: var(--red);
}

.freshness.fresh,
.freshness.closed,
.note-list .ok {
  background: rgba(36, 116, 72, 0.12);
  color: var(--green);
}

.freshness.watch,
.note-list .info {
  background: rgba(63, 111, 182, 0.13);
  color: var(--blue);
}

.freshness.stale,
.note-list .warning,
.note-list .required {
  background: rgba(178, 106, 31, 0.13);
  color: var(--amber);
}

.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf7;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
}

.pet-card .favourite {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  background: rgba(255, 250, 247, 0.92);
}

.favourite.is-on {
  color: var(--rose);
}

.pet-detail {
  overflow: hidden;
  min-height: 760px;
}

.detail-hero {
  display: grid;
  grid-template-columns: minmax(260px, 45%) 1fr;
  gap: 24px;
  min-height: 330px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.detail-hero img {
  border-radius: 8px;
  min-height: 330px;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.detail-title h1 {
  margin: 10px 0 4px;
  font-size: clamp(38px, 5vw, 74px);
  line-height: 0.98;
}

.fit-meter {
  display: grid;
  align-content: center;
  min-width: 116px;
  height: 116px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
}

.fit-meter strong {
  font-size: 28px;
}

.fit-meter span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.fit-meter.strong {
  background: rgba(58, 123, 83, 0.13);
}

.fit-meter.good {
  background: rgba(63, 111, 182, 0.13);
}

.fit-meter.review {
  background: rgba(178, 106, 31, 0.13);
}

.fit-meter.blocked {
  background: rgba(189, 59, 66, 0.12);
}

.tag-row,
.summary-strip,
.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.tag-row span,
.summary-strip span {
  background: #f7e5da;
  color: var(--ink);
}

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

.panel {
  padding: 18px;
}

.panel h2,
.apply-panel h2 {
  margin: 0 0 12px;
  font-size: 22px;
}

.reason-list,
.note-list,
.application-drawer ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.reason-list li,
.note-list li,
.application-drawer li {
  padding: 12px;
  border-radius: 6px;
  background: #fff1e9;
  color: var(--muted);
  line-height: 1.45;
}

.apply-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 22px 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #fff7ee, #ffe9e8);
}

.primary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--rose), var(--coral));
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.primary-action:hover {
  background: linear-gradient(135deg, #d85e74, #cb6145);
}

.primary-action:disabled {
  cursor: not-allowed;
  background: #a9b1ad;
}

.passport-view,
.rescue-view,
.insight-view {
  display: none;
}

body[data-view="passport"] .adopt-view,
body[data-view="rescue"] .adopt-view,
body[data-view="insight"] .adopt-view {
  display: none;
}

body[data-view="passport"] .passport-view,
body[data-view="rescue"] .rescue-view,
body[data-view="insight"] .insight-view {
  display: grid;
  gap: 18px;
}

body[data-view="passport"] .filter-panel,
body[data-view="rescue"] .filter-panel,
body[data-view="insight"] .filter-panel {
  display: none;
}

body[data-view="passport"] .workspace,
body[data-view="rescue"] .workspace,
body[data-view="insight"] .workspace {
  grid-template-columns: 1fr;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.check-card {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf7;
}

.check-card input {
  width: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.insight-grid article {
  min-height: 220px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf7;
}

.insight-grid h3 {
  margin: 0 0 10px;
}

.insight-grid small {
  display: block;
  margin-top: 14px;
  color: var(--amber);
}

.application-drawer {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  display: grid;
  gap: 14px;
  width: min(460px, calc(100vw - 44px));
  padding: 18px;
}

.application-drawer .close {
  position: absolute;
  top: 12px;
  right: 12px;
}

.application-drawer p {
  margin: 0;
  color: var(--coral);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.application-drawer h2 {
  margin: 0;
  padding-right: 42px;
}

.application-drawer textarea {
  min-height: 132px;
  resize: vertical;
}

.empty-state {
  display: grid;
  min-height: 300px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1160px) {
  .workspace,
  .adopt-view,
  .home-hero,
  .detail-hero,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    position: static;
  }

  .pet-detail {
    min-height: auto;
  }

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

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px;
  }

  .pwa-actions {
    width: 100%;
  }

  .install-button,
  .offline-status {
    flex: 1;
    justify-content: center;
  }

  .view-nav {
    width: 100%;
    overflow-x: auto;
  }

  .view-nav button {
    min-width: 78px;
  }

  .workspace {
    padding: 14px;
  }

  .home-hero {
    padding: 18px;
  }

  .home-hero-copy h2 {
    font-size: 42px;
  }

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

  .pet-card h2 {
    font-size: 19px;
  }

  .detail-title,
  .apply-panel {
    flex-direction: column;
    align-items: flex-start;
  }

  .fit-meter {
    width: 100%;
    height: auto;
    min-height: 86px;
  }

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