/* Portal Agro Master — visual corporativo (azul-marinho + cinza neutro) */
:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --ink: #0f1b2d;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e3e8ef;
  --line-2: #cfd7e3;
  --brand: #1f5fd6;
  --brand-hover: #184fb6;
  --brand-soft: #eaf1fd;
  --side: #0b1526;
  --side-2: #13213a;
  --side-ink: #c5d0e0;
  --side-muted: #7f8ea8;
  --ok: #0f7a4f;
  --ok-soft: #e7f6ef;
  --red: #c0352b;
  --red-soft: #fdeeec;
  --amber: #a55a00;
  --amber-soft: #fff4e0;
  --gray-soft: #eef1f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 1px 3px rgba(15, 27, 45, .04);
  font-family: "Segoe UI", "Inter", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14.5px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); text-underline-offset: 2px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.hidden { display: none !important; }
.show-sm { display: none !important; }
@media (max-width: 900px) { .show-sm { display: inline-flex !important; } }

/* ---------- Layout ---------- */
.shell { display: grid; grid-template-columns: 252px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; border-right: 1px solid #08101d; }
.brand { display: flex; gap: 11px; align-items: center; padding: 4px 10px 20px; }
.brand img { width: 36px; height: 36px; }
.brand b { display: block; font-size: 15px; color: #fff; letter-spacing: .01em; }
.brand small { color: var(--side-muted); font-size: 12px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em; color: var(--side-muted); padding: 16px 12px 6px; font-weight: 600; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-radius: 7px; color: var(--side-ink); text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
.nav a:hover { background: var(--side-2); color: #fff; }
.nav a.on { background: var(--side-2); color: #fff; border-left-color: #4d8af0; }
.nav a .soon { white-space: nowrap; font-size: 10.5px; background: rgba(255, 255, 255, .07); padding: 1px 7px; border-radius: 4px; color: var(--side-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.side .who { margin-top: auto; padding: 14px 12px 2px; border-top: 1px solid rgba(255, 255, 255, .08); font-size: 13px; color: var(--side-muted); }
.side .who b { display: block; color: #fff; font-weight: 600; }
.side .who button { margin-top: 10px; background: none; border: 1px solid rgba(255, 255, 255, .16); color: var(--side-ink); border-radius: 6px; padding: 5px 12px; cursor: pointer; }
.side .who button:hover { background: var(--side-2); }
.main { padding: 28px 36px 60px; min-width: 0; max-width: 1480px; }
.topbar { display: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card h2 { font-size: 14px; margin: 0 0 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-2); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { margin: 0; }
.card-head a { font-size: 13px; font-weight: 600; text-decoration: none; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { padding: 18px 20px 16px; text-decoration: none; color: inherit; display: flex; flex-direction: column-reverse; gap: 6px; position: relative; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.stat:hover { border-color: var(--line-2); box-shadow: 0 4px 14px rgba(15, 27, 45, .07); }
.stat::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--ok); }
.stat .n { font-size: 30px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.stat.amber::after { background: #e59a0b; }
.stat.blue::after { background: var(--brand); }
.stat.red::after { background: var(--red); }
.substats { display: flex; gap: 0; flex-wrap: wrap; color: var(--muted); font-size: 13px; margin-bottom: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.substats span { padding: 10px 18px; border-right: 1px solid var(--line); }
.substats span:last-child { border-right: 0; }
.substats b { color: var(--ink); display: block; font-size: 15px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid2 > * { min-width: 0; }
.stack { display: grid; gap: 16px; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 650; background: #f8fafc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f6f9fe; }
.sub { display: block; color: var(--muted); font-size: 12.5px; font-weight: 400; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Etiquetas ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-active { background: var(--ok-soft); color: var(--ok); border-color: #c4e8d6; }
.s-pending { background: var(--amber-soft); color: var(--amber); border-color: #f5dcac; }
.s-blocked { background: var(--gray-soft); color: #475569; border-color: #d9dfe8; }
.s-expired { background: var(--red-soft); color: var(--red); border-color: #f4c9c4; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 4px; background: var(--gray-soft); font-size: 11.5px; font-weight: 650; margin: 1px 4px 1px 0; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.chip.frota { background: #e8effc; color: #1d4aa0; }
.chip.campo { background: #eef1f5; color: #3b4a5e; }
.chip.maquinas { background: #f1eefa; color: #4c3a91; }

/* ---------- Botões e formulários ---------- */
.btn { border: 1px solid var(--line-2); background: #fff; padding: 7px 14px; border-radius: 7px; cursor: pointer; font-weight: 600; white-space: nowrap; color: var(--ink-2); text-decoration: none; display: inline-block; }
.btn:hover { background: #f6f8fb; border-color: #b9c4d3; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: #f0b8b1; }
.btn.small { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
.btn:disabled { opacity: .55; cursor: wait; }
.field { display: grid; gap: 5px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
input, select, textarea { width: 100%; padding: 8px 11px; border: 1px solid var(--line-2); border-radius: 7px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 3px solid #cfe0fb; border-color: var(--brand); }
textarea { min-height: 84px; resize: vertical; }
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.search { max-width: 340px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fbfcfe; border-radius: var(--radius) var(--radius) 0 0; }
.filters input, .filters select { width: auto; min-width: 180px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; background: #fff; }
.seg button { border: 0; border-right: 1px solid var(--line); background: none; padding: 7px 12px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--brand-soft); color: var(--brand); }

/* ---------- Cliente ---------- */
.info { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; }
.info div span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.info div b { font-weight: 600; word-break: break-word; }
.notes { margin-top: 14px; padding: 12px 14px; background: #f8fafc; border: 1px solid var(--line); border-left: 3px solid var(--line-2); border-radius: 6px; white-space: pre-wrap; color: var(--ink-2); }
.products { display: grid; gap: 12px; }
.product { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 12px; background: #fcfdfe; }
.product-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.product-top h3 { margin: 0; font-size: 15px; font-weight: 650; }
.product dl { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin: 0; }
.product dt { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.product dd { margin: 0; font-weight: 600; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.timeline .who { color: var(--muted); font-size: 12px; }
.timeline .t { font-weight: 600; }
.back { display: inline-block; margin-bottom: 10px; text-decoration: none; font-weight: 600; font-size: 13px; }
.alert { padding: 11px 16px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; }
.alert.warn { background: var(--amber-soft); border-color: #f3d69c; color: #6b3d03; }
.alert.ok { background: var(--brand-soft); border-color: #c9dbfa; color: #163f8f; }
.soon-box { padding: 40px; text-align: center; color: var(--muted); }
.soon-box h2 { color: var(--ink); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 20% -10%, #1d3a6b 0%, transparent 60%), linear-gradient(180deg, #0b1526 0%, #10203b 100%); }
.login .card { width: 100%; max-width: 400px; padding: 30px; border: 0; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.login .brand { padding: 0 0 20px; color: var(--ink); }
.login .brand b { color: var(--ink); font-size: 17px; }
.login .brand small { color: var(--muted); }
.login h1 { font-size: 19px; margin: 0 0 4px; }
.login p { color: var(--muted); margin: 0 0 18px; }
.error { color: var(--red); font-size: 13.5px; min-height: 1em; }

/* ---------- Modal e avisos ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11, 21, 38, .55); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 24px 60px rgba(0, 0, 0, .28); }
.modal header { padding: 20px 22px 0; }
.modal header h2 { margin: 0; font-size: 17px; }
.modal header p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.modal .body { padding: 18px 22px; }
.modal footer { padding: 14px 22px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); background: #f8fafc; border-radius: 0 0 12px 12px; }
.secret { font-size: 26px; font-weight: 700; letter-spacing: .06em; text-align: center; padding: 16px; background: var(--brand-soft); border-radius: 8px; font-family: Consolas, monospace; user-select: all; }
#toast-root { position: fixed; bottom: 18px; right: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--side); color: #fff; padding: 11px 16px; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); max-width: 360px; }
.toast.err { background: var(--red); }

/* ---------- Celular ---------- */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 25% 0 0; z-index: 40; transform: translateX(-102%); transition: transform .2s; height: 100%; }
  .shell.menu-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .4); }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 30; }
  .topbar button { background: none; border: 1px solid rgba(255, 255, 255, .2); color: #fff; border-radius: 6px; padding: 5px 10px; }
  .topbar img { width: 28px; height: 28px; }
  .main { padding: 18px 16px 50px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .substats span { flex: 1 1 45%; border-bottom: 1px solid var(--line); }
  .grid2, .form-row { grid-template-columns: 1fr; }
  .info { grid-template-columns: 1fr 1fr; }
  .product dl { grid-template-columns: 1fr 1fr; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .filters input, .filters select { min-width: 0; flex: 1 1 140px; }
  .hide-sm { display: none; }
  /* tabelas viram cartões no celular */
  table.cards-sm thead { display: none; }
  table.cards-sm, table.cards-sm tbody, table.cards-sm tr, table.cards-sm td { display: block; width: 100%; }
  table.cards-sm tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.cards-sm td { border: 0; padding: 3px 0; }
  table.cards-sm td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 6px; }
  table.cards-sm td.hide-sm { display: none; }
}
