:root {
  --green: #264216; --green-2: #35591f; --yellow: #f6c41e; --bg: #f4f6f1; --card: #fff; --ink: #1d2418; --muted: #6b7564;
  --line: #e2e6dc; --red: #d63c2f; --orange: #e68a00; --blue: #2e86ab; --ok: #2e8b3e; --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--green-2); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #c5ccbb; }
button.primary, .btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
button.primary:hover { background: var(--green-2); }
button.accent { background: var(--yellow); border-color: var(--yellow); color: var(--green); font-weight: 600; }
button.danger { color: var(--red); }
button.small { padding: 4px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; padding: 7px 9px; border: 1px solid #cfd5c6; border-radius: 7px; background: #fff; width: 100%; color: var(--ink); }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=color] { padding: 2px; height: 36px; width: 60px; }
textarea { min-height: 90px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1 1 160px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: #eef1ea; color: var(--muted); }
.badge.live { background: #e3f4e6; color: var(--ok); }
.badge.draft { background: #eef1ea; color: var(--muted); }
.badge.finished { background: #e6eef6; color: var(--blue); }
.badge.red { background: #fde7e5; color: var(--red); }
.badge.orange { background: #fff1d9; color: var(--orange); }
.chip { display: inline-block; background: #eef1ea; border-radius: 6px; padding: 1px 6px; font-size: 11px; margin: 1px 2px 1px 0; font-family: ui-monospace, Menlo, monospace; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 8px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbf8; position: sticky; top: 0; }
tr:hover td { background: #fafcf7; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #bbb; margin-right: 5px; vertical-align: middle; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--orange); } .dot.bad { background: var(--red); }
.empty { text-align: center; padding: 30px; color: var(--muted); }

/* barra de topo do backoffice */
.topbar { background: var(--green); color: #fff; display: flex; align-items: center; gap: 16px; padding: 0 18px; height: 54px; position: sticky; top: 0; z-index: 1000; }
.topbar .brand { font-weight: 800; letter-spacing: .02em; display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; }
.topbar .brand b { color: var(--yellow); }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: #dfe8d6; text-decoration: none; padding: 8px 10px; border-radius: 7px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar .alert-pill { background: var(--red); color: #fff; border-radius: 99px; padding: 3px 10px; font-weight: 700; font-size: 12px; text-decoration: none; }
.page { max-width: 1300px; margin: 0 auto; padding: 20px 18px 60px; }
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--line); margin: 6px 0 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.active { color: var(--green); border-color: var(--yellow); }

/* modal e toast */
.modal-bg { position: fixed; inset: 0; background: rgba(20,28,15,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 3000; padding: 40px 12px; overflow: auto; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 620px; padding: 20px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 4000; box-shadow: var(--shadow); }
.toast.err { background: var(--red); }

/* login */
.login { max-width: 360px; margin: 10vh auto; }
.login .logo { text-align: center; font-weight: 800; font-size: 22px; color: var(--green); margin-bottom: 16px; }
.login .logo b { color: #c99a00; }

/* ao vivo */
.live-layout { display: grid; grid-template-columns: 1fr 380px; gap: 14px; }
.live-layout .map { height: calc(100vh - 220px); min-height: 420px; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #dde5d5; }
.side-scroll { max-height: calc(100vh - 220px); overflow: auto; }
.alert-item { border-left: 4px solid var(--orange); background: #fff; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow); }
.alert-item.sos { border-color: var(--red); background: #fff6f5; }
.alert-item.done { opacity: .55; border-color: #ccc; }
.alert-item .t { font-weight: 700; }
@media (max-width: 900px) { .live-layout { grid-template-columns: 1fr; } .live-layout .map { height: 55vh; } .side-scroll { max-height: none; } }

/* marcadores no mapa */
.bib-marker { background: var(--green); color: #fff; border: 2px solid #fff; border-radius: 14px; font-weight: 800; font-size: 11px; height: 22px; min-width: 22px; padding: 0 5px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(0,0,0,.4); white-space: nowrap; }
.bib-marker.finished { background: #2e86ab; }
.bib-marker.waiting { background: #7d8775; }
.bib-marker.alert { background: var(--red); animation: pulse 1s infinite; }
.bib-marker.stale { opacity: .55; }
.bib-marker.sel { background: var(--yellow); color: var(--green); transform: scale(1.25); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(214,60,47,.7); } 50% { box-shadow: 0 0 0 8px rgba(214,60,47,0); } }
.flag-marker { font-size: 18px; }
.unit-marker { background: #fff; border: 3px solid #2e86ab; border-radius: 9px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; font-size: 16px; box-shadow: 0 1px 5px rgba(0,0,0,.4); }
.unit-marker.stale { opacity: .55; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.emoji-pick button { font-size: 18px; padding: 2px 6px; }
.leaflet-container { font: inherit; }
