/* ============================================================
   GrainVision AI — Annotation Platform
   Brand system aligned to Prayati Global (prayathiproducts.com):
   farm-to-fork agritech — deep field green, warm grain gold,
   clean warm-neutral surfaces, modern type. "Technology,
   Transparency, Trust."
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Plus+Jakarta+Sans:wght@600;700;800&display=swap');

:root {
  /* ── Brand ─────────────────────────────────────────────── */
  --brand:        #1E7A46;   /* Prayati field green — primary action */
  --brand-600:    #17663A;   /* hover / pressed */
  --brand-700:    #0F4B2B;
  --brand-50:     #EAF4EE;   /* tint for hovers / active nav */
  --grain:        #D9A526;   /* harvest gold accent */
  --grain-soft:   #FBF3DD;

  /* header uses a deep green so app chrome reads as "Prayati" */
  --header:       #10362A;
  --header-2:     #17482F;

  /* legacy token names kept so every template keeps working,
     repointed to the new brand */
  --navy:      var(--header);
  --navy-700:  #0C2A20;
  --navy-50:   var(--brand-50);
  --teal:      var(--brand);
  --teal-600:  var(--brand-600);

  --ink:       #17251E;
  --ink-soft:  #46574D;
  --muted:     #8A968D;
  --line:      #E4EAE1;
  --line-soft: #EFF3EC;
  --border:    #E4EAE1;
  --bg:        #F5F8F3;
  --card:      #FFFFFF;

  --ok:         #2E9E5B;
  --warn-amber: #B7791F;
  --warn-amber-bg: #FBF3DD;
  --warn-orange: #E67E22;
  --danger:     #E05242;

  /* label classes (functional data colours — unchanged) */
  --label-good: #2ECC71;
  --label-broken: #E67E22;
  --label-foreign: #E74C3C;
  --label-immature: #9B59B6;
  --label-fungal: #1ABC9C;
  --label-unlabeled: #95A5A6;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16,32,24,.05), 0 4px 14px rgba(16,32,24,.05);
  --shadow-lg: 0 18px 44px rgba(16,32,24,.16);
  --font: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Plus Jakarta Sans", var(--font);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--ink); margin: 0 0 .4em; line-height: 1.22; letter-spacing: -.01em; }

/* ── App shell ─────────────────────────────────────────────── */
.topbar {
  background: linear-gradient(100deg, var(--header) 0%, var(--header-2) 100%);
  color: #fff;
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 22px;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 1px 0 rgba(255,255,255,.04), 0 2px 12px rgba(16,32,24,.14);
}
.topbar .brand { display: flex; align-items: center; gap: 11px; font-weight: 700; font-family: var(--font-head); letter-spacing: -.01em; }
.topbar .brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(150deg, var(--brand) 0%, #2FA35C 100%);
  color: #fff; display: grid; place-items: center; font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16), 0 2px 6px rgba(0,0,0,.2);
}
.topbar .crumb { color: #A9C4B4; font-weight: 400; font-size: 13px; }
.topbar .spacer { flex: 1; }
.topbar .user {
  display: flex; align-items: center; gap: 9px; font-size: 13px; color: #CFE0D6;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(150deg, var(--brand) 0%, #2FA35C 100%); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.topbar a { color: #CFE0D6; }
.topbar a:hover { color: #fff; }

.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
  width: 232px; background: #fff; border-right: 1px solid var(--line);
  padding: 18px 14px; flex-shrink: 0;
}
.sidebar .group { font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 18px 10px 7px; font-weight: 700; }
.sidebar a {
  position: relative;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 13px; border-radius: var(--radius-sm); color: var(--ink-soft);
  font-weight: 500; margin-bottom: 3px;
}
.sidebar a:hover { background: var(--brand-50); text-decoration: none; color: var(--brand-700); }
.sidebar a.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.sidebar a.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}
.sidebar a .pill { background: var(--brand); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 1px 8px; font-weight: 700; }

.main { flex: 1; padding: 28px 36px; max-width: 1300px; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 23px; }
.page-head .sub { color: var(--ink-soft); font-size: 13px; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px;
}
.card + .card { margin-top: 18px; }
.card h3 { font-size: 15px; }
.card-title { font-size: 12px; font-weight: 700; color: var(--ink); margin-bottom: 14px;
  text-transform: uppercase; letter-spacing: .06em; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: var(--radius-sm); font-weight: 600;
  font-size: 13px; font-family: var(--font); transition: .14s ease;
}
.btn:hover { background: var(--brand-50); border-color: #cfe0d4; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(15,75,43,.2); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-teal { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-teal:hover { background: var(--brand-600); }
.btn-gold { background: var(--grain); border-color: var(--grain); color: #3d2f07; }
.btn-gold:hover { filter: brightness(.96); }
.btn-danger { color: var(--danger); border-color: #f1c7c1; background: #fdf3f1; }
.btn-danger:hover { background: #fbe9e6; }
.btn-warn { color: var(--warn-orange); border-color: #f3d8b8; background: #fdf6ec; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-lg { padding: 12px 22px; font-size: 14px; }
.btn.small { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────────── */
label.field { display: block; font-weight: 600; font-size: 12px;
  color: var(--ink-soft); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=email],
input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font);
  background: #fff; color: var(--ink); transition: .14s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30,122,70,.14);
}
.input-suffix { position: relative; }
.input-suffix .suffix { position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); color: var(--muted); font-size: 12px; }

/* ── Badges & banners ──────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-pending { background: var(--grain-soft); color: var(--warn-amber); }
.badge-approved { background: #e6f6ec; color: #1e8e4e; }
.badge-rejected { background: #fdf2f0; color: var(--danger); }
.badge-rework { background: #fef0e7; color: var(--warn-orange); }
.badge-warn { background: var(--grain-soft); color: var(--warn-amber); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

.banner { padding: 12px 15px; border-radius: var(--radius-sm); font-size: 13px;
  border: 1px solid transparent; margin-bottom: 12px; }
.banner-ok { background: #e9f6ee; border-color: #bce3cb; color: #1e7e45; }
.banner-amber { background: var(--warn-amber-bg); border-color: #ecdcae; color: var(--warn-amber); }
.banner-orange { background: #fdf1e7; border-color: #f3d2b0; color: #b35a17; }
.banner-info { background: var(--brand-50); border-color: #c8e2d3; color: var(--brand-700); }
.banner-error { background: #fdf2f0; border-color: #f1c7c1; color: #b53a2a; }

/* ── Tables ────────────────────────────────────────────────── */
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: left; font-size: 11px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); padding: 11px 12px;
  border-bottom: 1px solid var(--line); font-weight: 700; }
table.data td { padding: 12px; border-bottom: 1px solid var(--line-soft); }
table.data tr:hover td { background: var(--brand-50); }
table.data tr.dimmed td { opacity: .5; }
table.data tr.flagged td { background: var(--grain-soft); }

/* ── Stepper (assayer flow) ────────────────────────────────── */
.stepper { display: flex; align-items: center; gap: 8px; margin: 0 auto 26px;
  max-width: 640px; justify-content: center; }
.stepper .step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.stepper .num { width: 26px; height: 26px; border-radius: 50%; display: grid;
  place-items: center; font-size: 12px; font-weight: 700; background: #e7ede8; color: var(--muted); }
.stepper .step.done .num { background: var(--ok); color: #fff; }
.stepper .step.active .num { background: var(--brand); color: #fff; box-shadow: 0 0 0 4px var(--brand-50); }
.stepper .step.active { color: var(--brand-700); font-weight: 700; }
.stepper .bar { width: 40px; height: 2px; background: var(--line); }

/* ── Metric cards ──────────────────────────────────────────── */
.metric { text-align: left; }
.metric .value { font-family: var(--font-head); font-size: 30px; font-weight: 800; color: var(--brand-700); letter-spacing: -.02em; }
.metric .value.green { color: #1e8e4e; }
.metric .value.amber { color: var(--warn-amber); }
.metric .label { font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; }

/* ── Distribution / progress bars ──────────────────────────── */
.dist-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.dist-row .name { flex: 0 0 140px; display: flex; align-items: center; gap: 7px; }
.dist-row .track { flex: 1; height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.dist-row .fill { height: 100%; border-radius: 999px; }
.dist-row .pct { flex: 0 0 56px; text-align: right; font-weight: 700; }

.progress-bar { height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.progress-bar .fill { height: 100%; background: var(--brand); }

/* ── Auth ──────────────────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(140deg, var(--header) 0%, var(--brand-700) 55%, #0c2a20 100%); padding: 20px; }
.auth-card { width: 100%; max-width: 390px; background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 36px 32px; }
.auth-card .logo { width: 46px; height: 46px; border-radius: 12px;
  background: linear-gradient(150deg, var(--brand) 0%, #2FA35C 100%);
  color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 21px; margin-bottom: 16px; }

/* ── Annotation canvas ─────────────────────────────────────── */
.canvas-stage { background: #0e1512; border-radius: var(--radius); position: relative;
  display: grid; place-items: center; overflow: hidden; min-height: 460px; }
.canvas-stage svg { max-width: 100%; height: auto; display: block; }
.polygon { cursor: pointer; transition: fill-opacity .1s; }
.polygon:hover { stroke-width: 2.4; }
.toolbar { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tool { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: #fff; display: grid; place-items: center; cursor: pointer; font-size: 16px; }
.tool.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.label-panel { position: fixed; right: 24px; bottom: 24px; width: 300px; background: #fff;
  border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--line);
  padding: 18px; z-index: 60; display: none; }
.label-panel.open { display: block; }
.label-opt { display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-radius: var(--radius-sm); margin-bottom: 7px; cursor: pointer; font-weight: 600;
  min-height: 56px; border: 1px solid transparent; }
.label-opt:hover { filter: brightness(.97); }

.legend-row { display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; padding: 5px 0; }
.legend-row .left { display: flex; align-items: center; gap: 8px; }

.split { display: grid; grid-template-columns: 1.7fr 1fr; gap: 18px; align-items: start; }

/* messages */
.msg-stack { position: fixed; top: 74px; right: 20px; z-index: 80; width: 360px; }
.msg-stack .banner { box-shadow: var(--shadow-lg); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap { gap: 10px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.amber { color: var(--warn-amber); }
.green { color: #1e8e4e; }

/* ── Mobile menu primitives (hidden on desktop) ─────────────── */
.menu-toggle {
  display: none; background: transparent; border: 0; color: #fff;
  font-size: 22px; line-height: 1; padding: 6px 8px; cursor: pointer;
  border-radius: var(--radius-sm); margin-right: 2px;
}
.menu-toggle:hover { background: rgba(255,255,255,.12); }
.sidebar-backdrop {
  display: none; position: fixed; inset: 60px 0 0 0; z-index: 39;
  background: rgba(10,20,15,.5);
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .user-name { display: none; }
  .topbar .crumb { display: none; }
  .sidebar {
    position: fixed; top: 60px; bottom: 0; left: 0; z-index: 40;
    width: 250px; max-width: 82vw;
    transform: translateX(-100%); transition: transform .22s ease;
    overflow-y: auto; box-shadow: 2px 0 18px rgba(0,0,0,.18);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .sidebar-backdrop { display: block; }
  .main { padding: 16px; max-width: 100%; }
  .grid-2, .grid-4, .split, .canvas-grid { grid-template-columns: 1fr !important; }
  .btn { min-height: 44px; padding: 11px 18px; }
  .btn.small { min-height: 36px; }
  .sidebar a { padding: 12px 12px; }
  .tool { width: 46px; height: 46px; }
  input, select, textarea { min-height: 44px; font-size: 16px; }
  table.data { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .canvas-stage { height: 56vh !important; min-height: 320px !important; }
  .toolbar { flex-wrap: wrap; }
  .label-panel { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media (max-width: 560px) {
  .main { padding: 12px; }
  .card { padding: 16px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .page-head .btn, .page-head .btn-lg { width: 100%; justify-content: center; }
  .flex.gap { flex-wrap: wrap; }
  .flex-between { flex-wrap: wrap; gap: 10px; }
  h2 { font-size: 19px; }
  .canvas-stage { height: 48vh !important; }
}
