/* ============================================================
   PawKeep — Pet Health OS  ·  design system
   Direction: "the vet's office, reimagined as a health ledger"
   Warm ivory paper, deep clinical green, terracotta warmth,
   a Fraunces display serif over a humanist sans body.
   ============================================================ */

:root {
  /* palette */
  --paper: #f6f3ec;        /* warm ivory canvas */
  --paper-2: #efe9dd;      /* deeper ivory band */
  --card: #fffdf9;         /* card surface */
  --card-2: #fbf7ef;
  --ink: #1e2a25;          /* near-black green ink */
  --ink-soft: #4a574f;
  --ink-faint: #8a948c;
  --line: #e2dccd;         /* hairline */
  --line-2: #d3cbb8;

  --green: #1f6f54;        /* primary clinical green */
  --green-deep: #14523d;
  --green-soft: #e3efe8;
  --terra: #c05b3c;        /* terracotta accent / warmth */
  --terra-soft: #f7e6dd;
  --gold: #b0893a;
  --red: #b23a2e;
  --red-soft: #f7e0dc;
  --amber: #c98a2b;
  --amber-soft: #f8ecd7;

  /* urgency (triage) */
  --urg-emergency: #b23a2e;
  --urg-urgent: #c98a2b;
  --urg-monitor: #2f8f6b;

  /* type */
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "DM Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* shape + space */
  --r-sm: 8px;
  --r: 14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(30, 42, 37, .05), 0 1px 1px rgba(30,42,37,.03);
  --shadow: 0 2px 6px rgba(30,42,37,.05), 0 10px 30px -12px rgba(30,42,37,.18);
  --shadow-lg: 0 30px 70px -30px rgba(30,42,37,.35);

  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* faint paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  opacity: .5;
  background-image:
    radial-gradient(circle at 15% 10%, rgba(31,111,84,.03), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(192,91,60,.03), transparent 40%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/><feColorMatrix values='0 0 0 0 0.12 0 0 0 0 0.16 0 0 0 0 0.14 0 0 0 0.03 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-deep); }

h1, h2, h3, .display { font-family: var(--font-display); font-weight: 500; letter-spacing: -.01em; }
h1 { font-size: clamp(28px, 4vw, 40px); margin: 0; line-height: 1.08; }
h2 { font-size: 22px; margin: 0 0 4px; }
h3 { font-size: 17px; margin: 0 0 6px; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--font-body);
  font-size: 11px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--green);
}
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }

/* ---------- Layout shell ---------- */
.shell { position: relative; z-index: 1; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(246,243,236,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .row { display: flex; align-items: center; gap: 20px; height: 64px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--green); color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.brand .mark svg { width: 20px; height: 20px; }
.brand .name { font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -.02em; }
.brand .name b { color: var(--green); font-weight: 600; }
.brand .tag { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); margin-top: -2px; }

.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
  padding: 8px 13px; border-radius: 9px; font-weight: 600; font-size: 14px;
  color: var(--ink-soft); transition: .15s;
}
.nav a:hover { background: var(--green-soft); color: var(--green-deep); }
.nav a.active { background: var(--green); color: #fff; }
.nav .sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line-2); background: var(--card);
}
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--green); }
.dot.terra { background: var(--terra); }
.dot.amber { background: var(--amber); }
.dot.red { background: var(--red); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
}
.card.pad { padding: 20px; }
.card.hover { transition: transform .18s ease, box-shadow .18s ease, border-color .18s; }
.card.hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head .eyebrow { margin: 0; }

.grid { display: grid; gap: 18px; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }

/* ---------- Stat tiles ---------- */
.stat {
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 20px; position: relative; overflow: hidden;
}
.stat .label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); }
.stat .value { font-family: var(--font-display); font-size: 34px; line-height: 1; font-weight: 500; }
.stat .value small { font-size: 16px; color: var(--ink-faint); font-family: var(--font-body); font-weight: 600; }
.stat .foot { font-size: 12.5px; color: var(--ink-soft); }
.stat.accent::after {
  content: ""; position: absolute; right: -22px; top: -22px;
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--green-soft); opacity: .7;
}

/* ---------- Buttons ---------- */
.btn {
  --bg: var(--green); --fg: #fff;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg); color: var(--fg);
  border: 1px solid transparent; border-radius: 11px;
  padding: 10px 16px; font-family: var(--font-body);
  font-weight: 700; font-size: 14px; cursor: pointer;
  transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
  box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn .ico { width: 16px; height: 16px; }
.btn.ghost { --bg: transparent; --fg: var(--green-deep); border-color: var(--line-2); box-shadow: none; background: var(--card); }
.btn.ghost:hover { border-color: var(--green); background: var(--green-soft); }
.btn.terra { --bg: var(--terra); }
.btn.dark { --bg: var(--ink); }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.btn.lg { padding: 13px 22px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; justify-content: center; }

.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin: 0 0 6px; }
.field { margin-bottom: 14px; }
input, select, textarea {
  width: 100%; font-family: var(--font-body); font-size: 14.5px;
  color: var(--ink); background: var(--card);
  border: 1px solid var(--line-2); border-radius: 10px;
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
textarea { resize: vertical; min-height: 74px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  border: 1px solid var(--line-2); background: var(--card); color: var(--ink-soft);
  padding: 8px 13px; border-radius: 9px; font-weight: 600; font-size: 13.5px; cursor: pointer;
  transition: .13s;
}
.seg button:hover { border-color: var(--green); color: var(--green-deep); }
.seg button.on { background: var(--green); border-color: var(--green); color: #fff; }

/* severity 1-5 control */
.sev { display: flex; gap: 6px; }
.sev button {
  flex: 1; height: 40px; border: 1px solid var(--line-2); border-radius: 9px;
  font-weight: 700; cursor: pointer; background: var(--card); color: var(--ink-soft); transition: .13s;
}
.sev button:hover { transform: translateY(-1px); }
.sev button.on { color: #fff; border-color: transparent; }
.sev button[data-v="1"].on { background: #6aa58f; }
.sev button[data-v="2"].on { background: #4f9a76; }
.sev button[data-v="3"].on { background: var(--amber); }
.sev button[data-v="4"].on { background: var(--terra); }
.sev button[data-v="5"].on { background: var(--red); }

/* ---------- Badges / chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: var(--paper-2); color: var(--ink-soft); border: 1px solid var(--line);
}
.chip.green { background: var(--green-soft); color: var(--green-deep); border-color: transparent; }
.chip.terra { background: var(--terra-soft); color: #9c4526; border-color: transparent; }
.chip.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.chip.amber { background: var(--amber-soft); color: #8a5f1a; border-color: transparent; }
.chip.mono { font-family: var(--font-mono); }

.badge { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px; }
.badge.ehr { background: var(--green-soft); color: var(--green-deep); }
.badge.manual { background: var(--paper-2); color: var(--ink-soft); }
.badge.ocr { background: var(--amber-soft); color: #8a5f1a; }

/* ---------- Table-ish lists ---------- */
.list { display: flex; flex-direction: column; }
.list .item {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.list .item:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 700; font-size: 14.5px; }
.list .sub { font-size: 12.5px; color: var(--ink-faint); }

/* ---------- Sparkline / trend ---------- */
.spark { width: 100%; height: 46px; display: block; }
.spark .line { fill: none; stroke: var(--green); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.spark .area { fill: url(#sparkfill); opacity: .55; }
.spark .end { fill: var(--green); }
.trend-down { color: var(--terra); }

/* ---------- Triage verdict ---------- */
.verdict {
  border-radius: var(--r-lg); padding: 26px 28px; color: #fff; position: relative; overflow: hidden;
  box-shadow: var(--shadow);
}
.verdict::before {
  content: ""; position: absolute; inset: 0; opacity: .5;
  background: radial-gradient(circle at 85% 15%, rgba(255,255,255,.18), transparent 45%);
}
.verdict .tag { font-size: 11px; font-weight: 800; letter-spacing: .2em; text-transform: uppercase; opacity: .9; }
.verdict .big { font-family: var(--font-display); font-size: clamp(24px, 3.4vw, 34px); font-weight: 600; line-height: 1.05; margin: 6px 0 4px; }
.verdict .sub { opacity: .92; font-size: 14.5px; max-width: 60ch; }
.verdict .ico { position: absolute; right: 22px; top: 22px; width: 46px; height: 46px; opacity: .35; }
.verdict.emergency { background: linear-gradient(135deg, #b23a2e, #8f2a20); }
.verdict.urgent { background: linear-gradient(135deg, #c98a2b, #a56a1a); }
.verdict.monitor { background: linear-gradient(135deg, #2f8f6b, #1f6f54); }

.reason { display: flex; gap: 11px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.reason:last-child { border-bottom: 0; }
.reason .n {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  background: var(--green-soft); color: var(--green-deep);
  display: grid; place-items: center; font-weight: 800; font-size: 12px; font-family: var(--font-mono);
}
.reason p { margin: 0; font-size: 14.5px; }

/* ---------- Steps (intake) ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 20px; }
.steps .s { flex: 1; text-align: center; }
.steps .s .bar { height: 4px; border-radius: 3px; background: var(--line-2); }
.steps .s.on .bar { background: var(--green); }
.steps .s .lb { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); margin-top: 6px; }
.steps .s.on .lb { color: var(--green-deep); }

/* ---------- Modal ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 80; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(30,42,37,.45); backdrop-filter: blur(3px);
}
.modal-wrap.open { display: flex; }
.modal {
  width: min(560px, 100%); max-height: 88vh; overflow: auto;
  background: var(--card); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  border: 1px solid var(--line);
}
.modal .head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal .body { padding: 20px 22px; }
.modal .foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.x { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--ink-faint); line-height: 1; padding: 2px 6px; border-radius: 8px; }
.x:hover { background: var(--paper-2); color: var(--ink); }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  z-index: 100; background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none;
  transition: .3s; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); }

/* ---------- Reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(12px); animation: rise .5s ease forwards; }
@keyframes rise { to { opacity: 1; transform: none; } }
.d1 { animation-delay: .05s; } .d2 { animation-delay: .12s; } .d3 { animation-delay: .19s; }
.d4 { animation-delay: .26s; } .d5 { animation-delay: .33s; }

/* ---------- Utilities ---------- */
.flex { display: flex; } .aic { align-items: center; } .jcb { justify-content: space-between; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .wrap { flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.mt2 { margin-top: 2px; }
.right { margin-left: auto; }
.nowrap { white-space: nowrap; }
.empty { text-align: center; color: var(--ink-faint); padding: 30px 0; font-size: 14px; }
.hr { height: 1px; background: var(--line); border: 0; margin: 16px 0; }

.section-title { display: flex; align-items: baseline; gap: 10px; margin: 30px 0 14px; }
.section-title h2 { font-size: 20px; }
.section-title .count { font-size: 12px; font-weight: 700; color: var(--ink-faint); font-family: var(--font-mono); }

/* pet avatar */
.avatar {
  flex: none; width: 44px; height: 44px; border-radius: 13px;
  display: grid; place-items: center; font-family: var(--font-display); font-size: 20px; font-weight: 600;
  color: #fff; box-shadow: var(--shadow-sm);
}
.avatar.dog { background: linear-gradient(135deg, #c05b3c, #a54a2f); }
.avatar.cat { background: linear-gradient(135deg, #1f6f54, #14523d); }
.avatar.rabbit { background: linear-gradient(135deg, #b0893a, #8f6d2a); }
.avatar.bird { background: linear-gradient(135deg, #3a7ca5, #2a5f84); }
.avatar.exotic { background: linear-gradient(135deg, #6a5a9c, #4f4279); }
.avatar.sm { width: 34px; height: 34px; border-radius: 10px; font-size: 16px; }

/* progress bar */
.progress { height: 8px; border-radius: 6px; background: var(--paper-2); overflow: hidden; }
.progress > div { height: 100%; background: var(--green); border-radius: 6px; transition: width .6s ease; }

/* footer */
.footer { border-top: 1px solid var(--line); margin-top: 50px; padding: 22px 0 40px; }
.footer .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.footer .disc { font-size: 12px; color: var(--ink-faint); max-width: 70ch; }

/* responsive */
@media (max-width: 900px) {
  .cols-3 { grid-template-columns: 1fr 1fr; }
  .span-3 { grid-column: span 2; }
  .nav a { padding: 8px 10px; }
}
@media (max-width: 620px) {
  .cols-3, .cols-2, .form-row { grid-template-columns: 1fr; }
  .span-2, .span-3 { grid-column: span 1; }
  .brand .tag { display: none; }
  .nav a span.lbl { display: none; }
}