/* ============================================================
   G×E×M Framework — Design System
   Palette drawn from field/instrument materials: tilled soil,
   leaf canopy, grain amber — not the default AI cream/terracotta.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  --canopy-950: #12190f;
  --canopy-900: #1c2617;
  --canopy-800: #263420;
  --leaf-600: #4c7a3d;
  --leaf-500: #5f9450;
  --leaf-100: #e7f0e1;
  --soil-100: #f4f6f0;
  --soil-50:  #fbfcf9;
  --paper:    #ffffff;
  --amber-500:#d9a441;
  --amber-100:#faf1dc;
  --clay-500: #b5573a;
  --clay-100: #f7e6e0;
  --ink-900:  #1d2418;
  --ink-600:  #4a5443;
  --ink-400:  #7c8776;
  --line:     #dfe5d8;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-1: 0 1px 2px rgba(18,25,15,0.06), 0 1px 1px rgba(18,25,15,0.04);
  --shadow-2: 0 4px 16px rgba(18,25,15,0.08);

  --font-display: 'Fraunces', serif;
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font-family: var(--font-body);
  background: var(--soil-100);
  color: var(--ink-900);
  font-size: 15px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }

/* ---------- Shell layout ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background:
    repeating-linear-gradient(180deg, rgba(255,255,255,0.02) 0px, rgba(255,255,255,0.02) 1px, transparent 1px, transparent 34px),
    linear-gradient(180deg, var(--canopy-900), var(--canopy-950));
  color: #eef2ea;
  display: flex;
  flex-direction: column;
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { margin-bottom: 28px; padding: 0 8px; }
.brand-mark {
  display: block;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: #fff;
}
.brand-sub {
  display: block;
  font-size: 11.5px;
  color: #9db28f;
  margin-top: 4px;
  letter-spacing: 0.02em;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: #cfd9c6;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active {
  background: var(--leaf-600);
  color: #fff;
}

.user-chip {
  border-top: 1px solid rgba(255,255,255,0.08);
  padding: 14px 4px 12px;
  margin-top: 8px;
}
.user-chip-name { font-size: 13.5px; font-weight: 600; color: #eef2ea; }
.user-chip-role { font-size: 11.5px; color: #9db28f; margin-top: 2px; }
.user-chip-role a { color: #cfd9c6; text-decoration: underline; }
.user-chip-role a:hover { color: #fff; }

.sidebar-footer {
  font-size: 10.5px;
  color: #7f9271;
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 14px;
  line-height: 1.6;
}

.content {
  flex: 1;
  padding: 32px 40px 60px;
  max-width: 1240px;
}

/* ---------- Typography ---------- */
h1, h2, h3 { font-family: var(--font-display); color: var(--ink-900); margin: 0 0 4px; }
h1 { font-size: 30px; font-weight: 600; }
h2 { font-size: 21px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
.page-header { margin-bottom: 26px; }
.page-sub { color: var(--ink-400); font-size: 14px; margin-top: 4px; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--leaf-600);
  font-weight: 600;
}

/* ---------- Cards / Panels ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  box-shadow: var(--shadow-1);
  margin-bottom: 22px;
}
.card-flat { padding: 18px 20px; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 980px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: repeat(2,1fr); }
}

/* ---------- Stat tiles ---------- */
.stat-tile {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-tile .stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-400);
}
.stat-tile .stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 600;
  margin-top: 6px;
  color: var(--ink-900);
}
.stat-tile .stat-trend { font-size: 12.5px; margin-top: 6px; color: var(--leaf-600); font-weight: 500; }
.stat-tile.accent-amber .stat-value { color: var(--amber-500); }
.stat-tile.accent-clay .stat-value { color: var(--clay-500); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}
.btn-primary { background: var(--leaf-600); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--paper); border-color: var(--line); color: var(--ink-900); }
.btn-secondary:hover { background: var(--soil-100); }
.btn-danger { background: var(--clay-100); color: var(--clay-500); }
.btn-danger:hover { filter: brightness(0.97); }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }

/* ---------- Forms ---------- */
label { display:block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-600); }
input[type=text], input[type=number], input[type=date], input[type=email],
input[type=password], input[type=file], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--soil-50);
  color: var(--ink-900);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--leaf-500);
  outline-offset: 1px;
  background: #fff;
}
.field { margin-bottom: 16px; }
.field-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 16px; margin-bottom: 18px; }
legend { font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--leaf-600); padding: 0 6px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-400);
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  white-space: nowrap;
}
tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tbody tr:hover { background: var(--soil-50); }
.table-wrap { overflow-x: auto; }

/* ---------- Code / label pills (the "seed packet" signature) ---------- */
.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--leaf-100);
  color: var(--leaf-600);
  border: 1px solid #cfe3c5;
}
.pill-amber { background: var(--amber-100); color: #9c7420; border-color: #edd9a8; }
.pill-clay { background: var(--clay-100); color: var(--clay-500); border-color: #edcabf; }
.pill-muted { background: var(--soil-100); color: var(--ink-400); border-color: var(--line); }

/* ---------- Badges for QC / status ---------- */
.badge { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 5px; }
.badge-pass { background: var(--leaf-100); color: var(--leaf-600); }
.badge-fail { background: var(--clay-100); color: var(--clay-500); }
.badge-pending { background: var(--amber-100); color: #9c7420; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 16px; font-size: 13.5px; font-weight: 500; }
.alert-success { background: var(--leaf-100); color: var(--leaf-600); border: 1px solid #cfe3c5; }
.alert-danger { background: var(--clay-100); color: var(--clay-500); border: 1px solid #edcabf; }
.alert-info { background: var(--amber-100); color: #9c7420; border: 1px solid #edd9a8; }

/* ---------- Pipeline stage strip (signature element on dashboard) ---------- */
.stage-strip { display: flex; gap: 10px; margin: 20px 0 26px; }
.stage-chip {
  flex: 1;
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  border: 1px solid var(--line);
  background: var(--paper);
  position: relative;
}
.stage-chip .stage-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-400);
}
.stage-chip .stage-title { font-size: 13px; font-weight: 700; margin-top: 3px; }
.stage-chip.done { border-color: var(--leaf-500); }
.stage-chip.done::after {
  content: "";
  position: absolute; left:0; right:0; bottom:-1px; height:3px;
  background: var(--leaf-500); border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.stage-chip.external { border-style: dashed; }
.stage-chip.external .stage-title { color: var(--ink-400); }

/* ---------- Misc ---------- */
.flex-between { display:flex; align-items:center; justify-content:space-between; }
.text-muted { color: var(--ink-400); }
.text-mono { font-family: var(--font-mono); }
.mt-0 { margin-top:0; }
.section-gap { margin-top: 34px; }
.empty-state { text-align:center; padding: 44px 20px; color: var(--ink-400); }
.empty-state h3 { color: var(--ink-600); }
