/* ============================================================
   SWINE — clinical veterinary diagnostic UI
   Palette : pine green + cool paper + ochre/clay severity
   Type    : Space Grotesk (display) / Inter (body) / JetBrains Mono (readouts)
   ============================================================ */

:root {
  --bg:        #eef2f0;   /* cool paper */
  --surface:   #ffffff;
  --ink:       #15211d;   /* near-black, green-tinged */
  --muted:     #67776f;
  --line:      #d6ded9;

  --pine:      #1f6e5a;   /* primary */
  --pine-dark: #14503f;
  --pine-soft: #e4efe9;

  --mild:      #2f8f5b;
  --moderate:  #d4892b;
  --severe:    #c0492f;

  --radius:    14px;
  --shadow:    0 1px 2px rgba(20,80,63,.06), 0 8px 24px rgba(20,80,63,.07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: "Space Grotesk", "Inter", sans-serif;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}

a { color: var(--pine-dark); }

.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

.wrap { max-width: 760px; margin: 0 auto; padding: 0 20px; }
.wrap-wide { max-width: 1040px; margin: 0 auto; padding: 0 20px; }

/* ---- Brand mark ---- */
.brand {
  display: flex; align-items: baseline; gap: 12px;
}
.brand .logo {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700; font-size: 1.5rem; letter-spacing: .04em;
  color: var(--pine);
}
.brand .logo b { color: var(--ink); }
.eyebrow {
  font-family: "JetBrains Mono", monospace;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .18em;
  color: var(--muted);
}

/* ---- Public hero / detector ---- */
.hero { padding: 64px 0 28px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3rem); }
.hero p.lede { color: var(--muted); font-size: 1.05rem; margin: 14px 0 0; max-width: 56ch; }

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

.field-label {
  display: block; font-weight: 600; margin-bottom: 8px; font-size: .95rem;
}
textarea, input[type=text], input[type=password], select {
  width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px;
  font: inherit; color: var(--ink); background: #fbfdfc;
  resize: vertical;
}
textarea:focus, input:focus, select:focus {
  outline: 2px solid var(--pine); outline-offset: 1px; border-color: var(--pine);
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--pine); color: #fff; border: none;
  padding: 12px 20px; border-radius: 10px;
  font: 600 1rem "Inter", sans-serif; cursor: pointer;
  transition: background .15s ease;
}
.btn:hover { background: var(--pine-dark); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-ghost { background: transparent; color: var(--pine-dark); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--pine-soft); }
.btn-danger { background: var(--severe); }
.btn-danger:hover { background: #9c3a25; }

/* ---- Diagnostic result cards (the signature: lab readout) ---- */
.results { margin-top: 28px; display: grid; gap: 14px; }
.result {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
  border-left: 4px solid var(--pine);
}
.result.rank-1 { border-left-color: var(--pine); }
.result-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.result-name { font-size: 1.2rem; font-weight: 700; font-family: "Space Grotesk", sans-serif; }
.result-rank { font-family: "JetBrains Mono", monospace; font-size: .72rem; color: var(--muted); letter-spacing: .1em; }

.readout { text-align: right; min-width: 92px; }
.readout .pct { font-family: "JetBrains Mono", monospace; font-size: 1.5rem; font-weight: 700; color: var(--pine-dark); }
.readout .pct-label { font-family: "JetBrains Mono", monospace; font-size: .62rem; text-transform: uppercase; letter-spacing: .14em; color: var(--muted); }

.meter { height: 6px; background: var(--pine-soft); border-radius: 99px; overflow: hidden; margin: 12px 0 14px; }
.meter > i { display: block; height: 100%; background: var(--pine); border-radius: 99px; }

.result dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .92rem; }
.result dt { color: var(--muted); font-weight: 600; }
.result dd { margin: 0; }

.badge {
  font-family: "JetBrains Mono", monospace; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .08em; padding: 3px 9px; border-radius: 99px; font-weight: 600; white-space: nowrap;
}
.badge.mild     { background: #e3f3ea; color: var(--mild); }
.badge.moderate { background: #fbeed8; color: var(--moderate); }
.badge.severe   { background: #f8e2dc; color: var(--severe); }

.note { color: var(--muted); font-size: .85rem; margin-top: 22px; }
.empty, .error { padding: 16px 18px; border-radius: 10px; }
.empty { background: var(--pine-soft); color: var(--pine-dark); }
.error { background: #f8e2dc; color: var(--severe); }

.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.5);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Admin ---- */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.topbar .wrap-wide { display: flex; align-items: center; justify-content: space-between; }
.topbar nav { display: flex; gap: 18px; align-items: center; font-size: .92rem; }
.topbar nav a { text-decoration: none; color: var(--muted); font-weight: 600; }
.topbar nav a.active, .topbar nav a:hover { color: var(--pine-dark); }

.page { padding: 32px 0 64px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 14px; margin-bottom: 26px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stat .num { font-family: "JetBrains Mono", monospace; font-size: 2rem; font-weight: 700; color: var(--pine-dark); }
.stat .lbl { color: var(--muted); font-size: .85rem; }

table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
th { font-family: "JetBrains Mono", monospace; font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); background: #f7faf8; }
tr:last-child td { border-bottom: none; }
td .actions { display: flex; gap: 8px; }
td .actions a, td .actions button { font-size: .82rem; padding: 6px 12px; }

.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-weight: 500; }
.flash.ok  { background: #e3f3ea; color: var(--mild); }
.flash.err { background: #f8e2dc; color: var(--severe); }

.form-grid { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

/* ---- Login ---- */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { justify-content: center; margin-bottom: 8px; }

/* ---- Image upload (public) ---- */
.dropzone {
  display: grid; place-items: center; gap: 6px;
  min-height: 200px; padding: 20px;
  border: 2px dashed var(--line); border-radius: 12px;
  background: #fbfdfc; cursor: pointer; text-align: center;
  transition: border-color .15s ease, background .15s ease;
}
.dropzone:hover { border-color: var(--pine); background: var(--pine-soft); }
.dz-empty { display: grid; gap: 4px; color: var(--muted); }
.dz-empty strong { color: var(--ink); font-size: 1.05rem; }
.dz-empty span { font-family: "JetBrains Mono", monospace; font-size: .72rem; letter-spacing: .08em; }
.preview { max-width: 100%; max-height: 340px; border-radius: 10px; }

/* ---- Treatment callout (the thing the user came for) ---- */
.treatment {
  background: var(--pine-soft); border-radius: 10px;
  padding: 14px 16px; margin: 4px 0 16px;
}
.treatment-label {
  font-family: "JetBrains Mono", monospace; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--pine-dark); margin-bottom: 6px;
}
.treatment p { margin: 0; }

/* ---- Reference match strip ---- */
.refs { margin-top: 16px; }
.refs-label {
  font-family: "JetBrains Mono", monospace; font-size: .68rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted); margin-bottom: 8px;
}
.ref-strip { display: flex; gap: 10px; flex-wrap: wrap; }
.ref { margin: 0; width: 96px; }
.ref img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.ref figcaption { text-align: center; font-size: .72rem; color: var(--pine-dark); margin-top: 4px; }
.others { color: var(--muted); font-size: .9rem; margin: 14px 0 0; }

/* ---- Admin training-image gallery ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px,1fr)); gap: 16px; }
.thumb {
  margin: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.thumb img { width: 100%; height: 150px; object-fit: cover; }
.thumb figcaption { padding: 10px 12px; font-size: .78rem; color: var(--muted); flex: 1; }
.thumb form { padding: 0 12px 12px; }
.thumb .btn { width: 100%; justify-content: center; }

/* ---- Hybrid: low-confidence + AI suggestion ---- */
.lowconf {
  background: #fbeed8; color: #8a5a12; border-radius: 10px;
  padding: 12px 16px; margin-bottom: 14px; font-size: .92rem;
}
.ai-sug {
  border: 1px dashed var(--line); border-radius: 10px;
  padding: 12px 16px; margin-top: 16px; background: #fbfdfc;
}
.ai-sug-label {
  font-family: "JetBrains Mono", monospace; font-size: .66rem; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted); margin-bottom: 4px;
}
.ai-sug p { margin: 0; }
