:root {
  --primary: #2f6b3a; --accent: #c98a1b; --bg: #f6f4ee; --card: #fff; --ink: #1d2420; --muted: #66706a; --line: #dfe3dc;
  --ok: #2e7d32; --warn: #b26a00; --err: #b3261e; --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.4; }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: .2rem 0 .8rem; } h2 { font-size: 1.15rem; margin: .2rem 0 .6rem; } h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.muted { color: var(--muted); } .small { font-size: .86rem; } small { font-size: .8rem; }
.req { color: var(--err); }
button, input, select, textarea { font: inherit; }

/* layout */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; padding: .5rem 1rem; background: var(--card); border-bottom: 1px solid var(--line); padding-top: max(.5rem, env(safe-area-inset-top)); }
.brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.brand .logo { height: 36px; max-width: 80px; object-fit: contain; }
.brand strong { display: block; font-size: .95rem; color: var(--primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand span { display: block; font-size: .78rem; color: var(--muted); }
.top-right { margin-left: auto; display: flex; gap: .5rem; align-items: center; }
#farmSel { max-width: 220px; padding: .45rem; border-radius: 8px; border: 1px solid var(--line); }
.sync { display: flex; flex-direction: column; text-decoration: none; font-size: .78rem; padding: .3rem .6rem; border-radius: 8px; line-height: 1.15; color: var(--ink); background: #eef3ee; }
.sync small { color: var(--muted); font-size: .7rem; }
.sync.off { background: #fdecea; color: var(--err); } .sync.pend { background: #fff4e0; color: var(--warn); } .sync.err { background: #fdecea; color: var(--err); }
.shell { display: flex; min-height: calc(100vh - 58px); }
.side { width: 230px; flex: none; padding: .8rem .5rem; border-right: 1px solid var(--line); background: var(--card); position: sticky; top: 58px; height: calc(100vh - 58px); overflow-y: auto; }
.side a { display: flex; gap: .6rem; align-items: center; padding: .55rem .7rem; border-radius: 8px; text-decoration: none; color: var(--ink); font-size: .95rem; }
.side a span { width: 1.4rem; text-align: center; }
.side a.active { background: color-mix(in srgb, var(--primary) 14%, white); color: var(--primary); font-weight: 600; }
.side a:hover { background: #f0f2ee; }
.side hr { border: 0; border-top: 1px solid var(--line); margin: .6rem 0; }
.side .role { font-size: .78rem; color: var(--muted); padding: 0 .7rem; }
main { flex: 1; min-width: 0; padding: 1rem 1.2rem 6rem; outline: none; max-width: 1200px; }
.icon { background: none; border: 0; font-size: 1.5rem; cursor: pointer; }
.only-mobile { display: none; }
@media (max-width: 860px) {
  .only-mobile { display: block; }
  .side { position: fixed; left: 0; top: 0; height: 100vh; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 4px 0 16px rgba(0,0,0,.15); padding-top: max(1rem, env(safe-area-inset-top)); }
  .side.open { transform: none; }
  main { padding: .8rem .8rem 7rem; }
  .brand span, #farmSel { font-size: .8rem; } #farmSel { max-width: 130px; }
  .brand strong { max-width: 38vw; }
}

/* components */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.cards .card { margin: 0; }
.kpi span { display: block; color: var(--muted); font-size: .82rem; }
.kpi strong { display: block; font-size: 1.45rem; margin: .15rem 0; }
.kpi small { color: var(--muted); display: block; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; } @media (max-width: 860px) { .two { grid-template-columns: 1fr; } }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .3rem 1rem; align-items: end; }
.span3 { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: .25rem; margin: .4rem 0; }
.field > span { font-size: .86rem; font-weight: 600; }
.field small { color: var(--muted); }
input, select, textarea { width: 100%; padding: .6rem .65rem; border: 1px solid #c9cfc6; border-radius: 8px; background: #fff; min-height: 44px; }
input[type=checkbox], input[type=radio] { width: auto; min-height: auto; }
input[type=color] { padding: .15rem; height: 44px; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--primary) 60%, white); border-color: var(--primary); }
.check { display: flex; gap: .5rem; align-items: center; margin: .4rem 0; font-size: .92rem; }
.checks { display: flex; flex-wrap: wrap; gap: .2rem 1rem; }
input.huge { font-size: 2rem; padding: .7rem; text-align: center; font-weight: 600; }
input.mid { font-size: 1.15rem; font-weight: 600; max-width: 160px; }
input.xs { max-width: 70px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; padding: .6rem 1rem; min-height: 44px; border-radius: 10px; border: 1px solid #c9cfc6; background: #fff; color: var(--ink); text-decoration: none; cursor: pointer; font-weight: 600; }
.btn:hover { background: #f3f5f1; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: #e6b3ae; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: .3rem .6rem; min-height: 34px; font-size: .85rem; border-radius: 8px; }
.btn.big { width: 100%; padding: .9rem; font-size: 1.1rem; min-height: 56px; margin-top: .6rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .6rem; margin: 1rem 0; align-items: center; } .actions.wrap { flex-wrap: wrap; }
.actions .btn.big { width: auto; flex: 1; margin: 0; }
.actions.sticky { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); padding: .6rem 0 max(.6rem, env(safe-area-inset-bottom)); z-index: 5; flex-wrap: wrap; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 999px; vertical-align: middle; text-transform: lowercase; }
.badge.ok { background: #e3f1e4; color: var(--ok); } .badge.est { background: #fff1d6; color: var(--warn); } .badge.inc { background: #fde7d9; color: #a04a00; } .badge.nd { background: #eceeea; color: var(--muted); } .badge.err { background: #fdecea; color: var(--err); }
.banner { padding: .7rem .9rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem; }
.banner.warn { background: #fff4e0; border: 1px solid #f1d39c; } .banner.info { background: #e8f1f8; border: 1px solid #bcd5ea; }
.ack-row { display: flex; justify-content: space-between; gap: .6rem; align-items: center; padding: .4rem 0; border-top: 1px solid rgba(0,0,0,.06); }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: .5rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: .78rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); background: #fafbf8; position: sticky; top: 0; }
.tbl.compact th, .tbl.compact td { padding: .3rem .4rem; }
.tbl .r, .r { text-align: right; } .tbl tr.tot td { font-weight: 700; border-top: 2px solid var(--line); }
.tbl tr.warnrow td { background: #fff7e8; } .tbl tr.muted td { color: var(--muted); }
.tbl td.chg, .chgrow td { background: #fff7e8; }
.tbl.perm td, .tbl.perm th { text-align: center; } .tbl.perm td:first-child { text-align: left; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; align-items: center; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .35rem .75rem; cursor: pointer; font-size: .88rem; }
.chip.on { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, white); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .2rem 1rem; font-size: .9rem; margin-bottom: .8rem; } .kv span { color: var(--muted); }
details > summary { cursor: pointer; font-weight: 600; padding: .3rem 0; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; margin-bottom: 1rem; }
.filters label { display: flex; flex-direction: column; font-size: .8rem; color: var(--muted); }
.filters input, .filters select { min-height: 38px; padding: .35rem; }
.quick { display: flex; gap: .2rem; }
.page-head { margin-bottom: .6rem; } .page-head h1 { margin-bottom: .1rem; }
.alerts { padding-left: 1rem; } .alerts li { margin-bottom: .5rem; font-size: .9rem; }
.count { background: var(--err); color: #fff; font-size: .75rem; border-radius: 999px; padding: .05rem .45rem; vertical-align: middle; }
.chart { width: 100%; height: auto; font-size: 11px; } .chart text { fill: var(--muted); } .chart .grid { stroke: #e6e8e3; } .chart .goal { stroke: var(--accent); stroke-dasharray: 5 4; } .chart .goal-l { fill: var(--accent); }
pre { white-space: pre-wrap; background: #f7f7f4; padding: .6rem; border-radius: 8px; }

/* campo */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.2rem; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; min-height: 120px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; text-decoration: none; color: var(--ink); font-weight: 700; text-align: center; box-shadow: var(--shadow); padding: .8rem; }
.tile span { font-size: 2.2rem; } .tile:active { transform: scale(.98); }
.form-big .field > span { font-size: 1rem; }
.seg { border: 0; padding: 0; margin: .6rem 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.seg legend { font-size: .86rem; font-weight: 600; margin-bottom: .3rem; width: 100%; }
.seg label { flex: 1 1 140px; } .seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: .65rem .5rem; border: 1px solid #c9cfc6; border-radius: 10px; background: #fff; cursor: pointer; font-weight: 600; font-size: .92rem; }
.seg input:checked + span { background: var(--primary); color: #fff; border-color: var(--primary); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.load-head p { margin: .2rem 0; }
.load-list { display: flex; flex-direction: column; gap: .5rem; }
.load-row { display: grid; grid-template-columns: 1.4fr 1fr 1.2fr .9fr; gap: .6rem; align-items: center; background: var(--card); border: 2px solid var(--line); border-radius: 12px; padding: .6rem .8rem; }
.load-row.good { border-color: #9ccc9f; } .load-row.bad { border-color: #e7a19b; background: #fff8f7; }
.load-row small { display: block; color: var(--muted); font-size: .75rem; } .load-row b { font-size: 1.1rem; }
.lr-name { display: flex; gap: .5rem; align-items: center; } .seq { background: var(--primary); color: #fff; border-radius: 999px; width: 1.8rem; height: 1.8rem; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex: none; }
.lr-in input { max-width: none; }
.lr-dev { text-align: right; }
@media (max-width: 640px) { .load-row { grid-template-columns: 1fr 1fr; } .lr-name { grid-column: 1 / -1; } .lr-dev { text-align: left; } }
.load-sum { display: flex; flex-wrap: wrap; gap: 1.2rem; justify-content: space-between; }
.unl { align-items: end; }
.steps { display: flex; gap: .3rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .6rem; }
.step { white-space: nowrap; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: .3rem .7rem; font-size: .8rem; cursor: pointer; }
.step.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.q { border-bottom: 1px dashed var(--line); padding-bottom: .3rem; }
.farm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .8rem; }
.card.farm { display: flex; flex-direction: column; gap: .2rem; text-decoration: none; color: var(--ink); margin: 0; }
.card.farm:hover { border-color: var(--primary); }

/* auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 18%, var(--bg)), var(--bg)); }
.auth-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 18px; padding: 1.6rem; box-shadow: 0 8px 30px rgba(0,0,0,.08); }
.auth-brand { text-align: center; margin-bottom: 1rem; } .auth-brand img { border-radius: 16px; } .auth-brand h1 { font-size: 1.2rem; color: var(--primary); margin: .6rem 0 .1rem; } .auth-brand p { margin: 0; color: var(--muted); font-weight: 600; }

/* modal, toast, update */
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(760px, 94vw); max-height: 90vh; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog.modal form { padding: 1.1rem 1.2rem; display: flex; flex-direction: column; max-height: 90vh; }
dialog.modal .modal-body { overflow: auto; } dialog::backdrop { background: rgba(20,30,20,.45); }
.modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; margin-top: 1rem; }
.modal textarea { font-size: .85rem; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 100; display: flex; flex-direction: column; gap: .4rem; width: min(520px, 92vw); }
.toast { background: #1f2a22; color: #fff; padding: .75rem 1rem; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: .95rem; }
.toast.erro { background: var(--err); } .toast.aviso { background: #8a5300; }
.update-bar { position: fixed; top: 0; left: 0; right: 0; z-index: 200; background: #fff4e0; border-bottom: 1px solid #f1d39c; padding: .6rem 1rem; display: flex; gap: .8rem; justify-content: center; align-items: center; font-size: .92rem; }
.card.error { border-color: #e7a19b; }
@media print { .top, .side, .actions, .filters { display: none !important; } main { padding: 0; } }
