/* ============================================================================
   MGT — Shared design system
   Used by both mgtcattle.moorellafarming.com.au and mgtsheep.moorellafarming.com.au.
   Loaded once per page; replaces the per-file inline :root / chrome blocks.
   ============================================================================ */

:root {
  /* Palette */
  --paper: #F7F5F0;
  --card: #FFFFFF;
  --ink: #1A1F1C;
  --soft: #3D4540;
  --muted: #6B7670;
  --border: #C9C4B8;
  --border-light: #E4E0D7;
  --accent: #1A4D2E;
  --accent-soft: #E8EFD8;
  --accent-dark: #143A22;
  --warn: #B85C1E;
  --warn-soft: #FBEFE0;
  --error: #9E2B1F;
  --error-soft: #FDEDEA;
  --info: #2C5F8B;
  --info-soft: #DDE9F4;
  --gold: #C8A85B;

  /* Type scale */
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --font-display: "Fraunces", Georgia, serif;

  /* Layout */
  --max-content: 1200px;
  --max-narrow: 920px;
  --radius: 10px;
  --radius-lg: 14px;
  /* Build version (shows in footer) */
  --shadow-card: 0 1px 2px rgba(20,30,25,0.04);
  --shadow-pop: 0 6px 18px rgba(26,77,46,0.08);

  /* Legacy aliases — kept so ported v2 pages don't lose colour on var() lookups */
  --mute: var(--muted);
  --fg:   var(--ink);
  --bg:   var(--paper);
  --line: var(--border-light);
  --rule: var(--border-light);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 70px; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

/* ── Chrome (injected by nav.js) ───────────────────────────────────── */
.mgt-topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border-light);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 12.5px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.mgt-brand {
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.mgt-brand .product { color: var(--ink); margin-left: 6px; font-weight: 600; }
.mgt-brand .badge {
  display: inline-block; font-size: 10px; font-weight: 600;
  background: var(--accent); color: #fff; padding: 2px 6px; border-radius: 3px;
  margin-left: 8px; vertical-align: middle; letter-spacing: 0.04em;
}
.mgt-nav { display: flex; gap: 22px; align-items: center; }
.mgt-nav a {
  color: var(--muted); text-decoration: none;
  font-size: 12.5px; padding: 6px 0;
  border-bottom: 2px solid transparent;
  transition: color .12s ease, border-color .12s ease;
}
.mgt-nav a:hover { color: var(--ink); }
.mgt-nav a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.mgt-spacer { flex: 1; }
.mgt-user { color: var(--muted); font-size: 12px; }
.mgt-user a { color: var(--accent); text-decoration: none; margin-left: 10px; }
.mgt-cross-link {
  color: var(--muted); text-decoration: none; font-size: 11.5px;
  padding: 6px 10px; border: 1px solid var(--border-light); border-radius: 6px;
}
.mgt-cross-link:hover { border-color: var(--border); color: var(--ink); }

/* Mobile — collapse the topbar so it doesn't overflow on narrow screens */
@media (max-width: 760px) {
  .mgt-topbar {
    flex-wrap: wrap;
    gap: 12px 16px;
    padding: 10px 16px;
  }
  .mgt-brand { flex: 0 0 100%; font-size: 13px; }
  .mgt-nav { width: 100%; gap: 14px; overflow-x: auto; padding-bottom: 4px; }
  .mgt-nav a { white-space: nowrap; }
  .mgt-cross-link { font-size: 10.5px; padding: 5px 8px; }
  .mgt-user { font-size: 11px; }
  .mgt-spacer { display: none; }
  .wrap, .wrap-narrow { padding: 20px 16px 40px; }
  h1 { font-size: 26px; }
  .card { padding: 18px 18px; }
}

.mgt-footer {
  border-top: 1px solid var(--border-light);
  padding: 18px 28px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  background: var(--card);
  margin-top: 60px;
}
.mgt-footer a { color: var(--muted); text-decoration: none; margin: 0 10px; }
.mgt-footer a:hover { color: var(--ink); }
.mgt-footer .version { font-family: var(--font-mono); font-size: 10.5px; opacity: 0.7; margin-top: 4px; }

/* ── Page shell ───────────────────────────────────────────────────── */
.wrap { max-width: var(--max-content); margin: 0 auto; padding: 28px 28px 60px; }
.wrap-narrow { max-width: var(--max-narrow); margin: 0 auto; padding: 28px 28px 60px; }

h1 { font-weight: 500; font-size: 32px; margin: 0 0 8px; letter-spacing: -0.015em; }
h1 .badge { font-size: 11px; font-weight: 600; background: var(--accent); color: #fff; padding: 3px 8px; border-radius: 3px; margin-left: 10px; vertical-align: middle; }
h2 { font-weight: 500; font-size: 20px; margin: 0 0 12px; letter-spacing: -0.01em; }
h2.section-heading { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 30px 0 14px; }
h3 { font-weight: 600; font-size: 15px; margin: 0 0 6px; }
.subtitle { color: var(--soft); font-size: 14.5px; max-width: 800px; margin: 0 0 28px; line-height: 1.6; }

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}
.card h2 { font-size: 17px; font-weight: 500; margin: 0 0 4px; }
.card .h-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; }

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.tool-card {
  display: block;
  background: var(--card);
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  text-decoration: none;
  color: inherit;
  transition: border-color .15s ease, transform .15s ease;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.tool-card .glyph { font-size: 22px; margin-bottom: 6px; line-height: 1; }
.tool-card h3 { margin: 0 0 6px; font-size: 14.5px; font-weight: 600; }
.tool-card p { margin: 0; color: var(--soft); font-size: 12.5px; line-height: 1.5; }
.tool-card.disabled {
  opacity: 0.55;
  pointer-events: none;
  position: relative;
}
.tool-card.disabled h3::after {
  content: "In development";
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
}

/* ── Form controls ────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; margin-bottom: 16px; }
.field label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 5px;
}
.field .help { font-size: 11.5px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="password"],
.field input[type="date"],
.field select,
.field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13.5px;
  background: var(--card);
  color: var(--ink);
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 600px) { .field-row, .field-row.cols-3 { grid-template-columns: 1fr; } }

.unit { color: var(--muted); font-weight: 400; font-size: 11px; margin-left: 4px; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 600;
  text-decoration: none; cursor: pointer; border: none;
  transition: all .12s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--card); color: var(--accent); border: 1px solid var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }

/* ── Status / banners ─────────────────────────────────────────────── */
.status { padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 18px; }
.status.ok { background: var(--accent-soft); color: var(--accent); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.status.err { background: var(--error-soft); color: var(--error); }
.status.info { background: var(--info-soft); color: var(--info); }

.calib-banner {
  background: var(--warn-soft); border: 1px solid var(--warn);
  color: var(--warn); padding: 14px 18px; border-radius: 8px;
  margin-bottom: 20px; font-size: 13px;
}
.calib-banner.ok { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.calib-banner a { color: inherit; font-weight: 600; margin-left: 6px; }

/* ── Wizard step strip ────────────────────────────────────────────── */
.step-strip {
  display: flex; gap: 0; margin-bottom: 24px;
  background: var(--card); padding: 12px 16px;
  border-radius: var(--radius-lg); border: 1px solid var(--border-light);
  overflow-x: auto;
}
.step-strip a {
  flex: 1; min-width: 90px; text-align: center;
  padding: 9px 8px; border-radius: 6px;
  text-decoration: none; color: var(--muted);
  font-size: 11.5px; font-weight: 500;
  transition: background .12s ease;
}
.step-strip a:hover { background: var(--paper); }
.step-strip a.active { background: var(--accent); color: #fff; font-weight: 600; }
.step-strip a.filled { color: var(--ink); }
.step-strip a.filled .step-tick {
  display: inline-block; color: var(--accent); font-weight: 700;
  margin-right: 2px; font-size: 10.5px;
}
.step-strip a.active.filled { color: #fff; }
.step-strip a.active.filled .step-tick { color: #fff; }
.step-strip a.anchor-missing {
  background: var(--warn-soft);
  color: var(--warn);
}
.step-strip a.anchor-missing:hover { background: var(--warn-soft); filter: brightness(0.95); }
.step-strip a.active.anchor-missing { background: var(--warn); color: #fff; }
.step-strip a .step-label {
  display: block; font-size: 9.5px; opacity: 0.7;
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 1px;
}

.wizard-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--border-light);
  padding: 12px 28px;
  display: flex; align-items: center; gap: 14px;
  font-size: 12.5px;
  z-index: 40;
}
.wizard-footer .save-status { color: var(--muted); min-width: 90px; }
.wizard-footer .save-status.saved { color: var(--accent); }
.wizard-footer .save-status.error { color: var(--error); }

@media (max-width: 600px) {
  .wizard-footer { padding: 10px 14px; gap: 8px; font-size: 11.5px; }
  .wizard-footer .save-status { min-width: 0; flex: 1; }
  .wizard-footer .btn { padding: 8px 12px; font-size: 12px; }
  .step-strip { gap: 4px; padding: 8px; }
  .step-strip a { min-width: 70px; padding: 7px 6px; font-size: 10.5px; }
  .step-strip a .step-label { font-size: 8.5px; }
}

/* Profile pages have a sticky wizard-footer — reserve bottom padding so
   the last content row isn't hidden behind it, and suppress the nav.js
   page footer to avoid double-stacking. */
body[data-page="profile"] { padding-bottom: 70px; }
body[data-page="profile"] .mgt-footer { display: none; }

/* ── Tables ───────────────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--border-light);
}
.data-table th {
  font-weight: 600; font-size: 11px;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); background: var(--paper);
  position: sticky; top: 0;
}
.data-table tr:hover { background: var(--paper); }
.data-table .num { font-family: var(--font-mono); text-align: right; }

/* ── Tags / pills ─────────────────────────────────────────────────── */
.tag {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 10.5px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.tag-amber { background: var(--warn-soft); color: var(--warn); }
.tag-green { background: var(--accent-soft); color: var(--accent); }
.tag-blue  { background: var(--info-soft); color: var(--info); }
.tag-gold  { background: #FAF1D8; color: #8B6914; }

/* ── Auth gate / login card ───────────────────────────────────────── */
.auth-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border: 1px solid var(--border-light); border-radius: var(--radius-lg); padding: 32px; }
.auth-card h1 { font-size: 24px; margin: 0 0 6px; }
.auth-card .lede { color: var(--soft); font-size: 13.5px; margin: 0 0 24px; }
.auth-card .foot { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }
.auth-card .foot a { color: var(--accent); text-decoration: none; }

/* ── Utilities ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; left: -9999px; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.right { margin-left: auto; }
hr.rule { border: 0; border-top: 1px solid var(--border-light); margin: 30px 0; }
