:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #8a93a3;
  --line: #e6e9f0;
  --blue: #5b8def;
  --pink: #ef5b9c;
  --green: #2faf6a;
  --red: #e0564b;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 17px; color: var(--ink); }
.topbar nav a { margin-left: 18px; color: var(--muted); font-weight: 500; }
.topbar nav a:hover { color: var(--ink); text-decoration: none; }

main { max-width: 940px; margin: 0 auto; padding: 24px 22px 60px; }
h1 { font-size: 24px; margin: 8px 0 20px; }
h2 { font-size: 17px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.readonly-banner {
  background: #fff7e6; border: 1px solid #ffe0a3; color: #8a5a00;
  padding: 7px 13px; border-radius: 10px; margin-bottom: 16px;
  font-size: 13px; font-weight: 500;
}
.flashes { margin-bottom: 16px; }
.flash {
  background: #eef4ff; border: 1px solid #d6e3ff; color: #2f5fc4;
  padding: 9px 13px; border-radius: 10px; margin-bottom: 6px;
}

/* Dashboard cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; color: var(--ink); display: block; transition: box-shadow .15s, transform .15s;
  -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
.card:hover { text-decoration: none; box-shadow: 0 6px 20px rgba(31,39,51,.08); transform: translateY(-2px); }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.card .name { font-weight: 700; font-size: 17px; }
.coloring { color: var(--muted); font-size: 13px; margin-top: 2px; }
.weight { font-size: 30px; font-weight: 700; margin: 12px 0 0; }
.weight .g { font-size: 15px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.milestone { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.ms-label { color: var(--muted); }
.ms-date { font-weight: 600; }
/* Spay/neuter booking nudge (reached weight, not fixed) — mockup #3 bar style */
.card.needs-booking { border-color: #f0a93e; box-shadow: 0 0 0 2px #f7d79a inset; }
.book-alert { margin-top: 12px; border-radius: 10px; overflow: hidden;
  background: #fff4e5; border: 1.5px solid #f0a93e; }
.book-bar { height: 8px; background: #f6e2bd; }
.book-bar i { display: block; height: 100%; width: 100%;
  background: linear-gradient(90deg, #f0a93e, #e0792b); }
.book-txt { padding: 8px 11px; font-weight: 700; font-size: 13px; color: #9a5a12;
  display: flex; align-items: center; gap: 6px; }

.spark { display: block; margin-top: 12px; overflow: visible; }
.rate { margin-top: 8px; }
.done { color: var(--green); font-weight: 600; }

.sex { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.sex-M { background: #e7f0ff; color: var(--blue); }
.sex-F { background: #ffe9f3; color: var(--pink); }

/* Detail */
.detail-head { display: flex; justify-content: space-between; align-items: center; }
.detail-head .actions { display: flex; gap: 8px; align-items: center; }
.meta { display: flex; gap: 22px; color: var(--ink); margin-bottom: 10px; flex-wrap: wrap; }
.notes { background: #fffdf3; border: 1px solid #f0e6bf; padding: 10px 13px; border-radius: 10px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-top: 18px; }
.chart-wrap { position: relative; height: 360px; }
.range-box { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.range-box .ms-table { margin-top: 6px; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ms-table td, .hist td { font-size: 14px; }

/* Forms */
.stack-form { max-width: 460px; display: flex; flex-direction: column; gap: 14px; }
.stack-form label, .weight-form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); font-weight: 400;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.weight-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.form-actions { display: flex; gap: 10px; }

.btn {
  display: inline-block; padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; font-size: 14px;
}
.btn:hover { text-decoration: none; background: #f0f2f7; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #4a7ad8; }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: var(--red); color: #fff; }
.btn.adopt { background: #fff; border-color: var(--green); color: var(--green); }
.btn.adopt:hover { background: var(--green); color: #fff; }
.badge-adopted { font-size: 13px; font-weight: 600; color: var(--green);
  background: #e7f7ee; padding: 3px 10px; border-radius: 20px; vertical-align: middle; }
.badge-fixed { font-size: 13px; font-weight: 600; color: #7a5bd0;
  background: #efeaff; padding: 3px 10px; border-radius: 20px; vertical-align: middle; }
.check-label { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 600; }
.check-label input { width: auto; }
.link-btn.return { color: var(--blue); font-size: 13px; }
.link-btn.return:hover { color: #4a7ad8; text-decoration: underline; }
.detail-head form { margin: 0; }
.link-btn { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0; }
.link-btn:hover { color: var(--red); }

/* Quick weigh-in modal */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 26, 36, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 18px;
}
.overlay[hidden] { display: none; }
.modal {
  background: var(--card); border-radius: 16px; padding: 22px;
  width: 100%; max-width: 360px; box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.modal h2 { margin: 0 0 16px; }
.modal label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; margin-bottom: 14px; }
.modal #quick-grams { font-size: 22px; padding: 12px; text-align: center; }
.quick-row { display: flex; gap: 12px; }
.quick-row label { flex: 1; }

.code { background: #f1f3f8; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; overflow-x: auto; font-size: 13px; }
code { background: #f1f3f8; padding: 1px 5px; border-radius: 5px; font-size: 13px; }
