/* ============================================================================
   Genemap — Modern SaaS design system (v2)
   ----------------------------------------------------------------------------
   Sharp, professional, generous whitespace. Linear / Stripe / Vercel reference
   points. Off-white content surface + dark sidebar chrome + single brand
   accent (eucalypt green) + restrained bronze for highlights.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700;800;900&display=swap');

:root {
  /* ── Surfaces ──────────────────────────────────────────────────── */
  --paper: #F7FAF9;             /* airy off-white content background */
  --paper-alt: #EFF4F2;         /* subtle band for contrast */
  --card: #FFFFFF;              /* card surfaces */

  /* ── Text ──────────────────────────────────────────────────────── */
  --ink: #0B1F1C;               /* deep teal-ink body text */
  --ink-2: #0E2A22;             /* headings */
  --soft: #3F4F47;              /* secondary */
  --muted: #5B6B62;             /* tertiary */
  --faint: #8A968E;             /* captions */

  /* ── Hairlines / borders ───────────────────────────────────────── */
  --border: #E5EAE6;            /* primary hairline */
  --border-light: #EFF4F1;      /* very subtle */

  /* ── Brand accent (Genemap teal) ───────────────────────────────── */
  --accent: #0D9488;
  --accent-soft: #E6FAF6;       /* light teal wash */
  --accent-dark: #0F766E;       /* hover/active */
  --accent-glow: rgba(13,148,136,0.14);

  /* ── Bronze (sparingly — emphasis, italics) ────────────────────── */
  --bronze: #B07A30;
  --bronze-soft: #FAF1E0;
  --bronze-dark: #92400E;

  /* ── Status palette (refined for off-white background) ─────────── */
  --warn: #B45309;              /* amber-700 */
  --warn-soft: #FEF3C7;         /* amber-100 */
  --error: #B91C1C;             /* red-700 */
  --error-soft: #FEE2E2;        /* red-100 */
  --info: #1E40AF;              /* blue-800 */
  --info-soft: #DBEAFE;         /* blue-100 */
  --gold: #B45309;              /* legacy alias */

  /* ── Sidebar chrome — clean white (AgriWebb / TheFarmOS light) ─── */
  --sidebar-bg: #FFFFFF;        /* clean white chrome */
  --sidebar-bg-2: #F2F6F4;      /* hover wash */
  --sidebar-text: #5B6B62;      /* default link — muted */
  --sidebar-text-hover: #0B1F1C;
  --sidebar-text-active: #0F766E; /* teal-dark — active */
  --sidebar-active-bg: #E6FAF6;   /* teal-soft active pill */
  --sidebar-border: #E5EAE6;
  --sidebar-section: #8A968E;     /* section labels */
  --sidebar-width: 252px;
  --sidebar-width-mobile: 284px;

  /* ── Type ──────────────────────────────────────────────────────── */
  --font-body: "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-display: "Geist", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-serif: "Geist", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  /* ── Layout ────────────────────────────────────────────────────── */
  --max-content: 1280px;
  --max-narrow: 920px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* ── Shadows — soft, layered (TheFarmOS) ───────────────────────── */
  --shadow-card:  0 1px 2px rgba(11,31,23,.05), 0 1px 3px rgba(11,31,23,.04);
  --shadow-pop:   0 4px 12px rgba(11,31,23,.06), 0 12px 28px -8px rgba(11,31,23,.12);
  --shadow-modal: 0 24px 60px -16px rgba(11,31,23,.22), 0 8px 16px rgba(11,31,23,.08);
  --shadow-focus: 0 0 0 3px var(--accent-glow);

  /* Legacy aliases — keep so older pages still resolve */
  --mute: var(--muted);
  --fg:   var(--ink);
  --bg:   var(--paper);
  --line: var(--border);
  --rule: var(--border-light);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}

/* ════════════════════════════════════════════════════════════════════
   TOP NAV — sticky bar with grouped dropdown menus (TheFarmOS-style)
   Full-width sticky header: brand left, group dropdowns centre, org
   switcher + user right. Content sits in .app-main below (normal flow).
   [data-no-chrome="1"] pages (auth/overview) skip the chrome entirely.
   ═══════════════════════════════════════════════════════════════════ */
body:not([data-no-chrome="1"]) .app-main { min-height: 100vh; }

.gm-topnav {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.gm-topnav a, .gm-topnav button { font-family: inherit; }
.gm-tn-inner {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 0 24px;
  height: 60px;
  display: flex; align-items: center; gap: 16px;
}

/* Brand */
.gm-tn-brand { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; flex-shrink: 0; }
.gm-tn-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 900; font-size: 18px; box-shadow: var(--shadow-card); }
.gm-tn-word { font-family: var(--font-display); font-weight: 800; font-size: 19px; letter-spacing: -0.03em; color: var(--ink-2); }

/* Group triggers */
.gm-tn-menu { display: flex; align-items: center; gap: 2px; flex: 1; }
.gm-tn-group { position: relative; }
.gm-tn-trigger {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 12px; border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--soft);
  border-radius: 8px; transition: color .12s, background .12s;
}
.gm-tn-trigger:hover { color: var(--ink); background: var(--paper-alt); }
.gm-tn-group.open > .gm-tn-trigger { color: var(--accent-dark); background: var(--accent-soft); }
.gm-tn-trigger.has-active { color: var(--ink-2); font-weight: 600; }
.gm-tn-caret { width: 13px; height: 13px; opacity: .55; transition: transform .18s; }
.gm-tn-group.open > .gm-tn-trigger .gm-tn-caret { transform: rotate(180deg); }

/* Dropdown panel */
.gm-tn-dd {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 228px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-modal);
  padding: 6px; display: none; z-index: 60;
  max-height: 72vh; overflow-y: auto;
}
.gm-tn-group.open > .gm-tn-dd { display: block; }
.gm-tn-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  color: var(--soft); text-decoration: none; font-size: 13.5px; font-weight: 500;
  white-space: nowrap; transition: background .12s, color .12s;
}
.gm-tn-link:hover { background: var(--paper-alt); color: var(--ink); }
.gm-tn-link.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.gm-tn-ico { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex-shrink: 0; opacity: .65; }
.gm-tn-ico svg { width: 18px; height: 18px; display: block; }
.gm-tn-link:hover .gm-tn-ico { opacity: 1; }
.gm-tn-link.active .gm-tn-ico { opacity: 1; color: var(--accent); }

/* Right cluster: org switcher + user + mobile toggle */
.gm-tn-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; position: relative; }

.gm-sb-org {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; color: var(--ink-2); font-size: 13px; font-weight: 500;
  cursor: pointer; max-width: 210px; font-family: inherit;
  transition: border-color .12s, background .12s;
}
.gm-sb-org:hover { border-color: var(--accent); background: var(--paper-alt); }
.gm-sb-org-pip { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.gm-sb-org-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gm-sb-org-caret { color: var(--muted); font-size: 10px; flex-shrink: 0; }

.gm-sb-org-dd {
  position: absolute; right: 0; left: auto; top: calc(100% + 8px);
  min-width: 248px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 5px; z-index: 70; box-shadow: var(--shadow-modal); display: none;
}
.gm-sb-org-dd.open { display: block; }
.gm-sb-org-dd .group-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; padding: 8px 10px 4px; font-weight: 600; }
.gm-sb-org-dd .org-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background 0.1s; text-decoration: none; color: var(--ink); }
.gm-sb-org-dd .org-item:hover { background: var(--paper-alt); }
.gm-sb-org-dd .org-item.active { background: var(--accent-soft); }
.gm-sb-org-dd .org-item .nm { font-weight: 500; font-size: 13px; }
.gm-sb-org-dd .org-item .role { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.gm-sb-org-dd .divider { height: 1px; background: var(--border); margin: 4px 6px; }
.gm-sb-org-dd .footer-link { display: block; padding: 8px 10px; font-size: 12px; color: var(--muted); text-decoration: none; border-radius: 8px; }
.gm-sb-org-dd .footer-link:hover { background: var(--paper-alt); color: var(--accent-dark); }
.gm-sb-org-dd .prop-row { padding: 6px 10px; font-size: 12px; color: var(--muted); }
.gm-sb-org-dd .prop-row select { width: 100%; padding: 6px 8px; margin-top: 4px; background: var(--card); color: var(--ink); border: 1px solid var(--border); border-radius: 8px; font-family: inherit; font-size: 12px; }

/* User chip — avatar only in the bar */
.gm-sb-user { display: inline-flex; align-items: center; text-decoration: none; }
.gm-sb-user .avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12.5px; font-weight: 600; flex-shrink: 0; }
.gm-sb-user .info { display: none; }

/* Mobile toggle + drawer */
.gm-tn-toggle { display: none; width: 40px; height: 40px; border-radius: 8px; background: none; border: 1px solid var(--border); cursor: pointer; align-items: center; justify-content: center; }
.gm-tn-toggle svg { width: 18px; height: 18px; color: var(--ink); }
.gm-tn-mobile { display: none; border-top: 1px solid var(--border); background: var(--card); max-height: calc(100vh - 60px); overflow-y: auto; padding: 8px 14px 20px; }
.gm-tn-mobile.open { display: block; }
.gm-tn-mobile .m-group-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; padding: 14px 8px 4px; }
.gm-tn-mobile .gm-tn-link { font-size: 14.5px; padding: 11px 10px; }
.gm-tn-backdrop { display: none; position: fixed; inset: 60px 0 0; background: rgba(11,31,23,0.35); z-index: 40; }
.gm-tn-backdrop.open { display: block; }

/* Collapse the inline menu into a hamburger drawer when it gets tight */
@media (max-width: 1040px) {
  .gm-tn-menu { display: none; }
  .gm-tn-toggle { display: inline-flex; }
}
@media (max-width: 560px) {
  .gm-tn-inner { gap: 10px; padding: 0 16px; }
  .gm-sb-org { max-width: 128px; }
  .gm-tn-word { display: none; }
}

/* Footer (used inside .app-main) */
.mgt-footer {
  border-top: 1px solid var(--border);
  padding: 24px 28px;
  text-align: center;
  font-size: 11.5px;
  color: var(--muted);
  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; }

/* Legacy: pages that still reference .mgt-topbar — fully hide.
   nav.js no longer renders these but inline pages may. */
.mgt-topbar { display: none !important; }

/* ── Page shell ───────────────────────────────────────────────────── */
.wrap { max-width: var(--max-content); margin: 0 auto; padding: 32px 36px 80px; }
.wrap-narrow { max-width: var(--max-narrow); margin: 0 auto; padding: 32px 36px 80px; }
@media (max-width: 720px) {
  .wrap, .wrap-narrow { padding: 24px 20px 60px; }
}

/* ── Typography hierarchy — sharper, modern SaaS ─────────────────── */
h1 { font-weight: 700; font-size: 28px; margin: 0 0 8px; letter-spacing: -0.022em; line-height: 1.15; color: var(--ink-2); }
h1 .badge {
  font-size: 10px; font-weight: 600;
  background: var(--accent); color: #fff;
  padding: 3px 9px; border-radius: 999px;
  margin-left: 10px; vertical-align: middle; letter-spacing: 0.04em;
  text-transform: uppercase;
}
h2 { font-weight: 600; font-size: 18px; margin: 0 0 10px; letter-spacing: -0.014em; color: var(--ink-2); }
h2.section-heading { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin: 32px 0 14px; }
h3 { font-weight: 600; font-size: 14px; margin: 0 0 6px; letter-spacing: -0.008em; color: var(--ink-2); }
.subtitle { color: var(--soft); font-size: 14px; max-width: 76ch; margin: 0 0 28px; line-height: 1.6; }

/* ── Cards — borderless, subtle shadow ───────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.card h2 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.card .h-sub { font-size: 12.5px; color: var(--muted); margin: 0 0 16px; line-height: 1.55; }

.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; }

/* AI assistant FAB sits at bottom:18px right:18px by default, which
   overlaps the sticky wizard-footer on profile pages. Lift it above the
   footer so it doesn't cover the Next button. */
body[data-page="profile"] #mgt-ai-launcher { bottom: 80px !important; }
body[data-page="profile"] #mgt-ai-launcher + div,
body[data-page="profile"] #mgt-ai-panel { bottom: 140px !important; }

/* Conditional field greying — applied by wizard.js applyShowIf when a
   parent answer means the field doesn't apply. */
.field.field-disabled { opacity: 0.45; pointer-events: none; }
.field.field-disabled label { color: var(--muted); }

/* Inline info-tooltip icon next to a label. */
.field-tip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 6px;
  font-size: 11.5px; color: var(--muted); cursor: help;
  border-radius: 50%;
}
.field-tip:hover, .field-tip:focus { color: var(--accent); outline: 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; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.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; }

/* ============================================================================
   ISSUE 2 — Shared component classes (reduce inline <style> duplication)
   ============================================================================ */

/* Panel — generic content panel used across pages */
.panel {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-card);
}
.panel h2 {
  font-family: var(--font-body);
  font-size: 12px; font-weight: 600;
  color: var(--soft);
  margin: 0 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex; align-items: center; justify-content: space-between;
}
.panel h2 .right-link {
  font-weight: 500; font-size: 11.5px;
  text-transform: none; letter-spacing: 0;
  color: var(--accent); text-decoration: none;
}
.panel h2 .right-link:hover { text-decoration: underline; }

/* Stat mini — small metric display */
.stat-mini { text-align: center; }
.stat-mini .label {
  font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--muted); font-weight: 600;
  margin-bottom: 2px;
}
.stat-mini .value {
  font-family: var(--font-display); font-size: 24px; font-weight: 700;
  color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.014em;
}
.stat-mini .unit-label { font-size: 11px; color: var(--muted); }

/* Stat grid — row of stat-minis */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

/* Dropzone — file upload area */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--soft);
  font-size: 13px;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.dropzone .dropzone-icon { font-size: 28px; margin-bottom: 8px; display: block; }
.dropzone input[type="file"] { display: none; }

/* Spinner — inline loading spinner */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: gm-spin 0.7s linear infinite;
  vertical-align: middle;
}
.spinner-sm { width: 12px; height: 12px; border-width: 1.5px; }
.spinner-lg { width: 24px; height: 24px; border-width: 3px; }
@keyframes gm-spin { to { transform: rotate(360deg); } }

/* ============================================================================
   ISSUE 3 — Lucide icon system
   Loaded from CDN. Use: <i data-lucide="icon-name"></i> then call lucide.createIcons()
   ============================================================================ */

/* Icon sizing and alignment */
[data-lucide] {
  width: 16px; height: 16px;
  stroke-width: 1.8;
  vertical-align: middle;
  display: inline-block;
  flex-shrink: 0;
}
.icon-sm [data-lucide], [data-lucide].icon-sm { width: 14px; height: 14px; }
.icon-lg [data-lucide], [data-lucide].icon-lg { width: 20px; height: 20px; }
.icon-xl [data-lucide], [data-lucide].icon-xl { width: 24px; height: 24px; }

/* Activity feed icons — replace monospace codes */
.feed-icon svg { width: 14px; height: 14px; stroke-width: 2; }

/* ============================================================================
   ISSUE 5 — Loading skeletons
   ============================================================================ */

.skel {
  background: linear-gradient(90deg, var(--border-light) 25%, var(--paper) 50%, var(--border-light) 75%);
  background-size: 200% 100%;
  animation: gm-shimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
  color: transparent !important;
  pointer-events: none;
  user-select: none;
}
.skel * { visibility: hidden; }
@keyframes gm-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Skeleton presets */
.skel-text { height: 14px; margin-bottom: 8px; }
.skel-text.short { width: 40%; }
.skel-text.medium { width: 65%; }
.skel-heading { height: 28px; width: 50%; margin-bottom: 12px; }
.skel-card { height: 120px; border-radius: var(--radius-lg); margin-bottom: 16px; }
.skel-kpi { height: 90px; border-radius: var(--radius); }
.skel-chart { height: 220px; border-radius: var(--radius); }

/* Page loading overlay */
.page-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 300px; color: var(--muted); font-size: 13px;
  gap: 10px;
}

/* ============================================================================
   ISSUE 6 — Accessibility improvements
   ============================================================================ */

/* Focus-visible ring for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Skip to content link */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 13px;
  font-weight: 600;
  z-index: 999;
  transition: top 0.15s;
  text-decoration: none;
}
.skip-link:focus { top: 0; }

/* Improved contrast for small muted labels */
.label-contrast {
  color: var(--soft); /* zinc-700 instead of zinc-500 for small text */
  font-weight: 600;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ARIA live region for status updates */
[aria-live] { position: relative; }

/* ============================================================================
   ISSUE 7 — Toast notification system
   ============================================================================ */

.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--ink);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-modal);
  max-width: 380px;
  display: flex; align-items: center; gap: 10px;
  animation: gm-toast-in 0.25s ease-out;
  line-height: 1.4;
}
.toast.toast-success { background: #065F46; }
.toast.toast-error { background: var(--error); }
.toast.toast-warn { background: var(--warn); }
.toast .toast-dismiss {
  background: none; border: none; color: rgba(255,255,255,0.6);
  cursor: pointer; padding: 2px; font-size: 16px; line-height: 1;
  margin-left: auto; flex-shrink: 0;
}
.toast .toast-dismiss:hover { color: #fff; }
.toast.removing { animation: gm-toast-out 0.2s ease-in forwards; }
@keyframes gm-toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes gm-toast-out { to { opacity: 0; transform: translateY(12px); } }

@media (max-width: 600px) {
  .toast-container { left: 16px; right: 16px; bottom: 16px; }
  .toast { max-width: 100%; }
}

/* ============================================================================
   ISSUE 7 — Command palette (Cmd+K)
   ============================================================================ */

.cmd-palette-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 9998;
  display: none;
}
.cmd-palette-backdrop.open { display: flex; align-items: flex-start; justify-content: center; padding-top: 20vh; }
.cmd-palette {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%; max-width: 560px;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
}
.cmd-palette .cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}
.cmd-palette .cmd-input-wrap svg { color: var(--muted); width: 18px; height: 18px; flex-shrink: 0; }
.cmd-palette .cmd-input {
  flex: 1; border: none; outline: none;
  font-size: 15px; font-family: var(--font-body);
  background: transparent; color: var(--ink);
}
.cmd-palette .cmd-input::placeholder { color: var(--faint); }
.cmd-palette .cmd-results {
  max-height: 320px; overflow-y: auto;
  padding: 6px;
}
.cmd-palette .cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius);
  cursor: pointer; font-size: 13.5px; color: var(--ink);
  transition: background 0.08s;
}
.cmd-palette .cmd-item:hover, .cmd-palette .cmd-item.active {
  background: var(--paper);
}
.cmd-palette .cmd-item .cmd-icon { color: var(--muted); width: 16px; height: 16px; flex-shrink: 0; }
.cmd-palette .cmd-item .cmd-label { flex: 1; }
.cmd-palette .cmd-item .cmd-shortcut {
  font-size: 11px; color: var(--faint);
  font-family: var(--font-mono);
}
.cmd-palette .cmd-group-label {
  font-size: 10.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
  font-weight: 600; padding: 10px 14px 4px;
}
.cmd-palette .cmd-empty {
  text-align: center; padding: 32px; color: var(--muted); font-size: 13px;
}
.cmd-palette .cmd-footer {
  padding: 10px 18px; border-top: 1px solid var(--border-light);
  font-size: 11px; color: var(--faint);
  display: flex; gap: 16px;
}
.cmd-palette .cmd-footer kbd {
  background: var(--paper-alt); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; font-family: var(--font-mono);
  font-size: 10.5px; color: var(--muted);
}

/* ============================================================================
   ISSUE 8 — Responsive table handling
   ============================================================================ */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
}
.table-responsive::-webkit-scrollbar { height: 4px; }
.table-responsive::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.table-responsive .data-table { min-width: 600px; }

/* Mobile card view for key tables */
@media (max-width: 640px) {
  .table-card-mobile thead { display: none; }
  .table-card-mobile tbody tr {
    display: block;
    background: var(--card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 8px;
  }
  .table-card-mobile tbody td {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
  }
  .table-card-mobile tbody td:last-child { border-bottom: 0; }
  .table-card-mobile tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
}

/* ============================================================================
   ISSUE 7 — Dark mode support
   ============================================================================ */

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0A0A0A;
    --paper-alt: #18181B;
    --card: #141416;
    --ink: #FAFAFA;
    --ink-2: #F4F4F5;
    --soft: #A1A1AA;
    --muted: #71717A;
    --faint: #52525B;
    --border: #27272A;
    --border-light: #1E1E22;
    --accent: #2DD4BF;
    --accent-soft: rgba(45,212,191,0.12);
    --accent-dark: #5EEAD4;
    --accent-glow: rgba(45,212,191,0.14);
    /* sidebar — dark chrome in dark mode */
    --sidebar-bg: #0C1614;
    --sidebar-bg-2: #16211D;
    --sidebar-text: #9DB0A4;
    --sidebar-text-hover: #FFFFFF;
    --sidebar-text-active: #5EEAD4;
    --sidebar-active-bg: rgba(45,212,191,0.14);
    --sidebar-border: #1E2A26;
    --sidebar-section: #6B7670;
    --bronze: #D4A04A;
    --bronze-soft: rgba(212,160,74,0.10);
    --warn: #F59E0B;
    --warn-soft: rgba(245,158,11,0.12);
    --error: #EF4444;
    --error-soft: rgba(239,68,68,0.12);
    --info: #60A5FA;
    --info-soft: rgba(96,165,250,0.12);
    --shadow-card: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-pop: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-modal: 0 20px 60px rgba(0,0,0,0.6);
  }
  body { -webkit-font-smoothing: auto; }
  .data-table th { background: var(--paper-alt); }
  .data-table tr:hover { background: var(--paper-alt); }
  .toast { background: var(--card); border: 1px solid var(--border); color: var(--ink); }
  .toast.toast-success { background: #065F46; color: #fff; }
  .toast.toast-error { background: #991B1B; color: #fff; }
  .dropzone { border-color: var(--border); }
  .dropzone:hover, .dropzone.dragover { background: var(--accent-soft); border-color: var(--accent); }
  img, svg { opacity: 0.92; }

  /* Dark-mode fixes for hardcoded light colours */
  .tag-gold { background: rgba(212,160,74,0.15); color: #D4A04A; }
  .feed-icon.pulse { background: rgba(212,160,74,0.15); color: #D4A04A; }
}

/* Breadcrumb navigation */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--muted);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--ink); }
.breadcrumb .sep { color: var(--faint); font-size: 10px; }
.breadcrumb .current { color: var(--ink); font-weight: 600; }
