/* Planta Viva V6 — tema consistente + cultivo por espaço */
:root{
  --pv6-surface:#ffffff;
  --pv6-surface-2:#f6f7f2;
  --pv6-surface-3:#edf2eb;
  --pv6-text:#17231c;
  --pv6-muted:#68746c;
  --pv6-border:rgba(18,45,31,.10);
  --pv6-accent:#173d2c;
  --pv6-accent-soft:#e7efe8;
  --pv6-success:#2f7a50;
  --pv6-card-radius:18px;
}
html[data-theme="dark"]{
  --pv6-surface:#151e18;
  --pv6-surface-2:#101713;
  --pv6-surface-3:#1b271f;
  --pv6-text:#eef4ef;
  --pv6-muted:#98a69c;
  --pv6-border:rgba(255,255,255,.09);
  --pv6-accent:#e9f0ea;
  --pv6-accent-soft:#203027;
  --pv6-success:#78c69a;
}

/* Corrige a troca de tema dentro de modais, inclusive áreas sticky e CTAs. */
.modal-sheet{color:var(--pv6-text)!important;background:var(--jc-bg,var(--cream))!important}
.modal-sheet .detail-section,
.modal-sheet .hero-stat,
.modal-sheet .card,
.modal-sheet .pro-species,
.modal-sheet .signal-box,
.modal-sheet .mini-result,
.modal-sheet .add-space-preview{
  color:var(--pv6-text);
}
html[data-theme="dark"] .modal-sheet{
  background:#101713!important;
  border-color:var(--pv6-border)!important;
  scrollbar-color:#516158 #101713;
}
html[data-theme="dark"] .modal-head{
  background:rgba(16,23,19,.96)!important;
  color:var(--pv6-text)!important;
  border-color:var(--pv6-border)!important;
}
html[data-theme="dark"] .modal-title,
html[data-theme="dark"] .detail-section h3,
html[data-theme="dark"] .detail-section h2,
html[data-theme="dark"] .detail-section b,
html[data-theme="dark"] .check-item,
html[data-theme="dark"] .timeline-item,
html[data-theme="dark"] .hero-stat b,
html[data-theme="dark"] .section-inline h3{
  color:var(--pv6-text)!important;
}
html[data-theme="dark"] .detail-section,
html[data-theme="dark"] .hero-stat,
html[data-theme="dark"] .card,
html[data-theme="dark"] .pro-species,
html[data-theme="dark"] .add-space-preview{
  background:#151e18!important;
  border-color:var(--pv6-border)!important;
}
html[data-theme="dark"] .detail-row,
html[data-theme="dark"] .care-plan-row{
  border-color:var(--pv6-border)!important;
}
html[data-theme="dark"] .detail-row p,
html[data-theme="dark"] .detail-row b,
html[data-theme="dark"] .detail-section p,
html[data-theme="dark"] .timeline-item div,
html[data-theme="dark"] .pro-fact-grid small,
html[data-theme="dark"] .pro-fact-grid b,
html[data-theme="dark"] .space-guide-grid small,
html[data-theme="dark"] .space-guide-grid b{
  color:var(--pv6-muted)!important;
}
html[data-theme="dark"] .detail-tabs{
  background:linear-gradient(180deg,#101713 78%,rgba(16,23,19,0))!important;
}
html[data-theme="dark"] .detail-tabs button{
  background:#151e18!important;
  color:#c9d4cb!important;
  border-color:var(--pv6-border)!important;
}
html[data-theme="dark"] .detail-tabs button.active{
  background:#edf3ee!important;
  color:#101713!important;
  border-color:#edf3ee!important;
}
html[data-theme="dark"] .timeline-item span{
  background:#213127!important;
  color:#dce7df!important;
}
html[data-theme="dark"] .check-item:before{color:#77bd92!important}
html[data-theme="dark"] .tag{
  background:#243129!important;
  color:#b9c9be!important;
}
html[data-theme="dark"] .detail-actions{
  background:linear-gradient(180deg,rgba(16,23,19,0),#101713 30%)!important;
}
html[data-theme="dark"] .modal-sheet .btn.soft,
html[data-theme="dark"] .modal-sheet .btn.light{
  background:#202c24!important;
  color:#eef4ef!important;
  border:1px solid var(--pv6-border)!important;
}
html[data-theme="dark"] .modal-sheet .btn.soft:hover,
html[data-theme="dark"] .modal-sheet .btn.light:hover{background:#2a392f!important}
html[data-theme="dark"] .modal-sheet .btn:not(.soft):not(.light):not(.danger){
  background:#edf3ee!important;
  color:#102017!important;
}
html[data-theme="dark"] .modal-sheet .icon-btn{
  background:#17211a!important;
  color:#eef4ef!important;
  border-color:var(--pv6-border)!important;
}
html[data-theme="dark"] .pro-fact-grid>div,
html[data-theme="dark"] .space-guide-grid>div{
  background:#101713!important;
  border-color:var(--pv6-border)!important;
}
html[data-theme="dark"] .species-actions button{
  background:#101713!important;
  color:#d9e3dc!important;
  border-color:var(--pv6-border)!important;
}
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea{
  background:#0e1511!important;
  color:#edf3ee!important;
  border-color:var(--pv6-border)!important;
}
html[data-theme="dark"] .field label{color:#98a69c!important}
html[data-theme="dark"] .kpi{background:#101713!important;color:#c7d2c9!important;border-color:var(--pv6-border)!important}
html[data-theme="dark"] .calc-output{background:#18241c!important;color:#eef4ef!important}

/* Seletor de ambiente global */
.space-mode-section{margin-top:14px!important;padding-top:0!important;padding-bottom:0!important}
.space-mode-panel{
  display:grid;
  grid-template-columns:minmax(240px,1fr) minmax(360px,1.25fr);
  grid-template-areas:"copy controls" "summary summary";
  gap:14px;
  padding:18px;
  background:var(--pv6-surface);
  border:1px solid var(--pv6-border);
  border-radius:var(--v5-card-radius,18px);
}
.space-mode-panel.compact{grid-template-columns:minmax(240px,1fr) minmax(360px,1.15fr)}
.space-mode-copy{grid-area:copy;align-self:center}
.space-mode-copy h2{margin:5px 0 5px;font-size:22px;line-height:1.05;letter-spacing:-.04em}
.space-mode-copy p{margin:0;max-width:54ch;color:var(--pv6-muted);font-size:12px}
.space-mode-controls{grid-area:controls;display:grid;grid-template-columns:1fr 1fr;gap:8px}
.space-mode-controls button{
  min-height:92px;
  border:1px solid var(--pv6-border);
  border-radius:15px;
  background:var(--pv6-surface-2);
  color:var(--pv6-text);
  text-align:left;
  padding:13px 14px;
  display:grid;
  grid-template-columns:34px 1fr;
  grid-template-rows:auto auto;
  column-gap:10px;
  align-items:center;
  transition:.18s ease;
}
.space-mode-controls button>span{grid-row:1/3;width:34px;height:34px;border-radius:11px;background:var(--pv6-surface-3);display:grid;place-items:center;font-size:17px}
.space-mode-controls button b{font-size:14px;line-height:1.1}
.space-mode-controls button small{font-size:10px;color:var(--pv6-muted);margin-top:3px}
.space-mode-controls button:hover{transform:translateY(-1px);border-color:rgba(42,104,69,.25)}
.space-mode-controls button.active{background:#153d2b;color:#fff;border-color:#153d2b}
.space-mode-controls button.active>span{background:rgba(255,255,255,.12)}
.space-mode-controls button.active small{color:rgba(255,255,255,.68)}
html[data-theme="dark"] .space-mode-controls button.active{background:#edf3ee;color:#102017;border-color:#edf3ee}
html[data-theme="dark"] .space-mode-controls button.active>span{background:#dce7df}
html[data-theme="dark"] .space-mode-controls button.active small{color:#526158}
.space-mode-summary{grid-area:summary;display:flex;align-items:center;gap:12px;padding:12px 13px;border-radius:14px;background:var(--pv6-surface-2);border:1px solid var(--pv6-border)}
.space-mode-summary>span{width:38px;height:38px;border-radius:12px;background:var(--pv6-accent-soft);display:grid;place-items:center;font-size:18px;flex:0 0 auto}
.space-mode-summary small{display:block;font:800 8px/1.2 "JetBrains Mono",monospace;letter-spacing:.09em;color:var(--pv6-muted)}
.space-mode-summary b{display:block;font-size:13px;margin-top:3px}
.space-mode-summary p{margin:2px 0 0;font-size:10px;color:var(--pv6-muted)}

/* Compatibilidade nos cards */
.crop-body,.plant-body{position:relative}
.space-fit-badge{
  display:inline-flex;
  align-items:center;
  max-width:100%;
  min-height:23px;
  padding:5px 7px;
  margin-bottom:8px;
  border-radius:999px;
  background:#e7f1e9;
  color:#326148;
  font:800 8px/1.1 "JetBrains Mono",monospace;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.space-fit-badge.warn{background:#f1ece0;color:#705e39}
html[data-theme="dark"] .space-fit-badge{background:#213429;color:#96d0ab}
html[data-theme="dark"] .space-fit-badge.warn{background:#352f22;color:#d7c07f}

/* Contexto dentro das fichas */
.space-context-section{overflow:hidden}
.space-context-label{display:inline-flex;align-items:center;padding:6px 9px;border-radius:999px;background:var(--pv6-accent-soft);color:var(--pv6-text);font:800 8px/1 "JetBrains Mono",monospace;text-transform:uppercase;white-space:nowrap}
.space-segment{display:grid;grid-template-columns:1fr 1fr;gap:6px;margin:10px 0 12px;padding:4px;border-radius:13px;background:var(--pv6-surface-2);border:1px solid var(--pv6-border)}
.space-segment button{border:0;background:transparent;color:var(--pv6-muted);border-radius:10px;min-height:38px;font:800 9px/1 "JetBrains Mono",monospace;letter-spacing:.04em;text-transform:uppercase}
.space-segment button span{font-size:13px;margin-right:5px}
.space-segment button.active{background:var(--pv6-surface);color:var(--pv6-text);box-shadow:0 1px 4px rgba(15,35,24,.06)}
html[data-theme="dark"] .space-segment button.active{background:#253229;color:#eef4ef}
.space-guide-head{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;margin-bottom:10px}
.space-guide-head h3{margin:6px 0 3px!important;font-size:18px!important}
.space-guide-head p{margin:0!important;font-size:11px!important;color:var(--pv6-muted)!important}
.space-score{display:inline-flex;padding:6px 8px;border-radius:999px;background:#e0efe4;color:#2d6647;font:800 8px/1 "JetBrains Mono",monospace;white-space:nowrap}
html[data-theme="dark"] .space-score{background:#1f3527;color:#83c79c}
.space-guide-grid{display:grid;grid-template-columns:1fr 1fr;gap:7px}
.space-guide-grid>div{background:var(--pv6-surface-2);border:1px solid var(--pv6-border);border-radius:13px;padding:10px 11px;min-height:82px}
.space-guide-grid small{display:block;font:800 7px/1.2 "JetBrains Mono",monospace;letter-spacing:.08em;text-transform:uppercase;color:var(--pv6-muted)}
.space-guide-grid b{display:block;margin-top:6px;font-size:10px;line-height:1.5;color:var(--pv6-text)}

/* Planejador adaptado */
.planner-context{margin-top:12px;padding:11px 12px;border:1px solid var(--pv6-border);border-radius:13px;background:var(--pv6-surface)}
.planner-context>b{font-size:11px}
.planner-context p{margin:5px 0 8px!important;font-size:10px!important;color:var(--pv6-muted)!important}
.planner-context span{display:inline-flex;padding:5px 7px;border-radius:999px;background:var(--pv6-accent-soft);font:800 7px/1 "JetBrains Mono",monospace;color:var(--pv6-text)}
.add-space-preview{padding:12px;border:1px solid var(--pv6-border);border-radius:14px;background:var(--pv6-surface-2)}
.add-space-preview b{display:block;font-size:11px}
.add-space-preview small{display:block;margin-top:5px;color:var(--pv6-muted);font-size:10px;line-height:1.45}
.saved-space-card p{margin:8px 0 0;color:var(--pv6-muted);font-size:11px}

/* Horta: cards recomendados pelo espaço não devem parecer filtro oculto. */
#cropNow .section-head p:after{content:" O modo de espaço também influencia a ordem."}

@media(max-width:900px){
  .space-mode-panel,.space-mode-panel.compact{grid-template-columns:1fr;grid-template-areas:"copy" "controls" "summary"}
}
@media(max-width:620px){
  .space-mode-panel{padding:13px;gap:10px}
  .space-mode-copy h2{font-size:19px}
  .space-mode-controls{grid-template-columns:1fr 1fr}
  .space-mode-controls button{min-height:82px;padding:10px;grid-template-columns:28px 1fr;column-gap:7px}
  .space-mode-controls button>span{width:28px;height:28px;border-radius:9px;font-size:14px}
  .space-mode-controls button b{font-size:11px}
  .space-mode-controls button small{font-size:8px}
  .space-mode-summary p{font-size:9px}
  .space-guide-grid{grid-template-columns:1fr}
  .space-guide-grid>div{min-height:0}
  .space-guide-grid b{font-size:10px}
  .space-fit-badge{font-size:7px;padding:5px 6px}
}
