/* Cultivo App — tema escuro com verde. Pensado para celular primeiro. */

:root {
  --bg: #0b0f0c;
  --bg-elev: #121a14;
  --bg-card: #16221a;
  --line: #233229;
  --text: #e6efe8;
  --muted: #8fa596;
  --green: #35d07f;
  --green-strong: #1fb36a;
  --green-soft: rgba(53, 208, 127, 0.14);
  --danger: #ff6b6b;
  --warn: #ffc857;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Inter", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #10261a 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100dvh;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p { margin: 0 0 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem;
  background: rgba(11, 15, 12, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); }
.brand .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); box-shadow: 0 0 16px var(--green); }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar nav a { color: var(--muted); font-size: .95rem; }
.topbar nav a.active, .topbar nav a:hover { color: var(--text); text-decoration: none; }

main.container { max-width: 960px; margin: 0 auto; padding: 1.25rem 1rem 5rem; }
.center-screen { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; }
.auth-box { width: 100%; max-width: 400px; }

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Formulários */
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: .8rem .9rem;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .8rem 1.1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit; font-weight: 600;
  cursor: pointer;
  background: var(--green);
  color: #06140c;
  transition: transform .05s, background .15s;
}
.btn:hover { background: var(--green-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--green); }
.btn.small { padding: .45rem .75rem; font-size: .875rem; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }

/* Mensagens */
.flash { padding: .75rem 1rem; border-radius: 10px; margin-bottom: 1rem; border: 1px solid; font-size: .95rem; }
.flash.success { background: var(--green-soft); border-color: var(--green); color: var(--text); }
.flash.error { background: rgba(255, 107, 107, .12); border-color: var(--danger); }
.flash.warn { background: rgba(255, 200, 87, .12); border-color: var(--warn); }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; }
code.code { background: var(--bg-elev); padding: .2rem .45rem; border-radius: 6px; font-size: .95rem; letter-spacing: .05em; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; border: 1px solid var(--line); color: var(--muted); }
.badge.on { color: var(--green); border-color: var(--green); }

/* Estado vazio */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .icon { font-size: 2.5rem; margin-bottom: .5rem; }

/* Barra inferior (celular) */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; justify-content: space-around;
  background: rgba(11, 15, 12, 0.92);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  padding: .5rem 0 calc(.5rem + env(safe-area-inset-bottom));
}
.tabbar a { color: var(--muted); font-size: .75rem; display: flex; flex-direction: column; align-items: center; gap: .15rem; }
.tabbar a.active { color: var(--green); }
.tabbar .ico { font-size: 1.3rem; }
@media (min-width: 720px) { .tabbar { display: none; } }
@media (max-width: 719px) { .topbar nav .desktop-only { display: none; } }

/* ---------- Cultivos ---------- */
:root { --gold: #f2c14e; --purple: #b58ce0; }
h3 { font-size: 1rem; }
[hidden] { display: none !important; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.page-head h1 { margin: 0; }
section.card { margin-top: 1rem; }
.form-grid { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.form-grid .field.wide { grid-column: 1 / -1; }
.unit { color: var(--muted); font-weight: 400; }
.help { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
textarea { resize: vertical; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2.2rem; }
input.invalid, select.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 107, .15); }
label.check { display: flex; align-items: center; gap: .6rem; color: var(--text); font-size: 1rem; padding: .8rem .9rem; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; cursor: pointer; margin: 1.45rem 0 0; }
label.check input { width: 1.15rem; height: 1.15rem; accent-color: var(--green); }
.card-inner { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: 1rem 1rem 0; margin-bottom: .75rem; }
.plant-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1.25rem; }
.inline-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.inline-form .field { margin: 0; flex: 1; min-width: 150px; }

a.grow-card { color: var(--text); display: block; transition: border-color .15s, transform .1s; }
a.grow-card:hover { text-decoration: none; border-color: var(--green); transform: translateY(-1px); }
.grid > .card + .card { margin-top: 0; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .75rem 0; }
.grow-day { font-weight: 700; font-size: 1.1rem; }
.grow-day .muted { font-weight: 400; font-size: .9rem; }
.badge.stage-floracao, .badge.stage-pre_flora, .badge.stage-flush { color: var(--purple); border-color: var(--purple); }
.badge.stage-colheita, .badge.stage-secagem, .badge.stage-cura { color: var(--gold); border-color: var(--gold); }

.stats { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: .75rem 0 1rem; }
.stat { background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; padding: .9rem; }
.stat-num { font-size: 1.7rem; font-weight: 800; color: var(--green); line-height: 1.1; }
.stat-num.gold { color: var(--gold); }
.stat-label { color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.timeline { border-left: 2px solid var(--line); margin-left: .4rem; padding-left: 1rem; }
.timeline-item { position: relative; padding: .3rem 0; display: flex; flex-direction: column; }
.timeline-item::before { content: ""; position: absolute; left: calc(-1rem - 6px); top: .7rem; width: 10px; height: 10px; border-radius: 50%; background: var(--line); }
.timeline-item.current::before { background: var(--green); box-shadow: 0 0 10px var(--green); }
.profile-title { margin-top: 1.1rem; color: var(--muted); }
dl.profile { display: grid; gap: .5rem 1rem; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: .4rem 0 0; }
dl.profile dt { color: var(--muted); font-size: .8rem; }
dl.profile dd { margin: 0; }

/* ---------- Diário ---------- */
.form-grid.quick input { font-size: 1.25rem; font-weight: 700; padding: .9rem; }
.form-grid.quick input::placeholder { font-size: .9rem; font-weight: 400; }
details.group { margin-top: .6rem; padding: 0; }
details.group > summary { cursor: pointer; padding: 1rem 1.25rem; font-weight: 600; list-style: none; display: flex; justify-content: space-between; }
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after { content: "+"; color: var(--green); font-size: 1.2rem; line-height: 1; }
details.group[open] > summary::after { content: "–"; }
details.group > .form-grid { padding: 0 1.25rem .25rem; }
.chips-input { display: flex; flex-wrap: wrap; gap: .4rem; }
label.chip { margin: 0; cursor: pointer; }
label.chip input { position: absolute; opacity: 0; pointer-events: none; }
label.chip span { display: inline-block; padding: .45rem .8rem; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--text); font-size: .9rem; }
label.chip input:checked + span { border-color: var(--green); background: var(--green-soft); color: var(--green); }
label.chip input:focus-visible + span { box-shadow: 0 0 0 3px var(--green-soft); }
.btn.block { margin-top: .5rem; }
.entry { padding: .9rem 0; border-bottom: 1px solid var(--line); }
.entry:last-child { border-bottom: 0; padding-bottom: 0; }
.entry-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }
dl.entry-data { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem .9rem; margin: 0 0 .5rem; }
dl.entry-data dt { color: var(--muted); font-size: .75rem; }
dl.entry-data dd { margin: 0; font-weight: 600; }
dl.entry-data .calc dd { color: var(--green); }
.entry-notes { margin: .25rem 0 .5rem; color: var(--text); font-size: .95rem; }
.badge[class*="stage-"]:not(.stage-floracao):not(.stage-pre_flora):not(.stage-flush):not(.stage-colheita):not(.stage-secagem):not(.stage-cura) { color: var(--green); border-color: var(--green); }

/* ---------- Fotos ---------- */
input[type="file"] { width: 100%; padding: .7rem; background: var(--bg-elev); color: var(--muted); border: 1px dashed var(--line); border-radius: 10px; font: inherit; }
input[type="file"]::file-selector-button { margin-right: .75rem; padding: .5rem .8rem; border: 0; border-radius: 8px; background: var(--green); color: #06140c; font-weight: 600; cursor: pointer; }
details.group > .pad { padding: 0 1.25rem 1.25rem; }
.filters { display: flex; gap: .5rem; margin: 1rem 0 .5rem; flex-wrap: wrap; }
.filters select { flex: 1; min-width: 150px; }
.compare-bar { position: sticky; top: 3.6rem; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem .8rem; margin: .5rem 0; background: rgba(18, 26, 20, .95); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(8px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.gallery { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.gallery.mini { grid-template-columns: repeat(4, 1fr); }
.shot { margin: 0; background: var(--bg-card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: block; }
.shot img { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--bg-elev); }
.shot figcaption { padding: .5rem .6rem .6rem; display: flex; flex-direction: column; gap: .1rem; }
label.pick { display: flex; align-items: center; gap: .45rem; margin: 0; color: var(--text); font-size: .9rem; font-weight: 600; cursor: pointer; }
label.pick input { width: 1.1rem; height: 1.1rem; accent-color: var(--green); }
.compare { display: grid; gap: .75rem; grid-template-columns: 1fr 1fr; margin-bottom: 1rem; }
.compare-side { margin: 0 !important; padding: .5rem; }
.compare-side img { display: block; width: 100%; border-radius: 10px; }
.compare-side figcaption { padding: .6rem .3rem .2rem; }
.entry-photos { display: flex; gap: .4rem; flex-wrap: wrap; margin: .25rem 0 .6rem; }
.entry-photos img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.btn.danger.small { margin: 0 .4rem .4rem 0; }

/* ---------- Eventos ---------- */
.top-actions { display: grid; grid-template-columns: 2fr 1fr; gap: .6rem; margin: .5rem 0; }
.type-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .5rem; margin: .75rem 0 1rem; }
.type-chip { display: flex; align-items: center; gap: .5rem; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-card); color: var(--text); font-weight: 600; font-size: .95rem; }
.type-chip:hover { text-decoration: none; border-color: var(--green); }
.type-chip.on { border-color: var(--green); background: var(--green-soft); color: var(--green); }
.type-chip span { font-size: 1.2rem; }
.entry-badges { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.entry-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
table.weights input { min-width: 90px; }

/* ---------- Gráficos ---------- */
:root { --series: #22a865; }
.chart-card h2 { font-size: 1rem; margin-bottom: .25rem; }
.chart { position: relative; touch-action: pan-y; outline: none; border-radius: 8px; }
.chart:focus-visible { box-shadow: 0 0 0 3px var(--green-soft); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .stage { stroke: #3a4d40; stroke-width: 1; }
.chart .stage-label { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .series { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: var(--series); stroke: var(--bg-card); stroke-width: 2; }
.dot.warn { fill: var(--warn); }
.chart .end-label { fill: var(--text); font-size: 13px; font-weight: 700; font-family: var(--font); }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart .focus { fill: none; stroke: var(--text); stroke-width: 2; }
.chart .tip { position: absolute; top: -6px; transform: translate(-50%, -100%); background: #0b0f0c; border: 1px solid var(--line); border-radius: 8px; padding: .35rem .6rem; display: flex; flex-direction: column; align-items: center; white-space: nowrap; pointer-events: none; box-shadow: var(--shadow); z-index: 3; }
.chart .tip strong { font-size: 1rem; }
.chart .tip span { color: var(--muted); font-size: .78rem; }
.chart .tip .tip-warn { color: var(--text); }
.chart-note { display: flex; align-items: center; gap: .4rem; font-size: .85rem; color: var(--muted); margin: .4rem 0 0; }
details.chart-table { margin-top: .5rem; }
details.chart-table summary { cursor: pointer; color: var(--green); font-size: .9rem; }
.out-range { color: var(--warn); font-size: .75rem; font-weight: 600; white-space: nowrap; }
.alerts { border-color: var(--warn); }
.alerts ul { margin: .25rem 0 0; padding-left: 1.1rem; }
.alerts li { margin: .3rem 0; }
.quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .5rem; margin: .6rem 0; }
.quick-links a { text-align: center; padding: .6rem; border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--bg-card); font-size: .9rem; }
.quick-links a:hover { border-color: var(--green); text-decoration: none; }

/* ---------- Relatório e impressão ---------- */
.report header { margin-bottom: 1rem; }
@media print {
  :root { --bg: #fff; --bg-elev: #fff; --bg-card: #fff; --line: #bbb; --text: #000; --muted: #444; --green: #0a6b3a; --gold: #7a5a00; --purple: #5b3a8a; }
  body { background: #fff !important; color: #000; font-size: 11pt; }
  .topbar, .tabbar, .no-print, .flash { display: none !important; }
  main.container { max-width: none; padding: 0; }
  .card { box-shadow: none; border: 0; border-top: 1px solid #bbb; border-radius: 0; padding: .6rem 0; margin: 0 !important; break-inside: auto; }
  h1 { font-size: 18pt; } h2 { font-size: 13pt; }
  table { font-size: 9.5pt; } tr { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  a { color: #000; text-decoration: none; }
}

/* ---------- Sugestões ---------- */
.count { display: inline-block; min-width: 1.15rem; padding: 0 .3rem; border-radius: 999px; background: var(--gold); color: #1a1400; font-size: .7rem; font-weight: 800; line-height: 1.15rem; text-align: center; vertical-align: middle; }
.tabbar .ico { position: relative; }
.tabbar .ico .count { position: absolute; top: -.35rem; right: -.9rem; }
.reply { margin-top: .4rem; padding: .6rem .8rem; border-left: 3px solid var(--green); background: var(--green-soft); border-radius: 0 8px 8px 0; font-size: .95rem; }
.fb-filter { margin: .5rem 0 1rem; }
.fb-filter a:hover { text-decoration: none; border-color: var(--green); }
.badge.fb-nova { color: var(--gold); border-color: var(--gold); }
.badge.fb-em_analise { color: var(--purple); border-color: var(--purple); }
.badge.fb-feito { color: var(--green); border-color: var(--green); }
