:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d2430;
  --muted: #697386;
  --line: #dfe4ea;
  --primary: #2364aa;
  --primary-dark: #184a80;
  --green: #1d7f4f;
  --blue: #2364aa;
  --yellow: #9a6a00;
  --gray: #6b7280;
  --light-gray: #a3aab5;
  --danger: #b42318;
  --shadow: 0 10px 24px rgba(30, 41, 59, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 24px 32px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

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

h1 {
  font-size: 28px;
  font-weight: 760;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 16px;
}

.topbar p,
.empty p,
.notice p,
.muted-text {
  color: var(--muted);
}

.status {
  min-width: 88px;
  padding: 7px 12px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  gap: 20px;
  padding: 20px 32px 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel,
.output .panel {
  padding: 20px;
}

.input-panel {
  position: sticky;
  top: 16px;
  align-self: start;
}

.output {
  display: grid;
  gap: 16px;
}

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

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

.sub-form {
  display: grid;
  gap: 14px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.sub-form:first-of-type {
  margin-top: 0;
}

.section-subhead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  text-decoration: none;
}

button:hover {
  border-color: var(--primary);
}

.button-link:hover {
  border-color: var(--primary);
}

button.primary {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
}

button.primary:hover {
  background: var(--primary-dark);
}

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

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

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

.textareas {
  margin-top: 14px;
}

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

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

label small {
  color: var(--muted);
  font-size: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
}

textarea {
  resize: vertical;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(35, 100, 170, 0.18);
  border-color: var(--primary);
}

.analysis-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin: 18px 0 12px;
}

.analysis-head label {
  min-width: 160px;
}

.hidden {
  display: none;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.overview-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  min-height: 72px;
}

.overview-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.overview-item strong {
  font-size: 16px;
}

.current-pet-switcher,
.current-pet-context {
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 14px;
  padding: 10px 12px;
  background: #fafbfc;
  color: var(--muted);
  font-size: 13px;
}

.current-pet-switcher label {
  max-width: 360px;
}

.pet-card-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.pet-search-field {
  display: block;
  margin: 12px 0 16px;
}

.customer-link-panel {
  display: grid;
  gap: 12px;
  margin: 12px 0 16px;
  padding: 16px;
  border: 1px solid #c7dcf7;
  border-radius: 8px;
  background: #f3f8ff;
}

.customer-link-panel.hidden {
  display: none;
}

.customer-link-panel h3,
.customer-link-panel p {
  margin: 0;
}

.customer-qr-wrap {
  display: grid;
  justify-items: start;
  gap: 8px;
}

.customer-qr-wrap.hidden {
  display: none;
}

.customer-qr-wrap img {
  width: 160px;
  height: 160px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.pet-card,
.intake-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #ffffff;
}

.intake-card.resolved {
  background: #f8fafc;
}

.pet-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(35, 100, 170, 0.1);
}

.pet-card h3 {
  margin-bottom: 4px;
}

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

.pet-current-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 8px;
  background: #e8f1fb;
  color: var(--primary);
  font-size: 12px;
  font-weight: 750;
}

.pet-card p {
  color: var(--muted);
  font-size: 13px;
}

.pet-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trend-panel {
  margin-top: 16px;
}

.owner-note-panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.owner-note-panel textarea {
  margin-top: 12px;
}

.share-report-panel {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.post-confirm-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid #c7dcf7;
  border-radius: 8px;
  background: #f3f8ff;
}

.post-confirm-actions h3,
.post-confirm-actions p {
  margin: 0;
}

.post-confirm-actions.hidden {
  display: none;
}

.product-library-shell {
  display: grid;
  gap: 20px;
  padding: 20px 32px 32px;
}

.product-library-panel,
.product-score-panel {
  width: 100%;
}

.product-library-panel .overview-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.product-library-toolbar {
  display: grid;
  gap: 12px;
  margin: 16px 0;
}

.product-library-filters {
  display: grid;
  grid-template-columns: minmax(240px, 2fr) minmax(150px, 1fr) minmax(150px, 1fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.product-library-sortbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1fr) minmax(140px, 0.8fr);
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid #c7dcf7;
  border-radius: 8px;
  background: #f3f8ff;
}

.product-library-panel .table-wrap table,
.product-score-panel .table-wrap table {
  min-width: 900px;
}

.product-library-panel tbody tr:hover {
  background: #f8fafc;
}

.product-library-list-control {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #dbe5f2;
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.product-library-list-control .inline-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.product-library-list-control .inline-field span {
  white-space: nowrap;
}

.product-library-list-control select {
  min-height: 38px;
  padding: 6px 34px 6px 10px;
}

.product-library-list-control.hidden {
  display: none;
}

.product-library-page-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.product-library-page-actions button {
  white-space: nowrap;
}

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

.danger-text {
  color: #a6382b;
  border-color: #efc5bf;
  background: #fff8f7;
}

.danger-text:hover {
  border-color: #d67a70;
}

.muted-action {
  color: var(--muted);
  background: #f8fafc;
}

.product-library-hint {
  margin: 12px 0 0;
}

.workflow-hint {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.share-report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.share-report-head h3,
.share-report-head p {
  margin: 0;
}

.share-report-head p,
.share-expiry,
.share-qr-wrap p {
  color: var(--muted);
  font-size: 13px;
}

.share-url-field {
  display: block;
  margin-top: 14px;
}

.share-url-field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.share-url-field input {
  width: 100%;
  font-size: 14px;
}

.share-expiry {
  margin: 8px 0 0;
}

.share-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.danger-button {
  color: #a6382b;
  border-color: #efc5bf;
  background: #fff8f7;
}

.share-qr-wrap {
  margin-top: 14px;
  text-align: center;
}

.share-qr-wrap img {
  display: block;
  width: min(240px, 100%);
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--line);
  background: #ffffff;
}

.report-next-actions {
  position: sticky;
  bottom: 12px;
  z-index: 2;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 18px rgba(30, 41, 59, 0.08);
}

.trend-panel h3 {
  margin-bottom: 10px;
}

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

.trend-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #ffffff;
}

.trend-block h4 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.trend-block ul {
  display: grid;
  gap: 4px;
  margin: 0;
  padding-left: 18px;
  color: var(--text);
  font-size: 13px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

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

.score {
  font-weight: 800;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 760;
}

.tag.core {
  color: var(--green);
  background: #e7f5ed;
}

.tag.recommended {
  color: var(--blue);
  background: #e8f1fb;
}

.tag.auxiliary {
  color: var(--yellow);
  background: #fff4cf;
}

.tag.weak {
  color: var(--gray);
  background: #edf0f3;
}

.tag.not_applicable {
  color: var(--light-gray);
  background: #f4f5f6;
}

.label-groups {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

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

.recommend-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.recommend-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.recommend-item h3 {
  font-size: 15px;
}

.recommend-meta,
.scene-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.recommend-explain {
  margin: 10px 0;
}

.recommend-explain h4 {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.recommend-explain p,
.recommend-explain li {
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.recommend-explain ul {
  display: grid;
  gap: 3px;
  margin: 0;
  padding-left: 18px;
}

.scene-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  background: #fafbfc;
}

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

.confirm-block {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  min-height: 92px;
}

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

.confirm-block h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.confirm-block ul {
  display: grid;
  gap: 5px;
  padding: 0;
  margin: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

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

.mini-table {
  min-width: 560px;
}

.mini-table th,
.mini-table td {
  padding: 8px;
}

.label-group {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  min-height: 104px;
}

.label-group h3 {
  margin-bottom: 8px;
  font-size: 14px;
}

.label-group ul {
  display: grid;
  gap: 5px;
  padding: 0;
  margin: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

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

details {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0;
  background: #ffffff;
}

summary {
  cursor: pointer;
  padding: 12px;
  font-weight: 720;
}

.basis-content {
  border-top: 1px solid var(--line);
  padding: 12px;
  overflow-x: auto;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: #263241;
}

.notice {
  border-color: #f1d3cf;
  background: #fff8f7;
}

.notice h2 {
  color: var(--danger);
  margin-bottom: 8px;
}

.compact-notice {
  box-shadow: none;
  padding: 0;
}

.compact-notice summary {
  color: var(--danger);
  font-weight: 760;
}

.compact-notice p {
  padding: 0 12px 12px;
}

.care-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 20px;
  padding: 20px 32px 32px;
}

.care-nav {
  position: sticky;
  top: 16px;
  align-self: start;
  display: grid;
  gap: 8px;
}

.care-nav button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: #ffffff;
}

.care-nav button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: #edf4ff;
  border: 1px solid #d5e5fb;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.nav-badge.hidden {
  display: none;
}

.care-nav button.active .nav-badge {
  background: #ffffff;
  border-color: rgba(255, 255, 255, 0.8);
  color: var(--primary);
}

.care-main {
  display: grid;
  gap: 16px;
}

.care-main .panel {
  padding: 20px;
}

.home-cta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.home-cta p {
  margin-top: 4px;
  color: var(--muted);
}

.home-cta-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.record-subhead {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.problem-field {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.problem-field legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.problem-field label {
  display: inline-flex;
  grid-template-columns: auto;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-size: 13px;
}

.problem-field input {
  width: auto;
}

.scene-score-detail {
  border-top: 1px solid var(--line);
  margin-top: 16px;
  padding-top: 16px;
}

.error {
  color: var(--danger);
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .care-shell {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
  }

  .care-nav {
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

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

  .layout {
    padding: 14px;
  }

  .product-library-shell {
    padding: 14px;
  }

  .care-shell {
    padding: 14px;
  }

  .care-nav {
    grid-template-columns: 1fr;
  }

  .two,
  .nutrients,
  .overview-grid,
  .product-library-filters,
  .product-library-sortbar,
  .pet-card-list,
  .label-groups,
  .confirm-grid {
    grid-template-columns: 1fr;
  }

  .section-head,
  .section-subhead,
  .analysis-head,
  .home-cta,
  .post-confirm-actions,
  .product-library-list-control,
  .product-library-page-actions,
  .share-report-head,
  .report-next-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .share-report-actions button {
    flex: 1 1 calc(50% - 8px);
  }

  .home-cta-actions {
    justify-content: stretch;
  }

  .wide-field {
    grid-column: auto;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1;
  }

  .pet-card-actions button {
    flex: 1;
  }
}
