/* ═══════════════════════════════════════════════════════════
   KISARA AGRITECH — Design System v2
   Aesthetic: Field Intelligence · Premium Agricultural Platform
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ── TOKENS ──────────────────────────────────────────────── */
:root {
  /* Brand palette */
  --green:        #2D7D3A;
  --green-dark:   #1e5628;
  --green-mid:    #377a42;
  --green-light:  #e5f3e7;
  --green-pale:   #f0faf1;
  --navy:         #2D3580;
  --navy-mid:     #3840a0;
  --navy-light:   #e8eaf8;
  --navy-pale:    #f2f3fd;

  /* Surfaces */
  --surface:       #ffffff;
  --surface-muted: #f3f6f3;
  --surface-card:  #ffffff;

  /* Borders */
  --border:        #dde5dc;
  --border-light:  #edf2ec;
  --border-strong: #c5d3c4;

  /* Text */
  --text:         #0f1a0e;
  --text-muted:   #52654f;
  --text-xmuted:  #8ba08a;

  /* Semantic */
  --warning:      #a05800;
  --warning-bg:   #fff7e8;
  --danger:       #bc2d20;
  --danger-bg:    #fef0ee;
  --success-bg:   #ecf7ed;

  /* Geometry */
  --radius:    16px;
  --radius-sm: 12px;
  --radius-xs: 10px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 4px rgba(0,0,0,.05), 0 1px 2px rgba(0,0,0,.03);
  --shadow:    0 2px 10px rgba(0,0,0,.07), 0 1px 3px rgba(0,0,0,.04);
  --shadow-md: 0 6px 24px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg: 0 16px 48px rgba(0,0,0,.12), 0 4px 12px rgba(0,0,0,.06);
  --shadow-green: 0 4px 16px rgba(45,125,58,.28);
  --shadow-navy:  0 4px 16px rgba(45,53,128,.22);

  /* Typography */
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', SFMono-Regular, ui-monospace, monospace;
  --max-w: 480px;

  /* Instrument-panel number rendering */
  --num-features: "tnum" 1, "lnum" 1;
}

/* ── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--surface-muted);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100dvh;
  /* Subtle brand gradient at top */
  background-image: linear-gradient(180deg, rgba(45,125,58,.045) 0px, transparent 140px);
  background-attachment: local;
}

/* ── PAGE SHELL ──────────────────────────────────────────── */
.page {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px 56px;
}

/* ── HEADER ──────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 50;
  margin: 0 -16px 24px;
}
/* Subtle green accent line at very top */
.page-header::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green-dark), var(--green), var(--green-mid));
}

.logo-mark {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.logo-mark .name {
  font-size: 18px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: -0.6px;
  line-height: 1;
}
.logo-mark .sub {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-xmuted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-actions { display: flex; align-items: center; gap: 8px; }

/* ── LANGUAGE TOGGLE ─────────────────────────────────────── */
.lang-toggle { display: flex; gap: 2px; }
.lang-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 0.2px;
}
.lang-btn.active {
  background: var(--green);
  border-color: var(--green);
  color: white;
  box-shadow: 0 1px 4px rgba(45,125,58,.30);
}

/* ── SECTION LABELS ──────────────────────────────────────── */
.section-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-xmuted);
  margin: 28px 0 10px;
}

/* ── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  margin-bottom: 10px;
  animation: fadeUp 0.32s ease both;
  position: relative;
}
/* Inner top highlight for depth */
.card::after {
  content: '';
  position: absolute;
  top: 1px; left: 1px; right: 1px;
  height: 1px;
  background: rgba(255,255,255,1);
  border-radius: var(--radius) var(--radius) 0 0;
  pointer-events: none;
}

.card + .card { animation-delay: 60ms; }
.card + .card + .card { animation-delay: 120ms; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── METRIC CARDS ────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.metric-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  animation: fadeUp 0.32s ease both;
  position: relative;
  overflow: hidden;
}
/* Colored top accent bar */
.metric-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green-dark), var(--green-mid));
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.metric-card:nth-child(2) { animation-delay: 50ms; }
.metric-card:nth-child(3) { animation-delay: 100ms; }
.metric-card:nth-child(4) { animation-delay: 150ms; }

.metric-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-xmuted);
  margin-bottom: 6px;
}
.metric-value {
  font-size: 38px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1.5px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: var(--num-features);
  color: var(--text);
}
/* Gradient text for color variants */
.metric-value.green {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.metric-value.navy {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.metric-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 4px;
}

/* ── SUMMARY STRIP ───────────────────────────────────────── */
.summary-strip {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 55%, var(--green-mid) 100%);
  color: white;
  padding: 18px 20px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.32s ease both;
  box-shadow: var(--shadow-green);
}
.summary-strip::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
}
/* Inner top highlight */
.summary-strip::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: rgba(255,255,255,0.20);
}
.summary-strip strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.summary-strip .strip-number {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -1.2px;
  display: block;
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

/* ── PERIOD TOGGLE — iOS segmented style ─────────────────── */
.period-toggle {
  display: flex;
  background: rgba(0,0,0,.06);
  border-radius: 50px;
  padding: 3px;
  gap: 2px;
  margin-bottom: 20px;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.period-toggle::-webkit-scrollbar { display: none; }
.period-btn {
  flex: 1;
  min-width: fit-content;
  padding: 8px 14px;
  border: none;
  border-radius: 50px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
  -webkit-tap-highlight-color: transparent;
}
.period-btn.active {
  background: var(--surface);
  color: var(--green);
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.06);
}

/* ── FORMS ───────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.25px;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 10.5px;
}

input, select, textarea {
  width: 100%;
  height: 56px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-size: 16px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  outline: none;
}
textarea {
  height: auto;
  min-height: 80px;
  padding: 14px 16px;
  resize: none;
  line-height: 1.5;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3.5px rgba(45,125,58,.10);
  background: var(--green-pale);
}
input::placeholder { color: var(--text-xmuted); font-weight: 400; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238ba08a' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

.input-hint {
  font-size: 12px;
  color: var(--text-xmuted);
  margin-top: 5px;
  font-weight: 500;
}
.input-hint.pub-rate {
  color: var(--green);
  font-weight: 600;
}

/* ── DIVIDER ─────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), transparent);
  margin: 22px 0;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 54px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius-xs);
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: -0.1px;
}
.btn:active  { transform: scale(0.97); }
.btn:disabled { opacity: 0.38; pointer-events: none; }

.btn-primary {
  background: linear-gradient(160deg, var(--green-mid) 0%, var(--green) 50%, var(--green-dark) 100%);
  color: white;
  box-shadow: var(--shadow-green);
  letter-spacing: 0;
}
.btn-primary:active { box-shadow: 0 1px 4px rgba(45,125,58,.25); }

.btn-secondary {
  background: var(--surface);
  color: var(--green);
  border: 1.5px solid var(--green);
  box-shadow: var(--shadow-xs);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  height: 36px;
  font-size: 13px;
  font-weight: 600;
  width: auto;
  box-shadow: none;
}
.btn-sm { height: 38px; font-size: 13px; font-weight: 600; width: auto; padding: 0 16px; }

/* Pilot START JOB — commanding, can't miss it */
.btn-start {
  height: 64px;
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(160deg, var(--green-mid) 0%, var(--green) 60%, var(--green-dark) 100%);
  color: white;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-green);
  letter-spacing: 0.1px;
}
.btn-start::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(45,125,58,.4);
  animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(45,125,58,.35); }
  60%  { box-shadow: 0 0 0 12px rgba(45,125,58,0); }
  100% { box-shadow: 0 0 0 0 rgba(45,125,58,0); }
}

/* ── DEVIATION BUTTONS ───────────────────────────────────── */
.deviation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.deviation-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 18px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  font-family: var(--font);
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.deviation-btn:active { transform: scale(0.96); }
.deviation-btn .dev-icon { font-size: 26px; }
.deviation-btn.selected {
  border-color: var(--green);
  background: var(--green-pale);
  color: var(--green);
  box-shadow: 0 0 0 3px rgba(45,125,58,.10);
}

/* ── BOOKING CARDS ───────────────────────────────────────── */
.booking-card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 8px;
  border-left: 3px solid var(--border);
  border: 1px solid var(--border-light);
  border-left-width: 3px;
  border-left-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
  animation: fadeUp 0.25s ease both;
}
.booking-card.pending   { border-left-color: var(--navy); }
.booking-card.completed { border-left-color: var(--green); }
.booking-card.partial   { border-left-color: var(--warning); }
.booking-card.cancelled { border-left-color: #bbb; }

.booking-row    { display: flex; justify-content: space-between; align-items: flex-start; }
.booking-loc    { font-size: 15.5px; font-weight: 700; color: var(--text); line-height: 1.25; }
.booking-meta   { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.4; }
.booking-acres  {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green-dark), var(--green-mid));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -1.2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.booking-rate { font-size: 12px; color: var(--text-muted); text-align: right; margin-top: 3px; font-weight: 500; }

/* ── JOB CARDS (pilot view) ──────────────────────────────── */
.job-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  animation: fadeUp 0.32s ease both;
  position: relative;
}
.job-card::after {
  content: '';
  position: absolute;
  top: 1px; left: 1px; right: 1px;
  height: 1px;
  background: rgba(255,255,255,1);
  border-radius: var(--radius) var(--radius) 0 0;
  pointer-events: none;
}
.job-loc  { font-size: 21px; font-weight: 800; letter-spacing: -0.5px; }
.job-crop { font-size: 13px; color: var(--text-muted); margin-top: 3px; font-weight: 500; }
.job-number {
  font-size: 52px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -2.5px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  font-feature-settings: var(--num-features);
}
.job-number-label { font-size: 12px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; }
.job-rate { font-size: 15px; font-weight: 700; color: var(--navy); margin-top: 8px; }

.completion-panel {
  border-top: 1px solid var(--border-light);
  padding-top: 20px;
  margin-top: 18px;
  display: none;
}

/* ── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.badge-success { background: var(--success-bg);  color: var(--green); }
.badge-warning { background: var(--warning-bg);  color: var(--warning); }
.badge-danger  { background: var(--danger-bg);   color: var(--danger); }
.badge-muted   { background: var(--surface-muted); color: var(--text-muted); }
.badge-navy    { background: var(--navy-light);  color: var(--navy); }

/* ── FLAG ITEMS ──────────────────────────────────────────── */
.flag-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border: 1px solid var(--border-light);
  border-left: 3px solid var(--warning);
  box-shadow: var(--shadow-xs);
  animation: fadeUp 0.25s ease both;
}
.flag-item.critical {
  border-left-color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(188,45,32,.12);
  border-left-color: var(--danger);
}
.flag-label  { font-size: 13px; font-weight: 700; margin-bottom: 2px; color: var(--text); }
.flag-detail { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }

/* ── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state .e-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.55; }
.empty-state p { font-size: 14.5px; font-weight: 500; }

/* ── TOAST ───────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--text);
  color: white;
  padding: 12px 22px;
  border-radius: 28px;
  font-size: 14px;
  font-weight: 600;
  z-index: 1000;
  transition: transform 0.28s cubic-bezier(0.34,1.56,0.64,1);
  white-space: nowrap;
  max-width: calc(100vw - 48px);
  box-shadow: var(--shadow-md);
}
.toast.show    { transform: translateX(-50%) translateY(0); }
.toast.error   { background: var(--danger); }
.toast.success { background: var(--green); box-shadow: var(--shadow-green); }

/* ── MODAL SHEET ─────────────────────────────────────────── */
.sheet-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.40);
  z-index: 100;
  align-items: flex-end;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.sheet-overlay.open { display: flex; }
.sheet {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 8px 20px 48px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.34,1.36,0.64,1);
}
/* Sheet drag handle */
.sheet::before {
  content: '';
  display: block;
  width: 36px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 2px;
  margin: 12px auto 20px;
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

/* ── SPINNER ─────────────────────────────────────────────── */
.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  margin: 48px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── STAGGERED LIST ──────────────────────────────────────── */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 65ms; }
.stagger > *:nth-child(3) { animation-delay: 130ms; }
.stagger > *:nth-child(4) { animation-delay: 195ms; }
.stagger > *:nth-child(5) { animation-delay: 260ms; }
