:root {
  --blue: #1F4FD1; --blue-dark: #163A9C; --navy: #0B2A5B; --ink: #0F1E33; --muted: #4A5A70;
  --line: #D5DEEC; --field: #C5D1E3; --bg: #F3F6FB; --tint: #E8EFFB; --white: #FFFFFF;
  --red: #B42318; --red-bg: #FDECEA; --green: #1D6B3A; --green-bg: #E3F1E8; --amber-bg: #FFF4D6;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif; font-size: 17px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid rgba(31,79,209,.5); outline-offset: 2px; }
svg.i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
.hidden { display: none !important; }

/* header */
header.top { background: var(--white); border-bottom: 1px solid var(--line); }
header.top .bar { max-width: 1040px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px; min-height: 48px; color: var(--blue); font-size: 26px; font-weight: 700; letter-spacing: 2px; }
.spacer { flex: 1 1 auto; }
.btn-ghost { min-height: 48px; padding: 0 16px; border: 1.5px solid var(--field); border-radius: 12px; background: var(--white); font-weight: 700; display: inline-flex; align-items: center; gap: 8px; }

/* buttons */
.btn { min-height: 56px; padding: 0 28px; border: 0; border-radius: 14px; background: var(--blue); color: var(--white); font-size: 19px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 10px; }
.btn:hover { background: var(--blue-dark); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: var(--white); color: var(--ink); border: 1.5px solid var(--field); }
.back { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; background: none; border: 0; color: var(--blue); font-weight: 700; font-size: 18px; padding: 0; margin-bottom: 8px; }

/* login */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--tint); }
.card { background: var(--white); border: 1px solid var(--line); border-radius: 18px; padding: 28px; }
.login .card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 18px; box-shadow: 0 12px 32px rgba(11,42,91,.08); }
.logo { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--blue); }
.logo b { font-size: 46px; letter-spacing: 3px; line-height: 1.1; }

/* home tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 24px; }
.tile { min-height: 260px; background: var(--white); border: 2px solid var(--line); border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 24px; font-size: 30px; font-weight: 700; color: var(--ink); }
.tile:hover { border-color: var(--blue); }
.tile .ico { width: 120px; height: 120px; border-radius: 30px; background: var(--blue); color: var(--white); display: flex; align-items: center; justify-content: center; }
.tiles.books .tile { min-height: 200px; font-size: 24px; }
.tiles.books .tile .ico { width: 92px; height: 92px; border-radius: 24px; }
h1 { font-size: 32px; line-height: 1.2; margin: 0; }
h2 { font-size: 21px; margin: 0 0 12px; }

/* form */
form.patient { display: flex; flex-direction: column; gap: 16px; margin-top: 16px; }
.group { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label, .field > .lbl { font-weight: 700; font-size: 16px; }
.req { color: var(--red); }
input[type=text], input[type=tel], input[type=date], input[type=number], input[type=month], input[type=email], input[type=password], input[type=search], textarea, select {
  width: 100%; min-height: 52px; padding: 10px 14px; border: 1.5px solid var(--field); border-radius: 12px; background: var(--white); font-size: 18px; }
textarea { min-height: 90px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,79,209,.18); }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button { min-height: 52px; min-width: 76px; padding: 0 18px; border: 1.5px solid var(--field); border-radius: 12px; background: var(--white); font-size: 18px; font-weight: 700; }
.seg button[aria-pressed=true] { background: var(--blue); border-color: var(--blue); color: var(--white); }
.field.err input, .field.err .seg button { border-color: var(--red); }
.errmsg { color: var(--red); font-size: 15px; font-weight: 700; }
.banner { border-radius: 12px; padding: 14px 16px; font-weight: 700; }
.banner.bad { background: var(--red-bg); color: #8A1C12; }
.banner.good { background: var(--green-bg); color: var(--green); }
.banner.warn { background: var(--amber-bg); color: #6B4E00; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.booktag { display: inline-flex; align-items: center; gap: 8px; background: var(--tint); color: var(--navy); border-radius: 999px; padding: 6px 14px; font-weight: 700; }

/* search */
.searchbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.searchbar input { flex: 1 1 260px; min-height: 60px; font-size: 20px; border-radius: 999px; padding: 0 22px; }
.searchbar .btn { border-radius: 999px; min-height: 60px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chips button { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--field); background: var(--white); font-weight: 700; }
.chips button[aria-pressed=true] { background: var(--navy); border-color: var(--navy); color: var(--white); }
.dates { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 12px; color: var(--muted); font-weight: 700; }
.dates input { width: auto; min-height: 44px; font-size: 16px; }
.count { margin: 18px 0 10px; color: var(--muted); font-weight: 700; }
.results { display: flex; flex-direction: column; gap: 12px; }
.result { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; gap: 16px; align-items: flex-start; width: 100%; text-align: left; }
.result .date { flex: 0 0 auto; width: 76px; text-align: center; background: var(--tint); border-radius: 10px; padding: 6px 4px; color: var(--navy); font-weight: 700; line-height: 1.15; }
.result .date .d { font-size: 26px; display: block; }
.result .date .m { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; display: block; }
.result .date .y { font-size: 12px; color: var(--muted); display: block; font-weight: 400; }
.result .main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.result .name { font-size: 20px; font-weight: 700; color: var(--blue); }
.result .sub { color: var(--muted); font-size: 15px; }
.pill { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px; margin-left: 6px; vertical-align: 2px; }
.pill.vaccination { background: #E2EDFF; color: #1A44B8; }
.pill.sterilisation { background: #E1E8F5; color: var(--navy); }
.pill.sick_injured { background: #FCEBDD; color: #8A3D00; }
.pill.pts_surrendered { background: #EEE6F7; color: #4B2A7A; }
.pill.check { background: var(--amber-bg); color: #6B4E00; }
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 18px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 15px; }
.details div b { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }

/* reports */
.repbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 16px; }
.repbar .field { width: 220px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 20px; }
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.kpi .t { font-weight: 700; color: var(--muted); }
.kpi .n { font-size: 46px; font-weight: 700; color: var(--navy); line-height: 1.1; }
.kpi .s { color: var(--muted); font-size: 15px; }
.spin { width: 26px; height: 26px; border-radius: 50%; border: 3px solid #C9D7F2; border-top-color: var(--blue); animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 560px) {
  .tile { min-height: 180px; font-size: 26px; }
  .tile .ico { width: 92px; height: 92px; }
  h1 { font-size: 26px; }
}
