/* ============================================================
   Solubio Na Fazenda — Cordel Brasileiro brutalist
   Portado do design_handoff_solubio_na_fazenda/source/styles.css
   Adaptado pra mobile-first dentro do PWA Jinja+Tailwind.
   Coexiste com Tailwind: CSS plain via classes utilitarias.
   ============================================================ */

:root {
  /* Tokens — alinhados com base.html (mesmas cores, novos aliases) */
  --bg: #f4e8d0;
  --primary: #b83a2b;
  --secondary: #e8b931;
  --accent: #2e5266;
  --card: #fdf6e3;
  --fg: #1a1410;
  --muted: #efe2c5;
  --destructive: #992d22;
  --success: #4a6b2a;
  --border-w: 2px;
  --shadow: 3px 3px 0 var(--fg);
  --shadow-sm: 2px 2px 0 var(--fg);
  --shadow-lg: 4px 4px 0 var(--fg);
}

/* === FONTES (DM Sans + Bricolage + Mono) =================== */
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

/* === HEADER DE TELA (.app-header) ========================== */
.app-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: var(--border-w) solid var(--fg);
  background: var(--bg);
}
.app-header h1 {
  margin: 0;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.02em;
  flex: 1;
  line-height: 1;
}
.app-header .icon-btn,
.icon-btn {
  width: 36px; height: 36px;
  border: var(--border-w) solid var(--fg);
  background: var(--card);
  display: grid; place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  color: var(--fg);
  text-decoration: none;
}
.icon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--fg); }

/* === HERO HEADER (Roca) ==================================== */
.hero-header {
  padding: 14px 16px 14px;
  background: var(--primary);
  color: var(--card);
  border-bottom: 3px solid var(--fg);
}
.hero-header .hero-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 26px;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.hero-header .hero-eyebrow {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--card);
  opacity: 0.85;
}

/* === BOTTOM NAV (5 abas) =================================== */
.bnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 72px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--card);
  border-top: var(--border-w) solid var(--fg);
  z-index: 40;
  max-width: 28rem;
  margin: 0 auto;
}
.bnav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg);
  padding: 8px 4px 10px;
  position: relative;
  text-decoration: none;
}
.bnav-item iconify-icon { font-size: 24px; }
.bnav-item.active { background: var(--secondary); }
.bnav-item.active::before {
  content: '';
  position: absolute;
  top: -2px; left: 0; right: 0; height: 4px;
  background: var(--primary);
}

/* === CARDS ================================================= */
.card-cordel {
  background: var(--card);
  border: var(--border-w) solid var(--fg);
  box-shadow: var(--shadow);
  padding: 14px;
}
.card-cordel.flat { box-shadow: none; }
.card-cordel.thick { border-width: 3px; box-shadow: var(--shadow-lg); }
.card-cordel.muted { background: var(--muted); }
.card-cordel.secondary { background: var(--secondary); color: var(--fg); }
.card-cordel.accent { background: var(--accent); color: var(--card); }
.card-cordel.primary { background: var(--primary); color: var(--card); }

/* === LABELS / EYEBROW ====================================== */
.eyebrow {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
  opacity: 0.7;
}
.eyebrow.on-dark { color: var(--card); opacity: 0.85; }

.h-cordel {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.015em;
  line-height: 1.05;
}
.h-cordel.h1 { font-size: 28px; }
.h-cordel.h2 { font-size: 22px; }
.h-cordel.h3 { font-size: 16px; }

.mono { font-family: 'JetBrains Mono', monospace; }

/* === BOTOES "CARIMBO" ====================================== */
.btn-cordel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 16px;
  border: var(--border-w) solid var(--fg);
  background: var(--primary);
  color: var(--card);
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .08s, box-shadow .08s;
  text-decoration: none;
}
.btn-cordel:hover { transform: translate(-1px,-1px); box-shadow: 4px 4px 0 var(--fg); }
.btn-cordel:active { transform: translate(2px,2px); box-shadow: 1px 1px 0 var(--fg); }
.btn-cordel.full { width: 100%; }
.btn-cordel.secondary { background: var(--secondary); color: var(--fg); }
.btn-cordel.ghost { background: var(--card); color: var(--fg); }
.btn-cordel.accent { background: var(--accent); color: var(--card); }
.btn-cordel.destructive { background: var(--destructive); color: var(--card); }
.btn-cordel.sm { padding: 8px 10px; font-size: 10px; box-shadow: var(--shadow-sm); }

/* === INPUTS ================================================ */
.field-cordel { display: flex; flex-direction: column; gap: 6px; }
.field-cordel > label,
.field-cordel > .lbl {
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
}
.input-cordel {
  width: 100%;
  background: var(--card);
  border: var(--border-w) solid var(--fg);
  padding: 12px;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--fg);
  box-shadow: var(--shadow-sm);
  outline: none;
  border-radius: 0;
}
.input-cordel:focus {
  background: #fff;
  box-shadow: var(--shadow);
}
textarea.input-cordel { min-height: 96px; resize: vertical; }

/* === BADGES ================================================ */
.badge-cordel {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1.5px solid var(--fg);
  background: var(--muted);
  font-family: 'DM Sans', sans-serif;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  line-height: 1.2;
}
.badge-cordel.b-yellow { background: var(--secondary); }
.badge-cordel.b-red { background: var(--destructive); color: var(--card); }
.badge-cordel.b-teal { background: var(--accent); color: var(--card); }
.badge-cordel.b-green { background: var(--success); color: var(--card); }
.badge-cordel.b-cream { background: var(--card); }

/* === MISC: divider, row, col, stack, kpi, gaps ============= */
.divider-cordel { height: 0; border-top: 2px dashed var(--fg); opacity: 0.4; margin: 12px 0; }
.row-cordel { display: flex; align-items: center; gap: 8px; }
.row-cordel.between { justify-content: space-between; }
.col-cordel { display: flex; flex-direction: column; }
.stack-cordel { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.stack-cordel > * { flex: 0 0 auto; }
.tight { gap: 8px; }

.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* === Numerais grandes (KPIs) =============================== */
.bigval {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 32px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.midval {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.02em;
}

/* === PROGRESS =============================================== */
.progress-cordel {
  height: 14px;
  border: var(--border-w) solid var(--fg);
  background: var(--bg);
  position: relative;
  overflow: hidden;
}
.progress-cordel > span {
  display: block; height: 100%;
  background: var(--primary);
  background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(0,0,0,0.15) 6px 8px);
}
.progress-cordel.on-dark { background: rgba(255,255,255,0.18); border-color: var(--card); }

/* === Textura cordel woodcut sutil ========================== */
.woodcut {
  background-image:
    repeating-linear-gradient(45deg, transparent 0 5px, rgba(26,20,16,0.04) 5px 6px);
}

/* === Separador de secao =================================== */
.sep-line { border: 0; border-top: 2px solid var(--fg); margin: 0; }

/* === Linhas de lista (lrow) =============================== */
.lrow {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: var(--border-w) solid var(--fg);
  background: var(--card);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--fg);
}
.lrow .leading {
  width: 40px; height: 40px;
  border: var(--border-w) solid var(--fg);
  background: var(--secondary);
  display: grid; place-items: center;
  flex: 0 0 40px;
}
.lrow .leading.primary { background: var(--primary); color: var(--card); }
.lrow .leading.accent { background: var(--accent); color: var(--card); }
.lrow .body { flex: 1; min-width: 0; }
.lrow .title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.lrow .sub { font-size: 11px; opacity: 0.75; margin-top: 2px; }

/* === FAB =================================================== */
.fab-cordel {
  position: fixed;
  right: max(16px, calc(50% - 14rem + 16px));
  bottom: 88px;
  width: 56px; height: 56px;
  border: 3px solid var(--fg);
  background: var(--primary);
  color: var(--card);
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 30;
  text-decoration: none;
}
.fab-cordel iconify-icon { font-size: 28px; }
.fab-cordel:active { transform: translate(2px, 2px); box-shadow: var(--shadow-sm); }

/* === Photo placeholder cordel ============================= */
.photo-ph {
  border: var(--border-w) solid var(--fg);
  background:
    repeating-linear-gradient(45deg, var(--accent) 0 8px, #1f3b4d 8px 10px);
  color: var(--card);
  display: grid; place-items: center;
  position: relative;
  aspect-ratio: 1;
}
.photo-ph::after {
  content: '';
  position: absolute; inset: 8px;
  border: 1px dashed rgba(255,255,255,0.4);
}

/* === AI suggestion stripe ================================= */
.ai-stripe {
  border-left: 6px double var(--fg);
  padding-left: 10px;
}

/* === Tabs (segmented) ===================================== */
.tab-pills {
  display: flex;
  border: var(--border-w) solid var(--fg);
  box-shadow: var(--shadow-sm);
  background: var(--card);
}
.tab-pills > * {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 10px 8px;
  font-family: 'DM Sans', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  border-right: var(--border-w) solid var(--fg);
  text-decoration: none;
  color: var(--fg);
  text-align: center;
}
.tab-pills > *:last-child { border-right: 0; }
.tab-pills > .on { background: var(--fg); color: var(--card); }

/* === Mini chart (bars / donut / sparkline) ================ */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 60px; }
.bars > span {
  flex: 1;
  background: var(--primary);
  border: 1.5px solid var(--fg);
  min-height: 4px;
}
.bars > span:nth-child(2n) { background: var(--secondary); }
.bars > span:nth-child(3n) { background: var(--accent); }
.spark { width: 100%; height: 70px; display: block; }

.donut {
  width: 130px; height: 130px;
  border-radius: 50%;
  border: var(--border-w) solid var(--fg);
  background:
    conic-gradient(var(--primary) 0 38%, var(--secondary) 38% 62%, var(--accent) 62% 84%, var(--destructive) 84% 100%);
  position: relative;
}
.donut::after {
  content: '';
  position: absolute; inset: 22%;
  background: var(--card);
  border: var(--border-w) solid var(--fg);
  border-radius: 50%;
}

/* === Severity dots ========================================= */
.dot-sev {
  width: 10px; height: 10px;
  display: inline-block;
  border: 1.5px solid var(--fg);
  flex: 0 0 10px;
}
.dot-sev.alta { background: var(--destructive); }
.dot-sev.media { background: var(--secondary); }
.dot-sev.baixa { background: var(--success); }

/* === Chip ================================================== */
.chip-cordel {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  border: 1.5px solid var(--fg);
  background: var(--bg);
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
}

/* === OTP cells ============================================ */
.otp-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
.otp-grid .cell {
  aspect-ratio: 0.8;
  border: 3px solid var(--fg);
  background: var(--card);
  display: grid; place-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 28px;
  box-shadow: var(--shadow-sm);
}
.otp-grid .cell.on { background: var(--secondary); }

/* === Auth brand mark ===================================== */
.brand-mark { display: flex; align-items: center; gap: 10px; }
.brand-mark .seal {
  width: 56px; height: 56px;
  border: 3px solid var(--fg);
  background: var(--primary);
  color: var(--card);
  display: grid; place-items: center;
  box-shadow: var(--shadow-lg);
  position: relative;
}

/* === Hatch frame (auth hero) ============================= */
.hatch-frame {
  position: relative;
  padding: 18px;
  border: 3px solid var(--fg);
  background: var(--card);
  box-shadow: 5px 5px 0 var(--fg);
}
.hatch-frame::before, .hatch-frame::after {
  content: '';
  position: absolute;
  height: 8px; left: 4px; right: 4px;
  background: repeating-linear-gradient(90deg, var(--fg) 0 4px, transparent 4px 8px);
}
.hatch-frame::before { top: 4px; }
.hatch-frame::after { bottom: 4px; }

/* === Timeline (OnFarm detail) ============================ */
.tl { display: flex; flex-direction: column; gap: 10px; }
.tl-item {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: flex-start;
  position: relative;
}
.tl-item .pin {
  width: 18px; height: 18px;
  border: 2px solid var(--fg);
  background: var(--secondary);
  border-radius: 50%;
  margin-top: 2px;
  position: relative;
  z-index: 1;
}
.tl-item .pin.done { background: var(--success); }
.tl-item .pin.now { background: var(--primary); }
.tl-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 9px; top: 18px; bottom: -10px;
  border-left: 2px dashed var(--fg);
  z-index: 0;
}

/* === Banner ============================================== */
.banner-cordel {
  border: var(--border-w) solid var(--fg);
  background: var(--secondary);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.banner-cordel.warn { background: var(--destructive); color: var(--card); }
.banner-cordel.ok { background: var(--success); color: var(--card); }

/* === Avatar ============================================== */
.avatar-cordel {
  width: 36px; height: 36px;
  border: var(--border-w) solid var(--fg);
  background: var(--secondary);
  display: grid; place-items: center;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800;
  font-size: 14px;
  flex: 0 0 36px;
  overflow: hidden;
}
.avatar-cordel.lg { width: 64px; height: 64px; flex: 0 0 64px; font-size: 24px; border-width: 3px; }
.avatar-cordel img { width: 100%; height: 100%; object-fit: cover; }

/* === Pending pulse (sync badge) ========================== */
.pending-pulse { position: relative; }
.pending-pulse::after {
  content: '';
  position: absolute;
  top: -2px; right: -2px;
  width: 10px; height: 10px;
  background: var(--primary);
  border: 2px solid var(--fg);
  border-radius: 50%;
}

/* === Helpers leves ====================================== */
.text-center-c { text-align: center; }
.text-right-c { text-align: right; }
.opacity-70 { opacity: 0.7; }
.opacity-50 { opacity: 0.5; }
.full-w { width: 100%; }

/* === Layout shell mobile-first =========================== */
.phone-shell {
  max-width: 28rem;          /* ~ 448px - bate com max-w-md do Tailwind */
  margin: 0 auto;
  background: var(--bg);
  min-height: 100vh;
  position: relative;
  padding-bottom: 88px;       /* nav height + folga */
}
.phone-scroll { padding: 16px; }
