:root {
  --green: #1b5e20;
  --green-light: #43a047;
  --bg: #0f1115;
  --panel: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --err: #c62828;
  --shadow: 0 4px 20px rgba(0, 0, 0, .25);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, sans-serif; color: var(--text); }
body { overflow: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.err { color: var(--err); font-size: .85rem; min-height: 1.1em; margin: .3rem 0 0; }

button { font: inherit; border: none; border-radius: 10px; padding: .7rem 1rem; cursor: pointer; }
button.primary { background: var(--green); color: #fff; font-weight: 600; }
button.ghost { background: rgba(0,0,0,.06); color: var(--text); }
button:active { transform: translateY(1px); }
input { font: inherit; padding: .6rem .7rem; border: 1px solid #cfd4dc; border-radius: 8px; width: 100%; }

/* Gate */
.gate { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; padding: 1.5rem; z-index: 50; }
.gate-card { background: var(--panel); border-radius: 16px; padding: 1.6rem; width: 100%; max-width: 360px; box-shadow: var(--shadow); }
.gate-card h1 { margin: 0 0 .3rem; font-size: 1.4rem; color: var(--green); }
.gate-card input { margin: .5rem 0; }
.gate-card button { width: 100%; margin-top: .4rem; }
.gate-card .row { display: block; }

/* App layout */
#app { position: fixed; inset: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .6rem; padding: .5rem .8rem; background: var(--green); color: #fff; }
.topbar .brand { font-weight: 700; flex: 1; }
.topbar .ghost { background: rgba(255,255,255,.18); color: #fff; padding: .4rem .7rem; }
.badge { font-size: .75rem; padding: .2rem .5rem; border-radius: 999px; background: rgba(255,255,255,.2); }
.badge.online { background: #2e7d32; }
.badge.offline { background: #b71c1c; }
#map { flex: 1; }

/* Selector de capas base */
.layer-switcher { position: absolute; top: 3.2rem; left: .8rem; display: flex; gap: .25rem; background: rgba(255,255,255,.92); padding: .25rem; border-radius: 10px; box-shadow: var(--shadow); z-index: 15; }
.layer-switcher:empty { display: none; }
.layer-opt { padding: .35rem .6rem; font-size: .78rem; border-radius: 7px; background: transparent; color: var(--text); }
.layer-opt.active { background: var(--green); color: #fff; font-weight: 600; }

/* Draw HUD */
.draw-hud { position: absolute; left: 0; right: 0; bottom: 0; padding: 1rem; pointer-events: none; }
.draw-hud > * { pointer-events: auto; }
.draw-buttons { display: flex; gap: .5rem; flex-wrap: wrap; }
.draw-buttons button { box-shadow: var(--shadow); }
.area-readout { display: inline-block; background: rgba(0,0,0,.72); color: #fff; padding: .4rem .8rem; border-radius: 999px; margin-bottom: .6rem; font-size: .95rem; }
.fab { position: absolute; right: 1rem; bottom: 5rem; width: 48px; height: 48px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); font-size: 1.4rem; line-height: 1; padding: 0; }

/* Sheets */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-radius: 18px 18px 0 0; box-shadow: var(--shadow); padding: 1rem 1.1rem 1.4rem; max-height: 85vh; overflow-y: auto; z-index: 20; }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: #d0d4db; margin: 0 auto .8rem; }
.sheet h2 { margin: .2rem 0 .8rem; font-size: 1.1rem; }
#parcelForm label { display: block; margin-bottom: .7rem; font-size: .85rem; color: var(--muted); }
#parcelForm label input { margin-top: .25rem; color: var(--text); }
.phone-row { display: flex; gap: .5rem; }
.phone-row .cc { width: 68px; flex: none; text-align: center; }
.form-actions { display: flex; gap: .6rem; margin-top: .4rem; }
.form-actions button { flex: 1; }

/* Record list */
.list-toggle { position: absolute; top: 3.2rem; right: .8rem; background: #fff; box-shadow: var(--shadow); z-index: 15; padding: .4rem .7rem; font-size: .8rem; }
.list-sheet .list-head { display: flex; justify-content: space-between; align-items: center; }
.record-list { list-style: none; margin: 0; padding: 0; }
.record-list li { display: flex; justify-content: space-between; align-items: center; padding: .6rem .2rem; border-bottom: 1px solid #eef0f3; font-size: .9rem; }
.record-list .st { font-size: .72rem; padding: .15rem .5rem; border-radius: 999px; }
.st.pending { background: #fff3e0; color: #e65100; }
.st.synced { background: #e8f5e9; color: #2e7d32; }
.st.error { background: #ffebee; color: var(--err); }

/* Toast */
.toast { position: absolute; left: 50%; bottom: 6.5rem; transform: translateX(-50%); background: rgba(0,0,0,.85); color: #fff; padding: .6rem 1rem; border-radius: 10px; font-size: .9rem; z-index: 40; max-width: 90%; text-align: center; }

/* Vertex markers for manual drawing */
.vertex-dot { width: 14px; height: 14px; border-radius: 50%; background: #ffeb3b; border: 2px solid #333; box-shadow: 0 0 0 1px #fff; }
.gps-dot { width: 16px; height: 16px; border-radius: 50%; background: #1e88e5; border: 3px solid #fff; box-shadow: 0 0 0 1px #1e88e5; }
